Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeronika Irvine2001-05-11 13:46:50 +0000
committerVeronika Irvine2001-05-11 13:46:50 +0000
commit3275970ab8046022b8d2069b5c21bf117c223db7 (patch)
tree23ac5a3259be894e958f59fdd4103679c544e889
downloadeclipse.platform.swt-3275970ab8046022b8d2069b5c21bf117c223db7.tar.gz
eclipse.platform.swt-3275970ab8046022b8d2069b5c21bf117c223db7.tar.xz
eclipse.platform.swt-3275970ab8046022b8d2069b5c21bf117c223db7.zip
initializing database with SWT 0.105
-rwxr-xr-xbundles/org.eclipse.swt/.classpath_motif0
-rwxr-xr-xbundles/org.eclipse.swt/.classpath_win3216
-rwxr-xr-xbundles/org.eclipse.swt/.cvsignore2
-rwxr-xr-xbundles/org.eclipse.swt/.vcm_meta6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java168
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java111
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java950
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java462
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java1535
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderAdapter.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderEvent.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderListener.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java406
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java238
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java797
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java599
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java249
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java57
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java384
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java202
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java74
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java147
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java5426
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java177
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java62
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java344
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java179
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java701
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java100
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java561
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedEvent.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java163
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java477
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DND.java128
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDEvent.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDListener.java77
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceAdapter.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceListener.java70
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragUnderEffect.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetAdapter.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java98
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetListener.java172
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/NoDragUnderEffect.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/ByteArrayTransfer.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java206
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java460
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java540
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java63
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java100
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java94
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java196
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java214
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java63
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java102
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java130
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java357
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java437
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java610
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java136
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java157
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java81
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java61
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java87
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java50
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java562
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java1024
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java61
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnum.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IFont.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java55
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersist.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStorage.java144
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStream.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java155
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java50
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java420
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java588
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java1306
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java521
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java269
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java68
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFile.java128
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java626
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java179
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java524
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java158
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/PrintDialog.java51
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java261
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java254
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java499
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java698
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java169
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/ProgramSupport.java215
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java259
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c328
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/library/callback.h49
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/library/globals.c122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/library/globals.h71
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/library/library.h18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java1810
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java80
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java73
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java29
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlAdapter.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusAdapter.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusListener.java42
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpListener.java34
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyAdapter.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyEvent.java48
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyListener.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuAdapter.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuListener.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyListener.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseAdapter.java52
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseEvent.java68
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseListener.java51
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseMoveListener.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackAdapter.java53
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackListener.java53
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintEvent.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintListener.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionAdapter.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionEvent.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java50
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java66
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellListener.java61
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseEvent.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseListener.java40
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeAdapter.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeEvent.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeListener.java41
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TypedEvent.java56
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyEvent.java51
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyListener.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java45
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java3451
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java284
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java205
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java93
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java264
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java270
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java522
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGAppn.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGComment.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGEndOfImage.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFileFormat.java1891
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFrameHeader.java203
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGHuffmanTable.java262
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGQuantizationTable.java159
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGRestartInterval.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGScanHeader.java117
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGSegment.java54
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGStartOfImage.java29
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataInputStream.java88
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataOutputStream.java54
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java479
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWNode.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java525
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java333
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunkReader.java64
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngDecodingDataStream.java131
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngFileReadState.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTable.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTables.java156
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIdatChunk.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIendChunk.java39
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java372
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngLzBlockReader.java169
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java87
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngTrnsChunk.java133
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java667
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java284
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java157
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java638
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java29
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java151
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java207
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java84
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/EventTable.java85
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java110
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Layout.java76
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Listener.java45
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/RunnableLock.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java140
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java222
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/readme_swt.html550
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh59
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/gnome.c153
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc509
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/library.c32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak86
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/make_solaris.mak69
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.c1364
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.h459
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c7899
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/libswt-gnome0105.sobin0 -> 4713 bytes
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/libswt0105.sobin0 -> 1825715 bytes
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java197
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java154
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java434
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/DeviceData.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java164
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java321
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontMetrics.java47
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java1367
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java872
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java79
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java71
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/GNOME.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java54
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java1250
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/Visual.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XAnyEvent.java11
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XButtonEvent.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCharStruct.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XColor.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XEvent.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XExposeEvent.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFontStruct.java36
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XGCValues.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XImage.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XInputEvent.java10
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XKeyEvent.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XMotionEvent.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XRectangle.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowChanges.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowEvent.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java318
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java631
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java212
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java402
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java525
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java1196
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java439
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java1813
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java544
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java296
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java324
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java220
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java1401
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java254
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java870
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyle.java91
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyles.java133
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java246
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java336
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java408
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java1584
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java648
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java705
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java319
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java262
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java227
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java300
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java558
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java217
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java2027
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java865
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java406
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java885
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java337
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java2361
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java461
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java1032
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java1261
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java211
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java763
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java193
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java1469
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java1146
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java157
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java725
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/WidgetTable.java121
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/build.sh12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/library.c32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak34
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c1091
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h298
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c5896
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/libswt0104.sobin0 -> 372486 bytes
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java99
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java112
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java253
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java107
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java188
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java78
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java1407
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java612
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java153
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java71
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java2893
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java38
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java27
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java21
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java27
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java25
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java318
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java337
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java180
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java222
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java51
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java497
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java258
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java991
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java174
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java61
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java943
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java125
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java59
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java122
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java336
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java231
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java589
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java338
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java371
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java99
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java121
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java225
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java167
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java306
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java120
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java320
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java2027
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java541
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java236
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java360
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java135
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java2361
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java461
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java1032
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java619
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java155
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java325
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java115
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java1469
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java1146
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java157
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java441
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java101
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/build.bat23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/library.c28
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak67
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c3976
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h1514
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c7893
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc108
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/library/swtole.c3418
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java303
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java344
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java684
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/DeviceData.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java203
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java599
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java171
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java1656
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java31
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java1601
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java252
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Converter.java181
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ACCEL.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BITMAP.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DIBSECTION.java26
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DOCINFO.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HDITEM.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HELPINFO.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ICONINFO.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGFONT.java33
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGPEN.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LRESULT.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVITEM.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java16
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUINFO.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java35
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MSG.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHDR.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHEADER.java13
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java4445
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java18
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/POINT.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PRINTDLG.java29
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/RECT.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SIZE.java12
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTON.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TCITEM.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TOOLINFO.java19
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java14
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java15
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java23
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVITEM.java20
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java24
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java17
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WNDCLASSEX.java22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/package.html22
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java627
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java205
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java488
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java181
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java1247
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java608
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java3556
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java567
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java381
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java1000
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java233
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java1502
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java252
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java110
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java283
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java262
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java510
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java1427
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java716
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java657
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java158
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java223
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java284
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java369
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java884
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java313
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java944
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java734
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java685
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java193
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java2149
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java369
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java527
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java1652
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java612
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java581
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java272
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java1397
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java439
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java971
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/WidgetTable.java113
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/swt0105.dllbin0 -> 237568 bytes
587 files changed, 186648 insertions, 0 deletions
diff --git a/bundles/org.eclipse.swt/.classpath_motif b/bundles/org.eclipse.swt/.classpath_motif
new file mode 100755
index 0000000000..e69de29bb2
--- /dev/null
+++ b/bundles/org.eclipse.swt/.classpath_motif
diff --git a/bundles/org.eclipse.swt/.classpath_win32 b/bundles/org.eclipse.swt/.classpath_win32
new file mode 100755
index 0000000000..6cd92d2205
--- /dev/null
+++ b/bundles/org.eclipse.swt/.classpath_win32
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="lib" path="J:\teamswt\swt-builddir\jre\lib\rt.jar"/>
+ <classpathentry kind="src" path="Eclipse SWT\win32"/>
+ <classpathentry kind="src" path="Eclipse SWT\common"/>
+ <classpathentry kind="src" path="Eclipse SWT Printing\win32"/>
+ <classpathentry kind="src" path="Eclipse SWT Printing\common"/>
+ <classpathentry kind="src" path="Eclipse SWT Program\win32"/>
+ <classpathentry kind="src" path="Eclipse SWT AWT\win32"/>
+ <classpathentry kind="src" path="Eclipse SWT OLE Win32\win32"/>
+ <classpathentry kind="src" path="Eclipse SWT Drag and Drop\win32"/>
+ <classpathentry kind="src" path="Eclipse SWT Drag and Drop\common"/>
+ <classpathentry kind="src" path="Eclipse SWT Custom Widgets\common"/>
+ <classpathentry kind="src" path="bin\Eclipse SWT"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/bundles/org.eclipse.swt/.cvsignore b/bundles/org.eclipse.swt/.cvsignore
new file mode 100755
index 0000000000..43e9b71b6f
--- /dev/null
+++ b/bundles/org.eclipse.swt/.cvsignore
@@ -0,0 +1,2 @@
+bin
+.classpath \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/.vcm_meta b/bundles/org.eclipse.swt/.vcm_meta
new file mode 100755
index 0000000000..aae2e1b3ef
--- /dev/null
+++ b/bundles/org.eclipse.swt/.vcm_meta
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project-description>
+ <nature id="org.eclipse.jdt.core.javanature"/>
+ <builder name="org.eclipse.jdt.core.javabuilder">
+ </builder>
+</project-description>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
new file mode 100755
index 0000000000..5573ac6a09
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/SWT_AWT.java
@@ -0,0 +1,67 @@
+package org.eclipse.swt.internal.awt.win32;
+
+/* Win32, SUN AWT */
+import sun.awt.DrawingSurface;
+import sun.awt.windows.WDrawingSurfaceInfo;
+import sun.awt.windows.WEmbeddedFrame;
+
+/* SWT Imports */
+import org.eclipse.swt.*;
+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;
+import org.eclipse.swt.graphics.Rectangle;
+
+/* AWT Imports */
+import java.awt.Canvas;
+import java.awt.Panel;
+import java.awt.Dimension;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class SWT_AWT {
+
+public static Panel new_Panel (final Composite parent) {
+ int handle = parent.handle;
+ final WEmbeddedFrame frame = new WEmbeddedFrame (handle);
+ Panel panel = new Panel ();
+ frame.add (panel);
+ parent.addListener (SWT.Resize, new Listener () {
+ public void handleEvent (Event e) {
+ Rectangle rect = parent.getClientArea ();
+ frame.setSize (rect.width, rect.height);
+ frame.validate ();
+ }
+ });
+ return panel;
+}
+
+public static Shell new_Shell (Display display, final Canvas parent) {
+ DrawingSurface ds = (DrawingSurface)parent.getPeer();
+ WDrawingSurfaceInfo wds = (WDrawingSurfaceInfo)ds.getDrawingSurfaceInfo();
+ wds.lock ();
+ int handle = wds.getHWnd ();
+ wds.unlock ();
+ final Shell shell = Shell.win32_new (display, handle);
+ final Display newDisplay = shell.getDisplay ();
+ parent.addComponentListener(new ComponentAdapter () {
+ public void componentResized (ComponentEvent e) {
+ newDisplay.syncExec (new Runnable () {
+ public void run () {
+ Dimension dim = parent.getSize ();
+ shell.setSize (dim.width, dim.height);
+ }
+ });
+ }
+ });
+ shell.setVisible (true);
+ return shell;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT AWT/win32/org/eclipse/swt/internal/awt/win32/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java
new file mode 100755
index 0000000000..af654766de
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/AnimatedProgress.java
@@ -0,0 +1,168 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+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.
+ */
+public class AnimatedProgress extends Canvas {
+
+ private static final int SLEEP = 70;
+ private static final int DEFAULT_WIDTH = 160;
+ private static final int DEFAULT_HEIGHT = 18;
+ private boolean active = false;
+ private boolean showStripes = false;
+ private int value;
+ private int orientation = SWT.HORIZONTAL;
+ private boolean showBorder = false;
+
+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.
+ */
+public synchronized void clear(){
+ if (active)
+ stop();
+ showStripes = false;
+ redraw();
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ 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);
+}
+private 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);
+}
+private 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.
+*/
+public synchronized void start() {
+
+ 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() {
+ active = false;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
new file mode 100755
index 0000000000..d97f8be1f7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/BusyIndicator.java
@@ -0,0 +1,111 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Support for showing a Busy Cursor during a long running process.
+ */
+public class BusyIndicator {
+
+ static int[] counts = new int[0];
+ static Display[] displays = new Display[0];
+ static Cursor[] cursors = new Cursor[0];
+
+/**
+ * Runs the given <code>Runnable</code> while providing
+ * busy feedback using this busy indicator.
+ *
+ * @param 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 the runnable for which busy feedback is to be shown
+ * @see #showWhile
+ */
+
+public static void showWhile(Display display, Runnable runnable) {
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ runnable.run();
+ return;
+ }
+ }
+
+ int index = 0;
+ while (index < displays.length) {
+ if (displays[index] == display) break;
+ index++;
+ }
+ if (index == displays.length) {
+ Display[] newDisplays = new Display[displays.length + 1];
+ System.arraycopy(displays, 0, newDisplays, 0, displays.length);
+ displays = newDisplays;
+ displays[index] = display;
+ final Display d = display;
+ display.disposeExec( new Runnable() {
+ public void run() {
+ clear (d);
+ }
+ });
+
+ int[] newCounts = new int[counts.length + 1];
+ System.arraycopy(counts, 0, newCounts, 0, counts.length);
+ counts = newCounts;
+
+ Cursor[] newCursors = new Cursor[cursors.length + 1];
+ System.arraycopy(cursors, 0, newCursors, 0, cursors.length);
+ cursors = newCursors;
+ }
+
+ if (counts[index] == 0) {
+ cursors[index] = new Cursor(display, SWT.CURSOR_WAIT);
+ }
+
+ counts[index]++;
+
+ Shell[] shells = display.getShells();
+ for (int i = 0; i < shells.length; i++) {
+ shells[i].setCursor(cursors[index]);
+ }
+
+ try {
+ runnable.run();
+ } finally {
+ counts[index]--;
+ if (counts[index] == 0) {
+ shells = display.getShells();
+ for (int i = 0; i < shells.length; i++) {
+ shells[i].setCursor(null);
+ }
+ cursors[index].dispose();
+ cursors[index] = null;
+ }
+ }
+}
+
+static void clear(Display display) {
+ int index = 0;
+ while (index < displays.length) {
+ if (displays[index] == display) break;
+ index++;
+ }
+
+ if (index == displays.length) return;
+
+ if (cursors[index] != null) {
+ cursors[index].dispose();
+ }
+ cursors[index] = null;
+ counts[index] = 0;
+ displays[index] = null;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
new file mode 100755
index 0000000000..f263e2b2fd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CCombo.java
@@ -0,0 +1,950 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * The CCombo class represents a selectable user interface object
+ * that combines a text field and a list and issues notificiation
+ * when an item is selected from the list.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER, READ_ONLY</dd>
+ * <dt><b>Events:</b>
+ * <dd>Selection</dd>
+ * </dl>
+ */
+public final class CCombo extends Composite {
+
+ static final int ITEMS_SHOWING = 5;
+
+ Text text;
+ List list;
+ Shell popup;
+ Button arrow;
+
+public CCombo (Composite parent, int style) {
+ super (parent, checkStyle (style));
+
+ style = getStyle();
+
+ 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);
+
+ popup = new Shell (getShell (), SWT.ON_TOP | SWT.NO_TRIM);
+
+ int listStyle = SWT.SINGLE | SWT.V_SCROLL;
+ if ((style & SWT.FLAT) != 0) listStyle |= SWT.FLAT;
+ list = new List (popup, listStyle);
+
+ int arrowStyle = SWT.ARROW | SWT.DOWN;
+ if ((style & SWT.FLAT) != 0) arrowStyle |= SWT.FLAT;
+ arrow = new Button (this, arrowStyle);
+
+ Listener 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;
+ }
+
+ }
+ };
+
+ int [] popupEvents = {SWT.Close, SWT.Paint, SWT.Deactivate};
+ for (int i=0; i<popupEvents.length; i++) popup.addListener (popupEvents [i], listener);
+
+ int [] textEvents = {SWT.KeyDown, SWT.KeyUp, SWT.Modify, SWT.MouseDown, SWT.MouseUp, SWT.FocusIn, SWT.FocusOut, SWT.Traverse};
+ for (int i=0; i<textEvents.length; i++) text.addListener (textEvents [i], listener);
+
+ int [] listEvents = {SWT.MouseUp, SWT.FocusIn, SWT.FocusOut, SWT.Selection};
+ for (int i=0; i<listEvents.length; i++) list.addListener (listEvents [i], listener);
+
+ int [] comboEvents = {SWT.Dispose, SWT.Move, SWT.Resize};
+ for (int i=0; i<comboEvents.length; i++) this.addListener (comboEvents [i], listener);
+
+ int [] arrowEvents = {SWT.MouseDown};
+ for (int i=0; i<arrowEvents.length; i++) arrow.addListener (arrowEvents [i], listener);
+
+}
+static int checkStyle (int style) {
+ int mask = SWT.BORDER | SWT.READ_ONLY | SWT.FLAT;
+ return style & mask;
+}
+/**
+* Adds an item.
+* <p>
+* The item is placed at the end of the list.
+* Indexing is zero based.
+*
+* @param string the new item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the string is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the item cannot be added
+*/
+public void add (String string) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ list.add (string);
+}
+/**
+* Adds an item at an index.
+* <p>
+* The item is placed at an index in the list.
+* Indexing is zero based.
+*
+* This operation will fail when the index is
+* out of range.
+*
+* @param string the new item
+* @param index the index for the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the string is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the item cannot be added
+*/
+public void add (String string, int index) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ list.add (string, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addModifyListener (ModifyListener listener) {;
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+void arrowEvent (Event event) {
+ if (event.type != SWT.MouseDown || event.button != 1) return;
+ dropDown (!isDropped ());
+}
+/**
+* Clears the current selection.
+* <p>
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void clearSelection () {
+ text.clearSelection ();
+ list.deselectAll ();
+}
+void comboEvent (Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ if (popup != null && !popup.isDisposed ())
+ popup.dispose ();
+ popup = null;
+ text = null;
+ list = null;
+ arrow = null;
+ break;
+
+ case SWT.Move:
+ dropDown(false);
+ break;
+ case SWT.Resize:
+ internalLayout();
+ break;
+ }
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ int width = 0, height = 0;
+ Point textSize = text.computeSize (wHint, SWT.DEFAULT, changed);
+ Point arrowSize = arrow.computeSize(SWT.DEFAULT, SWT.DEFAULT, changed);
+ Point listSize = list.computeSize (wHint, SWT.DEFAULT, changed);
+ Point barSize = list.getVerticalBar().getSize();
+ int borderWidth = getBorderWidth();
+
+ height = Math.max (hHint, Math.max(textSize.y, arrowSize.y) + 2*borderWidth);
+ width = Math.max (wHint, Math.max(textSize.x + arrowSize.x + 2*borderWidth, listSize.x + 2) );
+ return new Point (width, height);
+}
+/**
+* Deselects an item.
+* <p>
+* If the item at an index is selected, it is
+* deselected. If the item at an index is not
+* selected, it remains deselected. Indices
+* that are out of range are ignored. Indexing
+* is zero based.
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselect (int index) {
+ list.deselect (index);
+}
+/**
+* Deselects all items.
+* <p>
+*
+* If an item is selected, it is deselected.
+* If an item is not selected, it remains unselected.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselectAll () {
+ list.deselectAll ();
+}
+void dropDown (boolean drop) {
+ if (drop == isDropped ()) return;
+ if (!drop) {
+ popup.setVisible (false);
+ return;
+ }
+ int index = list.getSelectionIndex ();
+ if (index != -1) list.setTopIndex (index);
+ Rectangle listRect = list.getBounds ();
+ int borderWidth = getBorderWidth();
+ Point point = toDisplay (new Point (0 - borderWidth, 0 - borderWidth));
+ Point comboSize = getSize();
+ popup.setBounds (point.x, point.y + comboSize.y, comboSize.x, listRect.height + 2);
+ popup.setVisible (true);
+ list.setFocus();
+}
+public Control [] getChildren () {
+ return new Control [0];
+}
+boolean getEditable () {
+ return text.getEditable ();
+}
+/**
+* Gets an item at an 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
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public String getItem (int index) {
+ return list.getItem (index);
+}
+/**
+* Gets the number of items.
+* <p>
+* This operation will fail if the number of
+* items could not be queried from the OS.
+*
+* @return the number of items in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_COUNT)
+* when the operation fails
+*/
+public int getItemCount () {
+ return list.getItemCount ();
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM_HEIGHT)
+* when the operation fails
+*/
+public int getItemHeight () {
+ return list.getItemHeight ();
+}
+/**
+* Gets the items.
+* <p>
+* This operation will fail if the items cannot
+* be queried from the OS.
+*
+* @return the items in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public String [] getItems () {
+ return list.getItems ();
+}
+/**
+* Gets the selection.
+* <p>
+* @return a point representing the selection start and end
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Point getSelection () {
+ return text.getSelection ();
+}
+/**
+* Gets the index of the selected item.
+* <p>
+* Indexing is zero based.
+* If no item is selected -1 is returned.
+*
+* @return the index of the selected item.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelectionIndex () {
+ return list.getSelectionIndex ();
+}
+/**
+* Gets the widget text.
+* <p>
+* If the widget has no text, an empty string is returned.
+*
+* @return the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText () {
+ return text.getText ();
+}
+/**
+* Gets the height of the combo's text field.
+* <p>
+* The operation will fail if the height cannot
+* be queried from the OS.
+
+* @return the height of the combo's text field.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ERROR_CANNOT_GET_ITEM_HEIGHT)
+* when the operation fails
+*/
+public int getTextHeight () {
+ return text.getLineHeight();
+}
+/**
+* Gets the text limit.
+* <p>
+* @return the text limit
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getTextLimit () {
+ return text.getTextLimit ();
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (String string) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return list.indexOf (string);
+}
+/**
+* Gets the index of an item.
+* <p>
+* The widget is searched starting at start including
+* the end position until an item is found that
+* is equal to the search itenm. If no item is
+* found, -1 is returned. Indexing is zero based.
+*
+* @param string the search item
+* @param index the starting position
+* @return the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (String string, int start) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return list.indexOf (string, start);
+}
+boolean isDropped () {
+ return popup.getVisible ();
+}
+void internalLayout () {
+ Rectangle rect = getClientArea();
+ int width = rect.width;
+ int height = rect.height;
+
+ if (isDropped ()) dropDown (false);
+ Point arrowSize = arrow.computeSize(SWT.DEFAULT, height);
+ text.setBounds (0, 0, width - arrowSize.x, height);
+ arrow.setBounds (width - arrowSize.x, 0, arrowSize.x, arrowSize.y);
+
+ Point size = getSize();
+ int listHeight = list.getItemHeight () * ITEMS_SHOWING;
+ Rectangle trim = list.computeTrim (0, 0, size.x - 2, listHeight);
+ list.setBounds (1, 1, size.x - 2, trim.height);
+}
+void listEvent (Event event) {
+ switch (event.type) {
+ 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.x = event.x;
+ e.y = event.y;
+ e.width = event.width;
+ e.height = event.height;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ notifyListeners(SWT.Selection, e);
+ event.doit = e.doit;
+ break;
+ }
+ case SWT.FocusOut: {
+ Control control = getDisplay ().getFocusControl ();
+ if (control == text) return;
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+ case SWT.FocusIn: {
+ Control control = getDisplay ().getFocusControl ();
+ if (control == text) return;
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ }
+}
+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:
+ dropDown (false);
+ break;
+ }
+}
+public void redraw (int x, int y, int width, int height, boolean all) {
+ if (!all) return;
+ Point location = text.getLocation();
+ text.redraw(x - location.x, y - location.y, width, height, all);
+ location = list.getLocation();
+ list.redraw(x - location.x, y - location.y, width, height, all);
+ if (arrow != null) {
+ location = arrow.getLocation();
+ arrow.redraw(x - location.x, y - location.y, width, height, all);
+ }
+}
+
+/**
+* Removes an item at an index.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param index the index of the item
+* @return the selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int index) {
+ list.remove (index);
+}
+/**
+* Removes a range of items.
+* <p>
+* Indexing is zero based. The range of items
+* is from the start index up to and including
+* the end index.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int start, int end) {
+ list.remove (start, end);
+}
+/**
+* Removes an item.
+* <p>
+* This operation will fail when the item
+* could not be removed from the OS.
+*
+* @param string the search item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (String string) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ list.remove (string);
+}
+/**
+* Removes all items.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void removeAll () {
+ text.setText ("");
+ list.removeAll ();
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeModifyListener (ModifyListener listener) {
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Modify, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener (SelectionListener listener) {
+ if (listener == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection,listener);
+}
+/**
+* Selects an item.
+* <p>
+* If the item at an index is not selected, it is
+* selected. Indices that are out of
+* range are ignored. Indexing is zero based.
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void select (int index) {
+ if (index == -1) {
+ list.deselectAll ();
+ text.setText ("");
+ 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);
+ if (text != null) text.setBackground(color);
+ if (list != null) list.setBackground(color);
+ if (arrow != null) arrow.setBackground(color);
+}
+
+
+/**
+* Sets the focus.
+*/
+public boolean setFocus () {
+ return text.setFocus ();
+}
+/**
+* Sets the widget font.
+*/
+public void setFont (Font font) {
+ super.setFont (font);
+ text.setFont (font);
+ list.setFont (font);
+ internalLayout ();
+}
+public void setForeground (Color color) {
+ super.setForeground(color);
+ if (text != null) text.setForeground(color);
+ if (list != null) list.setForeground(color);
+ if (arrow != null) arrow.setForeground(color);
+}
+/**
+* Sets the text of an item.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be changed in
+* the OS.
+*
+* @param index the index for the item
+* @param string the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+* @exception SWTError(ERROR_ITEM_NOT_MODIFIED)
+* when the operation fails
+*/
+public void setItem (int index, String string) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ list.setItem (index, string);
+}
+/**
+* Sets all items.
+* <p>
+* @param items the array of items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the operation fails
+*/
+public void setItems (String [] items) {
+ if (items == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int style = getStyle();
+ if ((style & SWT.READ_ONLY) != 0) text.setText ("");
+ list.setItems (items);
+}
+/**
+* Sets the new selection.
+* <p>
+* @param selection point representing the start and the end of the new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when selection is null
+*/
+public void setSelection (Point selection) {
+ if (selection == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ text.setSelection (selection.x, selection.y);
+}
+
+
+/**
+* Sets the widget text
+* <p>
+* @param string the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ 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 text limit
+* <p>
+* @param limit new text limit
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_BE_ZERO)
+* when limit is 0
+*/
+public void setTextLimit (int limit) {
+ text.setTextLimit (limit);
+}
+void textEvent (Event event) {
+ switch (event.type) {
+ case SWT.KeyDown: {
+
+ if (event.character == SWT.ESC) { // escape key cancels popup list
+ dropDown (false);
+ return;
+ }
+ if (event.keyCode == SWT.ARROW_UP || event.keyCode == SWT.ARROW_DOWN) {
+ 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;
+ notifyListeners(SWT.Selection, e);
+ }
+ }
+
+ // Further work : Need to add support for incremental search in pop up list as characters typed in text widget
+
+ 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;
+ }
+ 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.Modify: {
+ list.deselectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.Modify, e);
+ break;
+ }
+ case SWT.MouseDown: {
+ if (event.button != 1) return;
+ if (text.getEditable ()) return;
+ boolean dropped = isDropped ();
+ text.selectAll ();
+ if (!dropped) setFocus ();
+ dropDown (!dropped);
+ break;
+ }
+ case SWT.MouseUp: {
+ if (event.button != 1) return;
+ if (text.getEditable ()) return;
+ text.selectAll ();
+ break;
+ }
+ case SWT.FocusIn: {
+ if (getEditable ()) text.selectAll ();
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusIn, e);
+ break;
+ }
+ case SWT.FocusOut: {
+ Display display = getDisplay ();
+ Control focusControl = display.getFocusControl ();
+ if (isDropped ()) {
+ Control cursorControl = display.getCursorControl ();
+ if (cursorControl != list) dropDown (false);
+ if (focusControl != text) dropDown (false);
+ }
+ if (focusControl == list) return;
+ Event e = new Event();
+ e.time = event.time;
+ notifyListeners(SWT.FocusOut, e);
+ break;
+ }
+ case SWT.Traverse: {
+ if (event.detail == SWT.TRAVERSE_ARROW_PREVIOUS || event.detail == SWT.TRAVERSE_ARROW_NEXT) {
+ event.doit = false;
+ }
+ Event e = new Event();
+ e.time = event.time;
+ e.detail = event.detail;
+ e.doit = event.doit;
+ e.keyCode = event.keyCode;
+ notifyListeners(SWT.Traverse, e);
+ event.doit = e.doit;
+ break;
+ }
+ }
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java
new file mode 100755
index 0000000000..c2c372db5f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CLabel.java
@@ -0,0 +1,462 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * A Label which supports aligned text and/or an image and different border styles.
+ * <p>
+ * If there is not enough space a SmartLabel 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>SHADOW_IN, SHADOW_OUT, SHADOW_NONE</dd>
+ * <dt><b>Events:</b>
+ * <dd></dd>
+ * </dl>
+ */
+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 = "...";
+ /** 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 Image gradientImage;
+ private Color[] gradientColors;
+ private int[] gradientPercents;
+
+
+/**
+ * Create a CLabel with the given border style as a child of parent.
+ */
+public CLabel(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ 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);
+ }
+ });
+
+}
+/**
+ * Check the style bits to ensure that no invalid styles are applied.
+ */
+private static int checkStyle (int style) {
+ int mask = SWT.SHADOW_IN | SWT.SHADOW_OUT | SWT.SHADOW_NONE;
+ style = style & mask;
+ style |= SWT.NO_FOCUS | SWT.NO_BACKGROUND;
+ return style;
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ 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);
+}
+/**
+ * Returns the alignment.
+ * The alignment style (LEFT, CENTER or RIGHT) is returned.
+ */
+public int getAlignment() {
+ return align;
+}
+/**
+ * Return the CLabel's image or <code>null</code>.
+ */
+public Image getImage() {
+ 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);
+ 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 void setToolTipText (String string) {
+ super.setToolTipText (string);
+ appToolTipText = super.getToolTipText();
+}
+/**
+ * Return the Label's text.
+ */
+public String getText() {
+ return text;
+}
+public String getToolTipText () {
+ return appToolTipText;
+}
+/**
+ * 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);
+ }
+}
+private void onDispose(DisposeEvent event) {
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ }
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+}
+/*
+ * Process the paint event
+ */
+private void onPaint(PaintEvent event) {
+ Rectangle rect = getClientArea();
+ if (rect.width == 0 || rect.height == 0) return;
+
+ boolean shortenText = false;
+ String t = text;
+ Image i = image;
+ int availableWidth = rect.width - 2*hIndent;
+ Point extent = getTotalSize(i, t);
+ if (extent.x > availableWidth) {
+ i = null;
+ extent = getTotalSize(i, t);
+ if (extent.x > availableWidth) {
+ shortenText = true;
+ }
+ }
+
+ GC gc = event.gc;
+
+ // shorten the text
+ if (shortenText) {
+ t = shortenText(gc, text, availableWidth);
+ extent = getTotalSize(i, t);
+ 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-extent.x - hIndent;
+ }
+
+ // draw a background image behind the text
+ if (backgroundImage != null) {
+ Rectangle imageRect = backgroundImage.getBounds();
+ gc.drawImage(backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ 0, 0, rect.width, rect.height);
+ } else {
+ 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 (i != null) {
+ Rectangle imageRect = i.getBounds();
+ gc.drawImage(i, 0, 0, imageRect.width, imageRect.height,
+ x, (rect.height-imageRect.height)/2, imageRect.width, imageRect.height);
+ x += imageRect.width + GAP;
+ }
+ // draw the text
+ if (t != null) {
+ int textHeight = gc.getFontMetrics().getHeight();
+ gc.setForeground(getForeground());
+ gc.drawText(t, x, rect.y + (rect.height-textHeight)/2, true);
+ }
+}
+/**
+ * Set the alignment of the CLabel.
+ * Use the values LEFT, CENTER and RIGHT to align image and text within the available space.
+ */
+public void setAlignment(int align) {
+ if (align != SWT.LEFT && align != SWT.RIGHT && align != SWT.CENTER) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.align != align) {
+ this.align = align;
+ redraw();
+ }
+}
+/**
+ * Specify a gradiant of colours to be draw in the background of the CLabel.
+ * For example to draw a gradiant that varies from dark blue to blue and then to
+ * white, use the following call to setBackground:
+ * <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 gradiant
+ * in order of appearance left to right. The value <code>null</code> clears the
+ * background gradiant. 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.
+ */
+public void setBackground(Color[] colors, int[] percents) {
+ 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);
+ }
+ }
+
+ // Are these settings the same as before?
+ if (gradientImage == null && gradientColors == null && colors == null) {
+ if (backgroundImage != null) {
+ backgroundImage = null;
+ redraw();
+ }
+ return;
+ }
+ if (gradientColors != null && colors != null
+ && gradientColors.length == colors.length) {
+ boolean same = false;
+ for (int i = 0; i < gradientColors.length; i++) {
+ 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) return;
+ }
+
+ // Cleanup
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ }
+ gradientImage = null;
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ // Draw gradient onto an image
+ if (colors != null) {
+ int x = 0; int y = 0;
+ int width = 100; int height = 10;
+
+ Display display = getDisplay();
+ Image temp = new Image(display, width, height);
+ GC gc = new GC(temp);
+ if (colors.length == 1) {
+ gc.setBackground(colors[0]);
+ gc.fillRectangle(temp.getBounds());
+ }
+ int start = 0;
+ int end = 0;
+ for (int j = 0; j < colors.length - 1; j++) {
+ Color startColor = colors[j];
+ if (startColor == null) startColor = getBackground();
+ RGB rgb1 = startColor.getRGB();
+ Color endColor = colors[j+1];
+ if (endColor == null) endColor = getBackground();
+ RGB rgb2 = endColor.getRGB();
+ start = end;
+ end = (width) * percents[j] / 100;
+ int range = Math.max(1, end - start);
+ for (int k = 0; k < (end - start); k++) {
+ int r = rgb1.red + k*(rgb2.red - rgb1.red)/range;
+ r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);
+ int g = rgb1.green + k*(rgb2.green - rgb1.green)/range;
+ g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);
+ int b = rgb1.blue + k*(rgb2.blue - rgb1.blue)/range;
+ b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);
+ Color color = new Color(display, r, g, b);
+ gc.setBackground(color);
+ gc.fillRectangle(start + k,y,1,height);
+ gc.setBackground(getBackground());
+ color.dispose();
+ }
+ }
+ gc.dispose();
+ gradientImage = temp;
+ gradientColors = colors;
+ gradientPercents = percents;
+ backgroundImage = temp;
+ }
+
+ redraw();
+}
+public void setBackground(Image image) {
+ if (image == backgroundImage) return;
+
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = 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.
+ */
+public void setImage(Image image) {
+ if (image != this.image) {
+ this.image = image;
+ redraw();
+ }
+}
+/**
+ * Set the label's text.
+ * The value <code>null</code> clears it.
+ */
+public void setText(String text) {
+ if (text == null) text = "";
+ if (! text.equals(this.text)) {
+ this.text = text;
+ redraw();
+ }
+}
+/**
+ * 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.
+ */
+protected String shortenText(GC gc, String t, int width) {
+ int w = gc.textExtent(ellipsis).x;
+ int l = t.length();
+ int pivot = l/2;
+ int s = pivot;
+ int e = pivot+1;
+ while (s >= 0 && e < l) {
+ String s1 = t.substring(0, s);
+ String s2 = t.substring(e, l);
+ int l1 = gc.textExtent(s1).x;
+ int l2 = gc.textExtent(s2).x;
+ if (l1+w+l2 < width) {
+ t = s1 + ellipsis + s2;
+ break;
+ }
+ s--;
+ e++;
+ }
+ return t;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
new file mode 100755
index 0000000000..4c4f90cbb8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java
@@ -0,0 +1,1535 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+
+
+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;
+
+ /**
+ * Color of innermost line of drop shadow border.
+ */
+ public static RGB borderInsideRGB = new RGB (132, 130, 132);
+ /**
+ * Color of middle line of drop shadow border.
+ */
+ public static RGB borderMiddleRGB = new RGB (143, 141, 138);
+ /**
+ * Color of outermost line of drop shadow border.
+ */
+ public static RGB borderOutsideRGB = new RGB (171, 168, 165);
+
+ /*
+ * 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.
+ */
+ public static int MIN_TAB_WIDTH = 3;
+
+ /* sizing, positioning */
+ int xClient, yClient;
+ boolean onBottom = false;
+ int fixedTabHeight = -1;
+ int imageHeight = -1;
+
+ /* item management */
+ private CTabItem items[] = new CTabItem[0];
+ private int selectedIndex = -1;
+ int topTabIndex = -1; // index of the left most visible tab.
+
+ /* External Listener management */
+ private CTabFolderListener[] tabListeners = new CTabFolderListener[0];
+
+ /* Color appearance */
+ Image backgroundImage;
+ private Image gradientImage;
+ private Color[] gradientColors;
+ private int[] gradientPercents;
+ Color selectionForeground;
+
+ // internal constants
+ private static final int DEFAULT_WIDTH = 64;
+ private static final int DEFAULT_HEIGHT = 64;
+
+ // scrolling arrows
+ private ToolBar scrollBar;
+ private ToolItem scrollLeft;
+ private ToolItem scrollRight;
+ private Image arrowLeftImage;
+ private Image arrowRightImage;
+ private Image arrowLeftDisabledImage;
+ private Image arrowRightDisabledImage;
+
+ // close button
+ boolean showClose = false;
+ ToolBar closeBar;
+ private ToolItem closeItem;
+ private Image closeImage;
+ private ToolBar inactiveCloseBar;
+ private ToolItem inactiveCloseItem;
+ private Image inactiveCloseImage;
+ private CTabItem inactiveItem;
+
+ private boolean shortenedTabs = false;
+
+ // borders
+ boolean showBorders = false;
+ private int BORDER_BOTTOM = 0;
+ private int BORDER_LEFT = 0;
+ private int BORDER_RIGHT = 0;
+ private int BORDER_TOP = 0;
+ private Color borderColor1;
+ private Color borderColor2;
+ private Color borderColor3;
+
+ // when disposing CTabFolder, don't try to layout the items or
+ // change the selection as each child is destroyed.
+ private boolean inDispose = false;
+
+ // keep track of size changes in order to redraw only affected area
+ // on Resize
+ private Rectangle oldArea;
+
+ // insertion marker
+ int insertionIndex = -2; // Index of insert marker. Marker always shown after index.
+ // -2 means no insert marker
+
+ // tool tip
+ private Shell tip;
+
+/**
+ * Construct a CTabFolder with the specified parent and style.
+ * @param parent org.eclipse.swt.widgets.Composite
+ * @param swtStyle int
+ */
+public CTabFolder(Composite parent, int style) {
+ super(parent, checkStyle (style));
+
+ onBottom = (getStyle() & SWT.BOTTOM) != 0;
+
+ borderColor1 = new Color(getDisplay(), borderInsideRGB);
+ borderColor2 = new Color(getDisplay(), borderMiddleRGB);
+ borderColor3 = new Color(getDisplay(), borderOutsideRGB);
+ Color foreground = getForeground();
+ Color background = getBackground();
+
+ // create scrolling arrow buttons
+ scrollBar = new ToolBar(this, SWT.FLAT);
+ scrollBar.setVisible(false);
+ scrollLeft = new ToolItem(scrollBar, SWT.PUSH);
+ scrollLeft.setEnabled(false);
+ scrollRight = new ToolItem(scrollBar, SWT.PUSH);
+ scrollRight.setEnabled(false);
+ initScrollButtons(foreground, background);
+
+ // create close buttons
+ closeBar = new ToolBar(this, SWT.FLAT);
+ closeBar.setVisible(false);
+ closeItem = new ToolItem(closeBar, SWT.PUSH);
+ initCloseButton(foreground, background);
+
+ inactiveCloseBar = new ToolBar(this, SWT.FLAT);
+ inactiveCloseBar.setVisible(false);
+ inactiveCloseItem = new ToolItem(inactiveCloseBar, SWT.PUSH);
+ initInactiveCloseButton(foreground, background);
+
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {
+ handleEvents(event);
+ }
+ };
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.MouseUp, listener);
+ addListener(SWT.MouseMove, listener);
+ addListener(SWT.MouseExit, listener);
+ addListener(SWT.Paint, listener);
+ addListener(SWT.Resize, listener);
+ scrollLeft.addListener(SWT.Selection, listener);
+ scrollRight.addListener(SWT.Selection, listener);
+ closeItem.addListener(SWT.Selection, listener);
+ inactiveCloseItem.addListener(SWT.Selection, listener);
+ inactiveCloseBar.addListener (SWT.MouseExit, listener);
+
+ setBorderVisible((style & SWT.BORDER) != 0);
+
+ // tool tip support
+ Display display = getDisplay();
+ tip = new Shell (getShell(), SWT.NONE);
+ tip.setLayout(new FillLayout());
+ Label label = new Label (tip, SWT.NONE);
+ label.setForeground (display.getSystemColor (SWT.COLOR_INFO_FOREGROUND));
+ label.setBackground (display.getSystemColor (SWT.COLOR_INFO_BACKGROUND));
+ addMouseTrackListener (new MouseTrackAdapter () {
+ public void mouseExit(MouseEvent e) {
+ if (tip.isVisible()) tip.setVisible(false);
+ }
+ public void mouseHover(MouseEvent e) {
+ Point pt = new Point (e.x, e.y);
+ CTabItem item = getItem(pt);
+ if (item != null) {
+ String tooltip = item.getToolTipText();
+ if (tooltip != null) {
+ pt.y = (onBottom) ? pt.y - 26 : pt.y + 26;
+ pt = toDisplay(pt);
+ tip.setLocation(pt);
+ Label label = (Label) (tip.getChildren() [0]);
+ label.setText(tooltip);
+ tip.pack();
+ tip.setVisible(true);
+ return;
+ }
+ }
+
+ tip.setVisible(false);
+ }
+ });
+
+}
+private static int checkStyle (int style) {
+ int mask = SWT.TOP | SWT.BOTTOM | SWT.FLAT;
+ style = style & mask;
+ // TOP and BOTTOM are mutually exlusive.
+ // TOP is the default
+ if ((style & SWT.TOP) != 0)
+ style = style & ~(SWT.TOP | SWT.BOTTOM) | SWT.TOP;
+ // reduce the flash by not redrawing the entire area on a Resize event
+ style |= SWT.NO_REDRAW_RESIZE;
+ return style;
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when listener is null</li>
+* </ul>
+*/
+public void addSelectionListener(SelectionListener listener) {
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError <ul>
+* <li>ERROR_NULL_ARGUMENT when listener is null</li>
+* </ul>
+*/
+public void addCTabFolderListener(CTabFolderListener listener) {
+ 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;
+ showClose = true;
+}
+private void closeNotify(CTabItem item, int time) {
+ CTabFolderEvent event = new CTabFolderEvent(this);
+ event.widget = this;
+ event.time = time;
+ event.item = item;
+ event.doit = true;
+ if (tabListeners != null) {
+ for (int i = 0; i < tabListeners.length; i++) {
+ tabListeners[i].itemClosed(event);
+ }
+ }
+ if (event.doit) {
+ item.dispose();
+ }
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ int minWidth = 0;
+ int minHeight = 0;
+
+ // tab width
+ if (items.length > 0) {
+ CTabItem lastItem = items[items.length-1];
+ minWidth = lastItem.x + lastItem.width;
+ }
+
+ // get max preferred size of 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);
+ minWidth = Math.max (minWidth, size.x);
+ minHeight = Math.max (minHeight, size.y);
+ }
+ }
+ if (minWidth == 0) minWidth = DEFAULT_WIDTH;
+ if (minHeight == 0) minHeight = DEFAULT_HEIGHT;
+
+ if (wHint != SWT.DEFAULT) minWidth = wHint;
+ if (hHint != SWT.DEFAULT) minHeight = hHint;
+
+ Rectangle trim = computeTrim(0, 0, minWidth, minHeight);
+ return new Point (trim.width, trim.height);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ int tabHeight = getTabHeight();
+ int trimX = x - marginWidth - BORDER_LEFT;
+ int trimY = y - marginHeight - tabHeight - BORDER_TOP;
+ if (onBottom) {
+ trimY = y - marginHeight - BORDER_TOP;
+ }
+ int trimWidth = width + BORDER_LEFT + BORDER_RIGHT + 2*marginWidth;
+ int trimHeight = height + BORDER_TOP + BORDER_BOTTOM + 2*marginHeight + tabHeight;
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+/**
+ * Create the specified item at 'index'.
+ */
+void createItem (CTabItem item, int index) {
+ if (0 > index || index > getItemCount ()){
+ SWT.error (SWT.ERROR_INVALID_RANGE);
+ }
+ // grow by one and rearrange the array.
+ 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;
+
+ item.parent = this;
+
+ if (selectedIndex >= index) {
+ selectedIndex ++;
+ }
+ if (items.length == 1) {
+ topTabIndex = 0;
+ }
+
+ layoutItems();
+ if (items.length == 1) {
+ redraw();
+ } else {
+ redrawTabArea(-1);
+ }
+}
+/**
+ * Destroy the specified item.
+ */
+void destroyItem (CTabItem item) {
+ if (inDispose) return;
+
+ int index = indexOf(item);
+ if (index == -1) return; // should this trigger an error?
+
+ insertionIndex = -2;
+
+ if (items.length == 1) {
+ items = new CTabItem[0];
+ selectedIndex = -1;
+ topTabIndex = 0;
+
+ Control control = item.getControl();
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ closeBar.setVisible(false);
+ redraw();
+ return;
+ }
+
+ // shrink by one and rearrange the array.
+ 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;
+
+ if (topTabIndex == items.length) {
+ --topTabIndex;
+ }
+
+ // move the selection if this item is selected
+ if (selectedIndex == index) {
+ Control control = item.getControl();
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ selectedIndex = -1;
+ setSelectionNotify(Math.max(0, index - 1));
+ } else if (selectedIndex > index) {
+ selectedIndex --;
+ }
+
+ layoutItems();
+ redrawTabArea(-1);
+}
+/**
+ * Dispose the items of the receiver
+ */
+private void onDispose() {
+ inDispose = true;
+
+ // items array is resized during CTabItem.dispose
+ // it is set to null if the last item is removed
+ int length = items.length;
+ for (int i = 0; i < length; i++) {
+ if (items[i] != null) {
+ items[i].dispose();
+ }
+ }
+
+ // clean up resources
+ if (tip != null && !tip.isDisposed()) {
+ tip.dispose();
+ tip = null;
+ }
+
+ if (gradientImage != null){
+ gradientImage.dispose();
+ gradientImage = null;
+ }
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ if (arrowLeftImage != null){
+ arrowLeftImage.dispose();
+ arrowLeftImage = null;
+ }
+
+ if (arrowRightImage != null){
+ arrowRightImage.dispose();
+ arrowRightImage = null;
+ }
+
+ if (arrowLeftDisabledImage != null) {
+ arrowLeftDisabledImage.dispose();
+ arrowLeftDisabledImage = null;
+ }
+
+ if (arrowRightDisabledImage != null) {
+ arrowRightDisabledImage.dispose();
+ arrowRightDisabledImage = null;
+ }
+
+ if (closeImage != null) {
+ closeImage.dispose();
+ closeImage = null;
+ }
+
+ if (inactiveCloseImage != null) {
+ inactiveCloseImage.dispose();
+ inactiveCloseImage = null;
+ }
+
+ if (borderColor1 != null) {
+ borderColor1.dispose();
+ borderColor1 = null;
+ }
+
+ if (borderColor2 != null) {
+ borderColor2.dispose();
+ borderColor2 = null;
+ }
+
+ if (borderColor3 != null) {
+ borderColor3.dispose();
+ borderColor3 = null;
+ }
+}
+/**
+ * Draw a border around the receiver.
+ */
+private void drawBorder(GC gc) {
+
+ Rectangle d = super.getClientArea();
+
+ if (showBorders) {
+ if ((getStyle() & SWT.FLAT) != 0) {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(d.x, d.y, d.x + d.width - 1, d.y + d.height - 1);
+ } else {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(d.x, d.y, d.x + d.width - 3, d.y + d.height - 3);
+
+ gc.setForeground(borderColor2);
+ gc.drawLine(d.x + 1, d.y + d.height - 2, d.x + d.width - 1, d.y + d.height - 2);
+ gc.drawLine(d.x + d.width - 2, d.y + 1, d.x + d.width - 2, d.y + d.height - 1);
+
+ gc.setForeground(borderColor3);
+ gc.drawLine(d.x + 2, d.y + d.height - 1, d.x + d.width - 2, d.y + d.height - 1);
+ gc.drawLine(d.x + d.width - 1, d.y + 2, d.x + d.width - 1, d.y + d.height - 2);
+
+ // fill in corners with parent's background
+ gc.setForeground(getParent().getBackground());
+ gc.drawLine(d.x + d.width - 2, d.y, d.x + d.width - 1, d.y);
+ gc.drawLine(d.x + d.width - 1, d.y + 1, d.x + d.width - 1, d.y + 1);
+
+ gc.drawLine(d.x, d.y + d.height - 2, d.x, d.y + d.height - 2);
+ gc.drawLine(d.x, d.y + d.height - 1, d.x + 1, d.y + d.height - 1);
+
+ gc.drawLine(d.x + d.width - 1, d.y + d.height - 1, d.x + d.width - 1, d.y + d.height - 1);
+ }
+
+ }
+
+ // draw a separator line
+ if (items.length > 0) {
+ int tabHeight = getTabHeight();
+ int lineY = d.y + BORDER_TOP + tabHeight;
+ if (onBottom) {
+ lineY = d.y + d.height - BORDER_BOTTOM - tabHeight - 1;
+ }
+ gc.setForeground(borderColor1);
+ gc.drawLine(d.x + BORDER_LEFT, lineY, d.x + d.width - BORDER_RIGHT, lineY);
+ }
+
+ gc.setForeground(getForeground());
+}
+public Rectangle getClientArea() {
+ Rectangle clientArea = super.getClientArea();
+ clientArea.x = xClient;
+ clientArea.y = yClient;
+ clientArea.width -= 2*marginWidth + BORDER_LEFT + BORDER_RIGHT;
+ clientArea.height -= 2*marginHeight + BORDER_TOP + BORDER_BOTTOM + getTabHeight() + 1;
+ return clientArea;
+}
+/**
+ * Return the height of item images. All images are scaled to
+ * the height of the first image.
+ */
+int getImageHeight() {
+ return imageHeight;
+}
+public int getTabHeight(){
+ if (fixedTabHeight > 0) return fixedTabHeight;
+
+ if (isDisposed()) return 0;
+
+ int tempHeight = 0;
+ GC gc = new GC(this);
+ for (int i=0; i < items.length; i++) {
+ int height = items[i].preferredHeight(gc);
+ tempHeight = Math.max(tempHeight, height);
+ }
+ gc.dispose();
+ return tempHeight;
+}
+/**
+ * Return the tab that is located at the specified index.
+ */
+public CTabItem getItem (int index) {
+ if (index < 0 || index > items.length)
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+/**
+* Gets the item at a point in the widget.
+* <p>
+*
+* @return the item at a point
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_CANNOT_GET_COUNT when the operation fails</li>
+* </ul>
+*/
+public CTabItem getItem (Point pt) {
+ for (int i = 0; i < items.length; i++) {
+ Rectangle bounds = items[i].getBounds();
+ if (bounds.contains(pt)) return items[i];
+ }
+ return null;
+}
+/**
+ * Return the number of tabs in the folder.
+ */
+public int getItemCount(){
+ return items.length;
+}
+/**
+ * Return the tab items.
+ */
+public CTabItem [] getItems() {
+ CTabItem[] tabItems = new CTabItem [items.length];
+ System.arraycopy(items, 0, tabItems, 0, items.length);
+ return tabItems;
+}
+/**
+ * Return the selected tab item, or an empty array if there
+ * is no selection.
+ */
+public CTabItem getSelection() {
+ if (selectedIndex == -1) return null;
+ return items[selectedIndex];
+}
+/**
+ * Return the index of the selected tab item, or -1 if there
+ * is no selection.
+ */
+public int getSelectionIndex() {
+ return selectedIndex;
+}
+
+private void handleEvents (Event event){
+ switch (event.type) {
+ case SWT.Dispose:
+ onDispose();
+ break;
+ case SWT.Paint:
+ onPaint(event);
+ break;
+ case SWT.Resize:
+ onResize();
+ break;
+ case SWT.MouseUp:
+ onMouseUp(event);
+ break;
+ case SWT.MouseExit:
+ if (event.widget == this) {
+ Rectangle inactiveBounds = inactiveCloseBar.getBounds();
+ if (inactiveBounds.contains(event.x, event.y)) return;
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+ if (event.widget == inactiveCloseBar) {
+ Rectangle bounds = getBounds();
+ if (bounds.contains(event.x, event.y)) return;
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+ break;
+ case SWT.MouseMove:
+ onMouseMove(event);
+ break;
+ case SWT.Selection:
+ if (event.widget == scrollLeft) {
+ scroll_scrollLeft();
+ }
+ if (event.widget == scrollRight) {
+ scroll_scrollRight();
+ }
+ if (event.widget == closeItem) {
+ closeNotify(getSelection(), event.time);
+ }
+ if (event.widget == inactiveCloseItem) {
+ closeNotify(inactiveItem, event.time);
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+ break;
+ default:
+ break;
+ }
+}
+/**
+ * Return the index of the specified tab or -1 if the tab is not
+ * in the receiver.
+ */
+public int indexOf(CTabItem item) {
+ 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;
+}
+/**
+ * 'item' has changed. Store the image size if this is the
+ * first item with an image.
+ */
+void itemChanged(CTabItem item) {
+ Image itemImage = item.getImage();
+ if (imageHeight == -1 && itemImage != null) {
+ imageHeight = itemImage.getBounds().height;
+ }
+
+ int height = getTabHeight();
+ Point size = scrollBar.computeSize(SWT.DEFAULT, height);
+ scrollBar.setSize(size);
+ height = (onBottom) ? height - 2 : height - 1;
+ size = closeBar.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ closeBar.setSize(size);
+ inactiveCloseBar.setSize(size);
+
+ layoutItems();
+ redrawTabArea(-1);
+}
+private void layoutButtons() {
+
+ boolean leftVisible = scroll_leftVisible();
+ boolean rightVisible = scroll_rightVisible();
+
+ if (leftVisible || rightVisible) {
+ Point size = scrollBar.getSize();
+ Rectangle area = super.getClientArea();
+ int x = area.x + area.width - size.x - BORDER_RIGHT;
+ int y = 0;
+ if (!onBottom) {
+ y = area.y + BORDER_TOP;
+ } else {
+ y = area.y + area.height - BORDER_BOTTOM - size.y;
+ }
+ scrollBar.setLocation(x, y);
+ scrollLeft.setEnabled(leftVisible);
+ scrollRight.setEnabled(rightVisible);
+ scrollBar.setVisible(true);
+ } else {
+ scrollBar.setVisible(false);
+ }
+
+ // When the close button is right at the edge of the Tab folder, hide it because
+ // otherwise it may block off a part of the border on the right
+ if (showClose) {
+ Point size = closeBar.getSize();
+ CTabItem item = getSelection();
+ if (item == null) {
+ closeBar.setVisible(false);
+ } else {
+ int x = item.x + item.width - size.x - 2;
+ int y = item.y + 1 + (item.height - 2 - size.y) / 2; // +1 for white line across top of tab
+ closeBar.setLocation(x, y);
+ if (scrollBar.isVisible()) {
+ Rectangle scrollRect = scrollBar.getBounds();
+ scrollRect.width += BORDER_RIGHT;
+ closeBar.setVisible(!scrollRect.contains(x, y));
+ } else {
+ closeBar.setVisible(true);
+ }
+ }
+ }
+}
+/**
+ * Layout the items and store the client area size.
+ */
+private void layoutItems() {
+ if (isDisposed()) return;
+
+ Rectangle area = super.getClientArea();
+ if (area.height == 0) return;
+
+ int tabHeight = getTabHeight();
+
+ shortenedTabs = false;
+ if (items.length > 0) {
+ int[] widths = new int[items.length];
+ int totalWidth = 0;
+ GC gc = new GC(this);
+ for (int i = 0; i < items.length; i++) {
+ widths[i] = items[i].preferredWidth(gc);
+ totalWidth += widths[i];
+ }
+ gc.dispose();
+ if (totalWidth < (area.width - BORDER_LEFT - BORDER_RIGHT) ) {
+ topTabIndex = 0;
+ } else {
+
+ int oldAverageWidth = 0;
+ int averageWidth = (area.width - BORDER_LEFT - BORDER_RIGHT) / items.length;
+ while (averageWidth > oldAverageWidth) {
+ int width = area.width - BORDER_LEFT - BORDER_RIGHT;
+ int count = items.length;
+ for (int i = 0; i < items.length; i++) {
+ if (widths[i] < averageWidth) {
+ width -= widths[i];
+ count--;
+ }
+ }
+ oldAverageWidth = averageWidth;
+ if (count > 0) {
+ averageWidth = width / count;
+ }
+ }
+ if (averageWidth > MIN_TAB_WIDTH * tabHeight) {
+ for (int i = 0; i < items.length; i++) {
+ if (widths[i] > averageWidth) {
+ widths[i] = averageWidth;
+ }
+ }
+ topTabIndex = 0;
+ shortenedTabs = true;
+ }
+ }
+ int x = area.x;
+ int y = area.y + BORDER_TOP;
+ if (onBottom) {
+ y = Math.max(0, area.y + area.height - BORDER_BOTTOM - tabHeight);
+ }
+ for (int i = topTabIndex - 1; i>=0; i--) {
+ // if the first visible tab is not the first tab
+ CTabItem tab = items[i];
+ tab.width = widths[i];
+ tab.height = getTabHeight();
+ x -= tab.width;
+ // layout tab items from right to left thus making them invisible
+ tab.x = x;
+ tab.y = y;
+ }
+
+ x = area.x + BORDER_LEFT;
+ for (int i=topTabIndex; i<items.length; i++) {
+ // continue laying out remaining, visible items left to right
+ CTabItem tab = items[i];
+ tab.x = x;
+ tab.y = y;
+ tab.height = tabHeight;
+ tab.width = widths[i];
+ x = x + tab.width;
+ }
+ }
+
+ xClient = area.x + BORDER_LEFT + marginWidth;
+ if (onBottom) {
+ yClient = area.y + BORDER_TOP + marginHeight;
+ } else {
+ yClient = area.y + BORDER_TOP + tabHeight + 1 + marginHeight;
+ // +1 is for the line at the bottom of the tabs
+ }
+
+ // resize the scrollbar and close butotns
+ layoutButtons();
+}
+/**
+ * Paint the receiver.
+ */
+private void onPaint(Event event) {
+ GC gc = event.gc;
+ Rectangle rect = super.getClientArea();
+ if (items.length == 0) {
+
+ if (showBorders) {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(rect.x + BORDER_RIGHT,
+ rect.y + BORDER_BOTTOM,
+ rect.x + rect.width - BORDER_RIGHT - 1,
+ rect.y + rect.height - BORDER_BOTTOM - 1);
+ // fill in top and left edge with parent's background color
+ gc.setBackground(getParent().getBackground());
+ gc.fillRectangle(rect.x, rect.y, BORDER_RIGHT, rect.height);
+ gc.fillRectangle(rect.x, rect.y, rect.width, BORDER_BOTTOM);
+
+ }
+ if (fixedTabHeight > 0) {
+ int y = rect.y + BORDER_BOTTOM + fixedTabHeight;
+ if (onBottom) {
+ y = rect.y + rect.height - fixedTabHeight - 1;
+ }
+ gc.setForeground(borderColor1);
+ gc.drawLine(rect.x + BORDER_RIGHT, y, rect.x + rect.width, y);
+ }
+ gc.setForeground(getForeground());
+ gc.setBackground(getBackground());
+ return;
+ }
+
+ // redraw the Border
+ drawBorder(gc);
+
+ rect.x += BORDER_LEFT;
+ rect.y += BORDER_TOP;
+ rect.width -= BORDER_LEFT + BORDER_RIGHT;
+ rect.height -= BORDER_TOP + BORDER_BOTTOM;
+ gc.setClipping(rect);
+
+ // Draw the unselected tabs first.
+ for (int i=0; i < items.length; i++) {
+ if (i != selectedIndex && event.getBounds().intersects(items[i].getBounds())) {
+ items[i].onPaint(gc, false);
+ }
+ }
+ // Selected tab comes last
+ if (selectedIndex != -1) {
+ items[selectedIndex].onPaint(gc, true);
+ }
+
+ // draw insertion mark
+ if (insertionIndex > -2) {
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
+ if (insertionIndex == -1) {
+ Rectangle bounds = items[0].getBounds();
+ gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+ gc.drawLine(bounds.x - 2, bounds.y, bounds.x + 2, bounds.y);
+ gc.drawLine(bounds.x - 1, bounds.y + 1, bounds.x + 1, bounds.y + 1);
+ gc.drawLine(bounds.x - 1, bounds.y + bounds.height - 2, bounds.x + 1, bounds.y + bounds.height - 2);
+ gc.drawLine(bounds.x - 2, bounds.y + bounds.height - 1, bounds.x + 2, bounds.y + bounds.height - 1);
+
+ } else {
+ Rectangle bounds = items[insertionIndex].getBounds();
+ gc.drawLine(bounds.x + bounds.width, bounds.y, bounds.x + bounds.width, bounds.y + bounds.height - 1);
+ gc.drawLine(bounds.x + bounds.width - 2, bounds.y, bounds.x + bounds.width + 2, bounds.y);
+ gc.drawLine(bounds.x + bounds.width - 1, bounds.y + 1, bounds.x + bounds.width + 1, bounds.y + 1);
+ gc.drawLine(bounds.x + bounds.width - 1, bounds.y + bounds.height - 2, bounds.x + bounds.width + 1, bounds.y + bounds.height - 2);
+ gc.drawLine(bounds.x + bounds.width - 2, bounds.y + bounds.height - 1, bounds.x + bounds.width + 2, bounds.y + bounds.height - 1);
+ }
+ }
+
+ gc.setForeground(getForeground());
+ gc.setBackground(getBackground());
+}
+private void redrawTabArea(int index) {
+ int x = 0, y = 0, width = 0, height = 0;
+ if (index == -1) {
+ Rectangle area = super.getClientArea();
+ if (area.width == 0 || area.height == 0) return;
+ width = area.x + area.width - BORDER_LEFT - BORDER_RIGHT;
+ height = getTabHeight() + 1; // +1 causes top line between content and tabs to be redrawn
+ x = area.x + BORDER_LEFT;
+ y = area.y + BORDER_TOP;
+ if (onBottom) {
+ y = Math.max(0, area.y + area.height - BORDER_BOTTOM - height);
+ }
+ } else {
+ CTabItem item = items[index];
+ x = item.x;
+ y = item.y;
+ width = item.width;
+ height = item.height;
+ }
+ redraw(x, y, width, height, false);
+}
+
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeSelectionListener(SelectionListener listener) {
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeCTabFolderListener(CTabFolderListener listener) {
+ 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];
+ showClose = false;
+ 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;
+}
+
+/**
+ * The widget was resized. Adjust the size of the currently selected page.
+ */
+private void onResize() {
+
+ if (items.length == 0) {
+ redraw();
+ return;
+ }
+
+ Rectangle area = super.getClientArea();
+ if (oldArea == null || oldArea.width == 0 || oldArea.height == 0) {
+ layoutItems();
+ redraw();
+ } else {
+ if (onBottom && oldArea.height != area.height) {
+ // move tabs up or down if tabs on bottom
+ layoutItems();
+ redraw();
+ } else {
+ int width = 0;
+ if (oldArea.width < area.width) {
+ width = area.width - oldArea.width + BORDER_RIGHT;
+ } else if (oldArea.width > area.width) {
+ width = BORDER_RIGHT;
+ }
+ redraw(area.x + area.width - width, area.y, width, area.height, false);
+
+ int height = 0;
+ if (oldArea.height < area.height) {
+ height = area.height - oldArea.height + BORDER_BOTTOM;
+ }
+ if (oldArea.height > area.height) {
+ height = BORDER_BOTTOM;
+ }
+ redraw(area.x, area.y + area.height - height, area.width, height, false);
+
+ if (oldArea.width != area.width) {
+ // resize the widths so that all tabs are visible
+ boolean wasShortened = shortenedTabs;
+ layoutItems();
+ if (wasShortened || shortenedTabs) {
+ redrawTabArea(-1);
+ }
+ }
+ }
+ }
+ oldArea = area;
+
+ // resize content
+ if (selectedIndex != -1) {
+ Control control = items[selectedIndex].getControl();
+ if (control != null && !control.isDisposed()) {
+ control.setBounds(getClientArea());
+ }
+ }
+}
+public void setBackground (Color color) {
+ super.setBackground(color);
+ color = getBackground();
+ Color foreground = getForeground();
+
+ // init inactive close button
+ initInactiveCloseButton(foreground, color);
+
+ // init scroll buttons
+ initScrollButtons(foreground, color);
+
+ // init close button
+ if (gradientColors == null) {
+ if (selectionForeground != null) {
+ foreground = selectionForeground;
+ }
+ initCloseButton(foreground, color);
+ }
+}
+/**
+ * Specify a gradiant of colours to be draw in the background of the selected tab.
+ * For example to draw a gradiant 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 gradiant
+ * in order of appearance left to right. The value <code>null</code> clears the
+ * background gradiant. 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.
+ */
+
+public void setSelectionBackground(Color[] colors, int[] percents) {
+ 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);
+ }
+ }
+ }
+
+ // Are these settings the same as before?
+ if (gradientImage == null && gradientColors == null && colors == null) {
+ if (backgroundImage != null) {
+ backgroundImage = null;
+ redrawTabArea(selectedIndex);
+ }
+ return;
+ }
+ 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]);
+ if (!same) break;
+ }
+ if (same) {
+ for (int i = 0; i < gradientPercents.length; i++) {
+ same = gradientPercents[i] == percents[i];
+ if (!same) break;
+ }
+ }
+ if (same) return;
+ }
+
+ // Cleanup
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
+ }
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = null;
+
+ // Draw gradient onto an image
+ if (colors != null) {
+ int x = 0; int y = 0;
+ int width = 100; int height = 10;
+
+ Display display = getDisplay();
+ Image temp = new Image(display, width, height);
+ GC gc = new GC(temp);
+ int start = 0;
+ int end = 0;
+ Color background = getBackground();
+ if (colors.length == 1) {
+ gc.setBackground(colors[0]);
+ gc.fillRectangle(temp.getBounds());
+ }
+ for (int j = 0; j < colors.length - 1; j++) {
+ Color startColor = colors[j];
+ if (startColor == null) startColor = getBackground();
+ RGB rgb1 = startColor.getRGB();
+ Color endColor = colors[j+1];
+ if (endColor == null) endColor = getBackground();
+ RGB rgb2 = endColor.getRGB();
+ start = end;
+ end = (width) * percents[j] / 100;
+ int range = Math.max(1, end - start);
+ for (int k = 0; k < (end - start); k++) {
+ int r = rgb1.red + k*(rgb2.red - rgb1.red)/range;
+ r = (rgb2.red > rgb1.red) ? Math.min(r, rgb2.red) : Math.max(r, rgb2.red);
+ int g = rgb1.green + k*(rgb2.green - rgb1.green)/range;
+ g = (rgb2.green > rgb1.green) ? Math.min(g, rgb2.green) : Math.max(g, rgb2.green);
+ int b = rgb1.blue + k*(rgb2.blue - rgb1.blue)/range;
+ b = (rgb2.blue > rgb1.blue) ? Math.min(b, rgb2.blue) : Math.max(b, rgb2.blue);
+ Color color = new Color(display, r, g, b);
+ gc.setBackground(color);
+ gc.fillRectangle(start + k,y,1,height);
+ gc.setBackground(background);
+ color.dispose();
+ }
+ }
+ gc.dispose();
+ gradientImage = temp;
+ gradientColors = colors;
+ gradientPercents = percents;
+ backgroundImage = temp;
+
+ Color closeBackground = colors[colors.length - 1];
+ if (closeBackground == null){
+ closeBackground = background;
+ }
+ Color closeForeground = getForeground();
+ initCloseButton(closeForeground, closeBackground);
+ } else {
+ Color closeBackground = getBackground();
+ Color closeForeground = getForeground();
+ initCloseButton(closeForeground, closeBackground);
+ }
+ if (selectedIndex > -1) redrawTabArea(selectedIndex);
+}
+public void setSelectionBackground(Image image) {
+ if (image == backgroundImage) return;
+ if (gradientImage != null) {
+ gradientImage.dispose();
+ gradientImage = null;
+ }
+ gradientColors = null;
+ gradientPercents = null;
+ backgroundImage = image;
+ redrawTabArea(selectedIndex);
+}
+public void setBorderVisible(boolean show) {
+ if (showBorders == show) return;
+
+ showBorders = show;
+ if (showBorders) {
+ if ((getStyle() & SWT.FLAT) != 0) {
+ BORDER_BOTTOM = BORDER_TOP = BORDER_LEFT = BORDER_RIGHT = 1;
+ } else {
+ BORDER_LEFT = BORDER_TOP = 1;
+ BORDER_RIGHT = BORDER_BOTTOM = 3;
+ }
+ } else {
+ BORDER_BOTTOM = BORDER_TOP = BORDER_LEFT = BORDER_RIGHT = 0;
+ }
+ layoutItems();
+ redraw();
+}
+public void setFont(Font font) {
+ if (font != null && font.equals(getFont())) return;
+ super.setFont(font);
+ layoutItems();
+ redrawTabArea(-1);
+}
+public void setForeground (Color color) {
+ super.setForeground(color);
+ color = getForeground();
+ Color background = getBackground();
+
+ initInactiveCloseButton(color, background);
+ initScrollButtons(color, background);
+
+ if (gradientColors != null) {
+ background = gradientColors[gradientColors.length - 1];
+ }
+ initCloseButton(color, background);
+}
+public void setSelectionForeground (Color color) {
+ if (selectionForeground == color) return;
+ if (color == null) color = getForeground();
+ selectionForeground = color;
+ if (selectedIndex > -1) {
+ redrawTabArea(selectedIndex);
+ }
+}
+public void setInsertMark(CTabItem item, boolean after) {
+ int index = -1;
+ if (item != null) {
+ index = indexOf(item);
+ }
+ setInsertMark(index, after);
+}
+public void setInsertMark(int index, boolean after) {
+ if (index < -1 || index >= getItemCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ if (index == -1) {
+ index = -2;
+ } else {
+ index = after ? index : --index;
+ }
+
+ if (insertionIndex == index) return;
+ int oldIndex = insertionIndex;
+ insertionIndex = index;
+ if (index > -1) redrawTabArea(index);
+ if (oldIndex > 1) redrawTabArea(oldIndex);
+}
+
+/**
+ * Set the selection to the tab at the specified index.
+ */
+public void setSelection(int index) {
+ if (index < 0 || index >= items.length)
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ if (selectedIndex == index) return;
+
+ if (showClose) {
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+ }
+
+ int oldIndex = selectedIndex;
+ selectedIndex = index;
+
+ Control control = items[index].control;
+ if (control != null && !control.isDisposed()) {
+ control.setBounds(getClientArea());
+ control.setVisible(true);
+ }
+
+ if (oldIndex != -1) {
+ control = items[oldIndex].control;
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ }
+ ensureVisible();
+
+ redrawTabArea(-1);
+}
+private void ensureVisible() {
+ // make sure item is visible
+ Rectangle area = super.getClientArea();
+ if (area.width == 0) return;
+ int areaWidth = area.x + area.width - BORDER_RIGHT;
+
+ CTabItem tabItem = items[selectedIndex];
+ if (selectedIndex < topTabIndex) {
+ topTabIndex = selectedIndex;
+ }
+ layoutItems();
+
+ int scrollWidth = scrollBar.getSize().x;
+ int width = areaWidth;
+ if (scroll_leftVisible() || scroll_rightVisible()) {
+ width -= scrollWidth;
+ }
+ while (tabItem.x + tabItem.width > width && selectedIndex != topTabIndex) {
+ topTabIndex++;
+ layoutItems();
+ width = areaWidth;
+ if (scroll_leftVisible() || scroll_rightVisible()) {
+ width -= scrollWidth;
+ }
+ }
+}
+/**
+ * Set the selection to the specified item.
+ */
+public void setSelection(CTabItem item) {
+ 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.
+ */
+private void setSelectionNotify(int index) {
+ int oldSelectedIndex = selectedIndex;
+ setSelection(index);
+ if (selectedIndex != oldSelectedIndex && selectedIndex != -1) {
+ Event event = new Event();
+ event.item = getItem(selectedIndex);
+ notifyListeners(SWT.Selection, event);
+ }
+}
+
+private void initCloseButton(Color foreground, Color background) {
+ if (closeImage != null) {
+ closeImage.dispose();
+ closeImage = null;
+ }
+ closeImage = drawCloseImage(foreground, background);
+ closeBar.setBackground(background);
+ closeBar.setForeground(foreground);
+ closeItem.setImage(closeImage);
+}
+private void initInactiveCloseButton(Color foreground, Color background) {
+ if (inactiveCloseImage != null) {
+ inactiveCloseImage.dispose();
+ inactiveCloseImage = null;
+ }
+ inactiveCloseImage = drawCloseImage(foreground, background);
+ inactiveCloseBar.setBackground(background);
+ inactiveCloseBar.setForeground(foreground);
+ inactiveCloseItem.setImage(inactiveCloseImage);
+}
+private Image drawCloseImage(Color foreground, Color background) {
+ Image image = new Image(getDisplay(), 9, 9);
+ GC gc = new GC(image);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, 9, 9);
+ gc.setForeground(foreground);
+ for (int i = 0; i < 8; i++) {
+ gc.drawLine(i, i, i + 1, i);
+ gc.drawLine(7 - i, i, 8 - i, i);
+ }
+ gc.dispose();
+ return image;
+}
+private void initScrollButtons(Color foreground, Color background) {
+
+ scrollBar.setBackground(background);
+
+ Display display = getDisplay();
+ Color shadow = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ if (arrowLeftImage != null) {
+ arrowLeftImage.dispose();
+ arrowLeftImage = null;
+ }
+ if (arrowLeftDisabledImage != null) {
+ arrowLeftDisabledImage.dispose();
+ arrowLeftDisabledImage = null;
+ }
+ arrowLeftImage = drawArrowImage(foreground, background, true);
+ arrowLeftDisabledImage = drawArrowImage(shadow, background, true);
+ scrollLeft.setImage(arrowLeftImage);
+ scrollLeft.setDisabledImage(arrowLeftDisabledImage);
+ scrollLeft.setHotImage(arrowLeftImage);
+
+ if (arrowRightImage != null) {
+ arrowRightImage.dispose();
+ arrowRightImage = null;
+ }
+ if (arrowRightDisabledImage != null) {
+ arrowRightDisabledImage.dispose();
+ arrowRightDisabledImage = null;
+ }
+ arrowRightImage = drawArrowImage(foreground, background, false);
+ arrowRightDisabledImage = drawArrowImage(shadow, background, false);
+ scrollRight.setImage(arrowRightImage);
+ scrollRight.setDisabledImage(arrowRightDisabledImage);
+ scrollRight.setHotImage(arrowRightImage);
+}
+
+private Image drawArrowImage (Color foreground, Color background, boolean left) {
+ // create image for left button
+ int arrow[] = new int[6];
+ if (left) {
+ arrow[0] = 4; arrow[1] = 0;
+ arrow[2] = 0; arrow[3] = 4;
+ arrow[4] = 4; arrow[5] = 8;
+ } else {
+ arrow[0] = 0; arrow[1] = 0;
+ arrow[2] = 4; arrow[3] = 4;
+ arrow[4] = 0; arrow[5] = 8;
+ }
+
+ Image image = new Image(getDisplay(), 5, 9);
+ GC gc = new GC(image);
+ gc.setBackground(background);
+ gc.fillRectangle(0, 0, 5, 9);
+ gc.setBackground(foreground);
+ gc.fillPolygon(arrow);
+ gc.setBackground(background);
+ gc.dispose();
+
+ return image;
+}
+/**
+ * A mouse button was pressed down.
+ * If one of the tab scroll buttons was hit, scroll in the appropriate
+ * direction.
+ * If a tab was hit select the tab.
+ */
+private void onMouseUp(Event event) {
+ for (int i=0; i<items.length; i++) {
+ if (items[i].getBounds().contains(new Point(event.x, event.y))) {
+ setSelectionNotify(i);
+ return;
+ }
+ }
+}
+private void onMouseMove(Event event) {
+ if (!showClose) return;
+
+ CTabItem item = null;
+ Rectangle itemRect = null;
+ for (int i=0; i<items.length; i++) {
+ itemRect = items[i].getBounds();
+ if (itemRect.contains(new Point(event.x, event.y))) {
+ item = items[i];
+ break;
+ }
+ }
+ if (item == inactiveItem) return;
+
+ inactiveCloseBar.setVisible(false);
+ inactiveItem = null;
+
+ if (item == null || item == getSelection()) return;
+
+ Point closeRect = inactiveCloseBar.getSize();
+ int x = itemRect.x + itemRect.width - closeRect.x - 2;
+ int y = itemRect.y + 1 + (itemRect.height - 2 - closeRect.y)/2;
+ if (scrollBar.isVisible()) {
+ Rectangle scrollArea = scrollBar.getBounds();
+ scrollArea.width += BORDER_RIGHT;
+ if (scrollArea.contains(x, y)) return;
+ }
+
+ inactiveCloseBar.setLocation(x, y);
+ inactiveCloseBar.setVisible(true);
+ inactiveItem = item;
+}
+/**
+ * Answer the area where the left scroll button is drawn.
+ */
+private Rectangle scroll_getBounds() {
+ if (scrollBar != null)
+ return scrollBar.getBounds();
+ return new Rectangle(0, 0, 0, 0);
+}
+
+/**
+ * Answer true if not all tabs can be visible in the receive
+ * thus requiring the scroll buttons to be visible.
+ */
+private boolean scroll_leftVisible() {
+ return topTabIndex > 0;
+}
+
+/**
+ * Answer true if not all tabs can be visible in the receive
+ * thus requiring the scroll buttons to be visible.
+ */
+private boolean scroll_rightVisible() {
+ if (topTabIndex < items.length - 1) {
+ // only show Scroll buttons if there is more than one item
+ // and if we are not alread at the last item
+ CTabItem tabItem = items[items.length-1];
+ int tabStopX = tabItem.x + tabItem.width;
+ Rectangle area = super.getClientArea();
+ if (tabStopX > area.x + area.width - BORDER_RIGHT) {
+ return true; // not all tabs fit in the client area
+ }
+ }
+ return false;
+}
+
+/**
+ * Scroll the tab items to the left.
+ */
+private void scroll_scrollLeft() {
+ if (scroll_leftVisible()) {
+ --topTabIndex;
+ layoutItems();
+ redrawTabArea(-1);
+ }
+}
+
+/**
+ * Scroll the tab items to the right.
+ */
+private void scroll_scrollRight() {
+ if (scroll_rightVisible()) {
+ topTabIndex++;
+ layoutItems();
+ redrawTabArea(-1);
+ }
+}
+public void setTabHeight(int height) {
+ if (height < 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ fixedTabHeight = height + CTabItem.TOP_MARGIN + CTabItem.BOTTOM_MARGIN;
+ layoutItems();
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderAdapter.java
new file mode 100755
index 0000000000..4c269a551e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderAdapter.java
@@ -0,0 +1,10 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class CTabFolderAdapter implements CTabFolderListener {
+ public void itemClosed(CTabFolderEvent event){};
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderEvent.java
new file mode 100755
index 0000000000..825d848700
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderEvent.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.widgets.*;
+
+public class CTabFolderEvent extends TypedEvent {
+ public Widget item;
+ public boolean doit;
+
+CTabFolderEvent(Widget w) {
+ super(w);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderListener.java
new file mode 100755
index 0000000000..fd3938d351
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolderListener.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+public interface CTabFolderListener {
+ public void itemClosed(CTabFolderEvent event);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
new file mode 100755
index 0000000000..fdcba65fc6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabItem.java
@@ -0,0 +1,406 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public class CTabItem extends Item {
+ CTabFolder parent;
+ int x,y,width,height = 0;
+ String toolTipText;
+ Control control; // the tab page
+
+ private Image disabledImage;
+
+ // internal constants
+ private static final int LEFT_MARGIN = 3;
+ private static final int RIGHT_MARGIN = 3;
+ static final int TOP_MARGIN = 2;
+ static final int BOTTOM_MARGIN = 2;
+ private static final int INTERNAL_SPACING = 2;
+
+ private static final String ellipsis = "...";
+
+/**
+ * Construct a CTabItem with the specified parent and style.
+ */
+public CTabItem (CTabFolder parent, int style) {
+ this(parent, style, parent.getItemCount());
+}
+/**
+ * Construct a CTabItem with the specified parent and style, inserted at
+ * the specified index.
+ */
+public CTabItem (CTabFolder parent, int style, int index) {
+ super (parent, checkStyle(style));
+ parent.createItem (this, index);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {
+ onDispose();
+ }
+ });
+}
+private static int checkStyle(int style) {
+ return SWT.NONE;
+}
+/**
+ * Dispose the receiver.
+ */
+private void onDispose() {
+ parent.destroyItem(this);
+ parent = null;
+ control = null;
+ toolTipText = null;
+}
+/**
+ * Return the bounds of the CTabItem.
+ */
+public Rectangle getBounds () {
+ return new Rectangle(x, y, width, height);
+}
+/**
+* Gets the control.
+* <p>
+* @return the control
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Control getControl () {
+ return control;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ if (parent == null) SWT.error(SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay();
+}
+public Image getDisabledImage(){
+ return disabledImage;
+}
+/**
+ * Return the parent of the CTabItem.
+ */
+public CTabFolder getParent () {
+ return parent;
+}
+/**
+ * Gets the tool tip text.
+ * <p>
+ * @return the tool tip text.
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public String getToolTipText () {
+ return toolTipText;
+}
+private int imageHeight() {
+ int imageHeight = 0;
+ if (parent.getImageHeight() != -1) {
+ imageHeight = parent.getImageHeight();
+ } else {
+ Image image = getImage();
+ if (image != null) {
+ imageHeight = image.getBounds().height;
+ }
+ }
+ return imageHeight;
+}
+private int imageWidth() {
+ int imageWidth = 0;
+ Image image = getImage();
+ if (image != null) {
+ imageWidth = image.getBounds().width;
+ }
+ return imageWidth;
+}
+/**
+ * Paint the receiver.
+ */
+void onPaint(GC gc, boolean isSelected) {
+
+ if (width == 0 || height == 0) return;
+
+ Display display = getDisplay();
+ Color highlightShadow = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+ Color normalShadow = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+
+ int index = parent.indexOf(this);
+
+ if (isSelected) {
+ // draw a background image behind the text
+ if (parent.backgroundImage != null) {
+ if (index == parent.topTabIndex){
+ Rectangle imageRect = parent.backgroundImage.getBounds();
+ gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ x + 1, y, width - 3, height);
+ } else {
+ Rectangle imageRect = parent.backgroundImage.getBounds();
+ gc.drawImage(parent.backgroundImage, 0, 0, imageRect.width, imageRect.height,
+ x + 2, y, width - 4, height);
+ }
+ }
+
+ // draw tab lines
+ if (!parent.onBottom) {
+ gc.setForeground(normalShadow);
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x + 1, y, x + 1, y);
+ gc.drawLine(x, y + 1, x, y + height - 2);
+ gc.drawLine(x, y + height - 1, x, y + height - 1);
+ }
+ gc.drawLine(x + width - 2, y, x + width - 2, y);
+ gc.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 2);
+ gc.drawLine(x + width - 1, y + height - 1, x + width - 1, y + height - 1);
+
+ gc.setForeground(highlightShadow);
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x + 2, y, x + 2, y);
+ gc.drawLine(x + 1, y + 1, x + 1, y + height - 2);
+ gc.drawLine(x + 1, y + height - 1, x + 1, y + height - 1);
+ } else {
+ gc.drawLine(x, y, x, y + height - 1);
+ }
+
+ gc.drawLine(x + width - 3, y, x + width - 3, y);
+ gc.drawLine(x + width - 2, y + 1, x + width - 2, y + height - 2);
+ gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1);
+
+ // light line across top
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x + 3, y, x + width - 4, y);
+ } else {
+ gc.drawLine(x + 1, y, x + width - 4, y);
+ }
+ } else {
+ gc.setForeground(normalShadow);
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x, y, x, y);
+ gc.drawLine(x, y + 1, x, y + height - 2);
+ gc.drawLine(x + 1, y + height - 1, x + 1, y + height - 1);
+ }
+ gc.drawLine(x + width - 1, y, x + width - 1, y);
+ gc.drawLine(x + width - 1, y + 1, x + width - 1, y + height - 2);
+ gc.drawLine(x + width - 2, y + height - 1, x + width - 2, y + height - 1);
+
+ gc.setForeground(highlightShadow);
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x + 1, y, x + 1, y);
+ gc.drawLine(x + 1, y + 1, x + 1, y + height - 2);
+ gc.drawLine(x + 2, y + height - 1, x + 2, y + height - 1);
+ } else {
+ gc.drawLine(x, y, x, y + height - 1);
+ }
+
+ gc.drawLine(x + width - 2, y, x + width - 2, y);
+ gc.drawLine(x + width - 2, y + 1, x + width - 2, y + height - 2);
+ gc.drawLine(x + width - 3, y + height - 1, x + width - 3, y + height - 1);
+
+ // light line across top and bottom
+ if (index != parent.topTabIndex) {
+ gc.drawLine(x + 1, y, x + width - 2, y);
+ gc.drawLine(x + 2, y + height - 1, x + width - 4, y + height - 1);
+ } else {
+ gc.drawLine(x + 1, y, x + width - 2, y);
+ gc.drawLine(x + 1, y + height - 1, x + width - 4, y + height - 1);
+ }
+ }
+ }
+
+ // draw Image
+ int xDraw = x + LEFT_MARGIN;
+
+ Image image = getImage();
+ if (!isSelected && image != null) {
+ Image temp = getDisabledImage();
+ if (temp != null){
+ image = temp;
+ }
+ }
+ if (image != null) {
+ Rectangle imageBounds = image.getBounds();
+ int imageHeight = imageHeight();
+ int imageY = y + (height - parent.getImageHeight()) / 2;
+ gc.drawImage(image,
+ imageBounds.x, imageBounds.y, imageBounds.width, imageBounds.height,
+ xDraw, imageY, imageBounds.width, imageHeight);
+ xDraw += imageBounds.width + INTERNAL_SPACING;
+ }
+
+ // draw Text
+ int textWidth = x + width - xDraw - RIGHT_MARGIN;
+ if (isSelected && parent.showClose) {
+ textWidth = x + width - xDraw - parent.closeBar.getSize().x - RIGHT_MARGIN;
+ }
+ String text = shortenText(gc, getText(), textWidth);
+
+ if (isSelected && parent.selectionForeground != null) {
+ gc.setForeground(parent.selectionForeground);
+ } else {
+ gc.setForeground(parent.getForeground());
+ }
+ int textY = y + (height - textHeight(gc)) / 2;
+ gc.drawString(text, xDraw, textY, true);
+
+ gc.setForeground(parent.getForeground());
+}
+private String shortenText(GC gc, String text, int width) {
+ if (gc.textExtent(text).x <= width) return text;
+
+ int ellipseWidth = gc.textExtent(ellipsis).x;
+ int length = text.length();
+ int end = length - 1;
+ while (end > 0) {
+ text = text.substring(0, end);
+ int l1 = gc.textExtent(text).x;
+ if (l1 + ellipseWidth <= width) {
+ return text + ellipsis;
+ }
+ end--;
+ }
+ return "";
+}
+/**
+ * Answer the preferred height of the receiver for the GC.
+ */
+int preferredHeight(GC gc) {
+ return Math.max(textHeight(gc), imageHeight()) + TOP_MARGIN + BOTTOM_MARGIN;
+}
+/**
+ * Answer the preferred width of the receiver for the GC.
+ */
+int preferredWidth(GC gc) {
+ int tabWidth = LEFT_MARGIN + RIGHT_MARGIN;
+ Image image = getImage();
+ if (image != null) tabWidth += imageWidth() + INTERNAL_SPACING;
+ tabWidth += textWidth(gc);
+ if (parent.showClose) tabWidth += parent.closeBar.getSize().x;
+ return tabWidth;
+}
+/**
+ * Sets the control.
+ * <p>
+ * @param control the new control
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public void setControl (Control control) {
+ if (control != null && 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.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public void setImage (Image image) {
+ Image oldImage = getImage();
+
+ super.setImage(image);
+ if (image == null || !image.equals(oldImage)) {
+ parent.itemChanged(this);
+ }
+}
+public void setDisabledImage (Image image) {
+ Image oldImage = getDisabledImage();
+
+ disabledImage = image;
+ if (disabledImage == null || !disabledImage.equals(oldImage)) {
+ parent.itemChanged(this);
+ }
+}
+
+/**
+ * Set the widget text.
+ * <p>
+ * This method sets the widget label. The label may include
+ * the mnemonic characters but must not contain line delimiters.
+ *
+ * @param string the new label for the widget
+ *
+ */
+public void setText (String string) {
+ String oldText = getText();
+
+ super.setText(string);
+ if (!string.equals(oldText)) {
+ parent.itemChanged(this);
+ }
+}
+
+/**
+ * Sets the tool tip text.
+ * <p>
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public void setToolTipText (String string) {
+ toolTipText = string;
+}
+/**
+ * Answer the text height.
+ */
+private int textHeight(GC gc) {
+ int textHeight = 0;
+
+ if (isDisposed()) return textHeight;
+
+ String text = getText();
+ if (text != null) {
+ textHeight = gc.stringExtent(text).y;
+ }
+ return textHeight;
+}
+/**
+ * Answer the text width.
+ */
+private int textWidth(GC gc) {
+ int textWidth = 0;
+
+ if (isDisposed()) return 0;
+
+ String text = getText();
+ if (text != null) {
+ textWidth = gc.stringExtent(text).x;
+ }
+ return textWidth;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java
new file mode 100755
index 0000000000..eb99ff6e53
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ControlEditor.java
@@ -0,0 +1,238 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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>
+*/
+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 minumum 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 minumum height value. The default value is 0.
+ */
+ public int minimumHeight = 0;
+
+ Composite parent;
+ Control editor;
+ private boolean hadFocus;
+ private Listener internalListener;
+/**
+* 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;
+
+ internalListener = new Listener() {
+ public void handleEvent(Event e) {
+ if (e.widget instanceof ScrollBar && e.type == SWT.Selection)
+ scroll (e);
+ else if (e.type == SWT.Resize)
+ resize ();
+ }
+ };
+
+ parent.addListener (SWT.Resize, internalListener);
+
+ ScrollBar hBar = parent.getHorizontalBar ();
+ if (hBar != null) hBar.addListener (SWT.Selection, internalListener);
+ ScrollBar vBar = parent.getVerticalBar ();
+ if (vBar != null) vBar.addListener (SWT.Selection, internalListener);
+}
+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.isDisposed()) {
+ parent.removeListener (SWT.Resize, internalListener);
+ ScrollBar hBar = parent.getHorizontalBar ();
+ if (hBar != null) hBar.removeListener (SWT.Selection, internalListener);
+ ScrollBar vBar = parent.getVerticalBar ();
+ if (vBar != null) vBar.removeListener (SWT.Selection, internalListener);
+ }
+
+ parent = null;
+ editor = null;
+ hadFocus = false;
+ internalListener = 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;
+}
+void resize () {
+ 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) editor.setFocus ();
+}
+void scroll (Event e) {
+ if (editor == null || editor.isDisposed()) return;
+ if (editor.getVisible ()) {
+ hadFocus = editor.isFocusControl();
+ }
+ boolean visible = e.detail != SWT.DRAG;
+ if (visible) {
+ editor.setBounds (computeBounds ());
+ }
+ editor.setVisible (visible);
+ if (visible && hadFocus) editor.setFocus ();
+}
+/**
+* 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;
+
+ editor.setVisible (false);
+ editor.setBounds (computeBounds ());
+ editor.setVisible (true);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
new file mode 100755
index 0000000000..0469aa577c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultContent.java
@@ -0,0 +1,797 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import java.io.*;
+import java.util.*;
+
+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+(int)Math.pow(2, 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+(int)Math.pow(2, replaceExpandExp)][2];
+ replaceExpandExp++;
+ System.arraycopy(linesArray, 0, newLines, 0, size);
+ }
+ int[] range = new int[] {start, length};
+ newLines[count] = range;
+ return newLines;
+}
+/**
+ * Adds <code>TextChangedEvent</code> listener. A <code>TextChangedEvent</code> is sent
+ * when changes to the textStore occur.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangedListener(TextChangedListener listener) {
+ if (listener == null) error(SWT.ERROR_NULL_ARGUMENT);
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ textListeners.addElement(typedListener);
+}
+/**
+ * Adjusts the gap to accomodate 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;
+}
+/**
+ * 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 lineCnt = 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, lineCnt);
+ lineCnt++;
+ start = i + 1;
+ } else if (ch == SWT.LF) {
+ indexedLines = addLineIndex(start, i - start + 1, indexedLines, lineCnt);
+ lineCnt++;
+ start = i + 1;
+ }
+ }
+ }
+ int[][] newLines = new int[lineCnt+1][2];
+ System.arraycopy(indexedLines, 0, newLines, 0, lineCnt);
+ int[] range = new int[] {start, i - start};
+ newLines[lineCnt]=range;
+ return newLines;
+}
+/**
+ * Inserts text.
+ * <p>
+ *
+ * @param position the position at which to insert the text
+ * @param length 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 sizeHint the size of the change
+ * @param line 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 lineCnt = 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++;
+ }
+ }
+ lineCnt++;
+ } else if (ch == SWT.LF) {
+ lineCnt++;
+ }
+ count++;
+ }
+ i++;
+ }
+ return lineCnt;
+}
+/**
+ * @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.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 buf = new StringBuffer();
+ int gapLength = gapEnd - gapStart;
+ buf.append(textStore, start, gapStart - start);
+ buf.append(textStore, gapEnd, length - gapLength - (gapStart - start));
+ return buf.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){
+ int position;
+ if ((charPosition > getCharCount()) || (charPosition < 0)) error(SWT.ERROR_INVALID_ARGUMENT);
+ 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 accomodate 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 continous 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 text changed listener.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangedListener(TextChangedListener 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 TextChangedEvent, <code>numNewLines</code> is the number of
+ * inserted lines and <code>numReplacedLines</code> is the number of deleted lines based
+ * on the change that occurs visually. For example:
+ * <ul>
+ * <li>(replacedText,newText) ==> (numReplacedLines,numNewLines)
+ * <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
+ */
+public void replaceTextRange(int start, int replaceLength, String newText){
+ StyledTextEvent event = new StyledTextEvent(this);
+ event.type = StyledText.TextReplaced;
+ event.start = start;
+ event.replacedLineCount = lineCount(start, replaceLength);
+ event.text = getTextRange(start, replaceLength);
+
+ // first delete the text to be replaced
+ delete(start, replaceLength, event.replacedLineCount + 1);
+ // then insert the new text
+ insert(start, newText);
+
+ // inform listeners
+ event.newLineCount = lineCount(start, newText.length());
+ event.replacedCharCount = replaceLength;
+ event.newCharCount = newText.length();
+ sendTextEvent(event);
+ // printLines();
+}
+/**
+ * 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 delmiter 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);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java
new file mode 100755
index 0000000000..d6eaac6976
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/DefaultLineStyler.java
@@ -0,0 +1,599 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+class DefaultLineStyler implements LineStyleListener, LineBackgroundListener {
+ StyledTextContent content;
+ StyleRange styles[] = new StyleRange[0];
+ int styleCount = 0; // the number of styles
+ int styleExpandExp = 1; // the expansion exponent, used to increase the styles array exponentially
+ int lineExpandExp = 1; // the expansion exponent, used to increase the lines array exponentially
+ int lineCount = 0;
+ Color lineBackgrounds[];
+
+/**
+ * Creates a new default line styler.
+ * <p>
+ *
+ * @param content the text to which the styles apply
+ */
+public DefaultLineStyler(StyledTextContent content) {
+ this.content = content;
+ lineCount = content.getLineCount();
+ lineBackgrounds = new Color[lineCount];
+}
+/**
+ * Inserts a style at the given location.
+ * <p>
+ *
+ * @param style the new style
+ * @param index the index at which to insert the style (the new style
+ * will reside at this index)
+ *
+ */
+void insertStyle(StyleRange style, int index) {
+ int size = styles.length;
+ if (styleCount == size) {
+ // expand the styles array by powers of 2
+ StyleRange[] newStyles = new StyleRange[size+(int)Math.pow(2, styleExpandExp)];
+ System.arraycopy(styles, 0, newStyles, 0, size);
+ styles = newStyles;
+ styleExpandExp++;
+ }
+ // shift the styles down to make room for the new style
+ for (int i=styleCount-1; i>=index; i--) {
+ styles[i+1]=styles[i];
+ }
+ styles[index] = style;
+ styleCount++;
+}
+/**
+ * Inserts a style, merging it with adjacent styles if possible.
+ * <p>
+ *
+ * @param style the new style
+ * @param index the index at which to insert the style (the new style
+ * will reside at this index)
+ * @return true if the style was inserted, false if the style was merged with an adjacent
+ * style
+ */
+boolean insertMergeStyle(StyleRange style, int index) {
+ if (mergeStyleBefore(style, index)) return false;
+ if (mergeStyleAfter(style, index)) return false;
+ insertStyle(style, index);
+ return true;
+}
+/**
+ * Merges the style with the style before it if possible.
+ * <p>
+ *
+ * @param style the new style
+ * @param index the index at which to attempt the merge.
+ * @return true if the style was merged, false otherwise
+ */
+boolean mergeStyleBefore(StyleRange style, int index) {
+ // see if the style is similar to the style before it and merge the
+ // styles if possible
+ if (index > 0) {
+ StyleRange previous = styles[index-1];
+ if (style.similarTo(previous)) {
+ // the start of style needs to be in the range of the previous style
+ // and the end of style needs to be < the start of the next style
+ int previousEnd = previous.start + previous.length;
+ if ((style.start <= previousEnd) && (style.start >= previous.start)) {
+ int styleEnd = style.start + style.length;
+ if ((index == styleCount) || (styleEnd <= styles[index].start)) {
+ previous.length = style.start + style.length - previous.start;
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+/**
+ * Merges the style with the style after it if possible.
+ * <p>
+ *
+ * @param style the new style
+ * @param index the index at which to attempt the merge.
+ * @return true if the style was merged, false otherwise
+ */
+boolean mergeStyleAfter(StyleRange style, int index) {
+ // see if the style is similar to the style that will be after it and
+ // merge the styles if possible
+ if (index < styleCount) {
+ StyleRange next = styles[index];
+ if (style.similarTo(next)) {
+ // the end of style needs to be in the range of the next style and
+ // the start of style needs to be > the end of the previous style
+ int styleEnd = style.start + style.length;
+ int nextEnd = next.start + next.length;
+ if ((styleEnd <= nextEnd) && (styleEnd >= next.start)) {
+ if ((index == 0) || (style.start >= styles[index-1].start + styles[index-1].length)) {
+ next.length = next.start + next.length - style.start;
+ next.start = style.start;
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+/**
+ * Removes style information that is defined for the range of text in <code>clearStyle</code>.
+ * <p>
+ *
+ * @param clearStyle the style information to use for clearing
+ */
+void clearStyle(StyleRange clearStyle) {
+ Point pt = getOverlappingStyles(clearStyle.start, clearStyle.length);
+ int clearStyleEnd = clearStyle.start + clearStyle.length - 1;
+
+ // no overlapped styles exist
+ if ((pt == null) || (pt.y == 0)) return;
+
+ // the newStyle overlaps one or more of the existing styles
+ // pt.x is the index of the first overlapped style, pt.y is the number of overlapped
+ // styles
+ int count = 0;
+ for (int i=pt.x; count<pt.y; i++) {
+ StyleRange overlap = styles[i];
+ int overlapEnd = overlap.start + overlap.length - 1;
+ if (overlap.start < clearStyle.start) {
+ if (overlapEnd <= clearStyleEnd) {
+ // the end of overlap needs to be cleared
+ overlap.length=clearStyle.start - overlap.start;
+ } else {
+ // middle of overlap needs to be cleared, this will
+ // cause overlap to be broken into two
+ StyleRange endStyle = (StyleRange)overlap.clone();
+ endStyle.start = clearStyleEnd + 1;
+ endStyle.length = overlapEnd - clearStyleEnd;
+ overlap.length = clearStyle.start - overlap.start;
+ insertStyle(endStyle, i+1);
+ break;
+ }
+ } else {
+ if (overlapEnd <= clearStyleEnd) {
+ // entire overlap needs to be cleared
+ deleteStyle(i);
+ i--;
+ } else {
+ // beginning of overlap needs to be cleared
+ overlap.start=clearStyleEnd + 1;
+ overlap.length=overlapEnd - overlap.start + 1;
+ break;
+ }
+ }
+ count++;
+ }
+}
+/**
+ * Increases the <code>linebackgrounds</code> array to accomodate new line background
+ * information.
+ * <p>
+ *
+ * @param numLines the number to increase the array by
+ */
+void expandLinesBy(int numLines) {
+ int size = lineBackgrounds.length;
+ if (size - lineCount >= numLines) {
+ return;
+ }
+ Color[] newLines = new Color[size+Math.max((int)Math.pow(2, lineExpandExp), numLines)];
+ System.arraycopy(lineBackgrounds, 0, newLines, 0, size);
+ lineBackgrounds = newLines;
+ lineExpandExp++;
+}
+/**
+ * Deletes the style at <code>index</code>.
+ * <p>
+ *
+ * @param index the index of the style to be deleted
+ */
+void deleteStyle(int index) {
+ // move the styles up
+ for (int i=index+1; i<styleCount; i++) {
+ styles[i-1] = styles[i];
+ }
+ styles[styleCount-1]=null;
+ styleCount--;
+}
+/**
+ * Returns the styles that are defined.
+ * <p>
+ *
+ * @return the copied array of styles
+ */
+StyleRange [] getStyleRanges() {
+ StyleRange[] newStyles = new StyleRange[styleCount];
+ System.arraycopy(styles, 0, newStyles, 0, styleCount);
+ return newStyles;
+}
+/**
+ * Handles the get line background color callback.
+ * <p>
+ *
+ * @param event.lineOffset line number (input)
+ * @param event.lineText line text (input)
+ * @param event.background line background color (output)
+ */
+public void lineGetBackground(LineBackgroundEvent event) {
+ event.lineBackground = lineBackgrounds[content.getLineAtOffset(event.lineOffset)];
+}
+/**
+ * Handles the get line style information callback.
+ * <p>
+ *
+ * @param event.lineOffset line number (input)
+ * @param event.lineText line text (input)
+ * @param event.styles array of StyleRanges, need to be in order (output)
+ */
+public void lineGetStyle(LineStyleEvent event) {
+ int lineStart = event.lineOffset;
+ int lineEnd = lineStart + event.lineText.length();
+
+ int high = searchForStyle(lineStart, lineEnd);
+ StyleRange style = null;
+ Vector lineStyles = new Vector();
+
+ // index will represent a style that
+ // -- starts after the line (end processing)
+ // -- ends before the line (continue processing)
+ // -- starts before the line, ends in the line (add range)
+ // -- starts in the line, ends in the line (add range)
+ // -- starts in the line, ends after the line (add range)
+ // -- starts before the line, ends after the line (add range)
+ for (int index = high; index < styleCount; index++) {
+ style = styles[index];
+ if (style.start > lineEnd)
+ // style starts after the line, end looping
+ break;
+ int styleEnd = style.start + style.length - 1;
+ if (styleEnd >= lineStart) lineStyles.add(style);
+ }
+ event.styles = new StyleRange[lineStyles.size()];
+ lineStyles.copyInto(event.styles);
+}
+/**
+ * Searches for the first style in the <code>start</code> - <code>end</code> range.
+ * <p>
+ *
+ * @return the index of the first style that overlaps the input range
+ */
+int searchForStyle(int start, int end) {
+ int high = styleCount;
+ int low = -1;
+ int index = high;
+ // find the index of the first style for the given range, use a binary search
+ while (high - low > 1) {
+ index = (high + low) / 2;
+ StyleRange style = styles[index];
+ int styleEnd = style.start + style.length - 1;
+ if (start <= style.start || end <= styleEnd || (start > style.start && styleEnd >= start && styleEnd < end)) {
+ high = index;
+ }
+ else {
+ low = index;
+ }
+ }
+ return high;
+}
+/**
+ * Updates the line background colors to reflect a new color. Called by StyledText.
+ * <p>
+ *
+ * @param startLine index of the first line to color
+ * @param lineCount number of lines to color starting at startLine
+ * @param background the background color for the lines
+ */
+void setLineBackground(int startLine, int count, Color background) {
+ for (int i=startLine; i<startLine + count; i++) {
+ lineBackgrounds[i]=background;
+ }
+}
+/**
+ * Update the styles to reflect the new style. <code>newStyle</code> will
+ * replace any old style for the range. When this method is called, the
+ * DefaultLineStyler may merge the new style with an existing style (if possible).
+ * Called by StyledText when a style is added. Called by StyledText.
+ * <p>
+ *
+ * @param newStyle the new style information.
+ */
+void setStyleRange(StyleRange newStyle) {
+ if (newStyle == null) {
+ styles = new StyleRange[0];
+ styleExpandExp = 1;
+ styleCount = 0;
+ return;
+ }
+ if (newStyle.length ==0) return;
+ if (newStyle.isUnstyled()) {
+ clearStyle(newStyle);
+ return;
+ }
+
+ Point pt = getOverlappingStyles(newStyle.start, newStyle.length);
+ int newStyleEnd = newStyle.start + newStyle.length - 1;
+
+ // no styles exist
+ if (pt == null) {
+ insertStyle(newStyle, 0);
+ return;
+ }
+
+ // newStyle does not overlap any other styles
+ if (pt.y == 0) {
+ insertMergeStyle(newStyle, pt.x);
+ return;
+ }
+
+ // the newStyle overlaps one or more of the existing styles
+ boolean added = false; // indicates whether or not the new style has been added
+ int count = 0;
+ // pt.x is the index of the first overlapped style, pt.y is the number of overlapped
+ // styles
+ for (int i=pt.x; count<pt.y; i++) {
+ StyleRange overlap = styles[i];
+ int overlapEnd = overlap.start + overlap.length - 1;
+ if (overlap.start < newStyle.start) {
+ if (overlapEnd <= newStyleEnd) {
+ // the end of overlap needs to be replaced by newStyle
+ if (newStyle.similarTo(overlap)) {
+ // update overlap to accomodate the new style
+ overlap.length = newStyle.start + newStyle.length - overlap.start;
+ } else {
+ overlap.length=newStyle.start - overlap.start;
+ // see if newStyle can be merged with the style after overlap, if so,
+ // processing is done
+ if (mergeStyleAfter(newStyle, i+1)) break;
+ // otherwise, insert the newStyle, newStyle may still overlap other
+ // styles after it so continue processing
+ insertStyle(newStyle, i+1);
+ i++;
+ }
+ added = true;
+ } else {
+ // middle of overlap needs to be replaced by newStyle, this will
+ // cause overlap to be broken into two
+ if (newStyle.similarTo(overlap)) break;
+ StyleRange endStyle = (StyleRange)overlap.clone();
+ endStyle.start = newStyleEnd + 1;
+ endStyle.length = overlapEnd - newStyleEnd;
+ overlap.length = newStyle.start - overlap.start;
+ insertStyle(newStyle, i+1);
+ i++;
+ insertStyle(endStyle, i+1);
+ // when newStyle overlaps the middle of a style, this implies that
+ // processing is done (no more overlapped styles)
+ break;
+ }
+ } else {
+ if (overlapEnd <= newStyleEnd) {
+ // overlap will be replaced by the newStyle, make sure newStyle
+ // hasn't already been added, if it has just delete overlap
+ if (!added) {
+ styles[i] = newStyle;
+ added = true;
+ } else {
+ deleteStyle(i);
+ i--;
+ }
+ } else {
+ // beginning of overlap needs to be replaced by newStyle
+ overlap.start=newStyleEnd + 1;
+ overlap.length=overlapEnd - overlap.start + 1;
+ if (!added) {
+ insertMergeStyle(newStyle, i);
+ }
+ // when newStyle overlaps only the beginning of a style, this implies
+ // that processing is done (no more overlapped styles)
+ break;
+ }
+ }
+ count++;
+ }
+}
+/**
+ * Sets the array of styles and discards old styles. Called by StyledText.
+ * <p>
+ *
+ * @param styles the new styles, must be in order and non-overlapping
+ */
+void setStyleRanges(StyleRange[] styles) {
+ this.styles = new StyleRange[styles.length];
+ System.arraycopy(styles, 0, this.styles, 0, styles.length);
+ styleCount = styles.length;
+ styleExpandExp = 1;
+}
+/**
+ * Updates the style ranges and line backgrounds to reflect a text change.
+ * Called by StyledText when a TextChangedEvent is received.
+ * <p>
+ *
+ * @param event the event with the text change information
+ */
+public void textChanged(TextChangedEvent event) {
+ int startLine = content.getLineAtOffset(event.start);
+ int startLineOffset = content.getOffsetAtLine(startLine);
+
+ textChanged(event.start, -event.replacedCharCount);
+ textChanged(event.start, event.newCharCount);
+
+ if (event.newCharCount == content.getCharCount()) {
+ // all text replaced, clear line backgrounds
+ linesChanged(0, -lineCount);
+ linesChanged(0, content.getLineCount());
+ return;
+ }
+
+ if (event.start != startLineOffset) {
+ startLine = startLine + 1;
+ }
+
+ linesChanged(startLine, -event.replacedLineCount);
+ linesChanged(startLine, event.newLineCount);
+}
+/*
+ * Updates the line backgrounds to reflect a text change.
+ * <p>
+ *
+ * @param start the starting line of the change that took place
+ * @param delta the number of lines in the change, > 0 indicates lines inserted,
+ * < 0 indicates lines deleted
+ */
+void linesChanged(int start, int delta) {
+ if (delta == 0) return;
+ boolean inserting = delta > 0;
+ if (inserting) {
+ // shift the lines down to make room for new lines
+ expandLinesBy(delta);
+ for (int i = lineCount-1; i >= start; i--) {
+ lineBackgrounds[i + delta]=lineBackgrounds[i];
+ }
+ for (int i=start; i<start + delta; i++) {
+ lineBackgrounds[i]=null;
+ }
+ } else {
+ // shift up the lines
+ for (int i = start - delta; i < lineCount; i++) {
+ lineBackgrounds[i+delta]=lineBackgrounds[i];
+ }
+ }
+ lineCount += delta;
+}
+/*
+ * Updates the style ranges to reflect a text change.
+ * <p>
+ *
+ * @param start the starting offset of the change that took place
+ * @param delta the length of the change, > 0 indicates text inserted,
+ * < 0 indicates text deleted
+ */
+void textChanged(int start, int delta) {
+ if (delta == 0) return;
+ StyleRange style;
+ // find the index of the first style for the given offset, use a binary search
+ // to find the index
+ int end;
+ boolean inserting = delta > 0;
+ if (inserting) {
+ end = (start + delta) - 1;
+ } else {
+ end = (start - delta) - 1;
+ }
+ int high = searchForStyle(start, end);
+ int index;
+ // update the styles that are in the affected range
+ for (index = high; index < styleCount; index++) {
+ style = styles[index];
+ if (inserting) {
+ if (style.start >= start) break;
+ // in the insert case only one style range will be directly affected,
+ // it will need to be split into two and then the newStyle inserted
+ StyleRange beforeStyle = (StyleRange)style.clone();
+ beforeStyle.length = start - style.start;
+ style.start = start;
+ style.length = style.length - beforeStyle.length;
+ if (beforeStyle.length != 0) insertStyle(beforeStyle, index);
+ index++;
+ break;
+ } else {
+ int styleEnd = style.start + style.length - 1;
+ if (style.start > end) break;
+ // in the delete case, any style that overlaps the change range will be
+ // affected
+ if (style.start < start) {
+ if (styleEnd <= end) {
+ // style starts before change range, ends in change range
+ style.length = start - style.start;
+ } else {
+ // style starts before change range, ends after change range
+ style.length = style.length + delta;
+ index++;
+ break;
+ }
+ } else {
+ if (styleEnd <= end) {
+ // style starts in change range, ends in change range
+ deleteStyle(index);
+ index--;
+ } else {
+ // style starts in change range, ends after change range
+ style.start = start;
+ style.length = styleEnd - end;
+ index++;
+ break;
+ }
+ }
+ }
+ }
+ // change the offsets of the styles after the affected styles
+ for (int i = index ; i < styleCount; i++) {
+ style = styles[i];
+ style.start = style.start + delta;
+ }
+}
+/**
+ * Returns the indexes of the styles that overlap the given range. Styles that partially
+ * or fully overlap the range will be returned.
+ * <p>
+ *
+ * @return Point where x is the index of the starting overlap style, y is the number of
+ * styles that overlap the range
+ */
+Point getOverlappingStyles(int start, int length) {
+ StyleRange style;
+ if (styleCount == 0) return null;
+ // find the index of the first style for the given offset, use a binary search
+ // to find the index
+ int end = start + length - 1;
+ int high = searchForStyle(start, end);
+ int count = 0;
+ for (int index = high; index < styleCount; index++) {
+ style = styles[index];
+ int styleEnd = style.start + style.length - 1;
+ if (style.start > end) break;
+ if (styleEnd >= start) count++;
+ }
+ return new Point(high, count);
+}
+/**
+ * Returns the background color of a line. Called by StyledText. It is safe to return
+ * the existing Color object since the colors are set and managed by the client.
+ * <p>
+ *
+ * @param index the line index
+ * @return the background color of the line at the given index
+ */
+Color getLineBackground(int index) {
+ return lineBackgrounds[index];
+}
+/**
+ * Returns the style for the character at <code>offset</code>. Called by StyledText.
+ * Returns a new style. Does not return the existing style.
+ * <p>
+ *
+ * @param offset the character position in the text
+ * @return a cloned StyleRange with start == offset and length == 1 if a style is
+ * specified or null if no style is specified
+ */
+StyleRange getStyleRangeAtOffset(int offset) {
+ if (styleCount == 0) return null;
+ Point pt = getOverlappingStyles(offset, 1);
+ if (pt == null || pt.y == 0) return null;
+ StyleRange newStyle = (StyleRange)styles[pt.x].clone();
+ newStyle.start = offset;
+ newStyle.length = 1;
+ return newStyle;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java
new file mode 100755
index 0000000000..26fd9c9473
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyEvent.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent after a text change occurs.
+ */
+public final class ExtendedModifyEvent extends TypedEvent {
+ public int start; // start offset of the new text
+ public int length; // length of the new text
+ public String replacedText; // replaced text or empty string if no text was replaced
+
+public ExtendedModifyEvent(StyledTextEvent e) {
+ super(e);
+ start = e.start;
+ length = e.end - e.start;
+ replacedText = e.text;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java
new file mode 100755
index 0000000000..5300f6da2d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ExtendedModifyListener.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import java.util.EventListener;
+
+public interface ExtendedModifyListener extends EventListener {
+/**
+ * This method is called after a text change occurs.
+ * <p>
+ *
+ * @param event.start the start offset of the new text (input)
+ * @param event.length the length of the new text (input)
+ * @param event.replacedText the replaced text (input)
+ */
+public void modifyText(ExtendedModifyEvent event);
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java
new file mode 100755
index 0000000000..fecd8742eb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundEvent.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ */
+public class LineBackgroundEvent extends TypedEvent {
+ public int lineOffset; // line start offset
+ public String lineText; // line text
+ public Color lineBackground; // line background color
+
+public LineBackgroundEvent(StyledTextEvent e) {
+ super(e);
+ lineOffset = e.detail;
+ lineText = e.text;
+}
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java
new file mode 100755
index 0000000000..7ea0deeb24
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineBackgroundListener.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+
+/* Imports */
+import java.util.*;
+
+
+public interface LineBackgroundListener extends EventListener {
+
+/**
+ * This method is called when a line is about to be drawn in order to get its
+ * background color.
+ * <p>
+ *
+ * @param event.lineOffset line start offset (input)
+ * @param event.lineText line text (input)
+ * @param event.lineBackground line background color (output)
+ */
+public void lineGetBackground(LineBackgroundEvent event);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java
new file mode 100755
index 0000000000..0bac2326a3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleEvent.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * This event is sent when a line is about to be drawn.
+ */
+public class LineStyleEvent extends TypedEvent {
+ public int lineOffset; // line start offset
+ public String lineText; // line text
+ public StyleRange[] styles; // array of StyleRanges
+
+public LineStyleEvent(StyledTextEvent e) {
+ super(e);
+ lineOffset = e.detail;
+ lineText = e.text;
+ styles = e.styles;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java
new file mode 100755
index 0000000000..6ece0586e5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/LineStyleListener.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import java.util.*;
+
+public interface LineStyleListener extends EventListener {
+/**
+ * This method is called when a line is about to be drawn in order to get the
+ * line's style information.
+ * <p>
+ *
+ * @param event.lineOffset line start offset (input)
+ * @param event.lineText line text (input)
+ * @param event.styles array of StyleRanges, need to be in order (output)
+ */
+public void lineGetStyle(LineStyleEvent event);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java
new file mode 100755
index 0000000000..f03c817c1c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/PopupList.java
@@ -0,0 +1,249 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+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 it 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 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.
+*/
+public class PopupList {
+ private Shell shell;
+ private List list;
+ private int minimumWidth;
+/**
+* Creates a PopupList above the specified shell.
+*/
+public PopupList(Shell parent) {
+
+ shell = new Shell(parent, 0);
+
+ 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);
+ }
+ };
+ });
+
+}
+/**
+* Gets the widget font.
+* <p>
+* @return the widget font
+*
+* @exception SWTError <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 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 SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_CANNOT_GET_ITEM when the operation fails</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 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);
+ 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 les 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 SWTError <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 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 SWTError <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 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 items the array of items
+*
+* This operation will fail when an item is null
+* or could not be added in the OS.
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when items is null</li>
+* <li>ERROR_ITEM_NOT_ADDED when the operation fails</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)
+ throw new SWTError(SWT.ERROR_INVALID_ARGUMENT);
+
+ minimumWidth = width;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
new file mode 100755
index 0000000000..533f6f2e82
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ST.java
@@ -0,0 +1,57 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+
+/**
+ * This class provides access to the public constants provided by <code>StyledText</code>.
+ */
+public class ST {
+
+ /* StyledText key action constants */
+ /* Navigation */
+ public static final int LINE_UP = SWT.ARROW_UP;
+ public static final int LINE_DOWN = SWT.ARROW_DOWN;
+ public static final int LINE_START = SWT.HOME;
+ public static final int LINE_END = SWT.END;
+ public static final int COLUMN_PREVIOUS = SWT.ARROW_LEFT;
+ public static final int COLUMN_NEXT = SWT.ARROW_RIGHT;
+ public static final int PAGE_UP = SWT.PAGE_UP;
+ public static final int PAGE_DOWN = SWT.PAGE_DOWN;
+ public static final int WORD_PREVIOUS = SWT.ARROW_LEFT | SWT.CTRL;
+ public static final int WORD_NEXT = SWT.ARROW_RIGHT | SWT.CTRL;
+ public static final int TEXT_START = SWT.HOME | SWT.CTRL;
+ public static final int TEXT_END = SWT.END | SWT.CTRL;
+ public static final int WINDOW_START = SWT.PAGE_UP | SWT.CTRL;
+ public static final int WINDOW_END = SWT.PAGE_DOWN | SWT.CTRL;
+
+ /* Selection */
+ public static final int SELECT_LINE_UP = SWT.ARROW_UP | SWT.SHIFT;
+ public static final int SELECT_LINE_DOWN = SWT.ARROW_DOWN | SWT.SHIFT;
+ public static final int SELECT_LINE_START = SWT.HOME | SWT.SHIFT;
+ public static final int SELECT_LINE_END = SWT.END | SWT.SHIFT;
+ public static final int SELECT_COLUMN_PREVIOUS = SWT.ARROW_LEFT | SWT.SHIFT;
+ public static final int SELECT_COLUMN_NEXT = SWT.ARROW_RIGHT | SWT.SHIFT;
+ public static final int SELECT_PAGE_UP = SWT.PAGE_UP | SWT.SHIFT;
+ public static final int SELECT_PAGE_DOWN = SWT.PAGE_DOWN | SWT.SHIFT;
+ public static final int SELECT_WORD_PREVIOUS = SWT.ARROW_LEFT | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_WORD_NEXT = SWT.ARROW_RIGHT | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_TEXT_START = SWT.HOME | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_TEXT_END = SWT.END | SWT.CTRL | SWT.SHIFT;
+ public static final int SELECT_WINDOW_START = SWT.PAGE_UP | SWT.CTRL| SWT.SHIFT;
+ public static final int SELECT_WINDOW_END = SWT.PAGE_DOWN | SWT.CTRL | SWT.SHIFT;
+
+ /* Modification */
+ public static final int CUT = SWT.DEL | SWT.SHIFT;
+ public static final int COPY = SWT.INSERT | SWT.CTRL;
+ public static final int PASTE = SWT.INSERT | SWT.SHIFT;
+ public static final int DELETE_PREVIOUS = SWT.BS;
+ public static final int DELETE_NEXT = SWT.DEL;
+
+ /* Miscellaneous */
+ public static final int TOGGLE_OVERWRITE = SWT.INSERT;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java
new file mode 100755
index 0000000000..27bc05ae52
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/SashForm.java
@@ -0,0 +1,384 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * The SashForm lays out its children in a Row or Column arrangement (as specified
+ * by the orientation) and places a Sash between the children.
+ * One child may be maximized to occupy the entire size of the SashForm.
+ * The relative sizes of the children may be specfied using weights.
+ *
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b><dd>HORIZONTAL, VERTICAL
+ * </dl>
+ */
+public class SashForm extends Composite {
+
+ public int SASH_WIDTH = 3;
+
+ private static final int DRAG_MINIMUM = 20;
+
+ private int orientation = SWT.HORIZONTAL;
+ private Sash[] sashes = new Sash[0];
+ private Control[] controls = new Control[0];
+ private Control maxControl = null;
+ private Listener sashListener;
+
+public SashForm(Composite parent, int style) {
+ super(parent, checkStyle(style));
+ if ((style & SWT.VERTICAL) != 0){
+ orientation = SWT.VERTICAL;
+ }
+
+ this.addListener(SWT.Resize, new Listener() {
+ public void handleEvent(Event e) {
+ layout(true);
+ }
+ });
+
+ sashListener = new Listener() {
+ public void handleEvent(Event e) {
+ onDragSash(e);
+ }
+ };
+}
+private static int checkStyle (int style) {
+ int mask = SWT.BORDER;
+ return style & mask;
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+
+ Control[] controls = getControls(true);
+ if (controls.length == 0) return new Point(wHint, hHint);
+
+ int width = 0;
+ int height = 0;
+ boolean vertical = (getStyle() & SWT.VERTICAL) != 0;
+ if (vertical) {
+ width = wHint;
+ height += (controls.length - 1) * SASH_WIDTH;
+ } else {
+ height = hHint;
+ width += controls.length *SASH_WIDTH;
+ }
+ for (int i = 0; i < controls.length; i++) {
+ if (vertical) {
+ Point size = controls[i].computeSize(wHint, SWT.DEFAULT);
+ height += size.y;
+ } else {
+ Point size = controls[i].computeSize(SWT.DEFAULT, hHint);
+ width += size.x;
+ }
+ }
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+
+ return new Point(width, height);
+}
+/**
+ * Answer SWT.HORIZONTAL if the controls in the SashForm are laid out side by side.
+ * Answer SWT.VERTICAL if the controls in the SashForm are laid out top to bottom.
+ */
+public int getOrientation() {
+ return orientation;
+}
+/**
+ * Answer the control that currently is maximized in the SashForm. This value may be null.
+ */
+public Control getMaximizedControl(){
+ 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).
+ */
+
+public int[] getWeights() {
+ Control[] cArray = getControls(false);
+ float[] ratios = new float[cArray.length];
+ for (int i = 0; i < cArray.length; i++) {
+ Float ratio = (Float)cArray[i].getData("layout ratio");
+ if (ratio != null) {
+ ratios[i] = ratio.floatValue();
+ } else {
+ ratios[i] = (float)0.2;
+ }
+ }
+
+ int[] weights = new int[cArray.length];
+ for (int i = 0; i < weights.length; i++) {
+ weights[i] = (int)(ratios[i] * 1000);
+ }
+ return weights;
+}
+private Control[] getControls(boolean onlyVisible) {
+ Control[] children = getChildren();
+ Control[] controls = new Control[0];
+ for (int i = 0; i < children.length; i++) {
+ if (children[i] instanceof Sash) continue;
+ if (onlyVisible && !children[i].getVisible()) continue;
+
+ Control[] newControls = new Control[controls.length + 1];
+ System.arraycopy(controls, 0, newControls, 0, controls.length);
+ newControls[controls.length] = children[i];
+ controls = newControls;
+ }
+ return controls;
+}
+public void layout(boolean changed) {
+ Rectangle area = getClientArea();
+ if (area.width == 0 || area.height == 0) return;
+
+ Control[] newControls = getControls(true);
+ if (controls.length == 0 && newControls.length == 0) return;
+ controls = newControls;
+
+ if (maxControl != null && !maxControl.isDisposed()) {
+ for (int i= 0; i < controls.length; i++){
+ if (controls[i] != maxControl) {
+ controls[i].setBounds(-200, -200, 0, 0);
+ } else {
+ controls[i].setBounds(area);
+ }
+ }
+ return;
+ }
+
+ // keep just the right number of sashes
+ if (sashes.length < controls.length - 1) {
+ Sash[] newSashes = new Sash[controls.length - 1];
+ System.arraycopy(sashes, 0, newSashes, 0, sashes.length);
+ int sashOrientation = (orientation == SWT.HORIZONTAL) ? SWT.VERTICAL : SWT.HORIZONTAL;
+ for (int i = sashes.length; i < newSashes.length; i++) {
+ newSashes[i] = new Sash(this, sashOrientation);
+ newSashes[i].addListener(SWT.Selection, sashListener);
+ }
+ sashes = newSashes;
+ }
+ if (sashes.length > controls.length - 1) {
+ if (controls.length == 0) {
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].dispose();
+ }
+ sashes = new Sash[0];
+ } else {
+ Sash[] newSashes = new Sash[controls.length - 1];
+ System.arraycopy(sashes, 0, newSashes, 0, newSashes.length);
+ for (int i = controls.length - 1; i < sashes.length; i++) {
+ sashes[i].dispose();
+ }
+ sashes = newSashes;
+ }
+ }
+
+ if (controls.length == 0) return;
+
+ // get the ratios
+ float[] ratios = new float[controls.length];
+ float total = 0;
+ for (int i = 0; i < controls.length; i++) {
+ Float ratio = (Float)controls[i].getData("layout ratio");
+ if (ratio != null) {
+ ratios[i] = ratio.floatValue();
+ } else {
+ ratios[i] = (float)0.2;
+ }
+ total += ratios[i];
+ }
+
+ if (orientation == SWT.HORIZONTAL) {
+ total += (float)sashes.length * ((float)SASH_WIDTH / (float)area.width);
+ } else {
+ total += (float)sashes.length * ((float)SASH_WIDTH / (float)area.height);
+ }
+
+ if (orientation == SWT.HORIZONTAL) {
+ int width = (int)((ratios[0] / total) * (float)area.width);
+ 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, SASH_WIDTH, area.height);
+ x += SASH_WIDTH;
+ width = (int)((ratios[i] / total) * (float)area.width);
+ controls[i].setBounds(x, area.y, width, area.height);
+ x += width;
+ }
+ if (controls.length > 1) {
+ sashes[sashes.length - 1].setBounds(x, area.y, SASH_WIDTH, area.height);
+ x += SASH_WIDTH;
+ width = area.width - x;
+ controls[controls.length - 1].setBounds(x, area.y, width, area.height);
+ }
+ } else {
+ int height = (int)((ratios[0] / total) * (float)area.height);
+ 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, SASH_WIDTH);
+ y += SASH_WIDTH;
+ height = (int)((ratios[i] / total) * (float)area.height);
+ 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, SASH_WIDTH);
+ y += SASH_WIDTH;
+ height = area.height - y;
+ controls[controls.length - 1].setBounds(area.x, y, area.width, height);
+ }
+
+ }
+}
+private void onDragSash(Event event) {
+ if (event.detail == SWT.DRAG) {
+ // constrain feedback
+ Rectangle area = getClientArea();
+ if (orientation == SWT.HORIZONTAL) {
+ event.x = Math.min(Math.max(DRAG_MINIMUM, event.x), area.width - DRAG_MINIMUM);
+ } else {
+ event.y = Math.min(Math.max(DRAG_MINIMUM, event.y), area.height - DRAG_MINIMUM);
+ }
+ return;
+ }
+
+ 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();
+ if (orientation == SWT.HORIZONTAL) {
+ int shift = event.x - sashBounds.x;
+ b1.width += shift;
+ b2.x += shift;
+ b2.width -= shift;
+ if (b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM) {
+ return;
+ }
+ c1.setData("layout ratio", new Float((float)b1.width / (float)area.width));
+ c2.setData("layout ratio", new Float((float)b2.width / (float)area.width));
+ } else {
+ int shift = event.y - sashBounds.y;
+ b1.height += shift;
+ b2.y += shift;
+ b2.height -= shift;
+ if (b1.height < DRAG_MINIMUM || b2.height < DRAG_MINIMUM) {
+ return;
+ }
+ c1.setData("layout ratio", new Float((float)b1.height / (float)area.height));
+ c2.setData("layout ratio", new Float((float)b2.height / (float)area.height));
+ }
+
+ 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.
+ */
+public void setOrientation(int orientation) {
+ if (this.orientation == orientation) return;
+ if (orientation != SWT.HORIZONTAL && orientation != SWT.VERTICAL) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.orientation = orientation;
+
+ int sashOrientation = (orientation == SWT.HORIZONTAL) ? SWT.VERTICAL : SWT.HORIZONTAL;
+ for (int i = 0; i < sashes.length; i++) {
+ sashes[i].dispose();
+ sashes[i] = new Sash(this, sashOrientation);
+ sashes[i].addListener(SWT.Selection, sashListener);
+ }
+ layout();
+}
+public void setLayout (Layout layout) {
+ // SashForm does not use Layout
+}
+/**
+ * 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.
+ */
+public void setMaximizedControl(Control control){
+ if (control == null) {
+ if (maxControl != null) {
+ this.maxControl = null;
+ layout();
+ 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();
+
+// // walk up
+// w= getParent();
+// if (w instanceof SplitForm)
+// ((SplitForm) w).internalMaximize(this);
+// else
+// layout(true);
+}
+
+/**
+ * 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.
+ */
+public void setWeights(int[] weights) {
+ 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++) {
+ cArray[i].setData("layout ratio", new Float((float)weights[i] / (float)total));
+ }
+
+ layout();
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
new file mode 100755
index 0000000000..cd9ac851a2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ScrolledComposite.java
@@ -0,0 +1,202 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+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>If the ScrolledComposite can be configured to stretch the content to be as big as the
+ * ScrolledComposite when the composite is resized to a size larger than the minimum width
+ * or minimum height and to provide scrolls when the ScrolledComposite is smaller than the
+ * minimum width and minimum height. Refer to the methods setExpandHorizontal,
+ * setExpandVertical, setMinWidth and setMinHeight.
+ *
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b><dd>H_SCROLL, V_SCROLL
+ * </dl>
+ */
+public class ScrolledComposite extends Composite {
+
+ private Control content;
+ private Listener contentListener;
+
+ private int minHeight = 0;
+ private int minWidth = 0;
+ private boolean expandHorizontal = false;
+ private boolean expandVertical = false;
+
+public ScrolledComposite(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ ScrollBar hBar = getHorizontalBar ();
+ if (hBar != null) {
+ hBar.addListener (SWT.Selection, new Listener () {
+ public void handleEvent (Event e) {
+ hScroll();
+ }
+ });
+ }
+
+ ScrollBar vBar = getVerticalBar ();
+ if (vBar != null) {
+ vBar.addListener (SWT.Selection, new Listener () {
+ public void handleEvent (Event e) {
+ vScroll();
+ }
+ });
+ }
+
+ addListener (SWT.Resize, new Listener () {
+ public void handleEvent (Event e) {
+ resize();
+ }
+ });
+
+ contentListener = new Listener() {
+ public void handleEvent(Event e) {
+ if (e.type != SWT.Resize) return;
+ resize();
+ }
+ };
+}
+
+private static int checkStyle (int style) {
+ int mask = SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER;
+ return style & mask;
+}
+/**
+ * Get the content that is being scrolled.
+ */
+public Control getContent() {
+ return content;
+}
+private void hScroll() {
+ if (content == null) return;
+ Point location = content.getLocation ();
+ ScrollBar hBar = getHorizontalBar ();
+ int hSelection = hBar.getSelection ();
+ content.setLocation (-hSelection, location.y);
+}
+private void resize() {
+ if (content == null) return;
+ Rectangle contentRect = content.getBounds();
+ Rectangle hostRect = getClientArea();
+ if (expandHorizontal) {
+ contentRect.width = Math.max(minWidth, hostRect.width);
+ }
+ if (expandVertical) {
+ contentRect.height = Math.max(minHeight, hostRect.height);
+ }
+
+ ScrollBar hBar = getHorizontalBar ();
+ 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;
+ contentRect.x = -hSelection;
+ }
+ }
+
+ ScrollBar vBar = getVerticalBar ();
+ 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;
+ contentRect.y = -vSelection;
+ }
+ }
+
+ content.setBounds (contentRect);
+}
+/**
+ * Set the content that will be scrolled.
+ */
+public void setContent(Control content) {
+ if (this.content != null && !this.content.isDisposed()) {
+ this.content.removeListener(SWT.Resize, contentListener);
+ content.setBounds(new Rectangle(-200, -200, 0, 0));
+ }
+
+ this.content = content;
+ if (this.content != null) {
+ this.content.addListener(SWT.Resize, contentListener);
+ resize();
+ }
+}
+/**
+ * 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 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.
+ */
+public void setExpandHorizontal(boolean expand) {
+ if (expand == expandHorizontal) return;
+ expandHorizontal = expand;
+ resize();
+}
+/**
+ * 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 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.
+ */
+public void setExpandVertical(boolean expand) {
+ if (expand == expandVertical) return;
+ expandVertical = expand;
+ resize();
+}
+public void setLayout (Layout layout) {
+ // do not allow a layout to be set on this class because layout is being handled by the resize listener
+ 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.
+ */
+public void setMinHeight(int height) {
+ if (height == minHeight) return;
+ minHeight = Math.max(0, height);
+ resize();
+}
+/**
+ * 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.
+ */
+
+public void setMinWidth(int width) {
+ if (width == minWidth) return;
+ minWidth = Math.max(0, width);
+ resize();
+}
+
+private void vScroll() {
+ Control[] children = getChildren();
+ if (children.length == 0) return;
+ Control content = children[0];
+ Point location = content.getLocation ();
+ ScrollBar vBar = getVerticalBar ();
+ int vSelection = vBar.getSelection ();
+ content.setLocation (location.x, -vSelection);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java
new file mode 100755
index 0000000000..a193ad5a24
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StackLayout.java
@@ -0,0 +1,74 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.*;
+
+/**
+ * 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 the call
+ * layout() on the composite which has the StackLayout.
+ */
+
+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 = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT) width = maxWidth;
+ if (hHint == SWT.DEFAULT) height = maxHeight;
+ return new Point(width + 2 * marginWidth, height + 2 * marginHeight);
+}
+
+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);
+
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java
new file mode 100755
index 0000000000..12623a5b22
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyleRange.java
@@ -0,0 +1,147 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class StyleRange implements Cloneable {
+ public int start; // style start offset. 0 based from the document start
+ public int length; // style length.
+ public Color foreground;
+ public Color background;
+ public int fontStyle = SWT.NORMAL; // may be SWT.NORMAL or SWT.BOLD
+
+public StyleRange() {
+}
+/**
+ * Create a new style range.
+ * <p>
+ *
+ * @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) {
+ this.start = start;
+ this.length = length;
+ this.foreground = foreground;
+ this.background = background;
+}
+
+/**
+ * Create a new style range.
+ * <p>
+ *
+ * @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 or SWT.BOLD
+ */
+public StyleRange(int start, int length, Color foreground, Color background, int fontStyle) {
+ this.start = start;
+ this.length = length;
+ this.foreground = foreground;
+ this.background = background;
+ this.fontStyle = fontStyle;
+}
+
+/**
+ * Compare the specified object to this StyleRange and answer if the two
+ * are equal. The object must be an instance of StyleRange and have the
+ * same field values.
+ * <p>
+ *
+ * @param object the object to compare with this object
+ * @return true if the objects are equal, false otherwise
+ */
+public boolean equals(Object object) {
+ StyleRange style;
+ if (object == this) return true;
+ if (object instanceof StyleRange) style = (StyleRange)object;
+ else return false;
+ if (this.start != style.start) return false;
+ if (this.length != style.length) return false;
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground)) return false;
+ } else if (style.foreground != null) return false;
+ if (this.background != null) {
+ if (!this.background.equals(style.background)) return false;
+ } else if (style.background != null) return false;
+ if (this.fontStyle != style.fontStyle) return false;
+ return true;
+}
+/**
+ * Returns an integer hash code for the receiver. Objects which are
+ * equal answer the same value for this method.
+ * <p>
+ *
+ * @return the receiver's hash
+ */
+public int hashCode() {
+ return start + length + foreground.hashCode() + background.hashCode() + fontStyle;
+}
+/**
+ * Returns whether or not the receiver is unstyled (i.e., does not have any
+ * style attributes specified).
+ * <p>
+ *
+ * @return true if the receiver is unstyled, false otherwise.
+ */
+public boolean isUnstyled() {
+ if (this.foreground != null) return false;
+ if (this.background != null) return false;
+ if (this.fontStyle != SWT.NORMAL) 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.
+ * <p>
+ *
+ * @param object the object to compare with this object
+ * @return true if the objects are similar, false otherwise
+ */
+public boolean similarTo(StyleRange style) {
+ if (this.foreground != null) {
+ if (!this.foreground.equals(style.foreground)) return false;
+ } else if (style.foreground != null) return false;
+ if (this.background != null) {
+ if (!this.background.equals(style.background)) return false;
+ } else if (style.background != null) return false;
+ if (this.fontStyle != style.fontStyle) return false;
+ return true;
+}
+/**
+ * Answers a new StyleRange with the same values as this StyleRange.
+ * <p>
+ *
+ * @return a shallow copy of this StyleRange
+ */
+public Object clone() {
+ StyleRange style = new StyleRange(start, length, foreground, background, fontStyle);
+ return style;
+}
+/**
+ * Answers a string description of the receiver.
+ * <p>
+ *
+ * @return a printable representation for the receiver.
+ */
+public String toString() {
+ StringBuffer buf = new StringBuffer();
+ buf.append(start + "," + length + " fg:" + foreground + " bg:" + background + " fStyle:");
+ if (fontStyle == SWT.NORMAL) {
+ buf.append("normal");
+ } else if (fontStyle == SWT.BOLD) {
+ buf.append("bold");
+ }
+ return buf.toString();
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
new file mode 100755
index 0000000000..b6f2c2ecda
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledText.java
@@ -0,0 +1,5426 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.dnd.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import java.util.*;
+
+/**
+ * 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, regular)
+ * </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>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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ * <dl>
+ * <dt><b>Styles:</b><dd>FULL_SELECTION, MULTI, SINGLE, READ_ONLY
+ * <dt><b>Events:</b><dd>ExtendedModify, LineGetBackground, LineGetStyle, Modify, Selection, Verify, VerifyKey
+ * </dl>
+ */
+public class StyledText extends Canvas {
+ static final int CARET_WIDTH = 1; // width of the caret. Used during content width calculation since
+ // Caret.getSize() does not return its width until it is made visible.
+ static final char TAB = '\t';
+
+ private final static String PlatformLineDelimiter = System.getProperty("line.separator");
+
+ StyledTextContent content;
+ TextChangedListener textChangedListener; // listener for TextReplaced and TextSet events from StyledTextContent
+ DefaultLineStyler defaultLineStyler;// used for setStyles API when no LineStyleListener is registered
+ boolean userLineStyle = false; // true=widget is using a user defined line style listener for line styles. false=widget is using the default line styler to store line styles
+ boolean userLineBackground = false;// true=widget is using a user defined line background listener for line backgrounds. false=widget is using the default line styler to store line backgrounds
+ int verticalScrollOffset = 0; // pixel based
+ int horizontalScrollOffset = 0; // pixel based
+ int topIndex = 0; // top visible line
+ int clientAreaHeight = 0; // the client area height. Needed to calculate content width for new
+ // visible lines during Resize callback
+ int contentWidth = 0; // width of widest known (already visible) line
+ int contentWidthIndex = 0; // line up to which the content width has been calculated
+ int lineHeight; // line height=font height
+ int tabLength = 4; // number of characters in a tab
+ int tabWidth; // width of a tab character in the current GC
+ Caret caret; // caret SWT widget
+ Cursor ibeamCursor;
+ int caretOffset = 0;
+ Point selection = new Point(0, 0); // x is character offset, y is length
+ int selectionAnchor; // position of selection anchor. 0 based offset from beginning of text
+ boolean editable = true;
+ 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.
+ boolean selectionVisible = true;
+ Hashtable keyActionMap = new Hashtable();
+ Font boldFont;
+ Font regularFont;
+ Clipboard clipboard;
+
+ boolean mouseDoubleClick = false; // true=a double click ocurred. Don't do mouse swipe selection.
+ int autoScrollDirection = SWT.NULL; // the direction of autoscrolling (up, down, right, left)
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final int ExtendedModify = 3000;
+ static final int LineGetStyle = 3002;
+ static final int LineGetBackground = 3001;
+ static final int TextReplaced = 3003;
+ static final int TextSet = 3004;
+ static final int VerifyKey = 3005;
+ /**
+ * 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 {
+ final int DEFAULT_FOREGROUND = 0;
+ final int DEFAULT_BACKGROUND = 1;
+ Vector colorTable = new Vector();
+
+ /**
+ * 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.
+ * <p>
+ *
+ * @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.addElement(getForeground());
+ colorTable.addElement(getBackground());
+ }
+ /**
+ * 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() == false) {
+ writeHeader();
+ write("\n}}\0");
+ super.close();
+ }
+ }
+ /**
+ * Returns the index of the specified color in the RTF color table.
+ * <p>
+ *
+ * @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) {
+ int index;
+
+ if (color == null) {
+ index = defaultIndex;
+ }
+ else {
+ index = colorTable.indexOf(color);
+ if (index == -1) {
+ index = colorTable.size();
+ colorTable.addElement(color);
+ }
+ }
+ return index;
+ }
+ /**
+ * 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\\deff0{\\fonttbl{\\f0\\fnil ");
+ header.append(fontData.getName());
+ 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.
+ * <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.
+ * @exception SWTException <ul>
+ * <li>ERROR_IO when the writer is closed. @see close()</li>
+ * </ul>
+ */
+ public void writeLine(String line, int lineOffset) {
+ StyleRange[] styles = new StyleRange[0];
+ Color lineBackground = null;
+ StyledTextEvent event;
+
+ if (isClosed()) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ event = getLineStyleData(lineOffset, line);
+ if (event != null) {
+ styles = event.styles;
+ }
+ event = getLineBackgroundData(lineOffset, line);
+ if (event != null) {
+ lineBackground = event.lineBackground;
+ }
+ if (lineBackground == null) {
+ lineBackground = getBackground();
+ }
+ writeStyledLine(line, lineOffset, styles, lineBackground);
+ }
+ /**
+ * Appends the specified line delmimiter to the RTF data.
+ * <p>
+ *
+ * @param lineDelimiter line delimiter to write as RTF.
+ * @exception SWTException <ul>
+ * <li>ERROR_IO when the writer is closed. @see close()</li>
+ * </ul>
+ */
+ public void writeLineDelimiter(String lineDelimiter) {
+ if (isClosed()) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ write(lineDelimiter, 0, lineDelimiter.length());
+ write("\\par ");
+ }
+ /**
+ * Appends the specified segment of "string" to the RTF data.
+ * Copy from <code>start</code> up to, but excluding, <code>end</code>.
+ * <p>
+ *
+ * @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) {
+ int index;
+
+ for (index = start; index < end; index++) {
+ char c = string.charAt(index);
+ if (c == '}' || c == '{' || c == '\\') {
+ break;
+ }
+ }
+ if (index == end) {
+ write(string.substring(start, end)); // string doesn't contain RTF formatting characters, write as is
+ }
+ else { // string needs to be transformed
+ char[] text = new char[end - start];
+
+ string.getChars(start, end, text, 0);
+ for (index = 0; index < text.length; index++) {
+ switch (text[index]) {
+ case '}':
+ case '{':
+ case '\\':
+ write("\\");
+ default:
+ write(text[index]);
+ }
+ }
+ }
+ }
+ /**
+ * Appends the specified line text to the RTF data.
+ * 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, StyleRange[] styles, Color lineBackground) {
+ int lineLength = line.length();
+ int lineIndex;
+ int copyEnd;
+ int startOffset = getStart();
+ int endOffset = startOffset + super.getCharCount();
+ int writeOffset = startOffset - lineOffset;
+
+ if (writeOffset >= line.length()) {
+ return; // whole line is outside write range
+ }
+ else
+ if (writeOffset > 0) {
+ lineIndex = writeOffset; // line starts before RTF write start
+ }
+ else {
+ lineIndex = 0;
+ }
+ if (lineBackground != null) {
+ write("{\\highlight");
+ write(getColorIndex(lineBackground, DEFAULT_BACKGROUND));
+ write(" ");
+ }
+ for (int i = 0; i < styles.length; i++) {
+ StyleRange style = styles[i];
+ int start = style.start - lineOffset;
+ int end = start + style.length;
+ int colorIndex;
+ // skip over partial first line
+ if (end < writeOffset) {
+ continue;
+ }
+ // break on partial last line
+ if (style.start > endOffset) {
+ break;
+ }
+ // write any unstyled text
+ if (lineIndex < start) {
+ // copy to start of style or end of write range (specified
+ // during object creation) or end of line
+ copyEnd = Math.min(start, endOffset - lineOffset);
+ copyEnd = Math.min(copyEnd, lineLength);
+ write(line, lineIndex, copyEnd);
+ lineIndex = copyEnd;
+ if (copyEnd != start) {
+ break;
+ }
+ }
+ // write styled text
+ colorIndex = getColorIndex(style.background, DEFAULT_BACKGROUND);
+ write("{\\cf");
+ write(getColorIndex(style.foreground, DEFAULT_FOREGROUND));
+ if (colorIndex != DEFAULT_BACKGROUND) {
+ write("\\highlight");
+ write(colorIndex);
+ }
+ if (style.fontStyle == SWT.BOLD) {
+ write("\\b");
+ }
+ write(" ");
+ // copy to end of style or end of write range (specified
+ // during object creation) or end of line
+ copyEnd = Math.min(end, endOffset - lineOffset);
+ copyEnd = Math.min(copyEnd, lineLength);
+ write(line, lineIndex, copyEnd);
+ if (style.fontStyle == SWT.BOLD) {
+ write("\\b0");
+ }
+ write("}");
+ lineIndex = copyEnd;
+ if (copyEnd != end) {
+ break;
+ }
+ }
+ copyEnd = Math.min(lineLength, endOffset - lineOffset);
+ if (lineIndex < copyEnd) {
+ write(line, lineIndex, copyEnd);
+ }
+ 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.
+ */
+ 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.
+ * <p>
+ *
+ * @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 == false) {
+ isClosed = true;
+ }
+ }
+ /**
+ * Returns the 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.
+ */
+ public int getStart() {
+ return startOffset;
+ }
+ /**
+ * Returns whether 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.
+ * <p>
+ *
+ * @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.
+ * 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.
+ * <p>
+ *
+ * @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. @see close()</li>
+ * </ul>
+ */
+ public void writeLine(String line, int lineOffset) {
+ int lineLength = line.length();
+ int lineIndex;
+ int copyEnd;
+ int writeOffset = startOffset - lineOffset;
+
+ if (isClosed) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ if (writeOffset >= lineLength) {
+ return; // whole line is outside write range
+ }
+ else
+ if (writeOffset > 0) {
+ lineIndex = writeOffset; // line starts before write start
+ }
+ else {
+ lineIndex = 0;
+ }
+ copyEnd = Math.min(lineLength, endOffset - lineOffset);
+ if (lineIndex < copyEnd) {
+ write(line.substring(lineIndex, copyEnd));
+ }
+ }
+ /**
+ * Appends the specified line delmimiter to the data.
+ * <p>
+ *
+ * @param lineDelimiter line delimiter to write
+ * @exception SWTException <ul>
+ * <li>ERROR_IO when the writer is closed. @see close()</li>
+ * </ul>
+ */
+ public void writeLineDelimiter(String lineDelimiter) {
+ if (isClosed) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ write(lineDelimiter);
+ }
+ }
+
+public StyledText(Composite parent, int style) {
+ // use NO_BACKGROUND style when implemented by SWT.
+ // always need to draw background in drawLine when using NO_BACKGROUND!
+ super(parent, checkStyle(style | SWT.NO_REDRAW_RESIZE | SWT.NO_BACKGROUND));
+ Display display = getDisplay();
+
+ if ((style & SWT.READ_ONLY) != 0) {
+ setEditable(false);
+ }
+ clipboard = new Clipboard(display);
+ calculateLineHeight();
+ calculateTabWidth();
+ caret = new Caret(this, SWT.NULL);
+ caret.setBounds(0, 0, CARET_WIDTH, lineHeight);
+ installDefaultContent();
+ calculateScrollBars();
+ createKeyBindings();
+ ibeamCursor = new Cursor(display, SWT.CURSOR_IBEAM);
+ setCursor(ibeamCursor);
+
+ setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+ initializeFonts();
+ installListeners();
+ installDefaultLineStyler();
+}
+
+/**
+ * Adds an extended modify listener. An ExtendedModify event is sent by the
+ * widget when the widget text has changed.
+ * <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>
+ */
+public void addExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+ checkWidget();
+ if (extendedModifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ StyledTextListener typedListener = new StyledTextListener(extendedModifyListener);
+ addListener(ExtendedModify, typedListener);
+}
+
+/**
+ * Maps a key to an action.
+ * 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 (one or more of SWT.CTRL, SWT.SHIFT, SWT.ALT)
+ * @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>
+ * @see org.eclipse.swt.SWT
+ * @see org.eclipse.swt.ST
+ */
+public void setKeyBinding(int key, int action) {
+ checkWidget();
+ if (action == SWT.NULL) {
+ keyActionMap.remove(new Integer(key));
+ }
+ else {
+ keyActionMap.put(new Integer(key), new Integer(action));
+ }
+}
+/**
+ * Adds a line background listener. A LineGetBackground event is sent by the
+ * widget to determine the background color for a line.
+ * <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>
+ */
+public void addLineBackgroundListener(LineBackgroundListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (userLineBackground == false) {
+ removeLineBackgroundListener(defaultLineStyler);
+ defaultLineStyler.setLineBackground(0, content.getLineCount(), null);
+ userLineBackground = true;
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(LineGetBackground, typedListener);
+}
+/**
+ * Adds a line style listener. A LineGetStyle event is sent by the widget to
+ * determine the styles for a line.
+ * <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>
+ */
+public void addLineStyleListener(LineStyleListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (userLineStyle == false) {
+ removeLineStyleListener(defaultLineStyler);
+ defaultLineStyler.setStyleRange(null);
+ userLineStyle = true;
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(LineGetStyle, typedListener);
+}
+/**
+ * Adds a modify listener. A Modify event is sent by the widget when the widget text
+ * has changed.
+ * <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>
+ */
+public void addModifyListener(ModifyListener modifyListener) {
+ checkWidget();
+ if (modifyListener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(modifyListener);
+ addListener(SWT.Modify, typedListener);
+}
+
+/**
+ * Adds a selection listener. A Selection event is sent by the widget when the
+ * selection has changed.
+ * <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>
+ */
+public void addSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+}
+
+/**
+ * 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.
+ * <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>
+ */
+public void addVerifyKeyListener(VerifyKeyListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ StyledTextListener typedListener = new StyledTextListener(listener);
+ addListener(VerifyKey, typedListener);
+}
+
+/**
+ * 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.
+ * <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>
+ */
+public void addVerifyListener(VerifyListener verifyListener) {
+ checkWidget();
+ if (verifyListener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ TypedListener typedListener = new TypedListener(verifyListener);
+ addListener(SWT.Verify, typedListener);
+}
+/**
+ * Appends a string to the text at the end of the widget.
+ * <p>
+ *
+ * @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 width of the widest visible line.
+ */
+void calculateContentWidth() {
+ if (lineHeight != 0) {
+ int itemCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+ calculateContentWidth(topIndex, Math.min(itemCount, content.getLineCount() - topIndex));
+ }
+}
+
+/**
+ * Calculates the width of the widget text in the specified line range.
+ * <p>
+ *
+ * @param startline the first line
+ * @param lineCount number of lines to consider for the calculation
+ * @param skipCalculated true=don't recalculated lines that have already been calculated
+ */
+void calculateContentWidth(int startLine, int lineCount) {
+ String line;
+ GC gc = new GC(this);
+ FontData fontData = gc.getFont().getFontData()[0];
+ int stopLine;
+
+ if (lineCount < 0) {
+ startLine += lineCount;
+ lineCount *= -1;
+ }
+ stopLine = startLine + lineCount;
+ setLineFont(gc, fontData, SWT.BOLD);
+ for (int i = startLine; i < stopLine; i++) {
+ line = content.getLine(i);
+ contentWidth = Math.max(contentWidth(line, i, gc) + CARET_WIDTH, contentWidth);
+ }
+ gc.dispose();
+}
+
+/**
+ * Calculates the line height
+ */
+void calculateLineHeight() {
+ GC gc = new GC(this);
+ lineHeight = gc.getFontMetrics().getHeight();
+ gc.dispose();
+}
+
+/**
+ * Calculates the width in pixel of a tab character
+ */
+void calculateTabWidth() {
+ StringBuffer tabBuffer = new StringBuffer(tabLength);
+ GC gc = new GC(this);
+
+ for (int i = 0; i < tabLength; i++) {
+ tabBuffer.append(' ');
+ }
+ tabWidth = gc.stringExtent(tabBuffer.toString()).x;
+ gc.dispose();
+}
+
+/**
+ * Calculates the scroll bars
+ */
+void calculateScrollBars() {
+ ScrollBar horizontalBar = getHorizontalBar();
+ ScrollBar verticalBar = getVerticalBar();
+
+ setScrollBars();
+ if (verticalBar != null) {
+ verticalBar.setIncrement(getVerticalIncrement());
+ }
+ if (horizontalBar != null) {
+ horizontalBar.setIncrement(getHorizontalIncrement());
+ }
+}
+
+/**
+ * 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);
+ }
+ return style;
+}
+
+/**
+ * Scrolls down the text to use new space made available by a resize or by
+ * deleted lines.
+ */
+void claimBottomFreeSpace() {
+ int clientAreaItemCount = getLineCountWhole();
+ int topIndex = getTopIndex();
+ int newTopIndex;
+ int lastItemIndex = content.getLineCount() - topIndex;
+
+ if (topIndex > 0 &&
+ lastItemIndex > 0 &&
+ lastItemIndex < clientAreaItemCount) {
+ newTopIndex = Math.max(0, topIndex - (clientAreaItemCount - lastItemIndex));
+ setTopIndex(newTopIndex);
+ }
+}
+
+/**
+ * Scrolls text to the right to use new space made available by a resize.
+ */
+void claimRightFreeSpace() {
+ int newHorizontalOffset = Math.max(0, contentWidth - getClientArea().width);
+
+ 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).
+ scrollHorizontalBar(newHorizontalOffset - horizontalScrollOffset);
+ }
+}
+
+/**
+ * Removes the widget selection.
+ * <p>
+ *
+ * @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;
+ int length = content.getCharCount();
+
+ resetSelection();
+ // redraw old selection, if any
+ if (selectionEnd - selectionStart > 0) {
+ // 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) {
+ redrawRange(redrawStart, redrawEnd - redrawStart, true);
+ }
+ if (sendEvent == true) {
+ sendSelectionEvent();
+ }
+ }
+}
+
+/**
+ * Computes 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>
+ */
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget();
+ int count, width, height, lineHeight;
+ boolean singleLine = (getStyle() & SWT.SINGLE) != 0;
+ lineHeight = getLineHeight();
+ count = content.getLineCount();
+
+ // If a height or width has been specified (via hHint and wHint),
+ // use those values. Otherwise calculate the size based on the
+ // text that is defined.
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ } else {
+ if (singleLine) count = 1;
+ height = count * lineHeight;
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ } else {
+ // Only calculate what can actually be displayed.
+ // Do this because measuring each text line is a
+ // time-consuming process.
+ int visibleCount = Math.min (count, getDisplay().getBounds().width / lineHeight);
+ calculateContentWidth(0, visibleCount);
+ width = contentWidth;
+ }
+
+ // Use default values if no text is defined.
+ if (width == 0) width = DEFAULT_WIDTH;
+ if (height == 0) {
+ if (singleLine) height = getLineHeight();
+ else height = DEFAULT_HEIGHT;
+ }
+
+ // Hardcode the inset margins. Assume text is inset
+ // 1 pixel on each side.
+ width += 2;
+ height += 2;
+
+ Rectangle rect = computeTrim(0,0,width,height);
+ return new Point (rect.width, rect.height);
+}
+/**
+ * Returns the width of the specified text. Expand tabs to tab stops using
+ * the widget tab width.
+ * This is a quick and inaccurate measurement. Text styles are not taken
+ * into consideration. The gc should be setup to reflect the widest
+ * possible font style.
+ * <p>
+ *
+ * @param text text to be measured.
+ * @param lineIndex index of the line.
+ * @param gc GC to use for measuring text
+ * @return width of the text with tabs expanded to tab stops
+ */
+int contentWidth(String text, int lineIndex, GC gc) {
+ int paintX = 0;
+ int textLength = text.length();
+
+ for (int i = 0; i < textLength; i++) {
+ int tabIndex = text.indexOf(TAB, i);
+ // is tab not present or past the rendering range?
+ if (tabIndex == -1 || tabIndex > textLength) {
+ tabIndex = textLength;
+ }
+ if (tabIndex != i) {
+ String tabSegment = text.substring(i, tabIndex);
+ paintX += gc.stringExtent(tabSegment).x;
+ if (tabIndex != textLength && tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ i = tabIndex;
+ }
+ else
+ if (tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ }
+ return paintX;
+}
+/**
+ * Copies the selected text to the clipboard. The text will be put in the
+ * clipboard in plain text format and RTF format.
+ * <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();
+ int length = selection.y - selection.x;
+ if (length > 0) {
+ RTFTransfer rtfTransfer = RTFTransfer.getInstance();
+ TextTransfer plainTextTransfer = TextTransfer.getInstance();
+ RTFWriter rtfWriter = new RTFWriter(selection.x, length);
+ TextWriter plainTextWriter = new TextWriter(selection.x, length);
+ String rtfText;
+ String plainText;
+ rtfText = getPlatformDelimitedText(rtfWriter);
+ plainText = getPlatformDelimitedText(plainTextWriter);
+ clipboard.setContents(
+ new String[]{rtfText, plainText},
+ new Transfer[]{rtfTransfer, plainTextTransfer});
+ }
+}
+
+/**
+ * Returns a string that uses only the line delimiter specified by the
+ * StyledTextContent implementation.
+ * 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) {
+ StringBuffer convertedText;
+ String delimiter = getLineDelimiter();
+ int length = text.length();
+ int crIndex = 0;
+ int lfIndex = 0;
+ int i = 0;
+
+ if (length == 0) {
+ return text;
+ }
+ convertedText = new StringBuffer(length);
+ 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 // CR occurs before LF or no LF present?
+ 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() == false || convertedText.length() == 0)) {
+ convertedText.append(text.substring(i));
+ }
+ return convertedText.toString();
+}
+
+/**
+ * Creates default key bindings.
+ */
+void createKeyBindings() {
+ // Navigation
+ setKeyBinding(SWT.ARROW_UP, ST.LINE_UP);
+ setKeyBinding(SWT.ARROW_DOWN, ST.LINE_DOWN);
+ setKeyBinding(SWT.HOME, ST.LINE_START);
+ setKeyBinding(SWT.END, ST.LINE_END);
+ setKeyBinding(SWT.ARROW_LEFT, ST.COLUMN_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT, ST.COLUMN_NEXT);
+ setKeyBinding(SWT.PAGE_UP, ST.PAGE_UP);
+ setKeyBinding(SWT.PAGE_DOWN, ST.PAGE_DOWN);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.CTRL, ST.WORD_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.CTRL, ST.WORD_NEXT);
+ setKeyBinding(SWT.HOME | SWT.CTRL, ST.TEXT_START);
+ setKeyBinding(SWT.END | SWT.CTRL, ST.TEXT_END);
+ setKeyBinding(SWT.PAGE_UP | SWT.CTRL, ST.WINDOW_START);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.CTRL, ST.WINDOW_END);
+
+ // Selection
+ setKeyBinding(SWT.ARROW_UP | SWT.SHIFT, ST.SELECT_LINE_UP);
+ setKeyBinding(SWT.ARROW_DOWN | SWT.SHIFT, ST.SELECT_LINE_DOWN);
+ setKeyBinding(SWT.HOME | SWT.SHIFT, ST.SELECT_LINE_START);
+ setKeyBinding(SWT.END | SWT.SHIFT, ST.SELECT_LINE_END);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.SHIFT, ST.SELECT_COLUMN_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.SHIFT, ST.SELECT_COLUMN_NEXT);
+ setKeyBinding(SWT.PAGE_UP | SWT.SHIFT, ST.SELECT_PAGE_UP);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.SHIFT, ST.SELECT_PAGE_DOWN);
+ setKeyBinding(SWT.ARROW_LEFT | SWT.CTRL | SWT.SHIFT, ST.SELECT_WORD_PREVIOUS);
+ setKeyBinding(SWT.ARROW_RIGHT | SWT.CTRL | SWT.SHIFT, ST.SELECT_WORD_NEXT);
+ setKeyBinding(SWT.HOME | SWT.CTRL | SWT.SHIFT, ST.SELECT_TEXT_START);
+ setKeyBinding(SWT.END | SWT.CTRL | SWT.SHIFT, ST.SELECT_TEXT_END);
+ setKeyBinding(SWT.PAGE_UP | SWT.CTRL | SWT.SHIFT, ST.SELECT_WINDOW_START);
+ setKeyBinding(SWT.PAGE_DOWN | SWT.CTRL | SWT.SHIFT, ST.SELECT_WINDOW_END);
+
+ // Modification
+ // Cut, Copy, Paste
+ // CUA style
+ setKeyBinding('\u0018' | SWT.CTRL, ST.CUT);
+ setKeyBinding('\u0003' | SWT.CTRL, ST.COPY);
+ setKeyBinding('\u0016' | SWT.CTRL, ST.PASTE);
+ // Wordstar style
+ setKeyBinding(SWT.DEL | SWT.SHIFT, ST.CUT);
+ setKeyBinding(SWT.INSERT | SWT.CTRL, ST.COPY);
+ setKeyBinding(SWT.INSERT | SWT.SHIFT, ST.PASTE);
+
+ setKeyBinding(SWT.BS, ST.DELETE_PREVIOUS);
+ setKeyBinding(SWT.DEL, ST.DELETE_NEXT);
+
+ // Miscellaneous
+ setKeyBinding(SWT.INSERT, ST.TOGGLE_OVERWRITE);
+}
+/**
+ * Moves the selected text to the clipboard. The text will be put in the
+ * clipboard in plain text format and RTF format.
+ * <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 (selection.y > selection.x) {
+ copy();
+ 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) {
+ Rectangle area = getClientArea();
+ if (event.y > area.height) doAutoScroll(SWT.DOWN);
+ else if (event.y < 0) doAutoScroll(SWT.UP);
+ else if (event.x < 0) doAutoScroll(SWT.LEFT);
+ else if (event.x > area.width) doAutoScroll(SWT.RIGHT);
+ else endAutoScroll();
+}
+/**
+ * Initiates autoscrolling.
+ * <p>
+ *
+ * @param direction SWT.UP, SWT.DOWN, SWT.RIGHT, SWT.LEFT
+ */
+void doAutoScroll(int direction) {
+ Runnable timer = null;
+ final int TIMER_INTERVAL = 5;
+
+ // If we're already autoscrolling in the given direction do nothing
+ if (autoScrollDirection == direction) {
+ return;
+ }
+
+ 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) {
+ doLineUp();
+ doSelection(SWT.LEFT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.DOWN) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.DOWN) {
+ doLineDown();
+ doSelection(SWT.RIGHT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.RIGHT) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.RIGHT) {
+ doColumnRight();
+ doSelection(SWT.RIGHT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ } else if (direction == SWT.LEFT) {
+ timer = new Runnable() {
+ public void run() {
+ if (autoScrollDirection == SWT.LEFT) {
+ doColumnLeft();
+ doSelection(SWT.LEFT);
+ display.timerExec(TIMER_INTERVAL, this);
+ }
+ }
+ };
+ }
+ if (timer != null) {
+ autoScrollDirection = direction;
+ display.timerExec(TIMER_INTERVAL, timer);
+ }
+}
+
+/**
+ * Deletes the character to the left of the caret. 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 line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (caretOffset == lineOffset) {
+ lineOffset = content.getOffsetAtLine(line - 1);
+ event.start = lineOffset + content.getLine(line - 1).length();
+ event.end = caretOffset;
+ }
+ else {
+ event.start = caretOffset - 1;
+ event.end = caretOffset;
+ }
+ sendKeyEvent(event);
+ }
+ claimBottomFreeSpace();
+}
+
+/**
+ * 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.
+ * <p>
+ *
+ * @see #doSelectionCursorLeft
+ */
+void doCursorLeft() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.x;
+ showCaret();
+ }
+ else {
+ doSelectionCursorLeft();
+ }
+}
+
+/**
+ * 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.
+ * <p>
+ *
+ * @see #doSelectionCursorRight
+ */
+void doCursorRight() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.y;
+ showCaret();
+ }
+ else {
+ doSelectionCursorRight();
+ }
+}
+/**
+ * Moves the caret one character to the left. Do not go to the previous line.
+ */
+void doColumnLeft() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine > 0) {
+ caretOffset--;
+ showCaret();
+ }
+}
+/**
+ * Moves the caret one character to the right. Do not go to the next line.
+ */
+void doColumnRight() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine < content.getLine(line).length()) {
+ caretOffset++;
+ showCaret();
+ }
+}
+
+/**
+ * Replaces the selection with the character or insert the character at the
+ * current caret position if no selection exists.
+ * 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;
+
+ if (textLimit > 0 && content.getCharCount() - (selection.y - selection.x) >= textLimit) {
+ return;
+ }
+ 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() == false) {
+ event.text = getLineDelimiter();
+ }
+ }
+ // no selection and overwrite mode is on and the typed key is not a
+ // tab character (tabs are always inserted without overwriting)?
+ else
+ if (selection.x == selection.y && overwrite == true && key != TAB) {
+ 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) {
+ sendKeyEvent(event);
+ }
+}
+
+/**
+ * Moves the caret after the last character of the widget content.
+ */
+void doContentEnd() {
+ 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();
+ }
+}
+
+/**
+ * Deletes the character to the right of the caret. 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 = caretOffset + 1;
+ }
+ sendKeyEvent(event);
+ }
+ claimBottomFreeSpace();
+}
+
+/**
+ * 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.
+ * Make the new caret position visible.
+ */
+void doLineDown() {
+ doSelectionLineDown();
+ showCaret();
+}
+
+/**
+ * Moves the caret to the end of the line.
+ */
+void doLineEnd() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+ int lineEndOffset = lineOffset + lineLength;
+
+ if (caretOffset < lineEndOffset) {
+ caretOffset = lineEndOffset;
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret to the beginning of the line.
+ */
+void doLineStart() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (caretOffset > lineOffset) {
+ caretOffset = lineOffset;
+ showCaret();
+ }
+ else // move up one line to remove line selection
+ if (line > 0 && selection.x < caretOffset) {
+ line--;
+ caretOffset = content.getOffsetAtLine(line);
+ 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() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (line > 0) {
+ line--;
+ lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+ if (offsetInLine > lineLength) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret to the specified location.
+ * <p>
+ *
+ * @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 = (y + verticalScrollOffset) / getLineHeight();
+ int lineCount = content.getLineCount();
+
+ if (line > lineCount - 1) {
+ line = lineCount - 1;
+ }
+ if (line >= 0) {
+ String lineText = content.getLine(line);
+ int offsetInLine = -1;
+ int newCaretOffset;
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (select && selection.x == lineOffset && line < lineCount - 1) {
+ GC gc = new GC(this);
+ int lineLength = lineText.length();
+ // represent the line break as one additional white space
+ // if the selection mouse event occurs beyond the line end
+ if (x + horizontalScrollOffset > textWidth(lineText, line, lineLength, gc)) {
+ line++;
+ offsetInLine = 0;
+ lineOffset = content.getOffsetAtLine(line);
+ }
+ gc.dispose();
+ }
+ if (offsetInLine == -1) {
+ offsetInLine = getOffsetAtX(lineText, lineOffset, x);
+ }
+ newCaretOffset = lineOffset + offsetInLine;
+ if (newCaretOffset != caretOffset) {
+ caretOffset = newCaretOffset;
+ if (select) {
+ doMouseSelection();
+ }
+ showCaret();
+ }
+ if (select == false) {
+ 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(SWT.LEFT);
+ }
+ else {
+ doSelection(SWT.RIGHT);
+ }
+}
+
+/**
+ * Scrolls one page down so that the last line (truncated or whole)
+ * of the current page becomes the fully visible top 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 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 line = content.getLineAtOffset(caretOffset);
+ int lineCount = content.getLineCount();
+
+ if (line < lineCount) {
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ int lineLength;
+ int verticalMaximum = content.getLineCount() * getVerticalIncrement();
+ int pageSize = getClientArea().height;
+ int scrollLines = Math.min(lineCount - line - 1, getLineCountWhole() - 1);
+ int scrollOffset;
+
+ line += scrollLines;
+ lineOffset = content.getOffsetAtLine(line);
+ lineLength = content.getLine(line).length();
+ // set cursor to end of line if cursor would be beyond the end
+ // of line or if page down goes to last line
+ if (offsetInLine > lineLength || line == lineCount - 1) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ if (select) {
+ doSelection(SWT.RIGHT);
+ }
+ // scroll one page down or to the bottom
+ scrollOffset = verticalScrollOffset + scrollLines * getVerticalIncrement();
+ if (scrollOffset + pageSize > verticalMaximum) {
+ scrollOffset = verticalMaximum - pageSize;
+ }
+ if (scrollOffset > verticalScrollOffset) {
+ setVerticalScrollOffset(scrollOffset, true);
+ }
+ else {
+ showCaret();
+ }
+ }
+}
+/**
+ * Moves the cursor to the end of the last fully visible line.
+ */
+void doPageEnd() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineCount = content.getLineCount();
+
+ if (line < lineCount) {
+ line = getBottomIndex();
+ caretOffset = content.getOffsetAtLine(line) + content.getLine(line).length();
+ showCaret();
+ }
+}
+/**
+ * Moves the cursor to the beginning of the first fully visible line.
+ */
+void doPageStart() {
+ if (content.getLineAtOffset(caretOffset) > topIndex) {
+ caretOffset = content.getOffsetAtLine(topIndex);
+ 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() {
+ int line = content.getLineAtOffset(caretOffset);
+
+ if (line > 0) {
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ int lineLength;
+ int scrollLines = Math.min(line, getLineCountWhole() - 1);
+ int scrollOffset;
+
+ line -= scrollLines;
+ lineOffset = content.getOffsetAtLine(line);
+ lineLength = content.getLine(line).length();
+ // set cursor to start of line if page up goes to first line
+ if (line == 0) {
+ offsetInLine = 0;
+ }
+ else
+ if (offsetInLine > lineLength) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ // scroll one page up or to the top
+ scrollOffset = Math.max(0, verticalScrollOffset - scrollLines * getVerticalIncrement());
+ if (scrollOffset < verticalScrollOffset) {
+ setVerticalScrollOffset(scrollOffset, true);
+ }
+ else {
+ showCaret();
+ }
+ }
+}
+/**
+ * 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 doSelectionLineDown() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (line < content.getLineCount() - 1) {
+ line++;
+ lineOffset = content.getOffsetAtLine(line);
+ int lineLength = content.getLine(line).length();
+ if (offsetInLine > lineLength) {
+ offsetInLine = lineLength;
+ }
+ caretOffset = lineOffset + offsetInLine;
+ }
+}
+/**
+ * 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 == SWT.LEFT) {
+ 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;
+ }
+ }
+ else // test whether selection actually changed. Fixes 1G71EO1
+ 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;
+ }
+ }
+ else // test whether selection actually changed. Fixes 1G71EO1
+ 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) {
+ redrawRange(redrawStart, redrawEnd - redrawStart, true);
+ sendSelectionEvent();
+ }
+}
+
+/**
+ * Moves the caret one character to the left or to the end of the previous
+ * line if the cursor is at the beginning of a line.
+ */
+void doSelectionCursorLeft() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine > 0) {
+ caretOffset--;
+ showCaret();
+ }
+ else
+ if (line > 0) {
+ line--;
+ lineOffset = content.getOffsetAtLine(line);
+ caretOffset = lineOffset + content.getLine(line).length();
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret one character to the right or to the beginning of the
+ * next line if the cursor is at the end of a line.
+ */
+void doSelectionCursorRight() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+
+ if (offsetInLine < content.getLine(line).length()) {
+ caretOffset++;
+ showCaret();
+ }
+ else
+ if (line < content.getLineCount() - 1) {
+ line++;
+ caretOffset = content.getOffsetAtLine(line);
+ showCaret();
+ }
+}
+
+/**
+ * Moves the caret to the beginning of the next line, selecting to the end
+ * of the line plus one whitespace to represent the line break.
+ * Do the regular line selection, if the selection does not start at the
+ * line start or if the last line is being selected.
+ */
+void doSelectionLineEnd() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+
+ if (selection.x == lineOffset && line < content.getLineCount() - 1) {
+ line++;
+ caretOffset = content.getOffsetAtLine(line);
+ showCaret();
+ }
+ else {
+ doLineEnd();
+ }
+}
+/**
+ * Moves the caret to the start of the word that is to the left of
+ * the current caret position.
+ * If a selection exists, move the caret to the start of the selection
+ * and remove the selection.
+ */
+void doWordLeft() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.x;
+ showCaret();
+ }
+ else {
+ doSelectionWordLeft();
+ }
+}
+
+/**
+ * Moves the caret to the end of the word that is to the right of
+ * the current caret position.
+ * If a selection exists, move the caret to the end of the selection
+ * and remove the selection.
+ */
+void doWordRight() {
+ if (selection.y - selection.x > 0) {
+ caretOffset = selection.y;
+ showCaret();
+ }
+ else {
+ doSelectionWordRight();
+ }
+}
+
+/**
+ * Moves the caret to the start of the word that is to the left of
+ * the current caret position.
+ */
+void doSelectionWordLeft() {
+ caretOffset = getWordStart(caretOffset);
+ showCaret();
+}
+
+/**
+ * Moves the caret to the end of the word that is to the right of
+ * the current caret position.
+ */
+void doSelectionWordRight() {
+ caretOffset = getWordEnd(caretOffset);
+ showCaret();
+}
+
+/**
+ * Draws the specified rectangle.
+ * Draw directly without invalidating the affected area when a gc is
+ * specified.
+ * <p>
+ *
+ * @param x the x position
+ * @param y the y position
+ * @param width the width
+ * @param height the height
+ * @param gc GC to use for direct drawing. If null the specified area
+ * is invalidated only.
+ * @param clearBackground true=clear the background, false=only draw the foregorund
+ */
+void draw(int x, int y, int width, int height, GC gc, boolean clearBackground) {
+ if (gc == null) {
+ redraw(x, y, width, height, false);
+ }
+ else {
+ int lineHeight = getLineHeight();
+ int startLine = (y + verticalScrollOffset) / lineHeight;
+ int endY = y + height;
+ int paintYFromTopLine = (startLine - topIndex) * lineHeight;
+ int topLineOffset = (topIndex * lineHeight - verticalScrollOffset);
+ int paintY = paintYFromTopLine + topLineOffset; // adjust y position for pixel based scrolling
+ int lineCount = content.getLineCount();
+ Color background = getBackground();
+ Color foreground = getForeground();
+
+ if (isSingleLine()) {
+ lineCount = 1;
+ if (startLine > 1) {
+ startLine = 1;
+ }
+ }
+ for (int i = startLine; paintY < endY && i < lineCount; i++, paintY += lineHeight) {
+ String line = content.getLine(i);
+ drawLine(line, i, paintY, gc, background, foreground, clearBackground);
+ }
+ if (clearBackground && paintY < endY) {
+ gc.setBackground(background);
+ gc.setForeground(background);
+ gc.fillRectangle(0, paintY, getClientArea().width, endY - paintY);
+ }
+ }
+}
+/**
+ * Draws a line of text at the specified location.
+ * <p>
+ *
+ * @param line the line to draw
+ * @param lineIndex index of the line to draw
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @param widgetBackground the widget background color. Used as the default rendering color.
+ * @param widgetForeground the widget foreground color. Used as the default rendering color.
+ */
+void drawLine(String line, int lineIndex, int paintY, GC gc, Color widgetBackground, Color widgetForeground, boolean clearBackground) {
+ int lineOffset = content.getOffsetAtLine(lineIndex);
+ int lineLength = line.length();
+ int selectionEndX = 0;
+ int clientAreaWidth = getClientArea().width;
+ int selectionStartOffset;
+ int selectionEndOffset;
+ int selectionLength;
+ boolean lineSelection;
+ StyleRange[] styles = new StyleRange[0];
+ Color lineBackground = null;
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ styles = event.styles;
+ }
+ event = getLineBackgroundData(lineOffset, line);
+ if (event != null) {
+ lineBackground = event.lineBackground;
+ }
+ if (lineBackground == null) {
+ lineBackground = widgetBackground;
+ }
+ // calculate offset of selection start and end relative to the line start
+ selectionStartOffset = Math.max(0, selection.x - lineOffset);
+ selectionEndOffset = selection.y - lineOffset;
+ selectionLength = selectionEndOffset - selectionStartOffset;
+ if (selectionLength == 0 || selectionVisible == false) {
+ selectionStartOffset = 0;
+ selectionEndOffset = 0;
+ }
+ lineSelection = selectionEndOffset > 0 && selectionStartOffset <= lineLength;
+ if (lineSelection == false && clearBackground) {
+ // draw background for completely unselected line
+ gc.setBackground(lineBackground);
+ gc.setForeground(lineBackground);
+ gc.fillRectangle(0, paintY, clientAreaWidth, lineHeight);
+ }
+ if (selectionStartOffset > 0) {
+ String unselectedLine;
+ if (selectionStartOffset > lineLength) {
+ unselectedLine = line;
+ }
+ else {
+ if (clearBackground) {
+ // draw background for partially unselected line
+ int selectionStartX = textWidth(line, lineOffset, 0, selectionStartOffset, styles, 0, gc);
+ gc.setBackground(lineBackground);
+ gc.setForeground(lineBackground);
+ gc.fillRectangle(0, paintY, selectionStartX - horizontalScrollOffset, lineHeight);
+ }
+ unselectedLine = line.substring(0, selectionStartOffset);
+ }
+ drawStyledLine(unselectedLine, lineOffset, 0, styles, 0, paintY, gc, lineBackground, widgetForeground);
+ }
+ if (selectionLength > 0 && lineSelection) {
+ // draw selected text
+ selectionEndX = drawLineSelection(line, lineOffset, selectionStartOffset, selectionLength, styles, paintY, gc) - horizontalScrollOffset;
+ if (selectionEndX < clientAreaWidth && clearBackground) {
+ // draw background after selection
+ gc.setBackground(lineBackground);
+ gc.setForeground(lineBackground);
+ gc.fillRectangle(selectionEndX, paintY, clientAreaWidth - selectionEndX, lineHeight);
+ }
+ selectionEndX += horizontalScrollOffset;
+ }
+ if (selectionEndOffset < lineLength) {
+ selectionEndOffset = Math.max(0, selectionEndOffset);
+ drawStyledLine(line, lineOffset, selectionEndOffset, styles, selectionEndX, paintY, gc, lineBackground, widgetForeground);
+ }
+}
+/**
+ * Draws the selected part of a line at the specified location.
+ * Draws selected text on top of unselected text.
+ * <p>
+ *
+ * @param line the line to draw
+ * @param lineOffset offset of the first character in the line.
+ * Relative to the start of the document.
+ * @param selectionStartOffset offset of the first selected character.
+ * Relative to the start of the line.
+ * @param selectionLength length, in characters, of the selection.
+ * @param styles line styles
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @return the x location of the selection end relative to first character location in the line
+ */
+int drawLineSelection(String line, int lineOffset, int selectionStartOffset, int selectionLength, StyleRange[] styles, int paintY, GC gc) {
+ int lineLength = line.length();
+ int paintX;
+ int selectionBackgroundWidth;
+
+ styles = filterLineStyles(styles);
+ paintX = textWidth(line, lineOffset, 0, selectionStartOffset, styles, 0, gc);
+ if (selectionStartOffset + selectionLength > lineLength) {
+ selectionLength = lineLength - selectionStartOffset;
+ if ((getStyle() & SWT.FULL_SELECTION) != 0) {
+ // use the greater of the client area width and the content width
+ // fixes 1G8IYRD
+ selectionBackgroundWidth = Math.max(getClientArea().width, contentWidth);
+ }
+ else {
+ // if the selection extends beyond this line, render an
+ // additional whitespace to represent the selected line break
+ selectionBackgroundWidth = textWidth(line + " ", lineOffset, selectionStartOffset, selectionLength + 1, styles, paintX, gc);
+ }
+ }
+ else {
+ selectionBackgroundWidth = textWidth(line, lineOffset, selectionStartOffset, selectionLength, styles, paintX, gc);
+ }
+ gc.setBackground(getSelectionBackground());
+ gc.setForeground(getSelectionForeground());
+ // fill the background first since expanded tabs are not
+ // drawn as spaces. tabs just move the draw position.
+ gc.fillRectangle(paintX - horizontalScrollOffset, paintY, selectionBackgroundWidth, lineHeight);
+ drawText(line, lineOffset, selectionStartOffset, selectionLength, styles, paintX, paintY, gc);
+ return paintX + selectionBackgroundWidth;
+}
+/**
+ * Draws the line at the specified location.
+ * <p>
+ *
+ * @param line the line to draw
+ * @param lineOffset offset of the first character in the line.
+ * Relative to the start of the document.
+ * @param renderOffset offset of the first character that should be rendered.
+ * Relative to the start of the line.
+ * @param styles the styles to use for rendering line segments. May be empty but not null.
+ * @param paintX x location to draw at
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @param lineBackground line background color, used when no style is specified for a line segment.
+ * @param lineForeground line foreground color, used when no style is specified for a line segment.
+ */
+void drawStyledLine(String line, int lineOffset, int renderOffset, StyleRange[] styles, int paintX, int paintY, GC gc, Color lineBackground, Color lineForeground) {
+ int lineLength = line.length();
+ Color background = gc.getBackground();
+ Color foreground = gc.getForeground();
+ StyleRange style = null;
+ StyleRange[] filteredStyles = filterLineStyles(styles);
+ int renderStopX = getClientArea().width + horizontalScrollOffset;
+
+ for (int i = 0; i < styles.length && paintX < renderStopX; i++) {
+ int styleLineLength;
+ int styleLineStart;
+ style = styles[i];
+ styleLineStart = Math.max(style.start - lineOffset, 0);
+ // render unstyled text between the start of the current
+ // style range and the end of the previously rendered
+ // style range
+ if (styleLineStart > renderOffset) {
+ background = setLineBackground(gc, background, lineBackground);
+ foreground = setLineForeground(gc, foreground, lineForeground);
+ // don't try to render more text than requested
+ styleLineStart = Math.min(lineLength, styleLineStart);
+ paintX = drawText(line, lineOffset, renderOffset, styleLineStart - renderOffset, filteredStyles, paintX, paintY, gc);
+ renderOffset = styleLineStart;
+ }
+ styleLineLength = Math.min(style.start - lineOffset + style.length, lineLength) - renderOffset;
+ if (styleLineLength == 0) {
+ // there are line styles but no text for those styles
+ // possible when called with partial line text
+ break;
+ }
+ else
+ if (styleLineLength < 0) {
+ // style ends before render start offset
+ continue;
+ }
+ // set style background color if specified
+ if (style.background != null) {
+ background = setLineBackground(gc, background, style.background);
+ foreground = setLineForeground(gc, foreground, style.background);
+ int fillWidth = textWidth(line, lineOffset, renderOffset, styleLineLength, filteredStyles, paintX, gc);
+ gc.fillRectangle(paintX - horizontalScrollOffset, paintY, fillWidth, lineHeight);
+ }
+ else {
+ background = setLineBackground(gc, background, lineBackground);
+ }
+ // set style foreground color if specified
+ if (style.foreground != null) {
+ foreground = setLineForeground(gc, foreground, style.foreground);
+ }
+ else {
+ foreground = setLineForeground(gc, foreground, lineForeground);
+ }
+ paintX = drawText(line, lineOffset, renderOffset, styleLineLength, filteredStyles, paintX, paintY, gc);
+ renderOffset += styleLineLength;
+ }
+ // render unstyled text at the end of the line
+ if ((style == null || renderOffset < lineLength) && paintX < renderStopX) {
+ setLineBackground(gc, background, lineBackground);
+ setLineForeground(gc, foreground, lineForeground);
+ drawText(line, lineOffset, renderOffset, lineLength - renderOffset, filteredStyles, paintX, paintY, gc);
+ }
+}
+
+/**
+ * Draws the text at the specified location. Expands tabs to tab stops using
+ * the widget tab width.
+ * <p>
+ *
+ * @param text text to draw
+ * @param lineOffset offset of the first character in the line.
+ * Relative to the start of the document.
+ * @param startOffset offset of the first character in text to draw
+ * @param length number of characters to draw
+ * @param styles line styles
+ * @param paintX x location to start drawing at
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @return x location where drawing stopped or 0 if the startOffset or
+ * length is outside the specified text.
+ */
+int drawText(String text, int lineOffset, int startOffset, int length, StyleRange[] lineStyles, int paintX, int paintY, GC gc) {
+ int endOffset = startOffset + length;
+ int textLength = text.length();
+ StyleRange[] styles;
+ FontData fontData = gc.getFont().getFontData()[0];
+
+ if (startOffset < 0 || startOffset >= textLength || startOffset + length > textLength) {
+ return paintX;
+ }
+ for (int i = startOffset; i < endOffset; i++) {
+ int tabIndex = text.indexOf(TAB, i);
+ // is tab not present or past the rendering range?
+ if (tabIndex == -1 || tabIndex > endOffset) {
+ tabIndex = endOffset;
+ }
+ if (tabIndex != i) {
+ String tabSegment = text.substring(i, tabIndex);
+ if (lineStyles != null) {
+ paintX = styledTextWidth(tabSegment, lineOffset + i, lineStyles, paintX, paintY, gc, true);
+ }
+ else {
+ fontData = setLineFont(gc, fontData, SWT.NORMAL);
+ gc.drawString(tabSegment, paintX - horizontalScrollOffset, paintY, true);
+ paintX += gc.stringExtent(tabSegment).x;
+ }
+ if (tabIndex != endOffset && tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ i = tabIndex;
+ }
+ else // is tab at current rendering offset?
+ if (tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= paintX % tabWidth;
+ }
+ }
+ return paintX;
+}
+
+/**
+ * Ends the autoscroll process.
+ */
+void endAutoScroll() {
+ autoScrollDirection = SWT.NULL;
+}
+
+/**
+ * @param styles styles that may contain font styles.
+ * @return null if the styles contain only regular font styles, the
+ * unchanged styles otherwise.
+ */
+StyleRange[] filterLineStyles(StyleRange[] styles) {
+ if (styles != null) {
+ int styleIndex = 0;
+ while (styleIndex < styles.length && styles[styleIndex].fontStyle == SWT.NORMAL) {
+ styleIndex++;
+ }
+ if (styleIndex == styles.length) {
+ styles = null;
+ }
+ }
+ return styles;
+}
+/**
+ * Returns the index of the last fully visible line.
+ * <p>
+ *
+ * @return index of the last fully visible line.
+ */
+int getBottomIndex() {
+ return Math.min(content.getLineCount(), topIndex + getLineCountWhole()) - 1;
+}
+
+
+/**
+ * Returns the caret position relative to the start of the text.
+ * <p>
+ *
+ * @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 content implementation that is used for text storage
+ * or null if no user defined content implementation has been set.
+ * <p>
+ *
+ * @return content implementation that is used for text storage or null
+ * 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;
+}
+
+/**
+ * Returns whether the widget implements double click mouse behavior.
+ * <p>
+ *
+ * @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.
+ * <p>
+ *
+ * @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;
+}
+
+/**
+ * Returns the horizontal scroll increment.
+ * <p>
+ *
+ * @return horizontal scroll increment.
+ */
+int getHorizontalIncrement() {
+ GC gc = new GC(this);
+ int increment = gc.getFontMetrics().getAverageCharWidth();
+
+ gc.dispose();
+ return increment;
+}
+
+/**
+ * Returns the horizontal scroll offset relative to the start of the line.
+ * <p>
+ *
+ * @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.
+ * <p>
+ *
+ * @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 action assigned to the key.
+ * Returns SWT.NULL if there is no action associated with the key.
+ * <p>
+ *
+ * @param key a key code defined in SWT.java or a character.
+ * Optionally ORd with a state mask (one or more of SWT.CTRL, SWT.SHIFT, SWT.ALT)
+ * @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>
+ * @see org.eclipse.swt.SWT
+ * @see org.eclipse.swt.ST
+ */
+public int getKeyBinding(int key) {
+ checkWidget();
+ Integer action = (Integer) keyActionMap.get(new Integer(key));
+ int intAction;
+
+ if (action == null) {
+ intAction = SWT.NULL;
+ }
+ else {
+ intAction = action.intValue();
+ }
+ return intAction;
+}
+
+/**
+ * Gets the number of characters.
+ * <p>
+ *
+ * @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 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.
+ * <p>
+ *
+ * @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();
+ Color lineBackground = null;
+
+ if (index < 0 || index > content.getLineCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (userLineBackground == false) {
+ lineBackground = defaultLineStyler.getLineBackground(index);
+ }
+ return lineBackground;
+}
+/**
+ * Gets the number of text lines.
+ * <p>
+ *
+ * @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 getLineAtOffset(getCharCount()) + 1;
+}
+/**
+ * Returns the number of lines that are at least partially displayed in the widget client area.
+ * <p>
+ *
+ * @return number of lines that are at least partially displayed in the widget client area.
+ */
+int getLineCountTruncated() {
+ int lineCount;
+ int lineHeight = getLineHeight();
+
+ if (lineHeight != 0) {
+ lineCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+ }
+ else {
+ lineCount = 1;
+ }
+ return lineCount;
+}
+
+/**
+ * Returns the number of lines that are completely displayed in the widget client area.
+ * <p>
+ *
+ * @return number of lines that are completely displayed in the widget client area.
+ */
+int getLineCountWhole() {
+ int lineCount;
+ int lineHeight = getLineHeight();
+
+ if (lineHeight != 0) {
+ lineCount = getClientArea().height / lineHeight;
+ }
+ else {
+ lineCount = 1;
+ }
+ return lineCount;
+}
+
+/**
+ * Returns the line at the specified offset in the text.
+ * 0 <= offset <= getCharCount() so that getLineAtOffset(getCharCount())
+ * returns the line of the insert location.
+ * <p>
+ *
+ * @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 line delimiter used for entering new lines by key down
+ * or paste operation.
+ * <p>
+ *
+ * @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>
+ *
+ * @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>
+ */
+public int getLineHeight() {
+ checkWidget();
+
+ if (lineHeight == 0) {
+ calculateLineHeight();
+ }
+ return lineHeight;
+}
+/**
+ * Returns the line style data for the given line or null if there is none.
+ * If there is a LineStyleListener but it does not set any styles, the
+ * StyledTextEvent.styles field will be initialized to an empty array.
+ */
+StyledTextEvent getLineStyleData(int lineOffset, String line) {
+ if (isListening(LineGetStyle)) {
+ StyledTextEvent event = new StyledTextEvent(content);
+ event.detail = lineOffset;
+ event.text = line;
+ notifyListeners(LineGetStyle, event);
+ if (event.styles == null) {
+ event.styles = new StyleRange[0];
+ }
+ return event;
+ }
+ return null;
+}
+/**
+ * Returns the line background data for the given line or null if there is none.
+ */
+StyledTextEvent getLineBackgroundData(int lineOffset, String line) {
+ if (isListening(LineGetBackground)) {
+ StyledTextEvent event = new StyledTextEvent(content);
+ event.detail = lineOffset;
+ event.text = line;
+ notifyListeners(LineGetBackground, event);
+ return event;
+ }
+ return null;
+}
+/**
+ * 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.
+ * <p>
+ *
+ * @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);
+ }
+ int line = getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ String lineContent = content.getLine(line);
+ int x = getXAtOffset(lineContent, line, offset - lineOffset);
+ int y = line * lineHeight - verticalScrollOffset;
+
+ return new Point(x, y);
+}
+/**
+ * Returns the offset at the given x location in the line.
+ * Doesn't properly handle ligatures and other context dependent characters or
+ * bidi. Ligatures are handled properly as long as they don't occur at lineXOffset.
+ * <p>
+ *
+ * @param line text of the line to calculate the offset in
+ * @param lineOffset offset of the first character in the line.
+ * 0 based from the beginning of the document.
+ * @param lineXOffset x location in the line
+ * @return offset of the character at the x location relative to the start of the
+ * line.
+ */
+int getOffsetAtX(String line, int lineOffset, int lineXOffset) {
+ int x = 0;
+ GC gc = new GC(this);
+ int low = -1;
+ int high = line.length();
+ int offset;
+ StyleRange[] styles = null;
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ styles = filterLineStyles(event.styles);
+ }
+ lineXOffset += horizontalScrollOffset;
+ while (high - low > 1) {
+ offset = (high + low) / 2;
+ x = textWidth(line, lineOffset, 0, offset, styles, 0, gc);
+ int charWidth = textWidth(line, lineOffset, 0, offset + 1, styles, 0, gc) - x;
+ if (lineXOffset <= x + charWidth / 2) {
+ high = offset;
+ }
+ else {
+ low = offset;
+ }
+ }
+ offset = high;
+ gc.dispose();
+ return offset;
+}
+/**
+ * Returns the index of the last partially visible line.
+ *
+ * @return index of the last partially visible line.
+ */
+int getPartialBottomIndex() {
+ int partialLineCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+
+ return Math.min(content.getLineCount(), topIndex + partialLineCount) - 1;
+}
+/**
+ * Returns the content in the specified range using the platform line
+ * delimiter to separate lines.
+ * <p>
+ *
+ * @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 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
+ * @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.
+ * <p>
+ *
+ * @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.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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 background color to be used for rendering selected text.
+ * <p>
+ *
+ * @return background color to be used for rendering selected text
+ */
+Color getSelectionBackground() {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION);
+}
+/**
+ * Gets the number of selected characters.
+ * <p>
+ *
+ * @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 foreground color to be used for rendering selected text.
+ * <p>
+ *
+ * @return foreground color to be used for rendering selected text
+ */
+Color getSelectionForeground() {
+ return getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+}
+
+/**
+ * Returns the selected text.
+ * <p>
+ *
+ * @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);
+}
+
+/**
+ * Returns the style range at the given offset.
+ * 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>
+ *
+ * @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 (userLineStyle == false) {
+ return defaultLineStyler.getStyleRangeAtOffset(offset);
+ }
+ return null;
+}
+/**
+ * Returns the styles.
+ * 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>
+ *
+ * @return the styles or null 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>
+ */
+public StyleRange [] getStyleRanges() {
+ checkWidget();
+ StyleRange styles[];
+
+ if (userLineStyle == false) {
+ styles = defaultLineStyler.getStyleRanges();
+ }
+ else {
+ styles = new StyleRange[0];
+ }
+ return styles;
+}
+/**
+ * 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.
+ * <p>
+ *
+ * @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.
+ * <p>
+ *
+ * @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 widget content starting at start for length characters.
+ * <p>
+ *
+ * @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 < 0 || start > contentLength || end < 0 || end > contentLength || start > end) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ return content.getTextRange(start, length);
+}
+
+/**
+ * Gets the text limit. The text limit specifies the amount of text that the user
+ * can type into 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 int getTextLimit() {
+ checkWidget();
+
+ return textLimit;
+}
+
+/**
+ * Gets the top index. The top index is the index of the fully visible line that
+ * is currently at the top of the widget. 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. 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 verticalScrollOffset;
+}
+
+/**
+ * Returns the vertical scroll increment.
+ * <p>
+ *
+ * @return vertical scroll increment.
+ */
+int getVerticalIncrement() {
+ return getLineHeight();
+}
+
+/**
+ * Returns the offset of the character after the word at the specified
+ * offset.
+ * <p>
+ * There are two classes of words formed by a sequence of characters:
+ * <ul>
+ * <li>from 0-9 and A-z (ASCII 48-57 and 65-122)
+ * <li>every other character except line breaks
+ * </ul>
+ * </p>
+ * <p>
+ * Space characters ' ' (ASCII 20) are special as they are treated as
+ * part of the word leading up to the space character. Line breaks are
+ * treated as one word.
+ * </p>
+ */
+int getWordEnd(int offset) {
+ int line = content.getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ String lineText = content.getLine(line);
+ int lineLength = lineText.length();
+
+ if (offset >= getCharCount()) {
+ return offset;
+ }
+ if (offset == lineOffset + lineLength) {
+ line++;
+ offset = content.getOffsetAtLine(line);
+ }
+ else {
+ offset -= lineOffset;
+ char ch = lineText.charAt(offset);
+ boolean letterOrDigit = Character.isLetterOrDigit(ch);
+ while (offset < lineLength - 1 && Character.isLetterOrDigit(ch) == letterOrDigit) {
+ offset++;
+ ch = lineText.charAt(offset);
+ }
+ // skip over trailing whitespace
+ while (offset < lineLength - 1 && Character.isSpaceChar(ch)) {
+ offset++;
+ ch = lineText.charAt(offset);
+ }
+ if (offset == lineLength - 1 && (Character.isLetterOrDigit(ch) == letterOrDigit || Character.isSpaceChar(ch))) {
+ offset++;
+ }
+ offset += lineOffset;
+ }
+ return offset;
+}
+
+/**
+ * Returns the offset of the character after the word at the specified
+ * offset.
+ * <p>
+ * There are two classes of words formed by a sequence of characters:
+ * <ul>
+ * <li>from 0-9 and A-z (ASCII 48-57 and 65-122)
+ * <li>every other character except line breaks
+ * </ul>
+ * </p>
+ * <p>
+ * Spaces are ignored and do not represent a word. Line breaks are treated
+ * as one word.
+ * </p>
+ */
+int getWordEndNoSpaces(int offset) {
+ int line = content.getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ String lineText = content.getLine(line);
+ int lineLength = lineText.length();
+
+ if (offset >= getCharCount()) {
+ return offset;
+ }
+ if (offset == lineOffset + lineLength) {
+ line++;
+ offset = content.getOffsetAtLine(line);
+ }
+ else {
+ offset -= lineOffset;
+ char ch = lineText.charAt(offset);
+ boolean letterOrDigit = Character.isLetterOrDigit(ch);
+
+ while (offset < lineLength - 1 && Character.isLetterOrDigit(ch) == letterOrDigit && Character.isSpaceChar(ch) == false) {
+ offset++;
+ ch = lineText.charAt(offset);
+ }
+ if (offset == lineLength - 1 && Character.isLetterOrDigit(ch) == letterOrDigit && Character.isSpaceChar(ch) == false) {
+ offset++;
+ }
+ offset += lineOffset;
+ }
+ return offset;
+}
+
+/**
+ * Returns the start offset of the word at the specified offset.
+ * There are two classes of words formed by a sequence of characters:
+ * <p>
+ * <ul>
+ * <li>from 0-9 and A-z (ASCII 48-57 and 65-122)
+ * <li>every other character except line breaks
+ * </ul>
+ * </p>
+ * <p>
+ * Space characters ' ' (ASCII 20) are special as they are treated as
+ * part of the word leading up to the space character. Line breaks are treated
+ * as one word.
+ * </p>
+ */
+int getWordStart(int offset) {
+ int line = content.getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ String lineText = content.getLine(line);
+
+ if (offset <= 0) {
+ return offset;
+ }
+ if (offset == lineOffset) {
+ line--;
+ lineText = content.getLine(line);
+ offset = content.getOffsetAtLine(line) + lineText.length();
+ }
+ else {
+ char ch;
+ boolean letterOrDigit;
+
+ offset -= lineOffset;
+ // skip over trailing whitespace
+ do {
+ offset--;
+ ch = lineText.charAt(offset);
+ } while (offset > 0 && Character.isSpaceChar(ch));
+ letterOrDigit = Character.isLetterOrDigit(ch);
+ while (offset > 0 && Character.isLetterOrDigit(ch) == letterOrDigit && Character.isSpaceChar(ch) == false) {
+ offset--;
+ ch = lineText.charAt(offset);
+ }
+ if (offset > 0 || Character.isLetterOrDigit(ch) != letterOrDigit) {
+ offset++;
+ }
+ offset += lineOffset;
+ }
+ return offset;
+}
+
+/**
+ * Returns the x location of the character at the give offset in the line.
+ * <b>NOTE:</b> Does not return correct values for true italic fonts (vs. slanted fonts).
+ * <p>
+ *
+ * @return x location of the character at the give offset in the line.
+ */
+int getXAtOffset(String line, int lineIndex, int lineOffset) {
+ int x;
+
+ if (lineOffset == 0) {
+ x = 0;
+ }
+ else {
+ GC gc = new GC(this);
+ if (lineOffset > line.length()) {
+ // offset is not on the line. return an x location one character
+ // after the line to indicate the line delimiter.
+ line += " ";
+ lineOffset = line.length();
+ }
+ x = textWidth(line, lineIndex, lineOffset, gc);
+ gc.dispose();
+ }
+ return x - horizontalScrollOffset;
+}
+/**
+ * Inserts a string. The old selection is replaced with the new text.
+ * <p>
+ *
+ * @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 listener 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() {
+ textChangedListener = new TextChangedListener() {
+ public void textReplaced(TextChangedEvent event) {
+ handleTextChanged(event);
+ }
+ public void textSet(TextChangedEvent event) {
+ handleTextSet(event);
+ }
+ };
+ content = new DefaultContent();
+ content.addTextChangedListener(textChangedListener);
+}
+/**
+ * Creates a default line style listener.
+ * Used to store line background colors and styles.
+ * Removed when the user sets a LineStyleListener.
+ * <p>
+ *
+ * @see addLineStyleListener
+ */
+void installDefaultLineStyler() {
+ defaultLineStyler = new DefaultLineStyler(content);
+ StyledTextListener typedListener = new StyledTextListener(defaultLineStyler);
+ if (userLineStyle == false) {
+ addListener(LineGetStyle, typedListener);
+ }
+ if (userLineBackground == false) {
+ addListener(LineGetBackground, typedListener);
+ }
+}
+/**
+ * Adds event listeners
+ */
+void installListeners() {
+ ScrollBar verticalBar = getVerticalBar();
+ ScrollBar horizontalBar = getHorizontalBar();
+
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {
+ handleDispose();
+ }
+ });
+ addListener(SWT.KeyDown, new Listener() {
+ public void handleEvent(Event event) {
+ handleKeyDown(event);
+ }
+ });
+ addListener(SWT.MouseDown, new Listener() {
+ public void handleEvent(Event event) {
+ handleMouseDown(event);
+ }
+ });
+ addListener(SWT.MouseUp, new Listener() {
+ public void handleEvent(Event event) {
+ handleMouseUp(event);
+ }
+ });
+ addListener(SWT.MouseDoubleClick, new Listener() {
+ public void handleEvent(Event event) {
+ handleMouseDoubleClick(event);
+ }
+ });
+ addListener(SWT.MouseMove, new Listener() {
+ public void handleEvent(Event event) {
+ handleMouseMove(event);
+ }
+ });
+ addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event event) {
+ handlePaint(event);
+ }
+ });
+ addListener(SWT.Resize, new Listener() {
+ public void handleEvent(Event event) {
+ handleResize(event);
+ }
+ });
+ addListener(SWT.Traverse, new Listener() {
+ public void handleEvent(Event event) {
+ // do nothing
+ // hooked to disable automatic tab traversal on tab key press
+ }
+ });
+ 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);
+ }
+ });
+ }
+}
+/**
+ * Returns the widget text with style information encoded using RTF format
+ * specification version 1.5.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+String getRtf(){
+ checkWidget();
+ String rtfText = null;
+ int length = getCharCount();
+
+ if (length > 0) {
+ RTFWriter rtfWriter = new RTFWriter(0, length);
+ rtfText = getPlatformDelimitedText(rtfWriter);
+ }
+ return rtfText;
+}
+/**
+ * Frees resources.
+ */
+void handleDispose() {
+ Enumeration colors;
+
+ clipboard.dispose();
+ ibeamCursor.dispose();
+ if (boldFont != null) {
+ boldFont.dispose();
+ }
+ if (content != null) {
+ content.removeTextChangedListener(textChangedListener);
+ }
+}
+
+/**
+ * Updates the caret location and selection if mouse button 1 has been
+ * pressed.
+ */
+void handleMouseDoubleClick(Event event) {
+ if (event.button != 1 || doubleClickEnabled == false) {
+ return;
+ }
+ mouseDoubleClick = true;
+ caretOffset = getWordEndNoSpaces(caretOffset);
+ resetSelection();
+ caretOffset = getWordStart(caretOffset);
+ showCaret();
+ doMouseSelection();
+}
+
+/**
+ * Updates the caret location and selection if mouse button 1 has been
+ * pressed.
+ */
+void handleMouseDown(Event event) {
+ if (event.button != 1) {
+ return;
+ }
+ mouseDoubleClick = false;
+ doMouseLocationChange(event.x, event.y, (event.stateMask & SWT.SHIFT) != 0);
+}
+/**
+ * Autoscrolling ends when the mouse button is released.
+ */
+void handleMouseUp(Event event) {
+ endAutoScroll();
+}
+/**
+ * Updates the caret location and selection if mouse button 1 is pressed
+ * during the mouse move.
+ */
+void handleMouseMove(Event event) {
+ if (mouseDoubleClick == true || (event.stateMask & SWT.BUTTON1) == 0) {
+ return;
+ }
+ doMouseLocationChange(event.x, event.y, true);
+ doAutoScroll(event);
+}
+
+/**
+ * Replaces the selection with the clipboard text or insert the text at
+ * the current caret offset if there is no selection.
+ * 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.
+ * <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();
+ TextTransfer transfer = TextTransfer.getInstance();
+ String text;
+
+ text = (String) clipboard.getContents(transfer);
+ if (text != null && text.length() > 0) {
+ Event event = new Event();
+ event.start = selection.x;
+ event.end = selection.y;
+ event.text = getModelDelimitedText(text);
+ sendKeyEvent(event);
+ // fixes 1GBKN67
+ claimBottomFreeSpace();
+ }
+}
+/**
+ * Prints the widget's text to the default printer.
+ * <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 print() {
+ checkWidget();
+ new StyledTextPrinter(this).print();
+}
+
+/**
+ * Scrolls the widget horizontally.
+ */
+void handleHorizontalScroll(Event event) {
+ int scrollPixel = getHorizontalBar().getSelection() - horizontalScrollOffset;
+ scrollHorizontal(scrollPixel);
+}
+
+/**
+ * If a VerifyKey listener exists, verify that the key that was entered
+ * should be processed.
+ * <p>
+ *
+ * @param event keyboard event
+ */
+void handleKeyDown(Event event) {
+ 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 == true) {
+ handleKey(event);
+ }
+}
+
+/**
+ * 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.
+ * <p>
+ *
+ * @param event keyboard event
+ */
+void handleKey(Event event) {
+ int action;
+
+ if (event.keyCode != 0) {
+ action = getKeyBinding(event.keyCode | event.stateMask);
+ }
+ else {
+ action = getKeyBinding(event.character | event.stateMask);
+ }
+ if (action == SWT.NULL) {
+ // ignore anything below SPACE and ignore DEL
+ if (event.character > 31 && event.character != SWT.DEL ||
+ event.character == SWT.CR || event.character == SWT.LF ||
+ event.character == TAB) {
+ doContent(event.character);
+ }
+ }
+ else {
+ invokeAction(action);
+ }
+}
+/**
+ * Renders the invalidated area specified in the paint event.
+ * <p>
+ *
+ * @param event paint event
+ */
+void handlePaint(Event event) {
+ draw(event.x, event.y, event.width, event.height, event.gc, true);
+}
+/**
+ * Recalculates the scroll bars.
+ * <p>
+ *
+ * @param event resize event
+ */
+void handleResize(Event event) {
+ ScrollBar verticalBar = getVerticalBar();
+ int oldHeight = clientAreaHeight;
+
+ clientAreaHeight = getClientArea().height;
+ if (clientAreaHeight > oldHeight) {
+ int lineCount = content.getLineCount();
+ int oldBottomIndex = topIndex + oldHeight / lineHeight;
+ int newItemCount = (int) Math.ceil((float) (clientAreaHeight - oldHeight) / lineHeight);
+ oldBottomIndex = Math.min(oldBottomIndex, lineCount);
+ newItemCount = Math.min(newItemCount, lineCount - oldBottomIndex);
+ calculateContentWidth(oldBottomIndex, newItemCount);
+ }
+ setScrollBars();
+ claimBottomFreeSpace();
+ claimRightFreeSpace();
+}
+
+/**
+ * Updates the caret position and selection to reflect the content change.
+ * Redraws the changed area.
+ * <p>
+ *
+ * @param event.start the start offset of the change
+ * @param event.replacedCharCount the length of the replaced text
+ * @param event.newCharCount the length of the new text
+ * @param event.replacedLineCount number of replaced lines.
+ * @param event.newLineCount number of new lines.
+ */
+void handleTextChanged(TextChangedEvent event) {
+ int firstLine;
+ int firstLineOffset;
+ int offsetInLine;
+ String firstLineText;
+ int stopLine;
+ boolean isMultiLineChange = event.replacedLineCount > 0 || event.newLineCount > 0;
+ int textChangeX = -1;
+ int textChangeY;
+ int oldTabX = 0;
+ int textChangeStopX = -1;
+ int visibleItemCount = (int) Math.ceil((float) getClientArea().height / lineHeight);
+
+ if (event.replacedCharCount < 0) {
+ event.start += event.replacedCharCount;
+ event.replacedCharCount *= -1;
+ }
+ firstLine = content.getLineAtOffset(event.start);
+ firstLineText = content.getLine(firstLine);
+ firstLineOffset = content.getOffsetAtLine(firstLine);
+ offsetInLine = event.start - firstLineOffset;
+ if (isMultiLineChange == false) {
+ // get location of nearest tab and replace stop offset in old text
+ int oldTabIndex;
+ String oldLine;
+ StringBuffer oldLineText = new StringBuffer(firstLineText);
+ oldLineText.delete(offsetInLine, offsetInLine + event.newCharCount);
+ if (event.replacedText != null && event.replacedText.length() > 0) {
+ oldLineText.insert(offsetInLine, event.replacedText);
+ }
+ oldLine = oldLineText.toString();
+ oldTabIndex = oldLine.indexOf(TAB, offsetInLine + event.replacedCharCount);
+ oldTabX = getXAtOffset(oldLine, firstLine, oldTabIndex + 1);
+ if (event.newCharCount == 0) {
+ // characters were deleted. find out where the last deleted
+ // character stopped drawing
+ textChangeStopX = getXAtOffset(
+ oldLine,
+ firstLine,
+ offsetInLine + event.replacedCharCount);
+ }
+ else
+ if (event.replacedCharCount == 0) {
+ // characters were added. find out where before the styles are
+ // updated to reflect the text change
+ textChangeX = getXAtOffset(oldLine, firstLine, offsetInLine);
+ }
+ }
+ // notify default line styler about text change
+ if (defaultLineStyler != null) {
+ defaultLineStyler.textChanged(event);
+ }
+ // calculate width of visible changed lines
+ stopLine = firstLine + event.newLineCount + 1;
+ if (stopLine > topIndex && firstLine < topIndex + visibleItemCount) {
+ int startLine = Math.max(firstLine, topIndex);
+ calculateContentWidth(startLine, Math.min(stopLine, topIndex + visibleItemCount) - startLine);
+ }
+ setScrollBars();
+ textChangeY = firstLine * lineHeight - verticalScrollOffset;
+ if (textChangeX == -1) {
+ textChangeX = getXAtOffset(firstLineText, firstLine, offsetInLine);
+ }
+ if (isMultiLineChange) {
+ redrawMultiLineChange(textChangeX, textChangeY, event.newLineCount, event.replacedLineCount);
+ }
+ else {
+ int newTabIndex = firstLineText.indexOf(TAB, offsetInLine + event.newCharCount);
+ if (newTabIndex != -1) {
+ // there is at least one tab after the text change
+ int newTabX = getXAtOffset(firstLineText, firstLine, newTabIndex + 1);
+ redrawSingleLineTabChange(textChangeX, textChangeY, newTabX, oldTabX);
+ }
+ else {
+ if (textChangeStopX == -1) {
+ textChangeStopX = getXAtOffset(
+ firstLineText,
+ firstLine,
+ offsetInLine + event.newCharCount);
+ }
+ redrawSingleLineChange(
+ textChangeX,
+ textChangeY,
+ event.newCharCount,
+ event.replacedCharCount,
+ textChangeStopX);
+ }
+ }
+ // 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.
+ // fixes 1GB93QT
+ updateSelection(event.start, event.replacedCharCount, event.newCharCount);
+}
+/**
+ * Called when the widget content is set programatically, overwriting
+ * the old content. Resets the caret position, selection and scroll offsets.
+ * Recalculates the content width and scroll bars. Redraws the widget.
+ * <p>
+ *
+ * @param event text change event.
+ */
+void handleTextSet(TextChangedEvent event) {
+ reset();
+}
+/**
+ * Scrolls the widget vertically.
+ */
+void handleVerticalScroll(Event event) {
+ setVerticalScrollOffset(getVerticalBar().getSelection(), false);
+}
+/**
+ * Initializes the fonts used to render font styles.
+ * Presently only regular and bold fonts are supported.
+ */
+void initializeFonts() {
+ FontData fontData;
+
+ regularFont = getFont();
+ fontData = regularFont.getFontData()[0];
+ fontData.setStyle(fontData.getStyle() | SWT.BOLD);
+ boldFont = new Font(getDisplay(), fontData);
+}
+/**
+ * Executes the action.
+ * <p>
+ *
+ * @param action one of the actions defined in ST.java
+ * @see ST.java
+ */
+public void invokeAction(int action) {
+ switch (action) {
+ // Navigation
+ case ST.LINE_UP:
+ doLineUp();
+ clearSelection(true);
+ break;
+ case ST.LINE_DOWN:
+ doLineDown();
+ clearSelection(true);
+ break;
+ case ST.LINE_START:
+ doLineStart();
+ clearSelection(true);
+ break;
+ case ST.LINE_END:
+ doLineEnd();
+ clearSelection(true);
+ break;
+ case ST.COLUMN_PREVIOUS:
+ doCursorLeft();
+ clearSelection(true);
+ break;
+ case ST.COLUMN_NEXT:
+ doCursorRight();
+ clearSelection(true);
+ break;
+ case ST.PAGE_UP:
+ doPageUp();
+ clearSelection(true);
+ break;
+ case ST.PAGE_DOWN:
+ doPageDown(false);
+ clearSelection(true);
+ break;
+ case ST.WORD_PREVIOUS:
+ doWordLeft();
+ clearSelection(true);
+ break;
+ case ST.WORD_NEXT:
+ doWordRight();
+ 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:
+ doLineUp();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_LINE_DOWN:
+ doSelectionLineDown();
+ doSelection(SWT.RIGHT);
+ showCaret();
+ break;
+ case ST.SELECT_LINE_START:
+ doLineStart();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_LINE_END:
+ doSelectionLineEnd();
+ doSelection(SWT.RIGHT);
+ break;
+ case ST.SELECT_COLUMN_PREVIOUS:
+ doSelectionCursorLeft();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_COLUMN_NEXT:
+ doSelectionCursorRight();
+ doSelection(SWT.RIGHT);
+ break;
+ case ST.SELECT_PAGE_UP:
+ doPageUp();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_PAGE_DOWN:
+ doPageDown(true);
+ break;
+ case ST.SELECT_WORD_PREVIOUS:
+ doSelectionWordLeft();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_WORD_NEXT:
+ doSelectionWordRight();
+ doSelection(SWT.RIGHT);
+ break;
+ case ST.SELECT_TEXT_START:
+ doContentStart();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_TEXT_END:
+ doContentEnd();
+ doSelection(SWT.RIGHT);
+ break;
+ case ST.SELECT_WINDOW_START:
+ doPageStart();
+ doSelection(SWT.LEFT);
+ break;
+ case ST.SELECT_WINDOW_END:
+ doPageEnd();
+ doSelection(SWT.RIGHT);
+ break;
+ // Modification
+ case ST.CUT:
+ cut();
+ break;
+ case ST.COPY:
+ copy();
+ break;
+ case ST.PASTE:
+ paste();
+ break;
+ case ST.DELETE_PREVIOUS:
+ doBackspace();
+ clearSelection(true);
+ break;
+ case ST.DELETE_NEXT:
+ doDelete();
+ clearSelection(true);
+ break;
+ // Miscellaneous
+ case ST.TOGGLE_OVERWRITE:
+ overwrite = !overwrite; // toggle insert/overwrite mode
+ break;
+ }
+}
+/**
+ * Returns whether the font style in the given style range is changing
+ * from SWT.NORMAL to SWT.BOLD or vice versa.
+ * <p>
+ *
+ * @param range StyleRange to compare current font style with.
+ * @param start offset of the first font style to compare
+ * @param end offset behind the last font style to compare
+ * @return true if the font style is changing in the given style range,
+ * false if the font style is not changing in the given style 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>
+ */
+boolean isStyleChanging(StyleRange range, int start, int end) {
+ checkWidget();
+ int styleChangeOffset = -1;
+
+ for (int i = start; i < end; i++) {
+ StyleRange style = defaultLineStyler.getStyleRangeAtOffset(i);
+ if ((style != null && style.fontStyle != range.fontStyle) ||
+ (style == null && range.fontStyle != SWT.NORMAL)) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Sends the specified verify event, replace/insert text as defined by
+ * the event and send a modify event.
+ * <p>
+ *
+ * @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);
+ }
+ content.replaceTextRange(event.start, replacedLength, event.text);
+ // set the caret position prior to sending the modify event.
+ // fixes 1GBB8NJ
+ if (updateCaret) {
+ internalSetSelection(event.start + event.text.length(), 0);
+ // always update the caret location. fixes 1G8FODP
+ showCaret();
+ }
+ notifyListeners(SWT.Modify, event);
+ if (isListening(ExtendedModify)) {
+ notifyListeners(ExtendedModify, styledTextEvent);
+ }
+ }
+}
+/**
+ * Redraws the specified text range.
+ * <p>
+ *
+ * @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 area will be cleared before anything
+ * is redrawn. 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
+ * area have changed, clearBackground should be set to true. If only foreground colors
+ * have changed for the redraw area, clearBackground can be set to false.
+ */
+public void redrawRange(int start, int length, boolean clearBackground) {
+ Rectangle clientArea = getClientArea();
+ int lineHeight = getLineHeight();
+ int end = start + length;
+ int firstLine = content.getLineAtOffset(start);
+ int lastLine = content.getLineAtOffset(end);
+ int lineCount = lastLine - firstLine + 1;
+ int redrawX;
+ int redrawStopX;
+ int redrawY;
+ int firstLineOffset;
+ int offsetInFirstLine;
+ int partialBottomIndex = getPartialBottomIndex();
+ int partialTopIndex = verticalScrollOffset / lineHeight;
+ String line;
+ GC gc = null;
+
+ // do nothing if redraw range is completely invisible
+ if (firstLine > partialBottomIndex || lastLine < partialTopIndex) {
+ return;
+ }
+ if (clearBackground == false) {
+ gc = new GC(this);
+ }
+ // only redraw visible lines
+ if (partialTopIndex > firstLine) {
+ firstLine = partialTopIndex;
+ firstLineOffset = start = content.getOffsetAtLine(firstLine);
+ offsetInFirstLine = 0;
+ }
+ else {
+ firstLineOffset = content.getOffsetAtLine(firstLine);
+ offsetInFirstLine = start - firstLineOffset;
+ }
+ if (partialBottomIndex + 1 < lastLine) {
+ lastLine = partialBottomIndex + 1; // + 1 to redraw whole bottom line, including line break
+ end = content.getOffsetAtLine(lastLine);
+ }
+ // redraw first line
+ line = content.getLine(firstLine);
+ // calculate redraw start location
+ redrawX = getXAtOffset(line, firstLine, offsetInFirstLine);
+ redrawY = firstLine * lineHeight - verticalScrollOffset;
+ // calculate redraw stop location
+ if ((getStyle() & SWT.FULL_SELECTION) != 0 && lastLine > firstLine) {
+ redrawStopX = clientArea.width;
+ }
+ else {
+ redrawStopX = getXAtOffset(line, firstLine, end - firstLineOffset);
+ }
+ draw(redrawX, redrawY, redrawStopX - redrawX, lineHeight, gc, clearBackground);
+ firstLine++; // first line has been redrawn.
+
+ // redraw last line if more than line needs redrawing
+ if (lineCount > 1) {
+ int offsetInLastLine = end - content.getOffsetAtLine(lastLine);
+ // no redraw necessary if redraw offset is 0
+ if (offsetInLastLine > 0) {
+ line = content.getLine(lastLine);
+ redrawStopX = getXAtOffset(line, lastLine, offsetInLastLine);
+ redrawY = lastLine * lineHeight - verticalScrollOffset;
+ draw(0, redrawY, redrawStopX, lineHeight, gc, clearBackground);
+ }
+ lastLine--; // last line has been redrawn.
+ }
+ // redraw entire center lines if redraw range includes more than two lines
+ if (lastLine >= firstLine) {
+ int redrawStopY = (lastLine + 1) * lineHeight - verticalScrollOffset;
+ redrawY = firstLine * lineHeight - verticalScrollOffset;
+ draw(0, redrawY, clientArea.width, redrawStopY - redrawY, gc, clearBackground);
+ }
+ if (gc != null) {
+ gc.dispose();
+ }
+}
+/**
+ * Fixes the widget to display a text change.
+ * Bit blitting and redrawing is done as necessary.
+ * <p>
+ *
+ * @param x x location of the text change
+ * @param y y location of the text change
+ * @param newLineCount number of new lines.
+ * @param replacedLineCount number of replaced lines.
+ */
+void redrawMultiLineChange(int x, int y, int newLineCount, int replacedLineCount) {
+ Rectangle clientArea = getClientArea();
+ int lineHeight = getLineHeight();
+ int lineCount = newLineCount - replacedLineCount;
+ int sourceY;
+ int destinationY;
+
+ if (lineCount > 0) {
+ sourceY = y + lineHeight;
+ destinationY = y + lineCount * lineHeight + lineHeight;
+ }
+ else {
+ sourceY = y - lineCount * lineHeight + lineHeight;
+ destinationY = y + lineHeight;
+ }
+ scroll(
+ 0, destinationY, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+ // Always redrawing causes the bottom line to flash when a line is
+ // deleted. This is because SWT merges the paint area of the scroll
+ // with the paint area of the redraw call below.
+ // To prevent this we could call update after the scroll. However,
+ // adding update can cause even more flash if the client does other
+ // redraw/update calls (ie. for syntax highlighting).
+ // We could also redraw only when a line has been added or when
+ // contents has been added to a line. This would require getting
+ // line index info from the content and is not worth the trouble
+ // (the flash is only on the bottom line and minor).
+ // Specifying the NO_MERGE_PAINTS style bit prevents the merged
+ // redraw but could cause flash/slowness elsewhere.
+ redraw(x, y, clientArea.width, lineHeight, true);
+ if (newLineCount > 0) {
+ redraw(0, y + lineHeight, clientArea.width, newLineCount * lineHeight, true);
+ }
+}
+/**
+ * Fixes the widget after a text change local to one line ocurred.
+ * Bit blitting and/or redrawing is done as necessary.
+ * <p>
+ *
+ * @param textChangeX x location of the text change
+ * @param textChangeY y location of the text change
+ * @param newCharCount number of new characters
+ * @param replacedCharCount number of replaced characters
+ * @param textChangeStopX the x location of the character after last
+ * changed character
+ */
+void redrawSingleLineChange(int textChangeX, int textChangeY, int newCharCount, int replacedCharCount, int textChangeStopX) {
+ Rectangle clientArea = getClientArea();
+ int lineHeight = getLineHeight();
+
+ if (newCharCount == 0) {
+ // characters were deleted
+ scroll(
+ textChangeX, textChangeY, // destination x, y
+ textChangeStopX, textChangeY, // source x, y
+ clientArea.width, lineHeight, true);
+ }
+ else
+ if (replacedCharCount == 0) {
+ // characters were added
+ scroll(
+ textChangeStopX, textChangeY, // destination x, y
+ textChangeX, textChangeY, // source x, y
+ clientArea.width, lineHeight, true);
+ }
+ else {
+ // simple redraw if text has been replaced with other text
+ redraw(textChangeX, textChangeY, clientArea.width, lineHeight, true);
+ }
+}
+/**
+ * Fixes the widget after a text change local to one line ocurred.
+ * The line has a tab after the text change offset. Bit blitting
+ * and/or redrawing is done as necessary.
+ * <p>
+ *
+ * @param textChangeX x location of the text change
+ * @param textChangeY y location of the text change
+ * @param newTabX the x location of the tab closest to the insert
+ * location as measured with the text change.
+ * @param oldTabX the x location of the tab closest to the insert
+ * location as measured without the text change.
+ */
+void redrawSingleLineTabChange(int textChangeX, int textChangeY, int newTabX, int oldTabX) {
+ Rectangle clientArea = getClientArea();
+ int lineHeight = getLineHeight();
+
+ if (newTabX > oldTabX) {
+ scroll(
+ newTabX, textChangeY, // destination x, y
+ oldTabX, textChangeY, // source x, y
+ clientArea.width, lineHeight, true);
+ redraw(textChangeX, textChangeY, oldTabX - textChangeX, lineHeight, true);
+ }
+ else
+ if (newTabX < oldTabX) {
+ scroll(
+ newTabX, textChangeY, // destination x, y
+ oldTabX, textChangeY, // source x, y
+ clientArea.width, lineHeight, true);
+ redraw(textChangeX, textChangeY, newTabX - textChangeX, lineHeight, true);
+ }
+ else {
+ // tab location unchanged. redraw text between change offset and tab
+ redraw(textChangeX, textChangeY, newTabX - textChangeX, lineHeight, true);
+ }
+}
+/**
+ * Removes the specified extended modify listener.
+ * <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>
+ */
+public void removeExtendedModifyListener(ExtendedModifyListener extendedModifyListener) {
+ checkWidget();
+ if (extendedModifyListener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ removeListener(ExtendedModify, extendedModifyListener);
+}
+/**
+ * Removes the specified line background listener.
+ * <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>
+ */
+public void removeLineBackgroundListener(LineBackgroundListener listener) {
+ checkWidget();
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ removeListener(LineGetBackground, listener);
+ // use default line styler if last user line styler was removed.
+ if (isListening(LineGetBackground) == false && userLineBackground) {
+ StyledTextListener typedListener = new StyledTextListener(defaultLineStyler);
+ addListener(LineGetBackground, typedListener);
+ userLineBackground = false;
+ }
+}
+/**
+ * Removes the specified line style listener.
+ * <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>
+ */
+public void removeLineStyleListener(LineStyleListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(LineGetStyle, listener);
+ // use default line styler if last user line styler was removed. Fixes 1G7B1X2
+ if (isListening(LineGetStyle) == false && userLineStyle) {
+ StyledTextListener typedListener = new StyledTextListener(defaultLineStyler);
+ addListener(LineGetStyle, typedListener);
+ userLineStyle = false;
+ }
+}
+/**
+ * Removes the specified modify listener.
+ * <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>
+ */
+public void removeModifyListener(ModifyListener modifyListener) {
+ checkWidget();
+ if (modifyListener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Modify, modifyListener);
+}
+
+/**
+ * Removes the specified selection listener.
+ * <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>
+ */
+public void removeSelectionListener(SelectionListener listener) {
+ checkWidget();
+ if (listener == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+}
+
+/**
+ * Removes the specified verify listener.
+ * <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>
+ */
+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.
+ * <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>
+ */
+public void removeVerifyKeyListener(VerifyKeyListener listener) {
+ if (listener == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ removeListener(VerifyKey, listener);
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public void replaceTextRange(int start, int length, String text) {
+ checkWidget();
+ int contentLength = getCharCount();
+ int end = start + length;
+ Event event = new Event();
+
+ if (start < 0 || start > contentLength || end < 0 || end > contentLength || start > end) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ 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;
+ verticalScrollOffset = 0;
+ horizontalScrollOffset = 0;
+ contentWidth = 0;
+ contentWidthIndex = 0;
+ resetSelection();
+ // discard any styles that may have been set by creating a
+ // new default line styler
+ if (defaultLineStyler != null) {
+ removeLineBackgroundListener(defaultLineStyler);
+ removeLineStyleListener(defaultLineStyler);
+ installDefaultLineStyler();
+ }
+ calculateContentWidth();
+ if (verticalBar != null) {
+ verticalBar.setSelection(0);
+ }
+ if (horizontalBar != null) {
+ horizontalBar.setSelection(0);
+ }
+ setScrollBars();
+ setCaretLocation();
+ redraw();
+}
+
+/**
+ * Resets the selection.
+ */
+void resetSelection() {
+ selection.x = selection.y = caretOffset;
+ selectionAnchor = -1;
+}
+
+
+
+/**
+ * Scrolls the widget horizontally.
+ * <p>
+ *
+ * @param pixels number of pixels to scroll, > 0 = scroll left, < 0 scroll right
+ */
+void scrollHorizontal(int pixels) {
+ Rectangle clientArea;
+
+ if (pixels == 0) {
+ return;
+ }
+ clientArea = getClientArea();
+ scroll(
+ pixels * -1, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ horizontalScrollOffset += pixels;
+ setCaretLocation();
+}
+
+/**
+ * Scrolls the widget horizontally and adjust the horizontal scroll bar to
+ * reflect the new horizontal offset..
+ * <p>
+ *
+ * @param pixels number of pixels to scroll, > 0 = scroll left, < 0 scroll right
+ */
+void scrollHorizontalBar(int pixels) {
+ if (pixels == 0) {
+ return;
+ }
+ ScrollBar horizontalBar = getHorizontalBar();
+ if (horizontalBar != null) {
+ horizontalBar.setSelection(horizontalScrollOffset + pixels);
+ }
+ scrollHorizontal(pixels);
+}
+/**
+ * Selects all the text.
+ * <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();
+ setSelection(new Point(0, Math.max(getCharCount(),0)));
+}
+/**
+ * Replaces/inserts text as defined by the event.
+ * <p>
+ *
+ * @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 == false) {
+ return;
+ }
+ modifyContent(event, true);
+}
+
+/**
+ * Sends the specified selection event.
+ */
+void sendSelectionEvent() {
+ Event event = new Event();
+
+ event.x = selection.x;
+ event.y = selection.y;
+ notifyListeners(SWT.Selection, event);
+}
+
+/**
+ * Moves the Caret to the current caret offset.
+ */
+void setCaretLocation() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineStartOffset = content.getOffsetAtLine(line);
+ int lineX = getXAtOffset(content.getLine(line), line, caretOffset - lineStartOffset);
+ int lineHeight = getLineHeight();
+
+ // workaround for 1G3AKJO exposed by Leapfrog
+ // causes flashing but works
+ if (caret.isVisible() == false) {
+ setRedraw(true);
+ }
+ caret.setLocation(lineX, line * lineHeight - verticalScrollOffset);
+}
+/**
+ * Sets the caret offset.
+ * <p>
+ * <b>NOTE:</b> If offset is greater than the number of characters of text in the
+ * widget, the value will be ignored.
+ * </p>
+ *
+ * @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>
+ */
+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 {
+ caretOffset = offset;
+ }
+ // clear the selection if the caret is moved.
+ // don't notify listeners about the selection change.
+ clearSelection(false);
+ }
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+}
+
+/**
+ * Sets the content implementation to use for text storage.
+ * <p>
+ *
+ * @param content 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 content) {
+ checkWidget();
+ if (content == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (this.content != null) {
+ this.content.removeTextChangedListener(textChangedListener);
+ }
+ this.content = content;
+ content.addTextChangedListener(textChangedListener);
+ reset();
+}
+
+
+/**
+ * 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;
+}
+/**
+ * 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();
+ super.setFont(font);
+ if (boldFont != null) {
+ boldFont.dispose();
+ }
+ initializeFonts();
+ lineHeight = 0;
+ contentWidth = 0;
+ contentWidthIndex = 0;
+ setTabs(getTabs());
+ calculateContentWidth();
+ calculateScrollBars();
+ setTabs(tabLength);
+ caret.setSize(0, getLineHeight());
+ 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();
+ int clientAreaWidth = getClientArea().width;
+
+ 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) {
+ // 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 > contentWidth - clientAreaWidth) {
+ offset = Math.max(0, contentWidth - clientAreaWidth);
+ }
+ }
+ scrollHorizontalBar(offset - horizontalScrollOffset);
+}
+/**
+ * Sets the background color of the specified lines.
+ * 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. Should not be called if a LineBackgroundListener
+ * has been set since the listener maintains the line backgrounds.
+ * <p>
+ * During text changes, when entire lines are inserted or removed, the line
+ * background colors that are associated with the lines after the change
+ * will "move" with their respective text. For all other text changes,
+ * line background colors 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();
+ int partialBottomIndex = getPartialBottomIndex();
+ int lineHeight = getLineHeight();
+
+ // this API can not be used if the client is providing the line background
+ if (userLineBackground) {
+ return;
+ }
+ if (startLine < 0 || startLine + lineCount > content.getLineCount()) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ defaultLineStyler.setLineBackground(startLine, lineCount, background);
+ // do nothing if redraw range is completely invisible
+ 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;
+ redraw(
+ 0, startLine * lineHeight,
+ getClientArea().width, lineCount * lineHeight, true);
+}
+/**
+ * Sets the background of the specified GC for a line rendering operation,
+ * if it is not already set.
+ * </p>
+ *
+ * @param gc GC to set the background color in
+ * @param currentBackground background color currently set in gc
+ * @param newBackground new background color of gc
+ */
+Color setLineBackground(GC gc, Color currentBackground, Color newBackground) {
+ if (currentBackground.equals(newBackground) == false) {
+ gc.setBackground(newBackground);
+ }
+ return newBackground;
+}
+
+/**
+ * Sets the font of the specified GC if it is not already set.
+ * </p>
+ *
+ * @param gc GC to set the font in
+ * @param currentFont font data of font currently set in gc
+ * @param style desired style of the font in gc. Can be one of
+ * SWT.NORMAL, SWT.ITALIC, SWT.BOLD
+ * @return the font data of the font set in "gc". Same as "currentFont" if
+ * currentFont.getStyle() == "style".
+ */
+FontData setLineFont(GC gc, FontData currentFont, int style) {
+ if (currentFont.getStyle() != style) {
+ if (style == SWT.BOLD) {
+ currentFont.setStyle(style);
+ gc.setFont(boldFont);
+ }
+ else
+ if (style == SWT.NORMAL) {
+ currentFont.setStyle(style);
+ gc.setFont(regularFont);
+ }
+ }
+ return currentFont;
+}
+
+/**
+ * Sets the foreground of the specified GC for a line rendering operation,
+ * if it is not already set.
+ * </p>
+ *
+ * @param gc GC to set the foreground color in
+ * @param currentForeground foreground color currently set in gc
+ * @param newForeground new foreground color of gc
+ */
+Color setLineForeground(GC gc, Color currentForeground, Color newForeground) {
+ if (currentForeground.equals(newForeground) == false) {
+ gc.setForeground(newForeground);
+ }
+ return newForeground;
+}
+
+
+/**
+ * Adjusts the scroll bar maximum and page size to reflect content
+ * width/length changes.
+ */
+void setScrollBars() {
+ ScrollBar verticalBar = getVerticalBar();
+ ScrollBar horizontalBar = getHorizontalBar();
+ Rectangle clientArea = getClientArea();
+ final int INACTIVE = 1;
+
+ if (verticalBar != null) {
+ int maximum = content.getLineCount() * getVerticalIncrement();
+ // 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 (clientArea.height < maximum) {
+ verticalBar.setValues(
+ verticalBar.getSelection(),
+ verticalBar.getMinimum(),
+ maximum,
+ clientArea.height, // thumb size
+ verticalBar.getIncrement(),
+ clientArea.height); // page size
+ }
+ else
+ if (verticalBar.getThumb() != INACTIVE || verticalBar.getMaximum() != INACTIVE) {
+ verticalBar.setValues(
+ verticalBar.getSelection(),
+ verticalBar.getMinimum(),
+ INACTIVE,
+ INACTIVE,
+ verticalBar.getIncrement(),
+ INACTIVE);
+ }
+ }
+ if (horizontalBar != null) {
+ // 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 (clientArea.width < contentWidth) {
+ horizontalBar.setValues(
+ horizontalBar.getSelection(),
+ horizontalBar.getMinimum(),
+ contentWidth, // maximum
+ clientArea.width, // thumb size
+ horizontalBar.getIncrement(),
+ clientArea.width); // page size
+ }
+ 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).
+ * <p>
+ *
+ * @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_RANGE when start is outside the widget content
+ * </ul>
+ */
+public void setSelection (int start) {
+ 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
+ * @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_RANGE when start and end is outside the widget content
+ * </ul>
+ */
+public void setSelection(Point point) {
+ checkWidget();
+ if (point == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection(point.x, point.y);
+}
+/**
+ * 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
+ * @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_RANGE when start and end is outside the widget content
+ * </ul>
+ */
+public void setSelection(int start, int end) {
+ checkWidget();
+ int contentLength = getCharCount();
+
+ if (start > end || start < 0 || end > contentLength) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ internalSetSelection(start, end - start);
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+ showSelection();
+}
+/**
+ * Sets the selection. 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, start <= start + length <= getCharCount()
+ * must be true.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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 range specified by start and length is outside the widget content
+ * </ul>
+ */
+public void setSelectionRange(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);
+ }
+ internalSetSelection(start, length);
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+}
+/**
+ * Sets the selection.
+ * 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, start <= start + length
+ * <= getCharCount() must be true.
+ */
+void internalSetSelection(int start, int length) {
+ int end = start + length;
+
+ if (selection.x != start || selection.y != end) {
+ clearSelection(false);
+ selectionAnchor = selection.x = start;
+ caretOffset = selection.y = end;
+ if (length > 0) {
+ redrawRange(selection.x, selection.y - selection.x, true);
+ }
+ }
+}
+/**
+ * Adds the specified style. 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>
+ * 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();
+ boolean redrawFirstLine = false;
+ boolean redrawLastLine = false;
+
+ // this API can not be used if the client is providing the line styles
+ if (userLineStyle) {
+ return;
+ }
+ // check the range, make sure it falls within the range of the
+ // text
+ if (range != null && range.start + range.length > content.getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (range != null) {
+ // the first and last line needs to be redrawn completely if the
+ // font style is changing from SWT.NORMAL to something else or
+ // vice versa. fixes 1G7M5WE.
+ int rangeEnd = range.start + range.length;
+ int firstLine = content.getLineAtOffset(range.start);
+ int lastLine = content.getLineAtOffset(rangeEnd);
+ int firstLineOffset = content.getOffsetAtLine(firstLine);
+ if (isStyleChanging(range, range.start, Math.min(rangeEnd, firstLineOffset + content.getLine(firstLine).length()))) {
+ redrawFirstLine = true;
+ }
+ if (lastLine != firstLine) {
+ int lastLineOffset = content.getOffsetAtLine(lastLine);
+ if (isStyleChanging(range, lastLineOffset, rangeEnd)) {
+ redrawLastLine = true;
+ }
+ }
+ }
+ defaultLineStyler.setStyleRange(range);
+ if (range != null) {
+ int lineHeight = getLineHeight();
+
+ redrawRange(range.start, range.length, true);
+ if (redrawFirstLine) {
+ // redraw starting at the style change start offset since
+ // single line text changes, followed by style changes will
+ // flash otherwise
+ int firstLine = content.getLineAtOffset(range.start);
+ int firstLineOffset = content.getOffsetAtLine(firstLine);
+ String firstLineText = content.getLine(firstLine);
+ int redrawX = getXAtOffset(firstLineText, firstLine, range.start - firstLineOffset);
+ int redrawY = firstLine * lineHeight - verticalScrollOffset;
+ redraw(redrawX, redrawY, getClientArea().width, lineHeight, true);
+ }
+ if (redrawLastLine) {
+ // redraw the whole line if the font style changed on the last line
+ int lastLine = content.getLineAtOffset(range.start + range.length);
+ int redrawY = lastLine * lineHeight - verticalScrollOffset;
+ redraw(0, redrawY, getClientArea().width, lineHeight, true);
+ }
+ }
+ else {
+ redraw();
+ }
+ // make sure that the caret is positioned correctly.
+ // caret location may change if font style changes.
+ // fixes 1G8FODP
+ setCaretLocation();
+}
+
+/**
+ * Sets styles to be used for rendering the widget content. All styles
+ * will be replaced with the given set of styles.
+ * <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.
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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>
+ * <li>ERROR_INVALID_RANGE when the last of the style ranges is outside the valid range (> getCharCount())</li>
+ * </ul>
+ */
+public void setStyleRanges(StyleRange[] ranges) {
+ checkWidget();
+ // this API can not be used if the client is providing the line styles
+ if (userLineStyle) {
+ return;
+ }
+ if (ranges == null) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ // check the last range, make sure it falls within the range of the
+ // current text
+ if (ranges.length != 0) {
+ StyleRange last = ranges[ranges.length-1];
+ if (last.start + last.length > content.getCharCount()) {
+ SWT.error(SWT.ERROR_INVALID_RANGE);
+ }
+ }
+ defaultLineStyler.setStyleRanges(ranges);
+ redraw(); // bogus! only redraw affected area to avoid flashing
+ // make sure that the caret is positioned correctly.
+ // caret location may change if font style changes.
+ // fixes 1G8FODP
+ setCaretLocation();
+}
+
+/**
+ * Sets the tab width.
+ * <p>
+ *
+ * @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;
+ calculateTabWidth();
+ if (caretOffset > 0) {
+ caretOffset = 0;
+ showCaret();
+ clearSelection(false);
+ }
+ 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>
+ */
+public void setText(String text) {
+ checkWidget();
+ Event event = new Event();
+
+ event.start = 0;
+ event.end = getCharCount();
+ event.text = text;
+ event.doit = true;
+ notifyListeners(SWT.Verify, event);
+ if (event.doit) {
+ String replacedText = content.getTextRange(event.start, event.end - event.start);
+ content.setText(event.text);
+ event.end = event.start + event.text.length();
+ event.text = replacedText;
+ notifyListeners(SWT.Modify, event);
+ }
+}
+
+/**
+ * Sets the text limit.
+ * <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 index new top index. Must be between 0 and getLineCount() -
+ * visible lines per page. 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();
+ int lineCount = content.getLineCount();
+ int pageSize = Math.min(lineCount, getLineCountWhole());
+
+ if (getCharCount() == 0) {
+ return;
+ }
+ if (topIndex < 0) {
+ topIndex = 0;
+ }
+ else
+ if (topIndex > lineCount - pageSize) {
+ topIndex = lineCount - pageSize;
+ }
+ setVerticalScrollOffset(topIndex * getVerticalIncrement(), true);
+ // set the top index directly in case setVerticalScrollOffset didn't
+ // (ie. because the widget is not yet visible)
+ this.topIndex = topIndex;
+}
+/**
+ * Scrolls the widget vertically.
+ * <p>
+ *
+ * @param pixels number of pixels to scroll. > 0 = scroll up, < 0 scroll down
+ */
+void setVerticalScrollOffset(int pixelOffset, boolean adjustScrollBar) {
+ Rectangle clientArea;
+ ScrollBar verticalBar = getVerticalBar();
+ int verticalIncrement = getVerticalIncrement();
+
+ if (pixelOffset == verticalScrollOffset) {
+ return;
+ }
+ if (verticalBar != null && adjustScrollBar) {
+ verticalBar.setSelection(pixelOffset);
+ }
+ clientArea = getClientArea();
+ scroll(
+ 0, 0, // destination x, y
+ 0, pixelOffset - verticalScrollOffset, // source x, y
+ clientArea.width, clientArea.height, true);
+ if (verticalIncrement != 0) {
+ int oldTopIndex = topIndex;
+
+ topIndex = (int) Math.ceil((float) pixelOffset / verticalIncrement);
+ if (topIndex != oldTopIndex) {
+ int lineCount = content.getLineCount();
+ int visibleItemCount = (int) Math.ceil((float) clientArea.height / verticalIncrement);
+ int oldBottomIndex = Math.min(oldTopIndex + visibleItemCount, lineCount);
+ int newItemCount = topIndex - oldTopIndex;
+
+ if (Math.abs(newItemCount) > visibleItemCount) {
+ calculateContentWidth();
+ }
+ else {
+ if (newItemCount > 0) {
+ newItemCount = Math.min(newItemCount, lineCount - oldBottomIndex);
+ calculateContentWidth(oldBottomIndex, newItemCount);
+ }
+ else
+ if (newItemCount < 0) {
+ // make sure calculation range does not exceed number of lines
+ // fixes 1GBKCLF
+ calculateContentWidth(topIndex, Math.min(newItemCount * -1, lineCount - topIndex));
+ }
+ }
+ setScrollBars();
+ }
+ }
+ verticalScrollOffset = pixelOffset;
+ setCaretLocation();
+}
+/**
+ * Sets the caret location and scrolls the caret offset into view.
+ */
+void showCaret() {
+ int line = content.getLineAtOffset(caretOffset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = caretOffset - lineOffset;
+ String lineText = content.getLine(line);
+ int xAtOffset = getXAtOffset(lineText, line, offsetInLine);
+ int clientAreaWidth = getClientArea().width;
+ int verticalIncrement = getVerticalIncrement();
+ int horizontalIncrement = clientAreaWidth / 4;
+ boolean scrolled = false;
+
+ if (xAtOffset < 0) {
+ // always make 1/4 of a page visible
+ xAtOffset = Math.max(horizontalScrollOffset * -1, xAtOffset - horizontalIncrement);
+ scrollHorizontalBar(xAtOffset);
+ scrolled = true;
+ }
+ else
+ if (xAtOffset > clientAreaWidth) {
+ // always make 1/4 of a page visible
+ xAtOffset = Math.min(contentWidth - horizontalScrollOffset, xAtOffset + horizontalIncrement);
+ scrollHorizontalBar(xAtOffset - clientAreaWidth);
+ scrolled = true;
+ }
+ if (line < topIndex) {
+ setVerticalScrollOffset(line * verticalIncrement, true);
+ scrolled = true;
+ }
+ else
+ if (line > getBottomIndex()) {
+ setVerticalScrollOffset((line - getBottomIndex()) * verticalIncrement + verticalScrollOffset, true);
+ scrolled = true;
+ }
+ if (scrolled == false) {
+ caret.setLocation(xAtOffset, line * getLineHeight() - verticalScrollOffset);
+ }
+}
+/**
+ * Scrolls the specified offset into view.
+ * <p>
+ *
+ * @param offset offset that should be scolled into view
+ */
+void showOffset(int offset) {
+ int line = content.getLineAtOffset(offset);
+ int lineOffset = content.getOffsetAtLine(line);
+ int offsetInLine = offset - lineOffset;
+ String lineText = content.getLine(line);
+ int xAtOffset = getXAtOffset(lineText, line, offsetInLine);
+ int clientAreaWidth = getClientArea().width;
+ int verticalIncrement = getVerticalIncrement();
+ int horizontalIncrement = clientAreaWidth / 4;
+
+ if (xAtOffset < 0) {
+ // always make 1/4 of a page visible
+ xAtOffset = Math.max(horizontalScrollOffset * -1, xAtOffset - horizontalIncrement);
+ scrollHorizontalBar(xAtOffset);
+ }
+ else
+ if (xAtOffset > clientAreaWidth) {
+ // always make 1/4 of a page visible
+ xAtOffset = Math.min(contentWidth - horizontalScrollOffset, xAtOffset + horizontalIncrement);
+ scrollHorizontalBar(xAtOffset - clientAreaWidth);
+ }
+ if (line < topIndex) {
+ setVerticalScrollOffset(line * verticalIncrement, true);
+ }
+ else
+ if (line > getBottomIndex()) {
+ setVerticalScrollOffset((line - getBottomIndex()) * verticalIncrement + verticalScrollOffset, true);
+ }
+}
+
+/**
+ * Scrolls the selection into view.
+ * <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();
+ showOffset(selection.x);
+ showOffset(selection.y);
+}
+
+/**
+ * Returns the width of the specified text. Expand tabs to tab stops using
+ * the widget tab width.
+ * <p>
+ *
+ * @param line line to be measured.
+ * @param lineIndex index of the line relative to the first kine of the
+ * document
+ * @param length number of characters to measure. Tabs are counted
+ * as one character in this parameter.
+ * @param gc GC to use for measuring text
+ * @return width of the text with tabs expanded to tab stops or 0 if the
+ * length is beyond the text length.
+ */
+int textWidth(String line, int lineIndex, int length, GC gc) {
+ StyleRange[] styles = null;
+ int lineOffset = content.getOffsetAtLine(lineIndex);
+ StyledTextEvent event = getLineStyleData(lineOffset, line);
+
+ if (event != null) {
+ styles = filterLineStyles(event.styles);
+ }
+ return textWidth(line, lineOffset, 0, length, styles, 0, gc);
+}
+
+/**
+ * Returns the width of the specified text. Expand tabs to tab stops using
+ * the widget tab width.
+ * <p>
+ *
+ * @param text text to be measured.
+ * @param lineOffset offset of the first character in the line.
+ * @param startOffset offset of the character to start measuring and
+ * expand tabs.
+ * @param length number of characters to measure. Tabs are counted
+ * as one character in this parameter.
+ * @param styles line styles
+ * @param startXOffset x position of "startOffset" in "text". Used for
+ * calculating tab stops
+ * @param gc GC to use for measuring text
+ * @return width of the text with tabs expanded to tab stops or 0 if the
+ * startOffset or length is outside the specified text.
+ */
+int textWidth(String text, int lineOffset, int startOffset, int length, StyleRange[] lineStyles, int startXOffset, GC gc) {
+ int paintX = 0;
+ int endOffset = startOffset + length;
+ int textLength = text.length();
+ FontData fontData = gc.getFont().getFontData()[0];
+
+ if (startOffset < 0 || startOffset >= textLength || startOffset + length > textLength) {
+ return paintX;
+ }
+ for (int i = startOffset; i < endOffset; i++) {
+ int tabIndex = text.indexOf(TAB, i);
+ // is tab not present or past the rendering range?
+ if (tabIndex == -1 || tabIndex > endOffset) {
+ tabIndex = endOffset;
+ }
+ if (tabIndex != i) {
+ String tabSegment = text.substring(i, tabIndex);
+ if (lineStyles != null) {
+ paintX = styledTextWidth(tabSegment, lineOffset + i, lineStyles, paintX, 0, gc, false);
+ }
+ else {
+ fontData = setLineFont(gc, fontData, SWT.NORMAL);
+ paintX += gc.stringExtent(tabSegment).x;
+ }
+ if (tabIndex != endOffset && tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= (startXOffset + paintX) % tabWidth;
+ }
+ i = tabIndex;
+ }
+ else
+ if (tabWidth > 0) {
+ paintX += tabWidth;
+ paintX -= (startXOffset + paintX) % tabWidth;
+ }
+ }
+ return paintX;
+}
+
+/**
+ * Measures the text as rendered at the specified location. Expand tabs to tab stops using
+ * the widget tab width.
+ * <p>
+ *
+ * @param text text to draw
+ * @param textStartOffset offset of the first character in text relative
+ * to the first character in the document
+ * @param lineStyles styles of the line
+ * @param paintX x location to start drawing at
+ * @param paintY y location to draw at
+ * @param gc GC to draw on
+ * @param drawText true=measure and draw text, false=measure text only
+ * @return x location where drawing stopped or 0 if the startOffset or
+ * length is outside the specified text.
+ */
+int styledTextWidth(String text, int textStartOffset, StyleRange[] lineStyles, int paintX, int paintY, GC gc, boolean drawText) {
+ FontData fontData = gc.getFont().getFontData()[0];
+ String textSegment;
+ int textLength = text.length();
+ int textIndex = 0;
+
+ for (int styleIndex = 0; styleIndex < lineStyles.length; styleIndex++) {
+ StyleRange style = lineStyles[styleIndex];
+ int styleSegmentStart = style.start - textStartOffset;
+ int textEnd;
+ if (styleSegmentStart + style.length < 0) {
+ continue;
+ }
+ if (styleSegmentStart >= textLength) {
+ break;
+ }
+ // is there a style for the current string position?
+ if (textIndex < styleSegmentStart) {
+ fontData = setLineFont(gc, fontData, SWT.NORMAL);
+ textSegment = text.substring(textIndex, styleSegmentStart);
+ if (drawText) {
+ gc.drawString(textSegment, paintX - horizontalScrollOffset, paintY, true);
+ }
+ paintX += gc.stringExtent(textSegment).x;
+ textIndex = styleSegmentStart;
+ }
+ textEnd = Math.min(textLength, styleSegmentStart + style.length);
+ fontData = setLineFont(gc, fontData, style.fontStyle);
+ textSegment = text.substring(textIndex, textEnd);
+ if (drawText) {
+ gc.drawString(textSegment, paintX - horizontalScrollOffset, paintY, true);
+ }
+ paintX += gc.stringExtent(textSegment).x;
+ textIndex = textEnd;
+ }
+ // is there unmeasured and unstyled text?
+ if (textIndex < textLength) {
+ fontData = setLineFont(gc, fontData, SWT.NORMAL);
+ textSegment = text.substring(textIndex, textLength);
+ if (drawText) {
+ gc.drawString(textSegment, paintX - horizontalScrollOffset, paintY, true);
+ }
+ paintX += gc.stringExtent(textSegment).x;
+ }
+ return paintX;
+}
+
+/**
+ * Updates the selection and caret position depending on the text change.
+ * 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
+ return;
+ }
+ if (selection.x < startOffset) {
+ // clear selection fragment before text change
+ redrawRange(selection.x, startOffset - selection.x, true);
+ }
+ if (selection.y > startOffset + replacedLength) {
+ // clear selection fragment after text change
+ int netNewLength = newLength - replacedLength;
+ int redrawStart = startOffset + newLength;
+ redrawRange(redrawStart, selection.y + netNewLength - redrawStart, true);
+ }
+ if (selection.y > startOffset && selection.x < startOffset + replacedLength) {
+ // selection intersects replaced text. set caret behind text change
+ caretOffset = selection.x = selection.y = startOffset + newLength;
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+ }
+ else {
+ // move selection to keep same text selected
+ internalSetSelection(selection.x + newLength - replacedLength, selection.y - selection.x);
+ // always update the caret location. fixes 1G8FODP
+ setCaretLocation();
+ }
+}
+/**
+ * Returns whether the widget can have only one line.
+ * <p>
+ *
+ * @return true if widget can have only one line, false if widget can have
+ * multiple lines
+ */
+boolean isSingleLine() {
+ return (getStyle() & SWT.SINGLE) != 0;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
new file mode 100755
index 0000000000..839366cbf2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextContent.java
@@ -0,0 +1,177 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+
+public interface StyledTextContent {
+
+/**
+ * Called by StyledText to add itself as an Observer to content changes.
+ * Implementors should send a TextChangedEvent when changes to the content
+ * occur. The widget only updates the screen when it receives a TextChangedEvent.
+ * <p>
+ *
+ * @param listener the listener
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void addTextChangedListener(TextChangedListener 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 character offset without delimiters.
+ * <p>
+ *
+ * @param offset offset of the line to return. Does not include delimiters
+ * of preceeding lines. Offset 0 is the first character of the document.
+ * @return the line text without delimiters
+ */
+public String getLine(int offset);
+
+/**
+ * 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
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li>
+ * </ul>
+ */
+public void removeTextChangedListener(TextChangedListener listener);
+
+/**
+ * Replace the text with "newText" starting at position "start"
+ * for a length of "replaceLength".
+ * <p>
+ * Implementors have to notify TextChanged listeners after the content has
+ * been updated. The TextChangedEvent should be set as follows:
+ * <ul>
+ * <li>event.type = SWT.TextReplaced
+ * <li>event.start = start of the replaced text
+ * <li>event.numReplacedLines = number of replaced lines
+ * <li>event.numNewLines = number of new lines
+ * <li>event.replacedLength = length of the replaced text
+ * <li>event.newLength = length of the new text
+ * </ul>
+ * <b>NOTE:</b> numNewLines is the number of inserted lines and numReplacedLines is
+ * the number of deleted lines based on the change that occurs visually. For
+ * example:
+ * <ul>
+ * <li>(replacedText, newText) ==> (numReplacedLines, numNewLines)
+ * <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 preceeding lines, offset 0 is the first character of the document
+ * @param replaceLength start offset of text to replace
+ * @param newText start offset of text to replace
+ */
+public void replaceTextRange(int start, int replaceLength, String text);
+
+/**
+ * Set text to "text".
+ * Implementors have to notify TextChanged listeners after the content has
+ * been updated. The TextChangedEvent being sent must have the event type
+ * set to SWT.TextSet.
+ * <p>
+ *
+ * @param text the new text
+ */
+public void setText (String text);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java
new file mode 100755
index 0000000000..52c6ca7c8d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextEvent.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ *
+ */
+class StyledTextEvent extends Event {
+ // used by LineStyleEvent
+ StyleRange[] styles;
+ // used by LineBackgroundEvent
+ Color lineBackground;
+ // used by TextChangedEvent
+ int replacedCharCount;
+ int newCharCount;
+ int replacedLineCount;
+ int newLineCount;
+
+StyledTextEvent (StyledTextContent content) {
+ super();
+ data = content;
+}
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java
new file mode 100755
index 0000000000..7514f0bb44
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextListener.java
@@ -0,0 +1,62 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.widgets.*;
+import java.util.*;
+
+class StyledTextListener extends TypedListener {
+/**
+ */
+StyledTextListener(EventListener listener) {
+ super(listener);
+}
+/**
+ * Process StyledText events by invoking the event's handler.
+ */
+public void handleEvent(Event e) {
+ TextChangedEvent textChangedEvent;
+
+ switch (e.type) {
+ case StyledText.ExtendedModify:
+ ExtendedModifyEvent extendedModifyEvent = new ExtendedModifyEvent((StyledTextEvent) e);
+ ((ExtendedModifyListener) eventListener).modifyText(extendedModifyEvent);
+ break;
+
+ case StyledText.LineGetStyle:
+ LineStyleEvent lineStyleEvent = new LineStyleEvent((StyledTextEvent) e);
+ ((LineStyleListener) eventListener).lineGetStyle(lineStyleEvent);
+ ((StyledTextEvent) e).styles = lineStyleEvent.styles;
+ break;
+
+ case StyledText.LineGetBackground:
+ LineBackgroundEvent lineBgEvent = new LineBackgroundEvent((StyledTextEvent) e);
+ ((LineBackgroundListener) eventListener).lineGetBackground(lineBgEvent);
+ ((StyledTextEvent) e).lineBackground = lineBgEvent.lineBackground;
+ break;
+
+ case StyledText.VerifyKey:
+ VerifyEvent verifyEvent = new VerifyEvent(e);
+ ((VerifyKeyListener) eventListener).verifyKey(verifyEvent);
+ e.doit = verifyEvent.doit;
+ break;
+
+
+ case StyledText.TextReplaced:
+ textChangedEvent = new TextChangedEvent((StyledTextContent)e.data, (StyledTextEvent) e);
+ ((TextChangedListener) eventListener).textReplaced(textChangedEvent);
+ break;
+
+ case StyledText.TextSet:
+ textChangedEvent = new TextChangedEvent((StyledTextContent)e.data, (StyledTextEvent) e);
+ ((TextChangedListener) eventListener).textSet(textChangedEvent);
+ break;
+ }
+}
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java
new file mode 100755
index 0000000000..f9e18e66ef
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/StyledTextPrinter.java
@@ -0,0 +1,344 @@
+package org.eclipse.swt.custom;
+
+import java.io.*;
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.layout.*;
+import org.eclipse.swt.custom.*;
+import org.eclipse.swt.printing.*;
+
+class StyledTextPrinter {
+ class RTFState {
+ int fontStyle;
+ int foreground;
+ int background;
+ }
+ Vector savedState = new Vector();
+
+ StyledText styledText;
+ Printer printer;
+ GC gc;
+
+ String rtf;
+ int index, end;
+ StringBuffer wordBuffer;
+
+ /* We can optimize for fonts because we know styledText only has one font.
+ * As soon as we know the font name and point size, we will create and store
+ * Fonts for the following styles: normal, bold, italic, and bold italic.
+ */
+ Font fontTable[][] = new Font[1][4];
+ boolean creatingFontTable = false;
+ String fontName;
+ int fontSize;
+ int currentFontStyle = SWT.NORMAL;
+ int currentFont = -1;
+ int defaultFont = -1;
+
+ Vector colorTable = new Vector();
+ boolean creatingColorTable = false;
+ int red, green, blue;
+ int currentForeground = -1;
+ int currentBackground = -1;
+
+ String tabs = "";
+ int lineHeight = 0;
+ int tabWidth = 0;
+ int leftMargin, rightMargin, topMargin, bottomMargin;
+ int x, y;
+
+ public StyledTextPrinter(StyledText styledText) {
+ this.styledText = styledText;
+ }
+
+ public void print() {
+ printer = new Printer();
+ if (printer.startJob("StyledText")) {
+ Rectangle clientArea = printer.getClientArea();
+ Rectangle trim = printer.computeTrim(0, 0, 0, 0);
+ Point dpi = printer.getDPI();
+ leftMargin = dpi.x + trim.x; // one inch from left side of paper
+ rightMargin = clientArea.width - dpi.x + trim.x + trim.width; // one inch from right side of paper
+ topMargin = dpi.y + trim.y; // one inch from top edge of paper
+ bottomMargin = clientArea.height - dpi.y + trim.y + trim.height; // one inch from bottom edge of paper
+
+ /* Create a buffer for computing tab width. */
+ int tabSize = styledText.getTabs();
+ StringBuffer tabBuffer = new StringBuffer(tabSize);
+ for (int i = 0; i < tabSize; i++) tabBuffer.append(' ');
+ tabs = tabBuffer.toString();
+
+ /* Get RTF from the StyledText, determine what fonts and colors we need, and print. */
+ gc = new GC(printer);
+ x = leftMargin;
+ y = topMargin;
+ printStyledTextRTF();
+ printer.endJob();
+
+ /* Cleanup */
+ gc.dispose();
+ for (int i = 0; i < 4; i++) {
+ fontTable[currentFont][i].dispose();
+ }
+ for (int i = 0; i < colorTable.size(); i++) {
+ ((Color)colorTable.elementAt(i)).dispose();
+ }
+ }
+ printer.dispose();
+ }
+
+ void printStyledTextRTF() {
+ rtf = styledText.getRtf();
+ end = rtf.length();
+ index = 0;
+ wordBuffer = new StringBuffer();
+ while (index < end) {
+ char c = rtf.charAt(index);
+ index++;
+ switch (c) {
+ case '\\':
+ printWordBuffer();
+ parseControlWord();
+ break;
+ case '{':
+ printWordBuffer();
+ saveState();
+ break;
+ case '}':
+ printWordBuffer();
+ restoreState();
+ break;
+ case 0x0a:
+ case 0x0d:
+ printWordBuffer();
+ break;
+ default:
+ parseChar(c);
+ }
+ }
+ }
+
+ void parseControlWord() {
+ if (index >= end) return;
+ char c = rtf.charAt(index);
+ index++;
+ if (!Character.isLetter(c)) {
+ handleControlSymbol(c);
+ return;
+ }
+ StringBuffer controlWord = new StringBuffer();
+ controlWord.append(c);
+ while (index < end) {
+ c = rtf.charAt(index);
+ index++;
+ if (!Character.isLetter(c)) break;
+ controlWord.append(c);
+ }
+ boolean isNegative = false;
+ if (c == '-') {
+ isNegative = true;
+ c = rtf.charAt(index);
+ index++;
+ }
+ boolean hasParameter = false;
+ StringBuffer paramBuffer = new StringBuffer();
+ int parameter = 0;
+ if (Character.isDigit(c)) {
+ hasParameter = true;
+ paramBuffer.append(c);
+ while (index < end) {
+ c = rtf.charAt(index);
+ index++;
+ if (!Character.isDigit(c)) break;
+ paramBuffer.append(c);
+ }
+ try {
+ parameter = Integer.valueOf(paramBuffer.toString()).intValue();
+ } catch (NumberFormatException e) {}
+ if (isNegative) parameter = -parameter;
+ }
+ if (c != ' ') index--;
+ if (hasParameter) {
+ handleControlWord(controlWord.toString(), parameter);
+ } else {
+ handleControlWord(controlWord.toString());
+ }
+ }
+
+ void parseChar(char c) {
+ if (c == 0) return;
+ if (c == ';') {
+ if (creatingFontTable) {
+ fontName = wordBuffer.toString();
+ wordBuffer = new StringBuffer();
+ creatingFontTable = false;
+ return;
+ }
+ if (creatingColorTable) {
+ colorTable.addElement(new Color(printer, red, green, blue));
+ red = green = blue = 0;
+ return;
+ }
+ }
+ if (c != '\t') {
+ wordBuffer.append(c);
+ }
+ if (!Character.isLetterOrDigit(c) && !creatingFontTable) {
+ printWordBuffer();
+ if (c == '\t') {
+ x += tabWidth;
+ }
+ }
+ }
+
+ void printWordBuffer() {
+ if (wordBuffer.length() > 0) {
+ String word = wordBuffer.toString();
+ int wordWidth = gc.stringExtent(word).x;
+ if (x + wordWidth > rightMargin) {
+ /* word doesn't fit on current line, so wrap */
+ newline();
+ }
+ gc.drawString(word, x, y, true);
+ x += wordWidth;
+ wordBuffer = new StringBuffer();
+ }
+ }
+
+ void handleControlSymbol(char c) {
+ switch (c) {
+ case '\\':
+ case '{':
+ case '}':
+ parseChar(c);
+ }
+ }
+
+ void handleControlWord(String controlWord) {
+ if (controlWord.equals("par")) newline();
+ else if (controlWord.equals("b")) setFontStyle(currentFontStyle | SWT.BOLD);
+ else if (controlWord.equals("i")) setFontStyle(currentFontStyle | SWT.ITALIC);
+ else if (controlWord.equals("fnil")) setFont(defaultFont);
+ else if (controlWord.equals("fonttbl")) createFontTable();
+ else if (controlWord.equals("colortbl")) createColorTable();
+ }
+
+ void handleControlWord(String controlWord, int parameter) {
+ if (controlWord.equals("highlight")) setBackground(parameter);
+ else if (controlWord.equals("cf")) setForeground(parameter);
+ else if (controlWord.equals("b")) setFontStyle(currentFontStyle & ~SWT.BOLD);
+ else if (controlWord.equals("i")) setFontStyle(currentFontStyle & ~SWT.ITALIC);
+ else if (controlWord.equals("f")) setFont(parameter);
+ else if (controlWord.equals("fs")) setFontSize(parameter);
+ else if (controlWord.equals("red")) red = parameter;
+ else if (controlWord.equals("green")) green = parameter;
+ else if (controlWord.equals("blue")) blue = parameter;
+ else if (controlWord.equals("deff")) setDefaultFont(parameter);
+ }
+
+ void setDefaultFont(int number) {
+ defaultFont = number;
+ }
+
+ void setFont(int number) {
+ currentFont = number;
+ }
+
+ void createFontTable() {
+ creatingFontTable = true;
+ currentFont = 0;
+ }
+
+ void setFontSize(int size) {
+ fontSize = size / 2;
+ createFonts();
+ }
+
+ void createFonts() {
+ if (fontName != null && fontSize != -1) {
+ // currentFont must already be set
+ fontTable[currentFont][0] = new Font(printer, fontName, fontSize, SWT.NORMAL);
+ fontTable[currentFont][1] = new Font(printer, fontName, fontSize, SWT.BOLD);
+ fontTable[currentFont][2] = new Font(printer, fontName, fontSize, SWT.ITALIC);
+ fontTable[currentFont][3] = new Font(printer, fontName, fontSize, SWT.BOLD | SWT.ITALIC);
+ setFontStyle(SWT.NORMAL);
+ }
+ }
+
+ void setFontStyle(int style) {
+ // currentFont must already be set
+ Font font;
+ if ((style & SWT.BOLD) != 0) {
+ if ((style & SWT.ITALIC) != 0) {
+ font = fontTable[currentFont][3];
+ } else {
+ font = fontTable[currentFont][1];
+ }
+ } else if ((style & SWT.ITALIC) != 0) {
+ font = fontTable[currentFont][2];
+ } else {
+ font = fontTable[currentFont][0];
+ }
+ gc.setFont(font);
+ tabWidth = gc.stringExtent(tabs).x;
+ lineHeight = gc.getFontMetrics().getHeight();
+ currentFontStyle = style;
+ }
+
+ void createColorTable() {
+ creatingColorTable = true;
+ red = green = blue = 0;
+ }
+
+ void setForeground(int color) {
+ if (color != currentForeground) {
+ // colors must already be in table
+ gc.setForeground((Color)colorTable.elementAt(color));
+ currentForeground = color;
+ }
+ }
+
+ void setBackground(int color) {
+ if (color != currentBackground) {
+ // colors must already be in table
+ gc.setBackground((Color)colorTable.elementAt(color));
+ currentBackground = color;
+ }
+ }
+
+ void newline() {
+ x = leftMargin;
+ y += lineHeight;
+ if (y + lineHeight > bottomMargin) {
+ printer.endPage();
+ if (index + 1 < end) {
+ y = topMargin;
+ printer.startPage();
+ }
+ }
+ }
+
+ void saveState() {
+ RTFState state = new RTFState();
+ state.fontStyle = currentFontStyle;
+ state.foreground = currentForeground;
+ state.background = currentBackground;
+ savedState.addElement(state);
+ }
+
+ void restoreState() {
+ if (savedState.isEmpty()) return;
+ if (creatingColorTable) {
+ setForeground(0);
+ setBackground(1);
+ creatingColorTable = false;
+ }
+ RTFState state = (RTFState)savedState.remove(savedState.size() - 1);
+ setFontStyle(state.fontStyle);
+ if (state.foreground != -1) setForeground(state.foreground);
+ if (state.background != -1) setBackground(state.background);
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java
new file mode 100755
index 0000000000..a17caf48d7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableEditor.java
@@ -0,0 +1,179 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+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>
+* Table table = new Table(parent, SWT.FULL_SELECTION);
+* TableEditor editor = new TableEditor (table);
+* 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
+* int index = table.getSelectionIndex ();
+* if (index == -1) return;
+* TableItem item = table.getItem (index);
+*
+* // The control that will be the editor must be a child of the Table
+* Text text = new Text(table, SWT.NONE);
+*
+* //The text 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;
+*
+* // Open the text editor in the second column of the selected row.
+* editor.setEditor (text, item, 1);
+*
+* // Assign focus to the text control
+* text.setFocus ();
+* }
+* });
+* </pre></code>
+*/
+public class TableEditor extends ControlEditor {
+
+ Table table;
+ TableItem item;
+ int column = -1;
+ Listener columnListener;
+/**
+* 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 Listener() {
+ public void handleEvent(Event e) {
+ resize ();
+ }
+ };
+
+}
+Rectangle computeBounds () {
+ if (item == null || column == -1 || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+
+ Rectangle cell = item.getBounds(column);
+ Rectangle editorRect = new Rectangle(cell.x, cell.y, minimumWidth, cell.height);
+ Rectangle area = table.getClientArea();
+ if (cell.x < area.x + area.width) {
+ if (cell.x + cell.width > area.x + area.width) {
+ cell.width = area.width - cell.x;
+ }
+ }
+
+ if (grabHorizontal){
+ editorRect.width = Math.max(cell.width, minimumWidth);
+ }
+
+ 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;
+ }
+
+ 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 (this.column > -1 && this.column < table.getColumnCount()){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.removeListener(SWT.Resize, columnListener);
+ tableColumn.removeListener(SWT.Move, columnListener);
+ }
+
+ table = 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;
+}
+public void setColumn(int column) {
+
+ if (this.column > -1 && this.column < table.getColumnCount()){
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.removeListener(SWT.Resize, columnListener);
+ tableColumn.removeListener(SWT.Move, columnListener);
+ this.column = -1;
+ }
+
+ if (column < 0 || column >= table.getColumnCount()) return;
+
+ this.column = column;
+ TableColumn tableColumn = table.getColumn(this.column);
+ tableColumn.addListener(SWT.Resize, columnListener);
+ tableColumn.addListener(SWT.Move, columnListener);
+}
+/**
+* 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;
+}
+public void setItem (TableItem item) {
+ this.item = item;
+}
+public void setEditor (Control editor) {
+ TableItem item = null;
+ if (table.getItemCount() > 0) {
+ item = table.getItem(0);
+ }
+ this.setEditor(editor, item, 0);
+}
+
+/**
+* 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);
+ super.setEditor(editor);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java
new file mode 100755
index 0000000000..8ab256b7e1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTree.java
@@ -0,0 +1,701 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.Enumeration;
+import java.util.Vector;
+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.
+ *
+ * <dl>
+ * <dt><b>Styles:</b> <dd> SINGLE, MULTI, CHECK, FULL_SELECTION
+ * <dt><b>Events:</b> <dd> Selection, DefaultSelection, Collapse, Expand
+ * </dl>
+ */
+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 overriden (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];
+
+/**
+ * Creates a new instance of the widget.
+ *
+ * @param parent a composite widget
+ * @param style the bitwise OR'ing of widget styles
+ */
+public TableTree(Composite parent, int style) {
+ super(parent, SWT.NONE);
+ table = new Table(this, style);
+ setBackground(table.getBackground());
+ setForeground(table.getForeground());
+ setFont(table.getFont());
+ table.addListener(SWT.MouseDown, new Listener() {
+ public void handleEvent(Event e) {
+ onMouseDown(e);
+ }
+ });
+ table.addListener(SWT.Selection, new Listener() {
+ public void handleEvent(Event e) {
+ onSelection(e);
+ }
+ });
+ table.addListener(SWT.DefaultSelection, new Listener() {
+ public void handleEvent(Event e) {
+ onSelection(e);
+ }
+ });
+
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event e) {
+ onDispose();
+ }
+ });
+ addListener(SWT.Resize, new Listener() {
+ public void handleEvent(Event e) {
+ onResize();
+ }
+ });
+ addListener(SWT.FocusIn, new Listener() {
+ public void handleEvent(Event e) {
+ onFocusIn();
+ }
+ });
+}
+
+int addItem(TableTreeItem item, int index) {
+ if (index < 0 || index > items.length) throw new SWTError(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 receive selection events.
+ * <p>
+ *
+ * @param listener the selection listener
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_NULL_ARGUMENT when listener is null
+ * </ul>
+ */
+public void addSelectionListener(SelectionListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+/**
+ * Adds the listener to receive tree events.
+ * <p>
+ *
+ * @param listener the tree listener
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_NULL_ARGUMENT when listener is null
+ * </ul>
+ */
+public void addTreeListener(TreeListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Expand, typedListener);
+ addListener (SWT.Collapse, typedListener);
+}
+
+/**
+ * Computes the preferred size of the widget.
+ * <p>
+ * Calculate the preferred size of the widget based
+ * on the current contents. The hint arguments allow
+ * a specific client area width and/or height to be
+ * requested. The hints may be honored depending on
+ * the platform and the layout.
+ *
+ * @param wHint the width hint (can be SWT.DEFAULT)
+ * @param hHint the height hint (can be SWT.DEFAULT)
+ * @return a point containing the preferred size of the widget including trim
+ *
+ * @exception SWTError <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 Point computeSize (int wHint, int hHint) {
+ return table.computeSize (wHint, hHint, true);
+}
+
+/**
+ * Computes the widget trim.
+ * <p>
+ * Trim is widget specific and may include scroll
+ * bars and menu bar in addition to other trimmings
+ * that are outside of the widget's client area.
+ *
+ * @param x the x location of the client area
+ * @param y the y location of the client area
+ * @param width the width of the client area
+ * @param height the height of the client area
+ * @return a rectangle containing the trim of the widget.
+ *
+ * @exception SWTError <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 Rectangle computeTrim (int x, int y, int width, int height) {
+ 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 SWTError <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 () {
+ table.deselectAll();
+}
+
+/* Expand upward from the specified leaf item. */
+void expandItem (TableTreeItem item) {
+ if (item == null || item.getExpanded()) return;
+ expandItem(item.parentItem);
+ item.setExpanded(true);
+ Event event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Expand, event);
+}
+
+/**
+ * Gets the number of items.
+ * <p>
+ * @return the number of items in the widget
+ */
+public int getItemCount () {
+ 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 SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_CANNOT_GET_ITEM_HEIGHT when the operation fails
+ * </ul>
+ */
+public int getItemHeight () {
+ return table.getItemHeight();
+}
+
+/**
+ * Gets the items.
+ * <p>
+ * @return the items in the widget
+ *
+ */
+public TableTreeItem [] getItems () {
+ 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 SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_CANNOT_GET_SELECTION when the operation fails</li>
+ * </ul>
+ */
+public TableTreeItem [] getSelection () {
+ TableItem[] selection = table.getSelection();
+ TableTreeItem [] result = new TableTreeItem[selection.length];
+ for (int i = 0; i < selection.length; i++){
+ result[i] = (TableTreeItem) selection[i].getData();
+ }
+ 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 SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_CANNOT_GET_COUNT when the operation fails</li>
+ * </ul>
+ */
+public int getSelectionCount () {
+ return table.getSelectionCount();
+}
+
+/**
+ * Returns the underlying Table control.
+ *
+ * @return the underlying Table control
+ */
+public Table getTable () {
+ 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) {
+ for (int i = 0; i < items.length; i++) {
+ if (item == items[i]) return i;
+ }
+ return -1;
+}
+
+void onDispose() {
+ 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 () {
+ Rectangle area = getClientArea();
+ table.setBounds(0, 0, area.width, area.height);
+}
+
+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);
+}
+public TableTreeItem getItem(Point point) {
+ 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 () {
+ table.setFocus();
+}
+
+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();
+ 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 SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_ITEM_NOT_REMOVED when the operation fails
+ * </ul>
+ */
+public void removeAll () {
+ 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.
+ * <p>
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_NULL_ARGUMENT when listener is null
+ * </ul>
+ */
+public void removeSelectionListener (SelectionListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_NULL_ARGUMENT when listener is null
+ * </ul>
+ */
+public void removeTreeListener (TreeListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ removeListener(SWT.Expand, listener);
+ removeListener(SWT.Collapse, listener);
+}
+
+/**
+ * Selects all items.
+ * <p>
+ * If an item is not selected, it is selected.
+ * If an item is selected, it remains selected.
+ *
+ * @exception SWTError <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 () {
+ table.selectAll();
+}
+
+/**
+ * Sets the widget background color.
+ * <p>
+ * When new color is null, the background reverts
+ * to the default system color for the widget.
+ *
+ * @param color the new color (or null)
+ *
+ * @exception SWTError <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 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();
+ }
+}
+
+/**
+ * Sets the enabled state.
+ * <p>
+ * A disabled widget is typically not selectable from
+ * the user interface and draws with an inactive or
+ * grayed look.
+ *
+ * @param enabled the new enabled state
+ *
+ * @exception SWTError <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 setEnabled (boolean enabled) {
+ super.setEnabled(enabled);
+ table.setEnabled(enabled);
+}
+
+/**
+ * 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 SWTError <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 setFont (Font font) {
+ super.setFont(font);
+ table.setFont(font);
+}
+
+/**
+ * Gets the widget foreground color.
+ * <p>
+ * @return the widget foreground color
+ *
+ * @exception SWTError <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 setForeground (Color color) {
+ super.setForeground(color);
+ table.setForeground(color);
+}
+
+/**
+ * Sets the pop up menu.
+ * <p>
+ * Every control has an optional pop up menu that is
+ * displayed when the user requests a popup menu for
+ * the control. The sequence of key strokes/button
+ * presses/button releases that is used to request
+ * a pop up menu is platform specific.
+ *
+ * @param menu the new pop up menu
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_MENU_NOT_POP_UP when the menu is not a POP_UP</li>
+ * <li>ERROR_NO_COMMON_PARENT when the menu is not in the same widget tree</li>
+ * </ul>
+ */
+public void setMenu (Menu menu) {
+ super.setMenu(menu);
+ table.setMenu(menu);
+}
+
+/**
+ * Sets the selection.
+ * <p>
+ * @param items new selection
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_NULL_ARGUMENT when items is null
+ * </ul>
+ */
+public void setSelection (TableTreeItem[] items) {
+ TableItem[] tableItems = new TableItem[items.length];
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] == null) throw new SWTError(SWT.ERROR_NULL_ARGUMENT);
+ if (!items[i].getVisible()) expandItem (items[i]);
+ tableItems[i] = items[i].tableItem;
+ }
+ table.setSelection(tableItems);
+}
+
+/**
+ * Sets the tool tip text.
+ * <p>
+ * @param string the new tool tip text (or null)
+ *
+ * @exception SWTError <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 setToolTipText (String string) {
+ super.setToolTipText(string);
+ table.setToolTipText(string);
+}
+
+/**
+ * Shows the item.
+ * <p>
+ * @param item the item to be shown
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed
+ * <li>ERROR_NULL_ARGUMENT when item is null
+ * </ul>
+ */
+public void showItem (TableTreeItem item) {
+ if (item == null) throw new SWTError (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 SWTError <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 () {
+ table.showSelection();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java
new file mode 100755
index 0000000000..75a0814d5f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeEditor.java
@@ -0,0 +1,100 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+*
+* 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>The TableTreeEditor performs the same functions as the TableEditor except that the cell is in
+* a TableTree. Refer to TableEditor for additional information. The significant differnce is that
+* the Control provided as the editor <b>must</b> be created with its parent being the <b>Table</b>
+* control that is underneath the TableTree specified in the TableTreeEditor constructor.
+* The Table can be obtained from the TableTree using tableTree.getTable().
+*
+*/
+public class TableTreeEditor {
+
+ public int horizontalAlignment = SWT.CENTER;
+ public boolean grabHorizontal = false;
+ public int minimumWidth = 0;
+
+ TableTreeItem item;
+ TableEditor editor;
+/**
+* Creates a TableTreeEditor for the specified TableTree.
+*
+* @param tableTree the TableTree Control above which this editor will be displayed
+*
+*/
+public TableTreeEditor (TableTree tableTree) {
+ editor = new TableEditor (tableTree.getTable ());
+}
+/**
+ * Removes all associations between the TableTreeEditor and the cell in the TableTree. The
+ * TableTree and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+
+ editor.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 editor.getColumn ();
+}
+/**
+* Returns the Control that is displayed above the cell being edited.
+*
+* @return the Control that is displayed above the cell being edited
+*/
+public Control getEditor () {
+ return editor.getEditor ();
+}
+/**
+* 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;
+}
+/**
+* Specify the Control that is to be displayed and the cell in the TableTree 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 <b>Table</b>
+* control that is underneath the TableTree specified in the TableTreeEditor constructor.
+* The Table can be obtained from the TableTree using tableTree.getTable().
+*
+* @param editor the Control that is displayed above the cell being edited
+* @param item the TableTreeItem 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 control, TableTreeItem item, int column) {
+ if (control == null) {
+ editor.setEditor (null, null, -1);
+ return;
+ }
+
+ this.item = item;
+ TableItem tableItem = item.tableItem;
+ editor.horizontalAlignment = horizontalAlignment;
+ editor.grabHorizontal = grabHorizontal;
+ editor.minimumWidth = minimumWidth;
+
+ editor.setEditor (control, tableItem, column);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java
new file mode 100755
index 0000000000..a73f8f6433
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TableTreeItem.java
@@ -0,0 +1,561 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * A TableTreeItem is a selectable user interface object
+ * that represents an item in a heirarchy of items in a
+ * TableTree.
+ */
+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;
+ boolean expanded;
+ boolean checked;
+
+/**
+ * Create a new instance of a root item.
+ *
+ * @param parent the TableTree that contains this root item
+ * @param style the bitwise OR'ing of widget styles
+ */
+public TableTreeItem(TableTree parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Create a new instance of a root item in the position
+ * indicated by the specified index.
+ *
+ * @param parent the TableTree that contains this root item
+ * @param style the bitwise OR'ing of widget styles
+ * @param index specifies the position of this item in the TableTree
+ * relative to other root items
+ */
+public TableTreeItem(TableTree parent, int style, int index) {
+ this (parent, null, style, index);
+}
+
+/**
+ * Create a new instance of a sub item.
+ *
+ * @param parent this item's parent in the hierarchy of TableTree items
+ * @param style the bitwise OR'ing of widget styles
+ */
+public TableTreeItem(TableTreeItem parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
+/**
+ * Create a new instance of a sub item in the position
+ * indicated by the specified index.
+ *
+ * @param parent this item's parent in the hierarchy of TableTree items
+ * @param style the bitwise OR'ing of widget styles
+ * @param index specifies the position of this item in the TableTree
+ * relative to other children of the same parent
+ */
+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(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(null, 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);
+ }
+ addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ TableTreeItem.this.widgetDisposed(e);
+ }
+ });
+}
+void addCheck() {
+ Table table = parent.getTable();
+ if ((table.getStyle() & SWT.CHECK) == 0) return;
+ tableItem.setChecked(checked);
+}
+void addItem(TableTreeItem item, int index) {
+ if (item == null) throw new SWTError(SWT.ERROR_NULL_ARGUMENT);
+ if (index < 0 || index > items.length) throw new SWTError(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);
+}
+
+/**
+ * Gets the widget bounds at the specified index.
+ * <p>
+ * @return the widget bounds at the specified index
+ *
+ * @exception SWTError <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 Rectangle getBounds (int index) {
+ if (tableItem != null) {
+ return tableItem.getBounds(index);
+ } else {
+ return new Rectangle(0, 0, 0, 0);
+ }
+}
+/**
+* Gets the checked state.
+* <p>
+* @return the item checked state.
+*
+* @exception SWTError <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 boolean getChecked () {
+ if (tableItem == null) {
+ return checked;
+ }
+ return tableItem.getChecked();
+}
+
+/**
+ * Gets the Display.
+ * <p>
+ * This method gets the Display that is associated
+ * with the widget.
+ *
+ * @return the widget data
+ *
+ * @exception SWTError <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 Display getDisplay () {
+ TableTree parent = this.parent;
+ if (parent == null) throw new SWTError (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * Gets the expanded state of the widget.
+ * <p>
+ * @return a boolean that is the expanded state of the widget
+ */
+public boolean getExpanded () {
+ return expanded;
+}
+
+/**
+ * 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
+ */
+public Image getImage () {
+ 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) {
+ if (0 < index && index < images.length) return images[index];
+ return null;
+}
+
+int getIndent() {
+ if (parentItem == null) return 0;
+ return parentItem.getIndent() + 1;
+}
+
+/**
+ * Gets the number of sub items.
+ * <p>
+ * @return the number of sub items
+ */
+public int getItemCount () {
+ return items.length;
+}
+
+/**
+ * Gets the sub items.
+ * <p>
+ * @return the sub items
+ */
+public TableTreeItem[] getItems () {
+ 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;
+}
+
+/**
+ * Gets the parent.
+ * <p>
+ * @return the parent
+ */
+public TableTree getParent () {
+ return parent;
+}
+
+/**
+ * Gets the parent item.
+ * <p>
+ * @return the parent item.
+ */
+public TableTreeItem getParentItem () {
+ return parentItem;
+}
+
+/**
+ * Gets the first item text.
+ * <p>
+ * @return the item text at index 0, which can be null
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_CANNOT_GET_TEXT when the operation fails</li>
+ * </ul>
+ */
+public String getText () {
+ 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) {
+ 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) {
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] == item) return i;
+ }
+ return -1;
+}
+
+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;
+}
+
+void widgetDisposed(DisposeEvent e) {
+ for (int i = items.length - 1; i >= 0; i--) {
+ items[i].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;
+}
+
+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 checked state.
+* <p>
+* @param checked the new checked state.
+*
+* @exception SWTError <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 setChecked (boolean checked) {
+ if (tableItem != null) {
+ tableItem.setChecked(checked);
+ }
+ this.checked = checked;
+}
+/**
+ * Sets the expanded state.
+ * <p>
+ * @param expanded the new expanded state.
+ *
+ * @exception SWTError <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) {
+ if (items.length == 0) 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 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 SWTError <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) {
+ 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
+ */
+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 SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+public void setText(int index, String text) {
+ 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);
+}
+
+/**
+ * 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 SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when string is null</li>
+ * </ul>
+ */
+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(this);
+ tableItem.setImageIndent(getIndent());
+ 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;
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedEvent.java
new file mode 100755
index 0000000000..0aea1259ec
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedEvent.java
@@ -0,0 +1,41 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+
+/**
+ * This event is sent by the StyledTextContent implementor when a change to
+ * the text occurs.
+ */
+public class TextChangedEvent extends TypedEvent {
+ public int start; // replace start offset
+ public String replacedText; // the replaced text or empty String of no text was replaced
+ public int replacedCharCount; // length of text being replaced
+ public int newCharCount; // length of new text
+ public int replacedLineCount; // number of lines replaced
+ public int newLineCount; // number of new lines
+
+/**
+ * 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);
+}
+TextChangedEvent(StyledTextContent source, StyledTextEvent e) {
+ super(source);
+ start = e.start;
+ replacedCharCount = e.replacedCharCount;
+ newCharCount = e.newCharCount;
+ replacedLineCount = e.replacedLineCount;
+ newLineCount = e.newLineCount;
+ replacedText = e.text;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java
new file mode 100755
index 0000000000..3a523f1e2c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TextChangedListener.java
@@ -0,0 +1,41 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import java.util.*;
+
+/**
+ * The StyledText widget implements this listener to receive
+ * notification when changes to the model occur.
+ * It is not intended for use by users of the StyledText widget
+ * or implementors of StyledTextContent. Users should listen to
+ * the ModifyEvent or ExtendedModifyEvent that is sent by the StyledText
+ * widget to receive text change notifications.
+ */
+
+public interface TextChangedListener extends EventListener {
+/**
+ * @param event.start replace start offset (input)
+ * @param event.replacedText text being replaced (input)
+ * @param event.replacedCharCount length of text being replaced (input)
+ * @param event.newCharCount length of new text (input)
+ * @param event.replacedLineCount number of lines replaced (input)
+ * @param event.newLineCount number of new lines (input)
+ */
+public void textReplaced(TextChangedEvent event);
+
+/**
+ * @param event.start replace start offset (input)
+ * @param event.replacedText text being replaced (input)
+ * @param event.replacedCharCount length of text being replaced (input)
+ * @param event.newCharCount length of new text (input)
+ * @param event.replacedLineCount number of lines replaced (input)
+ * @param event.newLineCount number of new lines (input)
+ */
+public void textSet(TextChangedEvent event);
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java
new file mode 100755
index 0000000000..b00e3d77ff
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/TreeEditor.java
@@ -0,0 +1,163 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.events.*;
+
+/**
+*
+* 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>
+* Tree tree = new Tree(parent, SWT.FULL_SELECTION);
+* TreeEditor editor = new TreeEditor (tree);
+* 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
+* int index = tree.getSelectionIndex ();
+* if (index == -1) return;
+* TreeItem item = tree.getItem (index);
+*
+* // The control that will be the editor must be a child of the Tree
+* Text text = new Text(tree, SWT.NONE);
+*
+* //The text 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;
+*
+* // Open the text editor on the selected row.
+* editor.setEditor (text, item);
+*
+* // Assign focus to the text control
+* text.setFocus ();
+* }
+* });
+* </pre></code>
+*/
+public class TreeEditor extends ControlEditor {
+ Tree tree;
+ TreeItem item;
+ TreeListener treeListener;
+/**
+* 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;
+ treeListener = new TreeAdapter () {
+ final Runnable runnable = new Runnable() {
+ public void run() {
+ if (TreeEditor.this.tree.isDisposed() || editor == null) return;
+ resize();
+ editor.setVisible(true);
+ }
+ };
+ public void treeCollapsed(TreeEvent e) {
+ if (editor == null) return;
+ editor.setVisible(false);
+ Display display = TreeEditor.this.tree.getDisplay();
+ display.asyncExec(runnable);
+ }
+ public void treeExpanded(TreeEvent e) {
+ if (editor == null) return;
+ editor.setVisible(false);
+ Display display = TreeEditor.this.tree.getDisplay();
+ display.asyncExec(runnable);
+ }
+ };
+ tree.addTreeListener(treeListener);
+}
+Rectangle computeBounds () {
+ if (item == null || item.isDisposed()) return new Rectangle(0, 0, 0, 0);
+
+ Rectangle cell = item.getBounds();
+ 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, cell.height);
+
+ if (grabHorizontal) {
+ editorRect.width = Math.max(area.x + area.width - cell.x, minimumWidth);
+ }
+
+ if (horizontalAlignment == SWT.RIGHT) {
+ editorRect.x = Math.max(cell.x, cell.x + cell.width - editorRect.width);
+ } else if (horizontalAlignment == SWT.LEFT) {
+ // do nothing - cell.x is the right answer
+ } else { // default is CENTER
+ editorRect.x = Math.max(cell.x, cell.x + (cell.width - editorRect.width)/2);
+ }
+
+ return editorRect;
+}
+/**
+ * Removes all associations between the TreeEditor and the cell in the tree. The
+ * tree and the editor Control are <b>not</b> disposed.
+ */
+public void dispose () {
+ if (treeListener != null)
+ tree.removeTreeListener(treeListener);
+ treeListener = null;
+ tree = null;
+ item = null;
+ super.dispose();
+}
+/**
+* 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;
+}
+public void setItem (TreeItem item) {
+ this.item = item;
+}
+
+/**
+* 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
+*/
+public void setEditor (Control editor, TreeItem item) {
+ setItem (item);
+ super.setEditor (editor);
+}
+public void setEditor (Control editor) {
+ TreeItem item = null;
+ if (tree.getItemCount() != 0) {
+ item = tree.getItems()[0];
+ }
+ this.setEditor(editor, item);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java
new file mode 100755
index 0000000000..a5766fc2d8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/VerifyKeyListener.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.custom;
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000, 2001
+ */
+
+/* Imports */
+import org.eclipse.swt.events.*;
+import java.util.*;
+
+public interface VerifyKeyListener extends EventListener {
+/**
+ * @param event.character the character that was typed (input)
+ * @param event.keyCode the key code that was typed (input)
+ * @param event.stateMask the state of the keyboard (input)
+ * @param event.doit processed or not (output)
+ */
+public void verifyKey (VerifyEvent event);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java
new file mode 100755
index 0000000000..aafe3891fa
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/ViewForm.java
@@ -0,0 +1,477 @@
+package org.eclipse.swt.custom;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+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;
+
+ /**
+ * Color of innermost line of drop shadow border.
+ */
+ public static RGB borderInsideRGB = new RGB (132, 130, 132);
+ /**
+ * Color of middle line of drop shadow border.
+ */
+ public static RGB borderMiddleRGB = new RGB (143, 141, 138);
+ /**
+ * Color of outermost line of drop shadow border.
+ */
+ public static RGB borderOutsideRGB = new RGB (171, 168, 165);
+
+ // SWT widgets
+ private Control topLeft;
+ private Control topCenter;
+ private Control topRight;
+ private Control content;
+
+ // Configuration and state info
+ private boolean separateTopCenter = false;
+ private int drawLine1 = -1;
+ private int drawLine2 = -1;
+
+ private boolean showBorder = false;
+
+ private int BORDER_TOP = 0;
+ private int BORDER_BOTTOM = 0;
+ private int BORDER_LEFT = 0;
+ private int BORDER_RIGHT = 0;
+
+ private Color borderColor1;
+ private Color borderColor2;
+ private Color borderColor3;
+
+ private Rectangle oldArea;
+/**
+* Creates a ViewForm.
+* <p>
+* This method creates a child widget using style bits
+* to select a particular look or set of properties.
+*
+* @param parent a composite widget (cannot be null)
+* @param style the bitwise OR'ing of widget styles
+*
+* @exception SWTError <ul>
+* <li> ERROR_THREAD_INVALID_ACCESS when called from the wrong thread </li>
+* <li> ERROR_ERROR_NULL_ARGUMENT when the parent is null </li>
+* </ul>
+*/
+public ViewForm(Composite parent, int style) {
+ super(parent, checkStyle(style));
+
+ borderColor1 = new Color(getDisplay(), borderInsideRGB);
+ borderColor2 = new Color(getDisplay(), borderMiddleRGB);
+ borderColor3 = new Color(getDisplay(), borderOutsideRGB);
+ setBorderVisible((style & SWT.BORDER) != 0);
+
+ addPaintListener(new PaintListener() {
+ public void paintControl(PaintEvent event) {
+ onPaint(event.gc);
+ }
+ });
+ addControlListener(new ControlAdapter(){
+ public void controlResized(ControlEvent e) {
+ onResize();
+ }
+ });
+
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event e) {
+ onDispose();
+ }
+ });
+}
+/**
+ * Check the style bits to ensure that no invalid styles are applied.
+ * @private
+ */
+private static int checkStyle (int style) {
+ int mask = SWT.FLAT;
+ return style & mask | SWT.NO_REDRAW_RESIZE;
+}
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ // size of title bar area
+ Point leftSize = new Point(0, 0);
+ if (topLeft != null) {
+ leftSize = topLeft.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
+ Point centerSize = new Point(0, 0);
+ if (topCenter != null) {
+ centerSize = topCenter.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
+ Point rightSize = new Point(0, 0);
+ if (topRight != null) {
+ rightSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
+ Point size = new Point(0, 0);
+ // calculate width of title bar
+ if (separateTopCenter) {
+ size.x = leftSize.x + rightSize.x;
+ size.x = Math.max(centerSize.x, size.x);
+ size.y = Math.max(leftSize.y, rightSize.y);
+ if (topCenter != null){
+ size.y += centerSize.y;
+ }
+ } else {
+ size.x = leftSize.x + centerSize.x + rightSize.x;
+ size.y = Math.max(leftSize.y, Math.max(centerSize.y, rightSize.y));
+ }
+
+ if (content != null) {
+ Point contentSize = new Point(0, 0);
+ contentSize = content.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ size.x = Math.max (size.x, contentSize.x);
+ size.y += contentSize.y;
+ }
+
+ size.x += 2 * marginWidth + BORDER_LEFT + BORDER_RIGHT;
+ size.y += 2 * marginHeight + BORDER_TOP + BORDER_BOTTOM;
+
+ return size;
+}
+public Rectangle getClientArea() {
+ Rectangle clientArea = super.getClientArea();
+ clientArea.x += BORDER_LEFT;
+ clientArea.y += BORDER_TOP;
+ clientArea.width -= BORDER_LEFT + BORDER_RIGHT;
+ clientArea.height -= BORDER_TOP + BORDER_BOTTOM;
+ return clientArea;
+}
+/**
+* Returns the content area.
+*/
+public Control getContent() {
+ return content;
+}
+/**
+* Returns Control that appears in the top center of the pane.
+* Typically this is a toolbar.
+*/
+public Control getTopCenter() {
+ return topCenter;
+}
+/**
+* Returns the Control that appears in the top left corner of the pane.
+* Typically this is a label such as CLabel.
+*/
+public Control getTopLeft() {
+ 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.
+*/
+public Control getTopRight() {
+ return topRight;
+}
+public void layout (boolean changed) {
+ Rectangle rect = getClientArea();
+
+ drawLine1 = -1;
+ drawLine2 = -1;
+
+ Point leftSize = new Point(0, 0);
+ if (topLeft != null && !topLeft.isDisposed()) {
+ leftSize = topLeft.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
+ Point centerSize = new Point(0, 0);
+ if (topCenter != null && !topCenter.isDisposed()) {
+ centerSize = topCenter.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
+ Point rightSize = new Point(0, 0);
+ if (topRight != null && !topRight.isDisposed()) {
+ rightSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ }
+
+ int minTopWidth = leftSize.x + centerSize.x + rightSize.x + 2*marginWidth + 1; // +1 for highlight line
+ int height = rect.y + marginHeight;
+
+ boolean top = false;
+ if (separateTopCenter || minTopWidth > rect.width) {;
+ int topHeight = Math.max(rightSize.y, leftSize.y);
+ if (topRight != null && !topRight.isDisposed()) {
+ top = true;
+ topRight.setBounds(rect.x + rect.width - marginWidth - rightSize.x,
+ rect.y + 1 + marginHeight,
+ rightSize.x, topHeight);
+ height += 1 + topHeight; // +1 for highlight line
+ }
+ if (topLeft != null && !topLeft.isDisposed()) {
+ top = true;
+ leftSize = topLeft.computeSize(rect.width - 2* marginWidth - rightSize.x - 1, SWT.DEFAULT);
+ topLeft.setBounds(rect.x + 1 + marginWidth,
+ rect.y + 1 + marginHeight,
+ leftSize.x, topHeight);
+ height = Math.max(height, rect.y + marginHeight + 1 + topHeight); // +1 for highlight line
+ }
+ if (topCenter != null && !topCenter.isDisposed()) {
+ top = true;
+ if (height > rect.y + marginHeight) {
+ drawLine1 = height;
+ height += 1; // +1 for divider line
+ }
+ centerSize = topCenter.computeSize(rect.width - 2 * marginWidth, SWT.DEFAULT);
+ topCenter.setBounds(rect.x + rect.width - marginWidth - centerSize.x,
+ height,
+ centerSize.x, centerSize.y);
+ height += centerSize.y;
+
+ }
+ } else {
+ int topHeight = Math.max(rightSize.y, Math.max(centerSize.y, leftSize.y));
+ if (topRight != null && !topRight.isDisposed()) {
+ top = true;
+ topRight.setBounds(rect.x + rect.width - marginWidth - rightSize.x,
+ rect.y + marginHeight + 1, // +1 for highlight line
+ rightSize.x, topHeight);
+ height += 1 + topHeight; // +1 for highlight line
+ }
+ if (topCenter != null && !topCenter.isDisposed()) {
+ top = true;
+ topCenter.setBounds(rect.x + rect.width - marginWidth - rightSize.x - centerSize.x,
+ rect.y + marginHeight + 1, // +1 for highlight line
+ centerSize.x, topHeight);
+ height = Math.max(height, rect.y + marginHeight + 1 + topHeight); // +1 for highlight line
+ }
+ if (topLeft != null && !topLeft.isDisposed()) {
+ top = true;
+ leftSize = topLeft.computeSize(rect.width - 2 * marginWidth - rightSize.x - centerSize.x - 1, topHeight);
+ topLeft.setBounds(rect.x + marginWidth + 1, // +1 for highlight line
+ rect.y + marginHeight + 1, // +1 for highlight line
+ leftSize.x, topHeight);
+ height = Math.max(height, rect.y + marginHeight + 1 + topHeight); // +1 for highlight line
+ }
+ }
+
+ if (content != null && !content.isDisposed()) {
+ if (top) {
+ drawLine2 = height;
+ height += 1; // +1 for divider line
+ }
+ content.setBounds(rect.x + marginWidth,
+ height,
+ rect.width - 2 * marginWidth,
+ rect.y + rect.height - height - marginHeight);
+ }
+}
+private void onDispose() {
+ if (borderColor1 != null) {
+ borderColor1.dispose();
+ }
+ borderColor1 = null;
+
+ if (borderColor2 != null) {
+ borderColor2.dispose();
+ }
+ borderColor2 = null;
+
+ if (borderColor3 != null) {
+ borderColor3.dispose();
+ }
+ borderColor3 = null;
+}
+/**
+* Draws the focus border.
+*/
+private void onPaint(GC gc) {
+ Rectangle d = super.getClientArea();
+
+ if (showBorder) {
+ if ((getStyle() & SWT.FLAT) !=0) {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(d.x, d.y, d.x + d.width - 1, d.y + d.height - 1);
+ } else {
+ gc.setForeground(borderColor1);
+ gc.drawRectangle(d.x, d.y, d.x + d.width - 3, d.y + d.height - 3);
+
+ gc.setForeground(borderColor2);
+ gc.drawLine(d.x + 1, d.y + d.height - 2, d.x + d.width - 1, d.y + d.height - 2);
+ gc.drawLine(d.x + d.width - 2, d.y + 1, d.x + d.width - 2, d.y + d.height - 1);
+
+ gc.setForeground(borderColor3);
+ gc.drawLine(d.x + 2, d.y + d.height - 1, d.x + d.width - 2, d.y + d.height - 1);
+ gc.drawLine(d.x + d.width - 1, d.y + 2, d.x + d.width - 1, d.y + d.height - 2);
+ }
+ }
+
+ if (drawLine1 != -1) {
+ // top seperator line
+ gc.setForeground(borderColor1);
+ gc.drawLine(d.x + BORDER_LEFT, drawLine1, d.x + d.width - BORDER_RIGHT, drawLine1);
+ }
+ if (drawLine2 != -1) {
+ // content separator line
+ gc.setForeground(borderColor1);
+ gc.drawLine(d.x + BORDER_LEFT, drawLine2, d.x + d.width - BORDER_RIGHT, drawLine2);
+ }
+ // highlight on top
+ int y = drawLine1;
+ if (y == -1){
+ y = drawLine2;
+ }
+ if (y != -1) {
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ gc.drawLine(d.x + BORDER_LEFT + marginWidth, d.y + BORDER_TOP + marginHeight,
+ d.x + BORDER_LEFT + marginWidth, y - 1);
+ gc.drawLine(d.x + BORDER_LEFT + marginWidth, d.y + BORDER_TOP + marginHeight,
+ d.x + d.width - BORDER_RIGHT - marginWidth - 1, d.y + BORDER_TOP + marginHeight);
+ }
+
+ gc.setForeground(getForeground());
+}
+private void onResize() {
+ layout();
+
+ Rectangle area = super.getClientArea();
+ if (oldArea == null || oldArea.width == 0 || oldArea.height == 0) {
+ redraw();
+ } else {
+ int width = 0;
+ if (oldArea.width < area.width) {
+ width = area.width - oldArea.width + BORDER_RIGHT;
+ } else if (oldArea.width > area.width) {
+ width = BORDER_RIGHT;
+ }
+ redraw(area.x + area.width - width, area.y, width, area.height, false);
+
+ int height = 0;
+ if (oldArea.height < area.height) {
+ height = area.height - oldArea.height + BORDER_BOTTOM;
+ }
+ if (oldArea.height > area.height) {
+ height = BORDER_BOTTOM;
+ }
+ redraw(area.x, area.y + area.height - height, area.width, height, false);
+ }
+ oldArea = area;
+}
+/**
+* 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.
+*/
+public void setContent(Control content) {
+ if (content != null && content.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.content != null && !this.content.isDisposed()) {
+ this.content.setVisible(false);
+ }
+ this.content = content;
+ layout();
+}
+
+/**
+* Set the widget font.
+* This will apply the font to the topLeft, topRight and topCenter widgets.
+*/
+public void setFont(Font f) {
+ super.setFont(f);
+ if (topLeft != null && !topLeft.isDisposed()) topLeft.setFont(f);
+ if (topCenter != null && !topCenter.isDisposed()) topCenter.setFont(f);
+ if (topRight != null && !topRight.isDisposed()) topRight.setFont(f);
+
+ layout();
+}
+public void setLayout (Layout layout) {
+ // no layout may be set on the ViewForm
+ return;
+}
+/**
+* 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.
+*/
+public void setTopCenter(Control topCenter) {
+ if (topCenter != null && topCenter.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.topCenter != null && !this.topCenter.isDisposed()) {
+ this.topCenter.setVisible(false);
+ }
+ this.topCenter = topCenter;
+ layout();
+}
+/**
+* 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.
+*/
+public void setTopLeft(Control c) {
+ if (c != null && c.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.topLeft != null && !this.topLeft.isDisposed()) {
+ this.topLeft.setVisible(false);
+ }
+ this.topLeft = c;
+ layout();
+}
+/**
+* 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.
+*/
+public void setTopRight(Control c) {
+ if (c != null && c.getParent() != this) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (this.topRight != null && !this.topRight.isDisposed()) {
+ this.topRight.setVisible(false);
+ }
+ this.topRight = c;
+ layout();
+}
+public void setBorderVisible(boolean show) {
+ if (showBorder == show) return;
+
+ showBorder = show;
+ if (showBorder) {
+ if ((getStyle() & SWT.FLAT)!= 0) {
+ BORDER_LEFT = BORDER_TOP = BORDER_RIGHT = BORDER_BOTTOM = 1;
+ } else {
+ BORDER_LEFT = BORDER_TOP = 1;
+ BORDER_RIGHT = BORDER_BOTTOM = 3;
+ }
+ } else {
+ BORDER_BOTTOM = BORDER_TOP = BORDER_LEFT = BORDER_RIGHT = 0;
+ }
+
+ layout();
+ 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.
+*/
+public void setTopCenterSeparate(boolean show) {
+ separateTopCenter = show;
+ layout();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DND.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DND.java
new file mode 100755
index 0000000000..bfe342091a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DND.java
@@ -0,0 +1,128 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+
+/**
+ *
+ * Class DND contains all the constants used in defining a
+ * DragSource or a DropTarget.
+ *
+ */
+
+
+public class DND {
+
+ /**
+ * Drag and Drop Operation: no drag/drop operation is performed
+ */
+ 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
+ */
+ public final static int DROP_COPY = 1;
+ /**
+ * Drag and Drop Operation: the data is added to the drop target and removed from the drag source
+ */
+ public final static int DROP_MOVE = 2;
+ /**
+ * Drag and Drop Operation: the drop target makes a link to the data in the drag source
+ */
+ public final static int DROP_LINK = 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
+ */
+ public static final int DragEnd = 2000;
+ /**
+ * DragSource Event: the data to be dropped is required from the drag source
+ */
+ public static final int DragSetData = 2001;
+ /**
+ * DropTarget Event: the cursor has entered the drop target boundaries
+ */
+ public static final int DragEnter = 2002;
+ /**
+ * DropTarget Event: the cursor has left the drop target boundaries
+ */
+ public static final int DragLeave = 2003;
+ /**
+ * DropTarget Event: the cursor is moving over the drop target
+ */
+ public static final int DragOver = 2004;
+ /**
+ * DropTarget Event: the operation being performed has changed
+ * (usually due to the user changing the selected key while dragging)
+ */
+ public static final int DragOperationChanged = 2005;
+ /**
+ * DropTarget Event: the data is being dropped
+ */
+ public static final int Drop = 2006;
+ /**
+ * DropTarget Event: the drop target is given a last chance to modify the drop
+ */
+ public static final int DropAccept = 2007;
+ /**
+ * DragSource Event: a drag is about to begin
+ */
+ public static final int DragStart = 2008;
+
+ public static final int FEEDBACK_NONE = 0;
+ public static final int FEEDBACK_SELECT = 1;
+ public static final int FEEDBACK_INSERT_BEFORE = 2;
+ public static final int FEEDBACK_INSERT_AFTER = 3;
+
+ /**
+ * Error code for SWTError - drag source can not be initialized
+ */
+ public static final int ERROR_CANNOT_INIT_DRAG = 2000;
+ /**
+ * Error code for SWTError - drop target cannot be initialized
+ */
+ public static final int ERROR_CANNOT_INIT_DROP = 2001;
+ /**
+ * Error code for SWTError - Data can not be set on system clipboard
+ */
+ public static final int ERROR_CANNOT_SET_CLIPBOARD = 2002;
+
+
+ static final String INIT_DRAG_MESSAGE = "Can not initialize Drag";
+ static final String INIT_DROP_MESSAGE = "Can not initialize Drop";
+ static final String CANNOT_SET_CLIPBOARD_MESSAGE = "Can not set data in clipboard";
+
+public static void error (int code) {
+ error (code, 0);
+}
+
+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;
+ throw new SWTError (code, msg);
+ }
+ case DND.ERROR_CANNOT_INIT_DROP:{
+ String msg = DND.INIT_DROP_MESSAGE;
+ if (hresult != 0) msg += "result = "+hresult;
+ throw new SWTError (code, msg);
+ }
+ case DND.ERROR_CANNOT_SET_CLIPBOARD:{
+ String msg = DND.CANNOT_SET_CLIPBOARD_MESSAGE;
+ if (hresult != 0) msg += "result = "+hresult;
+ throw new SWTError (code, msg);
+ }
+ }
+
+ /* Unknown/Undefined Error */
+ SWT.error(code);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDEvent.java
new file mode 100755
index 0000000000..d7c41f301c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDEvent.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.widgets.*;
+
+class DNDEvent extends Event {
+
+ public TransferData dataType;
+ public TransferData[] dataTypes;
+ public int operations;
+ public int feedback;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDListener.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDListener.java
new file mode 100755
index 0000000000..5f2c2e7c1a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DNDListener.java
@@ -0,0 +1,77 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.widgets.Event;
+
+class DNDListener extends org.eclipse.swt.widgets.TypedListener {
+/**
+ * DNDListener constructor comment.
+ * @param listener java.util.EventListener
+ */
+DNDListener(java.util.EventListener listener) {
+ super(listener);
+}
+public void handleEvent (Event e) {
+ switch (e.type) {
+ case DND.DragStart: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((DragSourceListener) eventListener).dragStart (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragEnd: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((DragSourceListener) eventListener).dragFinished (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragSetData: {
+ DragSourceEvent event = new DragSourceEvent((DNDEvent)e);
+ ((DragSourceListener) eventListener).dragSetData (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragEnter: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragEnter (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragLeave: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragLeave (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragOver: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragOver (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.Drop: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).drop (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DropAccept: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dropAccept (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+ case DND.DragOperationChanged: {
+ DropTargetEvent event = new DropTargetEvent((DNDEvent)e);
+ ((DropTargetListener) eventListener).dragOperationChanged (event);
+ event.updateEvent((DNDEvent)e);
+ break;
+ }
+
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceAdapter.java
new file mode 100755
index 0000000000..ab728a91ea
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceAdapter.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class DragSourceAdapter implements DragSourceListener {
+ public void dragStart(DragSourceEvent event){};
+ public void dragFinished(DragSourceEvent event){};
+ public void dragSetData(DragSourceEvent event){};
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java
new file mode 100755
index 0000000000..655c2df91d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceEvent.java
@@ -0,0 +1,67 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.events.TypedEvent;
+
+/**
+ * The DragSourceEvent contains the event information passed in the methods of the DragSourceListener.
+ *
+ * <p>dragStart : When a drag operation is about to being, the following fields apply:
+ * <ul>
+ * <li>widget - (in) the DragSource object that is initiating the drag
+ * <li>time - (in) the time the drag action occurred
+ * <li>doit - (out) the application can set this value to false to prevent the drag from starting. Set to true by default.
+ * </ul></p>
+ *
+ * <p>dragSetData : When requesting data from the DragSource, the following fields apply:
+ * <ul>
+ * <li>widget - (in) the DragSource object that initiated the drag
+ * <li>time - (in) the time the drop occurred
+ * <li>dataType - (in) the type of data requested. This is a TransferData object and can be used with the Transfer subclasses.
+ * <li>data - (out) the application inserts the actual data here (must match the dataType). This is a Java object and
+ * the type of Java object that the application should insert here depends on the data type.
+ * For example, a TextTransfer requires a Java String containing the text; a FileTransfer requires
+ * a Java array of String with each String in the array representing the full path of the file.
+ * To determine what type of object you need to place in this field, consult the description of
+ * the Transfer subclass
+ * </ul></p>
+ *
+ * <p>dragFinished : When a drag operation has been completed, the following fields apply:
+ * <ul>
+ * <li>widget - (in) the DragSource object that initiated the drag
+ * <li>time - (in) the time the drop occurred
+ * <li>doit - (in) true if the operation performed successfully
+ * <li>detail - (in) the operation that was performed (DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></p>
+ *
+ */
+
+public class DragSourceEvent extends TypedEvent {
+ public int detail;
+ public boolean doit;
+
+ /**
+ * Platform specific information about the type of data being transferred.
+ */
+ public TransferData dataType;
+
+public DragSourceEvent(DNDEvent e) {
+ super(e);
+ this.data = e.data;
+ this.detail = e.detail;
+ this.doit = e.doit;
+ this.dataType = e.dataType;
+}
+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;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceListener.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceListener.java
new file mode 100755
index 0000000000..3024d06d5f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragSourceListener.java
@@ -0,0 +1,70 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import java.util.EventListener;
+
+/**
+ * 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>.</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 EventListener {
+
+/**
+ * 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>widget - (in) the DragSource object that initiated the drag
+ * <li>time - (in) the time the drop occurred
+ * <li>doit - (out) set to fase by default. To cause a drag to begin, set this to true.
+ * </ul></p>
+ *
+ * @param event the information associated with the drag finished event
+ *
+ */
+public void dragStart(DragSourceEvent event);
+
+/**
+ * The data is required from the drag source.
+ *
+ * <p>The following fields in the DragSourceEvent apply:
+ * <ul>
+ * <li>widget - (in) the DragSource object that initiated the drag
+ * <li>time - (in) the time the drop occurred
+ * <li>dataType - (in) the type of data requested. This is a TransferData object and can be used with the Transfer subclasses.
+ * <li>data - (out) the application inserts the actual data here (must match the dataType)
+ * </ul></p>
+ *
+ * @param event the information associated with the drag set data event
+ */
+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>widget - (in) the DragSource object that initiated the drag
+ * <li>time - (in) the time the drop occurred
+ * <li>doit - (in) true if the operation performed successfully
+ * <li>detail - (in) the operation that was performed (DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></p>
+ *
+ * @param event the information associated with the drag finished event
+ *
+ */
+public void dragFinished(DragSourceEvent event);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragUnderEffect.java
new file mode 100755
index 0000000000..7c2c886e28
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DragUnderEffect.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+abstract class DragUnderEffect {
+
+abstract void show(int effect, int x, int y);
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetAdapter.java
new file mode 100755
index 0000000000..eaac3c6678
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetAdapter.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class DropTargetAdapter implements DropTargetListener {
+
+public void dragEnter(DropTargetEvent event){};
+public void dragLeave(DropTargetEvent event){};
+public void dragOperationChanged(DropTargetEvent event){};
+public void dragOver(DropTargetEvent event){};
+public void drop(DropTargetEvent event){};
+public void dropAccept(DropTargetEvent event){};
+
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java
new file mode 100755
index 0000000000..95a77d53f9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEvent.java
@@ -0,0 +1,98 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+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.
+ *
+ * <p>When in dragEnter(), dragOver(), dragLeave(), dragOperationChanged(), dropAccept(),
+ * the following fields apply:
+ * <ul>
+ * <li>(in)widget - the object on which the data will be dropped if the mouse is released
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the DropTarget <code>Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the DropTarget <code>Control</code>
+ * <li>(in)dataTypes - a list of the types of data that the DragSource can support
+ * <li>(in,out)currentDataType - the specific type of data that will be provided on a drop
+ * <li>(in)operations - a list of the operations that the DragSource can support (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK)
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul>
+ * 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.
+ * 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 list</code>.</p>
+ *
+ * <p>When in drop(), the following fields apply:
+ * <ul>
+ * <li>(in)widget - the object on which the data was dropped
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the DropTarget <code>Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the DropTarget <code>Control</code>
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * <li>(in)currentDataType - the specific type of data that is be contained in the <code>data</code> field
+ * <li>(in)data - the data (which is of type currentDataType); the type Java Object contained in this field is
+ * dependant on the Transfer subclass. For example, the TextTransfer subclass provides a
+ * String with the text in the String. The FileTransfer object provides an array of String with
+ * each String in the array containing the full path of the file.
+ * </ul>
+ * The application can cancel the drop operation by setting the detail field to DND.DROP_NONE.</p>
+ *
+ */
+public class DropTargetEvent extends TypedEvent {
+ public int x;
+ public int y;
+ public int detail;
+ /**
+ * A list of the operations that the DragSource can support
+ * (e.g. DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK).
+ */
+ public int operations;
+ public int feedback;
+ public Widget item;
+
+ /*
+ * Platform specfic data.
+ */
+ /**
+ * 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;
+
+
+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;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetListener.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetListener.java
new file mode 100755
index 0000000000..acd9e09f69
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetListener.java
@@ -0,0 +1,172 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.graphics.*;
+import java.util.EventListener;
+
+/**
+ * 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, change the operation
+ * that will be performed or stop any drop from happening on the current target.</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>
+ *
+ */
+public interface DropTargetListener extends EventListener {
+/**
+ * The cursor has entered the drop target boundaries.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget - the DragSource object that initiated the drag
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)dataTypes - a list of the types of data that the <code>DragSource</code> can support
+ * <li>(in,out)currentDataType - the specific type of data that will be provided
+ * <li>(in)operations - a list of the operations that the DragSource can support (e.g. <code>DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK</code>)
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></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.
+ * 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
+ *
+ */
+public void dragEnter(DropTargetEvent event);
+/**
+ * The cursor has left the drop target boundaries.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget - the DragSource object that initiated the drag
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)dataTypes - a list of the types of data that the <code>DragSource</code> can support
+ * <li>(in,out)currentDataType - the specific type of data that will be provided
+ * <li>(in)operations - a list of the operations that the DragSource can support (e.g. <code>DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK</code>)
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></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.
+ * 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 leave event
+ *
+ */
+
+public void dragLeave(DropTargetEvent event);
+/**
+ * The operation being performed has changed (usually due to the user changing the selected key while dragging).
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget - the DragSource object that initiated the drag
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)dataTypes - a list of the types of data that the <code>DragSource</code> can support
+ * <li>(in,out)currentDataType - the specific type of data that will be provided
+ * <li>(in)operations - a list of the operations that the DragSource can support (e.g. <code>DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK</code>)
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></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.
+ * 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
+ */
+
+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 - the DragSource object that initiated the drag
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)dataTypes - a list of the types of data that the <code>DragSource</code> can support
+ * <li>(in,out)currentDataType - the specific type of data that will be provided
+ * <li>(in)operations - a list of the operations that the DragSource can support (e.g. <code>DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK</code>)
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></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.
+ * 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 over event
+ *
+ */
+
+public void dragOver(DropTargetEvent event);
+/**
+ * The data is being dropped.
+ *
+ * <p>The following fields in DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget - the DragSource object that initiated the drag
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * <li>(in)currentDataType - the specific type of data that will be provided
+ * <li>(in)data - the data (which is of type currentDataType)
+ * </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
+ *
+ */
+
+public void drop(DropTargetEvent event);
+/**
+ * The drop target is given the chance to change the nature of the drop. It can veto the drop by setting the
+ * <code>event.detail</code> field to <code>DND.DROP_NONE</code>, it can change the data of data that will be
+ * dropped by setting the <code>event.currentDataType</code> field to a different value or it can change the
+ * operation that will be performed by changing the <code>event.detail</code> field.
+ *
+ * <p>The following fields in the DropTargetEvent apply:
+ * <ul>
+ * <li>(in)widget - the DragSource object that initiated the drag
+ * <li>(in)time - the time the drop occurred
+ * <li>(in)x - the x-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)y - the y-cordinate of the cursor relative to the <code>DropTarget Control</code>
+ * <li>(in)dataTypes - a list of the types of data that the <code>DragSource</code> can support
+ * <li>(in,out)currentDataType - the specific type of data that will be provided
+ * <li>(in)operations - a list of the operations that the DragSource can support (e.g. <code>DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK</code>)
+ * <li>(in,out)detail - the operation being performed (one of DND.DROP_MOVE, DND.DROP_COPY, DND.DROP_LINK, DND.DROP_NONE)
+ * </ul></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.
+ * 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
+ *
+ */
+public void dropAccept(DropTargetEvent event);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/NoDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/NoDragUnderEffect.java
new file mode 100755
index 0000000000..6cf7c6054c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/NoDragUnderEffect.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class NoDragUnderEffect extends DragUnderEffect {
+
+NoDragUnderEffect(Control control) {}
+void show(int effect, int x, int y){}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100755
index 0000000000..df1a8dd4b9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.motif.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+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){
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
+ }
+ return false;
+}
+protected void javaToNative (Object object, TransferData transferData){
+ if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
+ transferData.result = 0;
+ return;
+ }
+ byte[] buffer = (byte[])object;
+ transferData.pValue = OS.XtMalloc(buffer.length + 1);
+ OS.memmove(transferData.pValue, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.format = 8;
+ transferData.result = 1;
+}
+protected Object nativeToJava(TransferData transferData){
+
+ if (transferData.pValue == 0 || !(isSupportedType(transferData))) return null;
+
+ int size = transferData.format * transferData.length / 8;
+ byte[] buffer = new byte[size];
+ OS.memmove(buffer, transferData.pValue, size);
+ return buffer;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
new file mode 100755
index 0000000000..a7c099fe60
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,206 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/*
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ */
+public class Clipboard {
+
+ private Display display;
+ private final int MAX_RETRIES = 10;
+ private int shellHandle;
+
+
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.display = display;
+
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+}
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+public void dispose () {
+ if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+ shellHandle = 0;
+ display = null;
+}
+public Object getContents(Transfer transfer) {
+ if (display.isDisposed() ) return null;
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0) return null;
+ int xWindow = OS.XtWindow (shellHandle);
+ if (xWindow == 0) return null;
+
+ // Open clipboard for retrieval
+ int retries = 0;
+ int status = OS.XmClipboardStartRetrieve(xDisplay, xWindow, OS.XtLastTimestampProcessed(xDisplay));
+ while ( status == OS.XmClipboardLocked && retries < MAX_RETRIES) {
+ retries ++;
+ status = OS.XmClipboardStartRetrieve(xDisplay, xWindow, OS.XtLastTimestampProcessed(xDisplay));
+ };
+ if (status != OS.XmClipboardSuccess) return null;
+
+ // Does Clipboard have data in required format?
+ String type = null;
+ int[] length = new int[1];
+ String[] supportedTypes = transfer.getTypeNames();
+ for (int i = 0; i < supportedTypes.length; i++) {
+ if (OS.XmClipboardInquireLength(xDisplay, xWindow, supportedTypes[i].getBytes(), length) == 1 /*OS.XmClipboardSuccess*/ ) {
+ type = supportedTypes[i];
+ break;
+ }
+ }
+
+ // Retrieve data from Clipboard
+ byte[] data = null;
+ if (type != null) {
+ data = new byte[length[0]];
+ status = OS.XmClipboardRetrieve(xDisplay, xWindow, type.getBytes(), data, length[0], new int[1], new int[1]);
+ if (status != OS.XmClipboardSuccess) {
+ data = null;
+ }
+ }
+
+ // Close Clipboard
+ status = OS.XmClipboardEndRetrieve(xDisplay, xWindow);
+
+ if (data == null) return null;
+
+ // Pass data to transfer agent for conversion to a Java Object
+ // Memory is allocated here to emulate the way Drag and Drop transfers data.
+ TransferData transferData = new TransferData();
+ byte[] bName = Converter.wcsToMbcs (null, type, false);
+ transferData.type = OS.XmInternAtom (xDisplay, bName, false);
+ transferData.pValue = OS.XtMalloc(data.length);
+ OS.memmove(transferData.pValue, data, data.length);
+ transferData.length = data.length;
+ transferData.format = 8;
+ transferData.result = 1;
+
+ Object result = transfer.nativeToJava(transferData);
+
+ // Clean up allocated memory
+ OS.XtFree(transferData.pValue);
+
+ return result;
+}
+public void setContents(Object[] data, Transfer[] transferAgents){
+
+ if (data == null) {
+ DND.error(SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ if (transferAgents == null || data.length != transferAgents.length) {
+ DND.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ if (display.isDisposed() )
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0)
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+ int xWindow = OS.XtWindow (shellHandle);
+ if (xWindow == 0)
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+
+ // Open clipboard for setting
+ int[] item_id = new int[1];
+ int retries = 0;
+ int status = OS.XmClipboardStartCopy(xDisplay, xWindow, 0, OS.XtLastTimestampProcessed(xDisplay), shellHandle, 0, item_id);
+ while ( status == OS.XmClipboardLocked && retries < MAX_RETRIES) {
+ retries ++;
+ status = OS.XmClipboardStartCopy(xDisplay, xWindow, 0, OS.XtLastTimestampProcessed(xDisplay), shellHandle, 0, item_id);
+ };
+ if (status != OS.XmClipboardSuccess)
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+
+ // copy data directly over to System clipboard (not deferred)
+ for (int i = 0; i < transferAgents.length; i++) {
+ String[] names = transferAgents[i].getTypeNames();
+ for (int j = 0; j < names.length; j++) {
+
+ TransferData transferData = new TransferData();
+ byte[] bName = Converter.wcsToMbcs (null, names[j], false);
+ transferData.type = OS.XmInternAtom (xDisplay, bName, false);
+ transferAgents[i].javaToNative(data[i], transferData);
+ status = OS.XmClipboardFail;
+ if (transferData.result == 1 && transferData.format == 8){
+ byte[] buffer = new byte[transferData.length];
+ OS.memmove(buffer, transferData.pValue, transferData.length);
+ status = OS.XmClipboardCopy(xDisplay, xWindow, item_id[0], bName, buffer, transferData.length, 0, null);
+ }
+ // Clean up allocated memory
+ if (transferData.pValue != 0) {
+ OS.XtFree(transferData.pValue);
+ }
+ }
+ }
+
+ // close clipboard for setting
+ OS.XmClipboardEndCopy(xDisplay, xWindow, item_id[0]);
+
+ if (status != OS.XmClipboardSuccess)
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD);
+
+}
+/*
+ * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should
+ * NOT be used within an application because it provides platform specfic
+ * information.
+ */
+public String[] getAvailableTypeNames() {
+ int[] count = new int[1];
+ int[] max_length = new int[1];
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0)
+ DND.error(SWT.ERROR_UNSPECIFIED);
+ int xWindow = OS.XtWindow (shellHandle);
+ if (xWindow == 0)
+ DND.error(SWT.ERROR_UNSPECIFIED);
+ if (OS.XmClipboardInquireCount(xDisplay, xWindow, count, max_length) != OS.XmClipboardSuccess)
+ DND.error(SWT.ERROR_UNSPECIFIED);
+ String[] types = new String[count[0]];
+ for (int i = 0; i < count[0]; i++) {
+ byte[] buffer = new byte[max_length[0]];
+ int[] copied_length = new int[1];
+ int rc = OS.XmClipboardInquireFormat(xDisplay, xWindow, i + 1, buffer, buffer.length, copied_length);
+ if (rc == OS.XmClipboardNoData){
+ types[i] = "";
+ continue;
+ }
+ if (rc != OS.XmClipboardSuccess)
+ DND.error(SWT.ERROR_UNSPECIFIED);
+ byte[] buffer2 = new byte[copied_length[0]];
+ System.arraycopy(buffer, 0, buffer2, 0, copied_length[0]);
+ types[i] = new String(buffer2);
+ }
+ return types;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java
new file mode 100755
index 0000000000..db1d34e248
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,460 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * Class <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class defines the following items:<ul>
+ * <li>the <code>Control</code> that the user clicks on to intiate a drag;
+ * <li>the data that will be transferred on a successful drop;
+ * <li>and the modes (move, copy, link) of transfer that are allowed.
+ * </ul></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
+ * but it can also 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 interface
+ * <code>DragSourceListener</code> which uses the class <code>DragSourceEvent</code>.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.</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> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnd, DND.DragSetData
+ * </dl>
+ */
+public class DragSource extends Widget {
+
+ private Callback convertProc;
+ private Callback dragDropFinish;
+ private Callback dropFinish;
+
+ // info for registering as a drag source
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private boolean myDrag;
+
+ int dragContext;
+
+public DragSource(Control control, int style) {
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ 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){
+ DragSource.this.drag();
+ }
+
+ }
+ };
+ this.control.addListener (SWT.Dispose, controlListener);
+ this.control.addListener (SWT.DragDetect, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ onDispose();
+ }
+ });
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragStart, typedListener);
+ addListener (DND.DragSetData, typedListener);
+ addListener (DND.DragEnd, typedListener);
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+private int convertProcCallback(int widget, int pSelection, int pTarget, int pType_return, int ppValue_return, int pLength_return, int pFormat_return, int max_length, int client_data, int request_id) {
+ /*
+ pSelection - atom specifying which property is being used to transfer the selection (only support _MOTIF_DROP)
+ pTarget - atom specifying the type in which the requestor wants the information
+ pType_return - [out] type atom that data has been converted to (usually the same as pTarget)
+ ppValue_return - [out] set to a pointer to a block of memory
+ pLength_return - [out] number of elements in the array
+ pFormat_return - [out] size in bits of each element in the array
+
+ */
+
+ if (pSelection == 0 )
+ return 0;
+
+ // is this a drop?
+ int[] selection = new int[1];
+ OS.memmove(selection, pSelection, 4);
+ int motifDropAtom = Transfer.registerType("_MOTIF_DROP\0");
+ if (selection[0] != motifDropAtom) return 0;
+
+ // get the target value from pTarget
+ int[] target = new int[1];
+ OS.memmove(target, pTarget, 4);
+
+ // handle the "Move" case
+ if (target[0] == Transfer.registerType("DELETE\0")) { // DELETE corresponds to a Move request
+ OS.memmove(pType_return,new int[]{Transfer.registerType("NULL\0")}, 4);
+ OS.memmove(ppValue_return, new int[]{0}, 4);
+ OS.memmove(pLength_return, new int[]{0}, 4);
+ OS.memmove(pFormat_return, new int[]{8}, 4);
+ return 1;
+ }
+
+ // do we support the requested data type?
+ boolean dataMatch = true;
+ TransferData transferData = new TransferData();
+ transferData.type = target[0];
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData)){
+ dataMatch = true;
+ break;
+ }
+ }
+ if (!dataMatch) return 0;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = control;
+ //event.time = ??;
+ event.dataType = transferData;
+ try {
+ notifyListeners(DND.DragSetData,event);
+ } catch (Throwable err) {
+ return 0;
+ }
+
+ if (event.data == null) return 0;
+
+ Transfer transferAgent = null;
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData)){
+ transferAgent = transferAgents[i];
+ break;
+ }
+ }
+ if (transferAgent == null) return 0;
+
+ transferAgent.javaToNative(event.data, transferData);
+ if (transferData.result == 1){
+ OS.memmove(ppValue_return, new int[]{transferData.pValue}, 4);
+ OS.memmove(pType_return, new int[]{transferData.type}, 4);
+ OS.memmove(pLength_return, new int[]{transferData.length}, 4);
+ OS.memmove(pFormat_return, new int[]{transferData.format}, 4);
+ return 1;
+ } else {
+ OS.memmove(ppValue_return, new int[]{0}, 4);
+ OS.memmove(pLength_return, new int[]{0}, 4);
+ OS.memmove(pFormat_return, new int[]{8}, 4);
+ return 0;
+ }
+}
+private void drag() {
+ if (transferAgents == null)
+ return;
+
+ // Current event must be a Button Press event
+ Display display = control.getDisplay ();
+ if (display.xEvent.type != OS.ButtonPress) return;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = display.xEvent.pad2;
+ event.doit = true;
+
+ try {
+ notifyListeners(DND.DragStart, event);
+ } catch (Throwable e) {
+ event.doit = false;
+ }
+
+ if (!event.doit) {
+ int time = display.xEvent.pad2; // corresponds to time field in XButtonEvent
+ int[] args = new int[]{ OS.XmNdragOperations, OS.XmDROP_NOOP};
+ int dc = OS.XmGetDragContext(control.handle, time);
+ if (dc != 0){
+ OS.XtSetValues(dc, args, args.length /2);
+ } else {
+ dc = OS.XmDragStart(this.control.handle, display.xEvent, args, args.length/2);
+ }
+ return;
+ }
+
+ // set the protocol (optional)
+ // not implemented
+
+ // create pixmaps for icons (optional)
+ // not implemented
+
+ // Copy targets to global memory
+ TransferData[] transferData = new TransferData[0];
+ for (int i = 0; i < transferAgents.length; i++){
+ TransferData[] data = transferAgents[i].getSupportedTypes();
+ TransferData[] newTransferData = new TransferData[transferData.length + data.length];
+ System.arraycopy(transferData, 0, newTransferData, 0, transferData.length);
+ System.arraycopy(data, 0, newTransferData, transferData.length, data.length);
+ transferData = newTransferData;
+ }
+ int[] dataTypes = new int[transferData.length];
+ for (int i = 0; i < transferData.length; i++){
+ dataTypes[i] = transferData[i].type;
+ }
+ int pExportTargets = OS.XtMalloc(dataTypes.length * 4);
+ OS.memmove(pExportTargets, dataTypes, dataTypes.length * 4);
+
+ if (convertProc == null)
+ convertProc = new Callback(this, "convertProcCallback", 10);
+ if (convertProc == null) return;
+
+ int[] args = new int[]{
+ OS.XmNexportTargets, pExportTargets,
+ OS.XmNnumExportTargets, dataTypes.length,
+ OS.XmNdragOperations, opToOsOp(getStyle()),
+ OS.XmNconvertProc, convertProc.getAddress(),
+ OS.XmNoperationCursorIcon, 0,
+ OS.XmNsourceCursorIcon, 0,
+ OS.XmNstateCursorIcon, 0,
+ OS.XmNclientData, 0,
+ OS.XmNblendModel, OS.XmBLEND_ALL
+ };
+
+ // look for existing drag contexts
+ int time = display.xEvent.pad2; // corresponds to time field in XButtonEvent
+ dragContext = OS.XmGetDragContext(control.handle, time);
+ if (dragContext != 0){
+ OS.XtSetValues(dragContext, args, args.length /2);
+ } else {
+ dragContext = OS.XmDragStart(this.control.handle, display.xEvent, args, args.length / 2);
+ myDrag = true;
+ }
+ OS.XtFree(pExportTargets);
+ if (dragContext == 0) return;
+
+ // register a call back to clean up when drop is done (optional)
+ if (dragDropFinish == null)
+ dragDropFinish = new Callback(this, "dragDropFinishCallback", 3);
+ OS.XtAddCallback(dragContext, OS.XmNdragDropFinishCallback, dragDropFinish.getAddress(), 0);
+
+ // register a call back to tell user what happened (optional)
+ if (dropFinish == null)
+ dropFinish = new Callback(this, "dropFinishCallback", 3);
+ OS.XtAddCallback(dragContext, OS.XmNdropFinishCallback, dropFinish.getAddress(), 0);
+ return;
+}
+
+private int dragDropFinishCallback(int widget, int client_data, int call_data) {
+
+ // uncomment the following code when we allow users to specify their own source icons
+ // release the pre set source icon
+ //int pSourceIcon = OS.XtMalloc(4);
+ //int[] args = new int[]{OS.XmNsourceCursorIcon, pSourceIcon};
+ //OS.XtGetValues(control.handle, args, args.length / 2);
+ //int[] sourceIcon = new int[1];
+ //OS.memmove(sourceIcon, pSourceIcon, 4);
+ //if (sourceIcon[0] != 0)
+ //OS.XtDestroyWidget(sourceIcon[0]);
+ //OS.XtFree(pSourceIcon);
+
+ dragContext = 0;
+
+ if (convertProc != null)
+ convertProc.dispose();
+ convertProc = null;
+
+ if (dragDropFinish != null)
+ dragDropFinish.dispose();
+ dragDropFinish = null;
+
+ if (dropFinish != null)
+ dropFinish.dispose();
+ dropFinish = null;
+
+ return 0;
+}
+private int dropFinishCallback(int widget, int client_data, int call_data) {
+
+ XmDropFinishCallback data = new XmDropFinishCallback();
+ OS.memmove(data, call_data, XmDropFinishCallback.sizeof);
+
+ if (data.dropAction != OS.XmDROP || data.dropSiteStatus != OS.XmDROP_SITE_VALID) return 0;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this.control;
+ event.time = data.timeStamp;
+ event.detail = osOpToOp(data.operation);
+ event.doit = (data.completionStatus != 0);
+
+ try {
+ notifyListeners(DND.DragEnd,event);
+ } catch (Throwable err) {
+ }
+
+ return 0;
+}
+public Control getControl () {
+ return control;
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+private void onDispose() {
+
+ // Check if there is a drag in progress and cancel it
+ //if (dragContext != 0 && myDrag)
+ // OS.XmDragCancel(dragContext);
+
+ if (convertProc != null)
+ convertProc.dispose();
+ convertProc = null;
+
+ if (dragDropFinish != null)
+ dragDropFinish.dispose();
+ dragDropFinish = null;
+
+ if (dropFinish != null)
+ dropFinish.dispose();
+ dropFinish = null;
+
+ if (control != null && controlListener != null) {
+ control.removeListener(SWT.Dispose, controlListener);
+ control.removeListener(SWT.DragDetect, controlListener);
+ }
+ control = null;
+ controlListener = null;
+ transferAgents = null;
+}
+private byte opToOsOp(int operation){
+ byte osOperation = OS.XmDROP_NOOP;
+
+ if ((operation & DND.DROP_COPY) == DND.DROP_COPY)
+ osOperation |= OS.XmDROP_COPY;
+ if ((operation & DND.DROP_MOVE) == DND.DROP_MOVE)
+ osOperation |= OS.XmDROP_MOVE;
+ if ((operation & DND.DROP_LINK) == DND.DROP_LINK)
+ osOperation |= OS.XmDROP_LINK;
+
+ return osOperation;
+}
+private int osOpToOp(byte osOperation){
+ int operation = DND.DROP_NONE;
+
+ if ((osOperation & OS.XmDROP_COPY) == OS.XmDROP_COPY)
+ operation |= DND.DROP_COPY;
+ if ((osOperation & OS.XmDROP_MOVE) == OS.XmDROP_MOVE)
+ operation |= DND.DROP_MOVE;
+ if ((osOperation & OS.XmDROP_LINK) == OS.XmDROP_LINK)
+ operation |= DND.DROP_LINK;
+
+ return operation;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+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);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java
new file mode 100755
index 0000000000..cdef0449d4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,540 @@
+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.motif.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * 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> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.Drop, DND.DropAccept
+ * </dl>
+ */
+public class DropTarget extends Widget {
+
+ private Callback dropProc;
+ private Callback transferProc;
+ private Callback dragProc;
+
+ // info for registering as a droptarget
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ // info about data being dragged over site
+ private TransferData selectedDataType;
+ private TransferData[] dataTypes;
+ private int dropTransferObject;
+ private XmDropProcCallback droppedEventData;
+
+ private DragUnderEffect effect;
+
+public DropTarget(Control control, int style) {
+
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ dropProc = new Callback(this, "dropProcCallback", 3);
+ if (dropProc == null)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+
+ dragProc = new Callback(this, "dragProcCallback", 3);
+ if (dragProc == null)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP);
+
+ int[] args = new int[]{
+ OS.XmNdropSiteOperations, opToOsOp(style),
+ OS.XmNdropSiteActivity, OS.XmDROP_SITE_ACTIVE,
+ OS.XmNdropProc, dropProc.getAddress(),
+ OS.XmNdragProc, dragProc.getAddress()
+ };
+
+ // the OS may have registered this widget as a drop site on creation.
+ // Remove the registered drop site because it has preconfigured values which we do not want.
+ //OS.XmDropSiteUnregister(control.handle);
+ // Register drop site with our own values
+ OS.XmDropSiteRegister(control.handle, args, args.length / 2);
+
+ 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();
+ }
+ });
+
+ if (control instanceof Tree) {
+ effect = new TreeDragUnderEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragUnderEffect((Table)control);
+ } else {
+ effect = new NoDragUnderEffect(control);
+ }
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragEnter, typedListener);
+ addListener (DND.DragLeave, typedListener);
+ addListener (DND.DragOver, typedListener);
+ addListener (DND.DragOperationChanged, typedListener);
+ addListener (DND.Drop, typedListener);
+ addListener (DND.DropAccept, typedListener);
+
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+private int dragProcCallback(int widget, int client_data, int call_data) {
+
+ XmDragProcCallback callbackData = new XmDragProcCallback();
+ OS.memmove(callbackData, call_data, XmDragProcCallback.sizeof);
+
+ if (callbackData.reason == OS.XmCR_DROP_SITE_ENTER_MESSAGE){
+ releaseDropInfo();
+
+ // get the export targets
+ int ppExportTargets = OS.XtMalloc(4);
+ int pNumExportTargets = OS.XtMalloc(4);
+ int[] args = new int[]{
+ OS.XmNexportTargets, ppExportTargets,
+ OS.XmNnumExportTargets, pNumExportTargets
+ };
+
+ OS.XtGetValues(callbackData.dragContext, args, args.length / 2);
+ int[] numExportTargets = new int[1];
+ OS.memmove(numExportTargets, pNumExportTargets, 4);
+ OS.XtFree(pNumExportTargets);
+ int[] pExportTargets = new int[1];
+ OS.memmove(pExportTargets, ppExportTargets, 4);
+ OS.XtFree(ppExportTargets);
+ int[] exportTargets = new int[numExportTargets[0]];
+ OS.memmove(exportTargets, pExportTargets[0], 4*numExportTargets[0]);
+ //?OS.XtFree(pExportTargets[0]);
+
+ for (int i = 0, length = exportTargets.length; i < length; i++){
+ for (int j = 0, length2 = transferAgents.length; j < length2; j++){
+ TransferData transferData = new TransferData();
+ transferData.type = exportTargets[i];
+ if (transferAgents[j].isSupportedType(transferData)) {
+ TransferData[] newDataTypes = new TransferData[dataTypes.length + 1];
+ System.arraycopy(dataTypes, 0, newDataTypes, 0, dataTypes.length);
+ newDataTypes[dataTypes.length] = transferData;
+ dataTypes = newDataTypes;
+ break;
+ }
+ }
+ }
+ }
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this.control;
+ event.time = callbackData.timeStamp;
+ short [] root_x = new short [1];
+ short [] root_y = new short [1];
+ OS.XtTranslateCoords (this.control.handle, (short) callbackData.x, (short) callbackData.y, root_x, root_y);
+ event.x = root_x[0];
+ event.y = root_y[0];
+ event.dataTypes = dataTypes;
+ event.feedback = DND.FEEDBACK_SELECT;
+ event.operations = osOpToOp(callbackData.operations);
+ event.dataType = selectedDataType;
+ event.detail = osOpToOp(callbackData.operation);
+
+ try {
+ switch (callbackData.reason) {
+ case OS.XmCR_DROP_SITE_ENTER_MESSAGE :
+ if (dataTypes.length > 0) {
+ event.dataType = dataTypes[0];
+ }
+ notifyListeners(DND.DragEnter, event);
+ effect.show(event.feedback, event.x, event.y);
+ break;
+
+ case OS.XmCR_DROP_SITE_MOTION_MESSAGE :
+ notifyListeners(DND.DragOver, event);
+ effect.show(event.feedback, event.x, event.y);
+ break;
+ case OS.XmCR_OPERATION_CHANGED :
+ notifyListeners(DND.DragOperationChanged, event);
+ effect.show(event.feedback, event.x, event.y);
+ break;
+ case OS.XmCR_DROP_SITE_LEAVE_MESSAGE :
+ event.detail = DND.DROP_NONE;
+ notifyListeners(DND.DragLeave, event);
+ effect.show(DND.FEEDBACK_NONE, 0, 0);
+ return 0;
+ }
+ } catch (Throwable err) {
+ callbackData.dropSiteStatus = OS.XmDROP_SITE_INVALID;
+ callbackData.operation = opToOsOp(DND.DROP_NONE);
+ OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof);
+ return 0;
+ }
+
+ selectedDataType = null;
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (dataTypes[i].equals(event.dataType)) {
+ selectedDataType = event.dataType;
+ break;
+ }
+ }
+ int lastOperation = DND.DROP_NONE;
+ if (selectedDataType != null && ((event.detail & osOpToOp(callbackData.operations)) == event.detail)) {
+ lastOperation = event.detail;
+ }
+
+ callbackData.dropSiteStatus = OS.XmDROP_SITE_VALID;
+ callbackData.operation = opToOsOp(lastOperation);
+ OS.memmove(call_data, callbackData, XmDragProcCallback.sizeof);
+
+ return 0;
+}
+private int dropProcCallback(int widget, int client_data, int call_data) {
+
+ effect.show(DND.FEEDBACK_NONE, 0, 0);
+
+ droppedEventData = new XmDropProcCallback();
+ OS.memmove(droppedEventData, call_data, XmDropProcCallback.sizeof);
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this.control;
+ event.time = droppedEventData.timeStamp;
+ short [] root_x = new short [1];
+ short [] root_y = new short [1];
+ OS.XtTranslateCoords (this.control.handle, (short) droppedEventData.x, (short) droppedEventData.y, root_x, root_y);
+ event.x = root_x[0];
+ event.y = root_y[0];
+ event.dataTypes = dataTypes;
+ event.operations = osOpToOp(droppedEventData.operations);
+ event.dataType = selectedDataType;
+ event.detail = osOpToOp(droppedEventData.operation);
+
+ try {
+ notifyListeners(DND.DropAccept,event);
+ } catch (Throwable err) {
+ event.detail = DND.DROP_NONE;
+ event.dataType = null;
+ }
+
+ selectedDataType = null;
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (dataTypes[i].equals(event.dataType)) {
+ selectedDataType = event.dataType;
+ break;
+ }
+ }
+ int lastOperation = DND.DROP_NONE;
+ if (selectedDataType != null && ((event.detail & osOpToOp(droppedEventData.operations)) == event.detail)) {
+ lastOperation = event.detail;
+ }
+
+ if (lastOperation == DND.DROP_NONE) {
+ // this was not a successful drop
+ int[] args = new int[] {OS.XmNtransferStatus, OS.XmTRANSFER_FAILURE,
+ OS.XmNnumDropTransfers, 0};
+ dropTransferObject = OS.XmDropTransferStart(droppedEventData.dragContext, args, args.length / 2);
+ return 0;
+ }
+
+ // ask drag source for dropped data
+ int[] transferEntries = new int[2];
+ transferEntries[0] = 0;
+ transferEntries[1] = selectedDataType.type;
+
+ int pTransferEntries = OS.XtMalloc(transferEntries.length * 4);
+ OS.memmove(pTransferEntries, transferEntries, transferEntries.length * 4);
+ if (transferProc == null)
+ transferProc = new Callback(this, "transferProcCallback", 7);
+
+ if (transferProc != null){
+ int[] args = new int[] {OS.XmNdropTransfers, pTransferEntries,
+ OS.XmNnumDropTransfers, transferEntries.length / 2,
+ OS.XmNtransferProc, transferProc.getAddress()};
+
+ dropTransferObject = OS.XmDropTransferStart(droppedEventData.dragContext, args, args.length / 2);
+ OS.XtFree(pTransferEntries);
+ }
+
+ return 0;
+}
+/**
+ * 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;
+}
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+/**
+ * Returns the list of data types that can be transferred to this DropTarget.
+ *
+ * @return the list of data types that can be transferred to this DropTarget
+ *
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+public void notifyListeners (int eventType, Event event) {
+ Point coordinates = new Point(event.x, event.y);
+ coordinates = control.toControl(coordinates);
+ if (this.control instanceof Tree) {
+ event.item = ((Tree)control).getItem(coordinates);
+ }
+ if (this.control instanceof Table) {
+ event.item = ((Table)control).getItem(coordinates);
+ }
+ super.notifyListeners(eventType, event);
+}
+private void onDispose() {
+
+ if (dropProc != null)
+ dropProc.dispose();
+ dropProc = null;
+
+ if (transferProc != null)
+ transferProc.dispose();
+ transferProc = null;
+
+ if (dragProc != null)
+ dragProc.dispose();
+ dragProc = null;
+ //if (control != null && !control.isDisposed()){
+ // OS.XmDropSiteUnregister(control.handle);
+ //}
+ if (controlListener != null) {
+ control.removeListener(SWT.Dispose, controlListener);
+ }
+ controlListener = null;
+ control = null;
+ transferAgents = null;
+}
+private byte opToOsOp(int operation){
+ byte osOperation = OS.XmDROP_NOOP;
+
+ if ((operation & DND.DROP_COPY) == DND.DROP_COPY)
+ osOperation |= OS.XmDROP_COPY;
+ if ((operation & DND.DROP_MOVE) == DND.DROP_MOVE)
+ osOperation |= OS.XmDROP_MOVE;
+ if ((operation & DND.DROP_LINK) == DND.DROP_LINK)
+ osOperation |= OS.XmDROP_LINK;
+
+ return osOperation;
+}
+private int osOpToOp(byte osOperation){
+ int operation = DND.DROP_NONE;
+
+ if ((osOperation & OS.XmDROP_COPY) == OS.XmDROP_COPY)
+ operation |= DND.DROP_COPY;
+ if ((osOperation & OS.XmDROP_MOVE) == OS.XmDROP_MOVE)
+ operation |= DND.DROP_MOVE;
+ if ((osOperation & OS.XmDROP_LINK) == OS.XmDROP_LINK)
+ operation |= DND.DROP_LINK;
+
+ return operation;
+}
+private void releaseDropInfo(){
+ selectedDataType = null;
+ dataTypes = new TransferData[0];
+ droppedEventData = null;
+ dropTransferObject = 0;
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+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);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+
+ // register data types
+ TransferData[] transferData = new TransferData[0];
+ for (int i = 0, length = transferAgents.length; i < length; i++){
+ TransferData[] data = transferAgents[i].getSupportedTypes();
+ TransferData[] newTransferData = new TransferData[transferData.length + data.length];
+ System.arraycopy(transferData, 0, newTransferData, 0, transferData.length);
+ System.arraycopy(data, 0, newTransferData, transferData.length, data.length);
+ transferData = newTransferData;
+ }
+
+ int[] atoms = new int[transferData.length];
+ for (int i = 0, length = transferData.length; i < length; i++){
+ atoms[i] = transferData[i].type;
+ }
+
+ // Copy import targets to global memory
+ int pImportTargets = OS.XtMalloc(atoms.length * 4);
+ OS.memmove(pImportTargets, atoms, atoms.length * 4);
+
+ int[] args = new int[]{
+ OS.XmNimportTargets, pImportTargets,
+ OS.XmNnumImportTargets, atoms.length
+ };
+
+ OS.XmDropSiteUpdate(control.handle, args, args.length / 2);
+
+ OS.XtFree(pImportTargets);
+
+}
+private int transferProcCallback(int widget, int client_data, int pSelection, int pType, int pValue, int pLength, int pFormat) {
+
+ int[] type = new int[1];
+ OS.memmove(type, pType, 4);
+
+ // get dropped data object
+ Transfer transferAgent = null;
+ TransferData transferData = new TransferData();
+ transferData.type = type[0];
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData)){
+ transferAgent = transferAgents[i];
+ break;
+ }
+ }
+ if (transferAgent != null) {
+ transferData.pValue = pValue;
+ int[] length = new int[1];
+ OS.memmove(length, pLength, 4);
+ transferData.length = length[0];
+ int[] format = new int[1];
+ OS.memmove(format, pFormat, 4);
+ transferData.format = format[0];
+ Object data = transferAgent.nativeToJava(transferData);
+
+ OS.XtFree(transferData.pValue); //?? Should we be freeing this, and what about the other memory?
+
+ // notify listeners of drop
+ DNDEvent event = new DNDEvent();
+ event.widget = this.control;
+ event.time = droppedEventData.timeStamp;
+ short [] root_x = new short [1];
+ short [] root_y = new short [1];
+ OS.XtTranslateCoords (this.control.handle, (short) droppedEventData.x, (short) droppedEventData.y, root_x, root_y);
+ event.x = root_x[0];
+ event.y = root_y[0];
+ event.dataTypes = dataTypes;
+ event.operations = osOpToOp(droppedEventData.operations);
+ event.dataType = transferData;
+ event.detail = osOpToOp(droppedEventData.operation);
+ event.data = data;
+
+ try {
+ notifyListeners(DND.Drop,event);
+ } catch (Throwable err) {
+ event.detail = DND.DROP_NONE;
+ }
+
+ if ((event.detail & DND.DROP_MOVE) == DND.DROP_MOVE) {
+ OS.XmDropTransferAdd(dropTransferObject, new int[]{0, Transfer.registerType("DELETE\0")}, 1);
+ }
+ }
+
+ return 0;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100755
index 0000000000..8b70854312
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list\0";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+public static FileTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative(Object object, TransferData transferData) {
+
+ if (object == null || !(object instanceof String[])) return;
+
+ // build a byte array from data
+ String[] files = (String[])object;
+
+ // create a string separated by "new lines" to represent list of files
+ String nativeFormat = "file:";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += files[i]+"\r";
+ }
+ nativeFormat += "\0";
+ // pass byte array on to super to convert to native
+ super.javaToNative(nativeFormat.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ String string = new String(data);
+ // parse data and convert string to array of files
+ int start = string.indexOf("file:");
+ if (start == -1) return null;
+ start += 5;
+ String[] fileNames = new String[0];
+ while (start < string.length()) {
+ int end = string.indexOf("\r", start);
+ if (end == -1) end = string.length() - 1;
+
+ String fileName = string.substring(start, end);
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+
+ start = string.indexOf("file:", end);
+ if (start == -1) break;
+ start += 5;
+ }
+ return fileNames;
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100755
index 0000000000..af09aac900
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100755
index 0000000000..231db14dc3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,63 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.setSelection(new TableItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ TableItem item = table.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = table.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = table.toControl(coordinates);
+ item = table.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ if (item == null) {
+ table.setSelection(new TableItem[0]);
+ } else {
+ table.setSelection(new TableItem[] {item});
+ }
+ currentItem = item;
+ }
+ currentEffect = effect;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100755
index 0000000000..12afd23a9d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "STRING\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "text/plain\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "text/text\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private TextTransfer() {
+}
+public static TextTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
new file mode 100755
index 0000000000..98f63bd8bc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.motif.OS;
+import org.eclipse.swt.widgets.Display;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class Transfer {
+abstract public TransferData[] getSupportedTypes();
+abstract public boolean isSupportedType(TransferData transferData);
+abstract protected String[] getTypeNames();
+abstract protected int[] getTypeIds();
+abstract protected void javaToNative (Object object, TransferData transferData);
+abstract protected Object nativeToJava(TransferData transferData);
+public static int registerType(String formatName){
+
+ int xDisplay = Display.getDefault().xDisplay; // using default because we don't have a particular widget
+ byte[] bName = Converter.wcsToMbcs (null, formatName, false);
+ int atom = OS.XmInternAtom (xDisplay, bName, false);
+ return atom;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java
new file mode 100755
index 0000000000..a73cc97090
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TransferData {
+ public int type;
+
+ // attributes specific to set/get
+ int length;
+ int format;
+ int pValue;
+
+ int result;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100755
index 0000000000..e0babbfe6f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/motif/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,100 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = tree.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = tree.toControl(coordinates);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ tree.setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ tree.setInsertMark(item, effect == DND.FEEDBACK_INSERT_BEFORE);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ tree.setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ if (item == null) {
+ tree.setSelection(new TreeItem[0]);
+ } else {
+ tree.setSelection(new TreeItem[]{item});
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100755
index 0000000000..ec66fefb22
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+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){
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ if (transferData.type == types[i]) return true;
+ }
+ return false;
+}
+protected void javaToNative (Object object, TransferData transferData){
+ if ((object == null) || !(object instanceof byte[]) || !(isSupportedType(transferData))) {
+ transferData.result = 0;
+ return;
+ }
+ byte[] buffer = (byte[])object;
+// transferData.pValue = OS.XtMalloc(buffer.length + 1);
+// OS.memmove(transferData.pValue, buffer, buffer.length);
+ transferData.length = buffer.length;
+ transferData.format = 8;
+ transferData.result = 1;
+}
+protected Object nativeToJava(TransferData transferData){
+
+ if (transferData.pValue == 0 || !(isSupportedType(transferData))) return null;
+
+ int size = transferData.format * transferData.length / 8;
+ byte[] buffer = new byte[size];
+// OS.memmove(buffer, transferData.pValue, size);
+ return buffer;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
new file mode 100755
index 0000000000..a51be325c3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,94 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/*
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ */
+public class Clipboard {
+
+ private Display display;
+ private final int MAX_RETRIES = 10;
+ private int shellHandle;
+
+
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ this.display = display;
+
+// int widgetClass = OS.TopLevelShellWidgetClass ();
+// shellHandle = OS.XtAppCreateShell (null, null, widgetClass, display.xDisplay, null, 0);
+// OS.XtSetMappedWhenManaged (shellHandle, false);
+// OS.XtRealizeWidget (shellHandle);
+}
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+public void dispose () {
+// if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+// shellHandle = 0;
+ display = null;
+}
+public Object getContents(Transfer transfer) {
+ if (display.isDisposed() ) return null;
+ return null;
+}
+public void setContents(Object[] data, Transfer[] transferAgents){
+}
+/*
+ * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should
+ * NOT be used within an application because it provides platform specfic
+ * information.
+ */
+public String[] getAvailableTypeNames() {
+ int[] count = new int[1];
+ int[] max_length = new int[1];
+// int xDisplay = OS.XtDisplay (shellHandle);
+// if (xDisplay == 0)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// int xWindow = OS.XtWindow (shellHandle);
+// if (xWindow == 0)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// if (OS.XmClipboardInquireCount(xDisplay, xWindow, count, max_length) != OS.XmClipboardSuccess)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+ String[] types = new String[count[0]];
+// for (int i = 0; i < count[0]; i++) {
+// byte[] buffer = new byte[max_length[0]];
+// int[] copied_length = new int[1];
+// int rc = OS.XmClipboardInquireFormat(xDisplay, xWindow, i + 1, buffer, buffer.length, copied_length);
+// if (rc == OS.XmClipboardNoData){
+// types[i] = "";
+// continue;
+// }
+// if (rc != OS.XmClipboardSuccess)
+// DND.error(SWT.ERROR_UNSPECIFIED);
+// byte[] buffer2 = new byte[copied_length[0]];
+// System.arraycopy(buffer, 0, buffer2, 0, copied_length[0]);
+// types[i] = new String(buffer2);
+// }
+ return types;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
new file mode 100755
index 0000000000..ace4bd062c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,196 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * Class <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class defines the following items:<ul>
+ * <li>the <code>Control</code> that the user clicks on to intiate a drag;
+ * <li>the data that will be transferred on a successful drop;
+ * <li>and the modes (move, copy, link) of transfer that are allowed.
+ * </ul></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
+ * but it can also 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 interface
+ * <code>DragSourceListener</code> which uses the class <code>DragSourceEvent</code>.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.</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> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnd, DND.DragSetData
+ * </dl>
+ */
+public class DragSource extends Widget {
+
+ private Callback convertProc;
+ private Callback dragDropFinish;
+ private Callback dropFinish;
+
+ // info for registering as a drag source
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private boolean myDrag;
+
+ int dragContext;
+
+public DragSource(Control control, int style) {
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ 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){
+// DragSource.this.drag();
+ }
+
+ }
+ };
+ this.control.addListener (SWT.Dispose, controlListener);
+ this.control.addListener (SWT.DragDetect, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+// onDispose();
+ }
+ });
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragStart, typedListener);
+ addListener (DND.DragSetData, typedListener);
+ addListener (DND.DragEnd, typedListener);
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
+
+
+
+
+public Control getControl () {
+ return control;
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+
+
+
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+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);
+}
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
new file mode 100755
index 0000000000..f5184be09b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,214 @@
+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.photon.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ *
+ * 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> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.Drop, DND.DropAccept
+ * </dl>
+ */
+public class DropTarget extends Widget {
+
+ private Callback dropProc;
+ private Callback transferProc;
+ private Callback dragProc;
+
+ // info for registering as a droptarget
+ private Control control;
+ private Listener controlListener;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ // info about data being dragged over site
+ private TransferData selectedDataType;
+ private TransferData[] dataTypes;
+ private int dropTransferObject;
+
+ private DragUnderEffect effect;
+
+public DropTarget(Control control, int style) {
+
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ 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();
+ }
+ });
+
+ if (control instanceof Tree) {
+ effect = new TreeDragUnderEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragUnderEffect((Table)control);
+ } else {
+ effect = new NoDragUnderEffect(control);
+ }
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragEnter, typedListener);
+ addListener (DND.DragLeave, typedListener);
+ addListener (DND.DragOver, typedListener);
+ addListener (DND.DragOperationChanged, typedListener);
+ addListener (DND.Drop, typedListener);
+ addListener (DND.DropAccept, typedListener);
+
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+
+
+/**
+ * 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;
+}
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+/**
+ * Returns the list of data types that can be transferred to this DropTarget.
+ *
+ * @return the list of data types that can be transferred to this DropTarget
+ *
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+public void notifyListeners (int eventType, Event event) {
+ Point coordinates = new Point(event.x, event.y);
+ coordinates = control.toControl(coordinates);
+ if (this.control instanceof Tree) {
+ event.item = ((Tree)control).getItem(coordinates);
+ }
+ if (this.control instanceof Table) {
+ event.item = ((Table)control).getItem(coordinates);
+ }
+ super.notifyListeners(eventType, event);
+}
+
+
+
+
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+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);
+}
+public void setTransfer(Transfer[] transferAgents){
+}
+
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100755
index 0000000000..8b70854312
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+ private static final String TYPENAME = "text/uri-list\0";
+ private static final int TYPEID = registerType(TYPENAME);
+
+private FileTransfer() {}
+public static FileTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative(Object object, TransferData transferData) {
+
+ if (object == null || !(object instanceof String[])) return;
+
+ // build a byte array from data
+ String[] files = (String[])object;
+
+ // create a string separated by "new lines" to represent list of files
+ String nativeFormat = "file:";
+ for (int i = 0, length = files.length; i < length; i++){
+ nativeFormat += files[i]+"\r";
+ }
+ nativeFormat += "\0";
+ // pass byte array on to super to convert to native
+ super.javaToNative(nativeFormat.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData) {
+
+ byte[] data = (byte[])super.nativeToJava(transferData);
+ if (data == null) return null;
+ String string = new String(data);
+ // parse data and convert string to array of files
+ int start = string.indexOf("file:");
+ if (start == -1) return null;
+ start += 5;
+ String[] fileNames = new String[0];
+ while (start < string.length()) {
+ int end = string.indexOf("\r", start);
+ if (end == -1) end = string.length() - 1;
+
+ String fileName = string.substring(start, end);
+ String[] newFileNames = new String[fileNames.length + 1];
+ System.arraycopy(fileNames, 0, newFileNames, 0, fileNames.length);
+ newFileNames[fileNames.length] = fileName;
+ fileNames = newFileNames;
+
+ start = string.indexOf("file:", end);
+ if (start == -1) break;
+ start += 5;
+ }
+ return fileNames;
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100755
index 0000000000..af09aac900
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static RTFTransfer _instance = new RTFTransfer();
+ private static final String TYPENAME1 = "text/rtf\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "TEXT/RTF\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "application/rtf\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private RTFTransfer() {
+}
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100755
index 0000000000..231db14dc3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,63 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+ private TableItem[] selection = new TableItem[0];
+ private int currentEffect = DND.FEEDBACK_NONE;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = table.getSelection();
+ table.setSelection(new TableItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ table.setSelection(selection);
+ selection = new TableItem[0];
+ }
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ TableItem item = table.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = table.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = table.toControl(coordinates);
+ item = table.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ if (item == null) {
+ table.setSelection(new TableItem[0]);
+ } else {
+ table.setSelection(new TableItem[] {item});
+ }
+ currentItem = item;
+ }
+ currentEffect = effect;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100755
index 0000000000..12afd23a9d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+ private static final String TYPENAME1 = "STRING\0";
+ private static final int TYPEID1 = registerType(TYPENAME1);
+ private static final String TYPENAME2 = "text/plain\0";
+ private static final int TYPEID2 = registerType(TYPENAME2);
+ private static final String TYPENAME3 = "text/text\0";
+ private static final int TYPEID3 = registerType(TYPENAME3);
+
+private TextTransfer() {
+}
+public static TextTransfer getInstance () {
+ return _instance;
+}
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ String text = (String)object;
+ super.javaToNative(text.getBytes(), transferData);
+}
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ return new String(buffer);
+}
+protected String[] getTypeNames(){
+ return new String[]{TYPENAME1, TYPENAME2, TYPENAME3};
+}
+protected int[] getTypeIds(){
+ return new int[]{TYPEID1, TYPEID2, TYPEID3};
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
new file mode 100755
index 0000000000..be1aee9ab1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class Transfer {
+abstract public TransferData[] getSupportedTypes();
+abstract public boolean isSupportedType(TransferData transferData);
+abstract protected String[] getTypeNames();
+abstract protected int[] getTypeIds();
+abstract protected void javaToNative (Object object, TransferData transferData);
+abstract protected Object nativeToJava(TransferData transferData);
+public static int registerType(String formatName){
+ return 0;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
new file mode 100755
index 0000000000..a73cc97090
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TransferData {
+ public int type;
+
+ // attributes specific to set/get
+ int length;
+ int format;
+ int pValue;
+
+ int result;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100755
index 0000000000..f78887e054
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/photon/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,102 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = null;
+ if (effect != DND.FEEDBACK_NONE) item = findItem(x, y);
+ if (item == null) effect = DND.FEEDBACK_NONE;
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ tree.setSelection(selection);
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = tree.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = tree.toControl(coordinates);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setInsertMark(item, effect == DND.FEEDBACK_INSERT_AFTER);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ if (item == null) {
+ tree.setSelection(new TreeItem[0]);
+ } else {
+ tree.setSelection(new TreeItem[]{item});
+ }
+}
+private void setInsertMark (TreeItem item, boolean after) {
+ // not currently implemented
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java
new file mode 100755
index 0000000000..8f819f1abe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/ByteArrayTransfer.java
@@ -0,0 +1,130 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * The class <code>ByteArrayTransfer</code> provides a platform specific mechanism for transforming
+ * a Java array of bytes into a format that can be passed around in a Drag and Drop operation and vice
+ * versa.
+ *
+ * <p>This abstract class can be subclassed to provided utilities for transforming Java data types
+ * into the byte array based platform specific drag and drop data types. See TextTransfer and
+ * FileTransfer for examples. If the data you are transferring <b>does not</b> map to a byte array,
+ * you should sub-class Transfer directly and do your own mapping to the platform data types.</p>
+ *
+ */
+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];
+ data[i].formatetc = new FORMATETC();
+ data[i].formatetc.cfFormat = types[i];
+ data[i].formatetc.dwAspect = COM.DVASPECT_CONTENT;
+ data[i].formatetc.lindex = -1;
+ data[i].formatetc.tymed = COM.TYMED_HGLOBAL;
+ }
+
+ return data;
+}
+public boolean isSupportedType(TransferData transferData){
+
+ int[] types = getTypeIds();
+ for (int i = 0; i < types.length; i++) {
+ FORMATETC format = transferData.formatetc;
+ if (format.cfFormat == types[i] &&
+ (format.dwAspect & COM.DVASPECT_CONTENT) == COM.DVASPECT_CONTENT &&
+ (format.tymed & COM.TYMED_HGLOBAL) == COM.TYMED_HGLOBAL )
+ return true;
+ }
+ return false;
+}
+/**
+ *
+ * Converts a Java byte array to a platform specific representation of the byte array.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set to COM.S_OK.
+ * If this transfer agent is unable to perform the conversion, the transferData.result field
+ * will be set to the failure value of COM.DV_E_TYMED.</p>
+ *
+ * @param object a Java byte array containing the data to be transferred
+ *
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ *
+ */
+protected void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof byte[])) {
+ transferData.result = COM.E_FAIL;
+ return;
+ }
+
+ byte[] data = (byte[])object;
+
+ if (isSupportedType(transferData)) {
+ // Allocate the memory because the caller (DropTarget) has not handed it in
+ // The caller of this method must release the data when it is done with it.
+ int size = data.length;
+ int newPtr = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, size);
+ OS.MoveMemory(newPtr, data, size);
+
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.stgmedium.tymed = COM.TYMED_HGLOBAL;
+ transferData.stgmedium.unionField = newPtr;
+ transferData.stgmedium.pUnkForRelease = 0;
+ transferData.result = COM.S_OK;
+ return;
+ }
+
+ // did not match the TYMED
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.result = COM.DV_E_TYMED;
+}
+/**
+ *
+ * Converts a platform specific representation of a byte array to a Java byte array.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ *
+ * @return a Java byte array containing the transferred data if the conversion was successful; otherwise null
+ *
+ */
+protected Object nativeToJava(TransferData transferData){
+
+ if (!isSupportedType(transferData) || transferData.pIDataObject == 0) {
+ transferData.result = COM.E_FAIL;
+ return null;
+ }
+
+ IDataObject data = new IDataObject(transferData.pIDataObject);
+ data.AddRef();
+
+ FORMATETC formatetc = transferData.formatetc;
+
+ STGMEDIUM stgmedium = new STGMEDIUM();
+ stgmedium.tymed = COM.TYMED_HGLOBAL;
+ transferData.result = data.GetData(formatetc, stgmedium);
+ data.Release();
+
+ if (transferData.result != COM.S_OK) {
+ return null;
+ }
+
+ int size = OS.GlobalSize(stgmedium.unionField);
+ byte[] buffer = new byte[size];
+ int ptr = OS.GlobalLock(stgmedium.unionField);
+ OS.MoveMemory(buffer, ptr, size);
+ OS.GlobalUnlock(ptr);
+ OS.GlobalFree(stgmedium.unionField);
+
+ return buffer;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
new file mode 100755
index 0000000000..98310a4ba1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Clipboard.java
@@ -0,0 +1,357 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.widgets.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/*
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ */
+public class Clipboard {
+
+ // ole interfaces
+ private COMObject iUnknown;
+ private COMObject iDataObject;
+ private int refCount;
+
+ private final int MAX_RETRIES = 10;
+ private Transfer[] transferAgents = new Transfer[0];
+ private Object[] data = new Object[0];
+
+public Clipboard(Display display) {
+ checkSubclass ();
+ if (display == null) {
+ display = Display.getCurrent();
+ if (display == null) {
+ display = Display.getDefault();
+ }
+ }
+ if (display.getThread() != Thread.currentThread()) {
+ SWT.error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+
+ createCOMInterfaces();
+ this.AddRef();
+}
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = Clipboard.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+public void dispose () {
+ this.Release();
+}
+public Object getContents(Transfer transfer) {
+ int[] ppv = new int[1];
+ int retrys = 0;
+ while ((COM.OleGetClipboard(ppv) != COM.S_OK) && retrys < MAX_RETRIES) {
+ retrys++;
+ }
+ if (retrys == MAX_RETRIES) return null;
+
+ IDataObject dataObject = new IDataObject(ppv[0]);
+
+ TransferData[] allowed = transfer.getSupportedTypes();
+ TransferData match = null;
+ for (int i = 0; i < allowed.length; i++) {
+ if (dataObject.QueryGetData(allowed[i].formatetc) == COM.S_OK) {
+ match = allowed[i];
+ break;
+ }
+ }
+ if (match == null) return null;
+
+ match.pIDataObject = ppv[0];
+ return transfer.nativeToJava(match);
+}
+public void setContents(Object[] data, Transfer[] dataTypes){
+
+ boolean current = (COM.OleIsCurrentClipboard(this.iDataObject.getAddress()) == COM.S_OK);
+
+ if (data == null || dataTypes == null || data.length != dataTypes.length) {
+ DND.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ this.data = data;
+ this.transferAgents = dataTypes;
+
+ int retries = 0;
+ int result = 0;
+ while ((result = COM.OleSetClipboard(this.iDataObject.getAddress())) != COM.S_OK && retries < MAX_RETRIES){
+ retries++;
+ }
+ if (retries == MAX_RETRIES) {
+ DND.error(DND.ERROR_CANNOT_SET_CLIPBOARD, result);
+ }
+
+ if (COM.OleIsCurrentClipboard(this.iDataObject.getAddress()) != COM.S_OK) return;
+
+ retries = 0;
+ while ((COM.OleFlushClipboard() != COM.S_OK) && (retries < MAX_RETRIES)) {
+ retries++;
+ }
+
+ this.data = new Object[0];
+ this.transferAgents = new Transfer[0];
+}
+private int AddRef() {
+ refCount++;
+ return refCount;
+}
+private void createCOMInterfaces() {
+ // register each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+ iDataObject = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 2, 3, 2, 4, 1, 1}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return GetData(args[0], args[1]);}
+ // method4 GetDataHere - not implemented
+ public int method5(int[] args) {return QueryGetData(args[0]);}
+ // method6 GetCanonicalFormatEtc - not implemented
+ // method7 SetData - not implemented
+ public int method8(int[] args) {return EnumFormatEtc(args[0], args[1]);}
+ // method9 DAdvise - not implemented
+ // method10 DUnadvise - not implemented
+ // method11 EnumDAdvise - not implemented
+ };
+}
+private void disposeCOMInterfaces() {
+ if (iUnknown != null)
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iDataObject != null)
+ iDataObject.dispose();
+ iDataObject = null;
+}
+private int EnumFormatEtc(int dwDirection, int ppenumFormatetc) {
+ // only allow getting of data - SetData is not currently supported
+ if (dwDirection == COM.DATADIR_SET) return COM.E_NOTIMPL;
+
+ // what types have been registered?
+ TransferData[] allowedDataTypes = new TransferData[0];
+ for (int i = 0; i < transferAgents.length; i++){
+ TransferData[] formats = transferAgents[i].getSupportedTypes();
+ TransferData[] newAllowedDataTypes = new TransferData[allowedDataTypes.length + formats.length];
+ System.arraycopy(allowedDataTypes, 0, newAllowedDataTypes, 0, allowedDataTypes.length);
+ System.arraycopy(formats, 0, newAllowedDataTypes, allowedDataTypes.length, formats.length);
+ allowedDataTypes = newAllowedDataTypes;
+ }
+
+ OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC();
+ enumFORMATETC.AddRef();
+
+ FORMATETC[] formats = new FORMATETC[allowedDataTypes.length];
+ for (int i = 0; i < formats.length; i++){
+ formats[i] = allowedDataTypes[i].formatetc;
+ }
+ enumFORMATETC.setFormats(formats);
+
+ COM.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4);
+ return COM.S_OK;
+}
+private int GetData(int pFormatetc, int pmedium) {
+ /* Called by a data consumer to obtain data from a source data object.
+ The GetData method renders the data described in the specified FORMATETC
+ structure and transfers it through the specified STGMEDIUM structure.
+ The caller then assumes responsibility for releasing the STGMEDIUM structure.
+ */
+ if (pFormatetc == 0 || pmedium == 0) return COM.E_INVALIDARG;
+
+ if (QueryGetData(pFormatetc) != COM.S_OK) return COM.DV_E_FORMATETC;
+
+ TransferData transferData = new TransferData();
+ transferData.formatetc = new FORMATETC();
+ COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof);
+ transferData.type = transferData.formatetc.cfFormat;
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.result = COM.E_FAIL;
+
+ // get matching transfer agent to perform conversion
+ int transferIndex = -1;
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData)){
+ transferIndex = i;
+ break;
+ }
+ }
+ if (transferIndex == -1) return COM.DV_E_FORMATETC;
+
+ transferAgents[transferIndex].javaToNative(data[transferIndex], transferData);
+ COM.MoveMemory(pmedium, transferData.stgmedium, STGMEDIUM.sizeof);
+ return transferData.result;
+}
+private int QueryGetData(int pFormatetc) {
+
+ if (transferAgents == null) return COM.E_FAIL;
+
+ TransferData transferData = new TransferData();
+ transferData.formatetc = new FORMATETC();
+ COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof);
+ transferData.type = transferData.formatetc.cfFormat;
+
+ // is this type supported by the transfer agent?
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData))
+ return COM.S_OK;
+ }
+
+ return COM.DV_E_FORMATETC;
+}
+private int QueryInterface(int riid, int ppvObject) {
+
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ if (COM.IsEqualGUID(guid, COM.IIDIDataObject) ) {
+ COM.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+private int Release() {
+ refCount--;
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ COM.CoFreeUnusedLibraries();
+ }
+
+ return refCount;
+}
+
+/*
+ * Note: getAvailableTypeNames is a tool for writing a Transfer sub-class only. It should
+ * NOT be used within an application because it provides platform specfic
+ * information.
+ */
+public String[] getAvailableTypeNames() {
+ int[] ppv = new int[1];
+ int retrys = 0;
+ while ((COM.OleGetClipboard(ppv) != COM.S_OK) && retrys < MAX_RETRIES) {
+ retrys++;
+ }
+ if (retrys == MAX_RETRIES) return null;
+
+ IDataObject dataObject = new IDataObject(ppv[0]);
+
+ int[] ppFormatetc = new int[1];
+ int rc = dataObject.EnumFormatEtc(COM.DATADIR_GET, ppFormatetc);
+ dataObject.Release();
+ if (rc != COM.S_OK)
+ DND.error(SWT.ERROR_UNSPECIFIED);
+
+ IEnumFORMATETC enum = new IEnumFORMATETC(ppFormatetc[0]);
+
+ // Loop over enumerator and save any types that match what we are looking for
+ int rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, FORMATETC.sizeof);
+ int[] pceltFetched = new int[1];
+ enum.Reset();
+ String[] types = new String[0];
+ while (enum.Next(1, rgelt, pceltFetched) == COM.S_OK && pceltFetched[0] == 1) {
+ FORMATETC formatetc = new FORMATETC();
+ COM.MoveMemory(formatetc, rgelt, FORMATETC.sizeof);
+ int maxSize = 128;
+ byte[] buffer = new byte[maxSize];
+ int size = COM.GetClipboardFormatName(formatetc.cfFormat, buffer, maxSize);
+ String type = null;
+ if (size == 0) {
+ switch (formatetc.cfFormat) {
+ case COM.CF_HDROP:
+ type = "CF_HDROP";
+ break;
+ case COM.CF_TEXT:
+ type = "CF_TEXT";
+ break;
+ case COM.CF_BITMAP:
+ type = "CF_BITMAP";
+ break;
+ case COM.CF_METAFILEPICT:
+ type = "CF_METAFILEPICT";
+ break;
+ case COM.CF_SYLK:
+ type = "CF_SYLK";
+ break;
+ case COM.CF_DIF:
+ type = "CF_DIF";
+ break;
+ case COM.CF_TIFF:
+ type = "CF_TIFF";
+ break;
+ case COM.CF_OEMTEXT:
+ type = "CF_OEMTEXT";
+ break;
+ case COM.CF_DIB:
+ type = "CF_DIB";
+ break;
+ case COM.CF_PALETTE:
+ type = "CF_PALETTE";
+ break;
+ case COM.CF_PENDATA:
+ type = "CF_PENDATA";
+ break;
+ case COM.CF_RIFF:
+ type = "CF_RIFF";
+ break;
+ case COM.CF_WAVE:
+ type = "CF_WAVE";
+ break;
+ case COM.CF_UNICODETEXT:
+ type = "CF_UNICODETEXT";
+ break;
+ case COM.CF_ENHMETAFILE:
+ type = "CF_ENHMETAFILE";
+ break;
+ case COM.CF_LOCALE:
+ type = "CF_LOCALE";
+ break;
+ case COM.CF_MAX:
+ type = "CF_MAX";
+ break;
+ default:
+ continue;
+ }
+ } else {
+ byte[] buffer2 = new byte[size];
+ System.arraycopy(buffer, 0, buffer2, 0, size);
+ type = new String(buffer2);
+ }
+
+ String[] newTypes = new String[types.length + 1];
+ System.arraycopy(types, 0, newTypes, 0, types.length);
+ newTypes[types.length] = type;
+ types = newTypes;
+ }
+ OS.GlobalFree(rgelt);
+ enum.Release();
+
+ return types;
+
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
new file mode 100755
index 0000000000..e3437522d0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DragSource.java
@@ -0,0 +1,437 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.ole.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ *
+ * Class <code>DragSource</code> defines the source object for a drag and drop transfer.
+ *
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * <p>This class defines the following items:<ul>
+ * <li>the <code>Control</code> that the user clicks on to intiate a drag;
+ * <li>the data that will be transferred on a successful drop;
+ * <li>and the modes (move, copy, link) of transfer that are allowed.
+ * </ul></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
+ * but it can also 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 interface
+ * <code>DragSourceListener</code> which uses the class <code>DragSourceEvent</code>.
+ * The application is required to take the appropriate action to remove the data from the drag source
+ * when a successful move operation occurs.</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> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnd, DND.DragSetData
+ * </dl>
+ */
+
+public class DragSource extends Widget {
+
+ // ole interfaces
+ private COMObject iUnknown;
+ private COMObject iDropSource;
+ private COMObject iDataObject;
+ private int refCount;
+
+ // info for registering as a drag source
+ private Control control;
+ private Transfer[] transferAgents = new Transfer[0];
+
+ private Listener controlListener;
+
+/**
+ * Creates a new <code>DragSource</code> to handle dragging from the specified <code>Control</code>.
+ *
+ * @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
+ *
+ */
+public DragSource(Control control, int style) {
+
+ super (control, checkStyle (style));
+
+ this.control = control;
+
+ createCOMInterfaces();
+
+ this.AddRef();
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ if (event.type == SWT.Dispose){
+ DragSource.this.dispose();
+ }
+ if (event.type == SWT.DragDetect) {
+ DragSource.this.drag();
+ }
+ }
+ };
+ control.addListener (SWT.Dispose, controlListener);
+ control.addListener (SWT.DragDetect, controlListener);
+
+ this.addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event e) {
+ onDispose();
+ }
+ });
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void addDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragStart, typedListener);
+ addListener (DND.DragEnd, typedListener);
+ addListener (DND.DragSetData, typedListener);
+
+}
+private int AddRef() {
+ refCount++;
+ return refCount;
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+private void createCOMInterfaces() {
+ // register each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+
+ iDropSource = new COMObject(new int[]{2, 0, 0, 2, 1}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return QueryContinueDrag(args[0], args[1]);}
+ public int method4(int[] args) {return GiveFeedback(args[0]);}
+ };
+
+ iDataObject = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 2, 3, 2, 4, 1, 1}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return GetData(args[0], args[1]);}
+ // method4 GetDataHere - not implemented
+ public int method5(int[] args) {return QueryGetData(args[0]);}
+ // method6 GetCanonicalFormatEtc - not implemented
+ // method7 SetData - not implemented
+ public int method8(int[] args) {return EnumFormatEtc(args[0], args[1]);}
+ // method9 DAdvise - not implemented
+ // method10 DUnadvise - not implemented
+ // method11 EnumDAdvise - not implemented
+ };
+}
+private void onDispose () {
+ this.Release();
+
+ if (control != null && controlListener != null){
+ control.removeListener(SWT.Dispose, controlListener);
+ control.removeListener(SWT.DragDetect, controlListener);
+ }
+ controlListener = null;
+ control = null;
+
+ transferAgents = null;
+}
+
+private void disposeCOMInterfaces() {
+
+ if (iUnknown != null)
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iDropSource != null)
+ iDropSource.dispose();
+ iDropSource = null;
+
+ if (iDataObject != null)
+ iDataObject.dispose();
+ iDataObject = null;
+}
+private void drag() {
+
+ if (transferAgents == null || getStyle() == 0) return;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.doit = true;
+
+ try {
+ notifyListeners(DND.DragStart,event);
+ } catch (Throwable e) {
+ return;
+ }
+
+ if (!event.doit) return;
+
+ int[] pdwEffect = new int[1];
+ int result = COM.DoDragDrop(iDataObject.getAddress(), iDropSource.getAddress(), getStyle(), pdwEffect);
+
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.detail = pdwEffect[0];
+ event.doit = (result == COM.DRAGDROP_S_DROP);
+
+ try {
+ notifyListeners(DND.DragEnd,event);
+ } catch (Throwable e) {
+ }
+
+}
+
+private int EnumFormatEtc(int dwDirection, int ppenumFormatetc) {
+ // only allow getting of data - SetData is not currently supported
+ if (dwDirection == COM.DATADIR_SET) return COM.E_NOTIMPL;
+
+ // what types have been registered?
+ TransferData[] allowedDataTypes = new TransferData[0];
+ for (int i = 0; i < transferAgents.length; i++){
+ TransferData[] formats = transferAgents[i].getSupportedTypes();
+ TransferData[] newAllowedDataTypes = new TransferData[allowedDataTypes.length + formats.length];
+ System.arraycopy(allowedDataTypes, 0, newAllowedDataTypes, 0, allowedDataTypes.length);
+ System.arraycopy(formats, 0, newAllowedDataTypes, allowedDataTypes.length, formats.length);
+ allowedDataTypes = newAllowedDataTypes;
+ }
+
+ OleEnumFORMATETC enumFORMATETC = new OleEnumFORMATETC();
+ enumFORMATETC.AddRef();
+
+ FORMATETC[] formats = new FORMATETC[allowedDataTypes.length];
+ for (int i = 0; i < formats.length; i++){
+ formats[i] = allowedDataTypes[i].formatetc;
+ }
+ enumFORMATETC.setFormats(formats);
+
+ COM.MoveMemory(ppenumFormatetc, new int[] {enumFORMATETC.getAddress()}, 4);
+ return COM.S_OK;
+}
+/**
+ * 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;
+}
+private int GetData(int pFormatetc, int pmedium) {
+ /* Called by a data consumer to obtain data from a source data object.
+ The GetData method renders the data described in the specified FORMATETC
+ structure and transfers it through the specified STGMEDIUM structure.
+ The caller then assumes responsibility for releasing the STGMEDIUM structure.
+ */
+ if (pFormatetc == 0 || pmedium == 0) return COM.E_INVALIDARG;
+
+ if (QueryGetData(pFormatetc) != COM.S_OK) return COM.DV_E_FORMATETC;
+
+ TransferData transferData = new TransferData();
+ transferData.formatetc = new FORMATETC();
+ COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof);
+ transferData.type = transferData.formatetc.cfFormat;
+ transferData.stgmedium = new STGMEDIUM();
+ transferData.result = COM.E_FAIL;
+
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.dataType = transferData;
+ try {
+ notifyListeners(DND.DragSetData,event);
+ } catch (Throwable e) {
+ return COM.E_FAIL;
+ }
+
+ if (event.data == null) return COM.DV_E_FORMATETC;
+
+ // get matching transfer agent to perform conversion
+ Transfer transfer = null;
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(event.dataType )){
+ transfer = transferAgents[i];
+ break;
+ }
+ }
+ if (transfer == null) return COM.DV_E_FORMATETC;
+
+ transfer.javaToNative(event.data, transferData);
+ COM.MoveMemory(pmedium, transferData.stgmedium, STGMEDIUM.sizeof);
+ return transferData.result;
+}
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+/**
+ * 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;
+}
+private int GiveFeedback(int dwEffect) {
+ return COM.DRAGDROP_S_USEDEFAULTCURSORS;
+}
+private int QueryContinueDrag(int fEscapePressed, int grfKeyState) {
+ if (fEscapePressed != 0)
+ return COM.DRAGDROP_S_CANCEL;
+ if ((grfKeyState & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ return COM.DRAGDROP_S_DROP;
+
+ return COM.S_OK;
+}
+private int QueryGetData(int pFormatetc) {
+
+ if (transferAgents == null) return COM.E_FAIL;
+
+ TransferData transferData = new TransferData();
+ transferData.formatetc = new FORMATETC();
+ COM.MoveMemory(transferData.formatetc, pFormatetc, FORMATETC.sizeof);
+ transferData.type = transferData.formatetc.cfFormat;
+
+ // is this type supported by the transfer agent?
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData))
+ return COM.S_OK;
+ }
+
+ return COM.DV_E_FORMATETC;
+}
+private int QueryInterface(int riid, int ppvObject) {
+
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ if (COM.IsEqualGUID(guid, COM.IIDIDropSource)) {
+ COM.MoveMemory(ppvObject, new int[] {iDropSource.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ if (COM.IsEqualGUID(guid, COM.IIDIDataObject) ) {
+ COM.MoveMemory(ppvObject, new int[] {iDataObject.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+private int Release() {
+ refCount--;
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ COM.CoFreeUnusedLibraries();
+ }
+
+ return refCount;
+}
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeDragListener(DragSourceListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ removeListener (DND.DragStart, listener);
+ removeListener (DND.DragEnd, listener);
+ removeListener (DND.DragSetData, listener);
+}
+/**
+ * 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.
+ */
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DragSource.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
new file mode 100755
index 0000000000..ac988fc577
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/DropTarget.java
@@ -0,0 +1,610 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.ole.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ *
+ * 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> <dd>DND.DROP_NONE, DND.DROP_COPY, DND.DROP_MOVE, DND.DROP_LINK
+ * <dt><b>Events</b> <dd>DND.DragEnter, DND.DragLeave, DND.DragOver, DND.DragOperationChanged,
+ * DND.Drop, DND.DropAccept
+ * </dl>
+ */
+
+public class DropTarget extends Widget {
+
+
+ // interfaces
+ private COMObject iUnknown;
+ private COMObject iDropTarget;
+
+ // info for registering as a droptarget
+ private Control control;
+ private Listener controlListener;
+
+ private Transfer[] transferAgents = new Transfer[0];;
+
+ private int refCount;
+
+ // info about data being dragged over site
+ private TransferData selectedDataType;
+ private TransferData[] dataTypes;
+ private int lastOperation;
+ private int keyState;
+
+ private DragUnderEffect effect;
+
+ private int iDataObject;
+
+/**
+ * Creates a new <code>DropTarget</code> to handle dropping on the specified <code>Control</code>.
+ *
+ * @param control the <code>Control</code> over which the user positions the cursor to drop 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
+ *
+ */
+public DropTarget(Control control, int style) {
+
+ super (control, checkStyle(style));
+
+ this.control = control;
+
+ createCOMInterfaces();
+
+ int result = 0;
+ if ((result = COM.CoLockObjectExternal(iDropTarget.getAddress(), true, true)) != COM.S_OK)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP, result);
+ if ((result = COM.RegisterDragDrop( control.handle, iDropTarget.getAddress() )) != COM.S_OK)
+ DND.error(DND.ERROR_CANNOT_INIT_DROP, result);
+
+ controlListener = new Listener () {
+ public void handleEvent (Event event) {
+ DropTarget.this.dispose();
+ }
+ };
+
+ control.addListener (SWT.Dispose, controlListener);
+
+ this.addListener (SWT.Dispose, new Listener () {
+ public void handleEvent (Event event) {
+ onDispose();
+ }
+ });
+
+ if (control instanceof Tree) {
+ effect = new TreeDragUnderEffect((Tree)control);
+ } else if (control instanceof Table) {
+ effect = new TableDragUnderEffect((Table)control);
+ } else {
+ effect = new NoDragUnderEffect(control);
+ }
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void addDropListener(DropTargetListener listener) {
+ if (listener == null) DND.error (SWT.ERROR_NULL_ARGUMENT);
+ DNDListener typedListener = new DNDListener (listener);
+ addListener (DND.DragEnter, typedListener);
+ addListener (DND.DragLeave, typedListener);
+ addListener (DND.DragOver, typedListener);
+ addListener (DND.DragOperationChanged, typedListener);
+ addListener (DND.Drop, typedListener);
+ addListener (DND.DropAccept, typedListener);
+
+}
+private int AddRef() {
+ refCount++;
+ return refCount;
+}
+static int checkStyle (int style) {
+ if (style == SWT.NONE) return DND.DROP_MOVE;
+ return style;
+}
+private void createCOMInterfaces() {
+ // register each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+
+ iDropTarget = new COMObject(new int[]{2, 0, 0, 5, 4, 0, 5}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return DragEnter(args[0], args[1], args[2], args[3], args[4]);}
+ public int method4(int[] args) {return DragOver(args[0], args[1], args[2], args[3]);}
+ public int method5(int[] args) {return DragLeave();}
+ public int method6(int[] args) {return Drop(args[0], args[1], args[2], args[3], args[4]);}
+ };
+
+}
+private void onDispose () {
+ if (control == null) return;
+
+ COM.RevokeDragDrop(control.handle);
+
+ if (controlListener != null)
+ control.removeListener(SWT.Dispose, controlListener);
+ controlListener = null;
+ transferAgents = null;
+ control = null;
+
+ COM.CoLockObjectExternal(iDropTarget.getAddress(), false, true);
+
+ this.Release();
+
+ COM.CoFreeUnusedLibraries();
+}
+private void disposeCOMInterfaces() {
+
+ if (iUnknown != null)
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iDropTarget != null)
+ iDropTarget.dispose();
+ iDropTarget = null;
+}
+private int DragEnter(
+ int pDataObject, //Pointer to the interface of the source data object
+ int grfKeyState, //Current state of keyboard modifier keys
+ int pt_x, //Current cursor coordinates
+ int pt_y, //Current cursor coordinates
+ int pdwEffect //Pointer to the effect of the drag-and-drop operation
+){
+
+ selectedDataType = null;
+ dataTypes = new TransferData[0];
+ iDataObject = 0;
+ lastOperation = DND.DROP_NONE;
+
+ // Are any types being dragged for which we have a matching transfer object?
+ // Get enumerator of dragged types
+ IDataObject dataObject = new IDataObject(pDataObject);
+ dataObject.AddRef();
+ int[] address = new int[1];
+ if (dataObject.EnumFormatEtc(COM.DATADIR_GET, address) != COM.S_OK){
+ OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+ dataObject.Release();
+ return COM.S_OK;
+ }
+ IEnumFORMATETC enum = new IEnumFORMATETC(address[0]);
+ dataObject.Release();
+ iDataObject = pDataObject;
+
+ // Loop over enumerator and save any types that match what we are looking for
+ int rgelt = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, FORMATETC.sizeof);
+ int[] pceltFetched = new int[1];
+ enum.Reset();
+ while (enum.Next(1, rgelt, pceltFetched) == COM.S_OK && pceltFetched[0] == 1) {
+ TransferData transferData = new TransferData();
+ transferData.formatetc = new FORMATETC();
+ COM.MoveMemory(transferData.formatetc, rgelt, FORMATETC.sizeof);
+ transferData.type = transferData.formatetc.cfFormat;
+
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(transferData)){
+ TransferData[] newDataTypes = new TransferData[dataTypes.length + 1];
+ System.arraycopy(dataTypes, 0, newDataTypes, 0, dataTypes.length);
+ newDataTypes[dataTypes.length] = transferData;
+ dataTypes = newDataTypes;
+ break;
+ }
+ }
+ }
+ OS.GlobalFree(rgelt);
+ enum.Release();
+
+ // give listeners a chance to have input
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.x = pt_x;
+ event.y = pt_y;
+ event.dataTypes = dataTypes;
+ event.feedback = DND.FEEDBACK_SELECT;
+ int[] allowedEffects = new int[1];
+ OS.MoveMemory(allowedEffects, pdwEffect, 4);
+ allowedEffects[0] = osToOp(allowedEffects[0]);
+ event.operations = allowedEffects[0];
+ if (dataTypes.length > 0) {
+ event.dataType = dataTypes[0];
+ event.dataType.pIDataObject = pDataObject;
+ }
+ event.detail = DND.DROP_NONE;
+ // assign operation if it is allowed
+ keyState = osToOp(getOperationFromKeyState(grfKeyState));
+ if ((keyState & getStyle()) == keyState){
+ event.detail = keyState;
+ }
+
+ try {
+ notifyListeners(DND.DragEnter,event);
+ } catch (Throwable e) {
+ OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+ return COM.S_OK;
+ }
+
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (dataTypes[i].equals(event.dataType)){
+ selectedDataType = event.dataType;
+ break;
+ }
+ }
+ if (selectedDataType != null && ((allowedEffects[0] & event.detail) == event.detail)) {
+ lastOperation = event.detail;
+ }
+
+ effect.show(event.feedback, event.x, event.y);
+
+ OS.MoveMemory(pdwEffect, new int[] {opToOs(lastOperation)}, 4);
+ return COM.S_OK;
+}
+private int DragLeave()
+{
+ effect.show(DND.FEEDBACK_NONE, 0, 0);
+ keyState = DND.DROP_NONE;
+
+ // give listeners a chance to react
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.detail = DND.DROP_NONE;
+ try {
+ notifyListeners(DND.DragLeave, event);
+ } catch (Throwable e) {}
+
+ return COM.S_OK;
+}
+private int DragOver(
+ int grfKeyState, //Current state of keyboard modifier keys
+ int pt_x, //Current cursor coordinates
+ int pt_y,
+ int pdwEffect //Pointer to the effect of the drag-and-drop operation
+){
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.x = pt_x;
+ event.y = pt_y;
+ event.dataTypes = dataTypes;
+ event.feedback = DND.FEEDBACK_SELECT;
+ int[] allowedEffects = new int[1];
+ OS.MoveMemory(allowedEffects, pdwEffect, 4);
+ allowedEffects[0] = osToOp(allowedEffects[0]);
+ event.operations = allowedEffects[0];
+ event.dataType = selectedDataType;
+ if (event.dataType != null) {
+ event.dataType.pIDataObject = iDataObject;
+ }
+
+ try {
+ int oldKeyState = keyState;
+ keyState = osToOp(getOperationFromKeyState(grfKeyState));
+ if (keyState == oldKeyState) {
+ event.detail = lastOperation;
+ // update with new drag over info
+ notifyListeners(DND.DragOver,event);
+ } else {
+ event.detail = keyState;
+ // operation has changed
+ notifyListeners(DND.DragOperationChanged, event);
+ }
+ } catch (Throwable e) {
+ OS.MoveMemory(pdwEffect, new int[] {COM.DROPEFFECT_NONE}, 4);
+ return COM.S_OK;
+ }
+
+ // update drop data and drag under effect based on response from event
+ selectedDataType = null;
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (dataTypes[i].equals(event.dataType)){
+ selectedDataType = event.dataType;
+ break;
+ }
+ }
+
+ lastOperation = DND.DROP_NONE;
+ if (selectedDataType != null && ((allowedEffects[0] & event.detail) == event.detail)) {
+ lastOperation = event.detail;
+ }
+
+ effect.show(event.feedback, event.x, event.y);
+
+ OS.MoveMemory(pdwEffect, new int[] {opToOs(lastOperation)}, 4);
+ return COM.S_OK;
+}
+private int Drop(
+ int pDataObject, //Pointer to the interface for the source data
+ int grfKeyState, //Current state of keyboard modifier keys
+ int pt_x, //Current cursor coordinates
+ int pt_y,
+ int pdwEffect //Pointer to the effect of the drag-and-drop operation
+){
+
+ effect.show(DND.FEEDBACK_NONE, 0, 0);
+ keyState = DND.DROP_NONE;
+
+ // Send a DragLeave event to be consistant with Motif
+ DNDEvent event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.detail = DND.DROP_NONE;
+ try {
+ notifyListeners(DND.DragLeave, event);
+ } catch (Throwable e) {}
+
+ // Send a DropAccept event to be consistant with Motif
+ event = new DNDEvent();
+ event.widget = this;
+ event.time = OS.GetMessageTime();
+ event.x = pt_x;
+ event.y = pt_y;
+ event.dataTypes = dataTypes;
+ int[] allowedEffects = new int[1];
+ OS.MoveMemory(allowedEffects, pdwEffect, 4);
+ allowedEffects[0] = osToOp(allowedEffects[0]);
+ event.operations = allowedEffects[0];
+ event.dataType = selectedDataType;
+ if (event.dataType != null) {
+ event.dataType.pIDataObject = iDataObject;
+ }
+ event.detail = lastOperation;
+
+ try {
+ notifyListeners(DND.DropAccept,event);
+ } catch (Throwable e) {
+ event.dataType = null;
+ event.detail = DND.DROP_NONE;
+ }
+
+ selectedDataType = null;
+ for (int i = 0; i < dataTypes.length; i++) {
+ if (dataTypes[i].equals(event.dataType)){
+ selectedDataType = event.dataType;
+ break;
+ }
+ }
+ lastOperation = DND.DROP_NONE;
+ if (selectedDataType != null && (allowedEffects[0] & event.detail) == event.detail) {
+ lastOperation = event.detail;
+ }
+
+ if (lastOperation != DND.DROP_NONE){
+ // find the matching converter
+ Transfer matchingTransfer = null;
+ for (int i = 0; i < transferAgents.length; i++){
+ if (transferAgents[i].isSupportedType(event.dataType)){
+ matchingTransfer = transferAgents[i];
+ break;
+ }
+ }
+ if (matchingTransfer == null){
+ lastOperation = DND.DROP_NONE;
+ } else {
+ event.dataType.pIDataObject = pDataObject;
+ Object data = matchingTransfer.nativeToJava(event.dataType);
+ event.data = data;
+ try {
+ notifyListeners(DND.Drop,event);
+ lastOperation = DND.DROP_NONE;
+ if ((allowedEffects[0] & event.detail) == event.detail) {
+ lastOperation = event.detail;
+ }
+ } catch (Throwable e) {
+ lastOperation = DND.DROP_NONE;
+ }
+
+ }
+ }
+
+ OS.MoveMemory(pdwEffect, new int[] {osToOp(lastOperation)}, 4);
+ return COM.S_OK;
+}
+/**
+ * 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;
+}
+public Display getDisplay () {
+
+ if (control == null) DND.error(SWT.ERROR_WIDGET_DISPOSED);
+ return control.getDisplay ();
+}
+private int getOperationFromKeyState(int grfKeyState) {
+ boolean ctrl = (grfKeyState & OS.MK_CONTROL) != 0;
+ boolean shift = (grfKeyState & OS.MK_SHIFT) != 0;
+ if (ctrl && shift) {
+ // CTRL + SHIFT == Link
+ return COM.DROPEFFECT_LINK;
+ }
+ if (ctrl){
+ //CTRL == COPY
+ return COM.DROPEFFECT_COPY;
+ }
+
+ return COM.DROPEFFECT_MOVE; // default operation
+}
+/**
+ * Returns the list of data types that can be transferred to this DropTarget.
+ *
+ * @return the list of data types that can be transferred to this DropTarget
+ *
+ */
+public Transfer[] getTransfer(){
+ return transferAgents;
+}
+public void notifyListeners (int eventType, Event event) {
+ Point coordinates = new Point(event.x, event.y);
+ coordinates = control.toControl(coordinates);
+ if (this.control instanceof Tree) {
+ event.item = ((Tree)control).getItem(coordinates);
+ }
+ if (this.control instanceof Table) {
+ event.item = ((Table)control).getItem(coordinates);
+ }
+ super.notifyListeners(eventType, event);
+}
+private int opToOs(int operation) {
+ int osOperation = 0;
+ if ((operation & DND.DROP_COPY) != 0){
+ osOperation |= COM.DROPEFFECT_COPY;
+ }
+ if ((operation & DND.DROP_LINK) != 0) {
+ osOperation |= COM.DROPEFFECT_LINK;
+ }
+ if ((operation & DND.DROP_MOVE) != 0) {
+ osOperation |= COM.DROPEFFECT_MOVE;
+ }
+ return osOperation;
+}
+private int osToOp(int osOperation){
+ int operation = 0;
+ if ((osOperation & COM.DROPEFFECT_COPY) != 0){
+ operation |= DND.DROP_COPY;
+ }
+ if ((osOperation & COM.DROPEFFECT_LINK) != 0) {
+ operation |= DND.DROP_LINK;
+ }
+ if ((osOperation & COM.DROPEFFECT_MOVE) != 0) {
+ operation |= DND.DROP_MOVE;
+ }
+ return operation;
+
+}
+private int QueryInterface(int riid, int ppvObject) {
+
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIDropTarget)) {
+ COM.MoveMemory(ppvObject, new int[] {iDropTarget.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+private int Release() {
+ refCount--;
+
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ COM.CoFreeUnusedLibraries();
+ }
+
+ return refCount;
+}
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+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 list of data types that can be transferred to this DropTarget.
+ *
+ * @param transferAgents a list of Transfer objects which define the types of data that can be
+ * dropped on this target
+ */
+public void setTransfer(Transfer[] transferAgents){
+ this.transferAgents = transferAgents;
+}
+
+protected void checkSubclass () {
+ String name = getClass().getName ();
+ String validName = DropTarget.class.getName();
+ if (!validName.equals(name)) {
+ DND.error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java
new file mode 100755
index 0000000000..1c98e5ad7e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/FileTransfer.java
@@ -0,0 +1,136 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.ole.win32.*;
+
+/**
+ *
+ * The <code>FileTransfer</code> class is used to transfer files in a drag and drop operation.
+ *
+ */
+public class FileTransfer extends ByteArrayTransfer {
+
+ private static FileTransfer _instance = new FileTransfer();
+
+private FileTransfer() {}
+/**
+ *
+ * Returns the singleton instance of the FileTransfer class.
+ *
+ * @return the singleton instance of the FileTransfer class
+ *
+ */
+public static FileTransfer getInstance () {
+ return _instance;
+}
+/**
+ *
+ * Converts a list of file names to a platform specific representation of these file names.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set to COM.S_OK.
+ * If this transfer agent is unable to perform the conversion, the transferData.result field
+ * will be set to the failure value of COM.DV_E_TYMED.</p>
+ *
+ * @param object a list of file names
+ *
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specific format of the data
+ *
+ */
+public void javaToNative(Object object, TransferData transferData) {
+
+ if (object == null || !(object instanceof String[])) {
+ transferData.result = COM.E_FAIL;
+ return;
+ }
+
+ // build a byte array from data
+ String[] fileNames = (String[]) object;
+ int fileNameSize = 0;
+ byte[][] files = new byte[fileNames.length][];
+ for (int i = 0; i < fileNames.length; i++) {
+ files[i] = (fileNames[i]+'\0').getBytes(); // each name is null terminated
+ fileNameSize += files[i].length;
+ }
+ byte[] buffer = new byte[DROPFILES.sizeof + fileNameSize + 1]; // there is an extra null terminator at the very end
+ DROPFILES dropfiles = new DROPFILES();
+ dropfiles.pFiles = DROPFILES.sizeof;
+ dropfiles.pt_x = dropfiles.pt_y = 0;
+ dropfiles.fNC = 0;
+ dropfiles.fWide = 0;
+ COM.MoveMemory(buffer, dropfiles, DROPFILES.sizeof);
+
+ int offset = DROPFILES.sizeof;
+ for (int i = 0; i < fileNames.length; i++) {
+ System.arraycopy(files[i], 0, buffer, offset, files[i].length);
+ offset += files[i].length;
+ }
+
+ // pass byte array on to super to convert to native
+ super.javaToNative(buffer, transferData);
+}
+/**
+ *
+ * Converts a platform specific representation of a list of file names to a Java array of String.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ *
+ * @return a Java array of String containing a list of file names if the conversion was successful; otherwise null
+ *
+ */
+public Object nativeToJava(TransferData transferData) {
+
+ if (!isSupportedType(transferData) || transferData.pIDataObject == 0) {
+ transferData.result = COM.E_FAIL;
+ return null;
+ }
+
+ // get file names from IDataObject
+ IDataObject dataObject = new IDataObject(transferData.pIDataObject);
+ dataObject.AddRef();
+
+ FORMATETC formatetc = new FORMATETC();
+ formatetc.cfFormat = COM.CF_HDROP;
+ formatetc.ptd = 0;
+ formatetc.dwAspect = COM.DVASPECT_CONTENT;
+ formatetc.lindex = -1;
+ formatetc.tymed = COM.TYMED_HGLOBAL;
+
+ STGMEDIUM stgmedium = new STGMEDIUM();
+ stgmedium.tymed = COM.TYMED_HGLOBAL;
+
+ transferData.result = dataObject.GetData(formatetc, stgmedium);
+ dataObject.Release();
+ if (transferData.result != COM.S_OK) {
+ return null;
+ }
+
+ // How many files are there?
+ int count = COM.DragQueryFile(stgmedium.unionField, 0xFFFFFFFF, null, 0);
+ String[] fileNames = new String[count];
+ for (int i = 0; i < count; i++){
+ // How long is the name ?
+ int size = COM.DragQueryFile(stgmedium.unionField, i, null, 0) + 1;
+ byte[] lpszFile = new byte[size];
+ // Get file name and append it to string
+ COM.DragQueryFile(stgmedium.unionField, i, lpszFile, size);
+ String fileName = new String(lpszFile);
+ // remove terminating '\0'
+ int index = fileName.indexOf("\0");
+ fileName = fileName.substring(0, index);
+ fileNames[i] = fileName;
+ }
+ COM.DragFinish(stgmedium.unionField); // frees data associated with HDROP data
+ return fileNames;
+}
+protected int[] getTypeIds(){
+ return new int[] {COM.CF_HDROP};
+}
+protected String[] getTypeNames(){
+ return new String[] {"CF_HDROP"};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java
new file mode 100755
index 0000000000..0310b3b42a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/OleEnumFORMATETC.java
@@ -0,0 +1,157 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.ole.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+
+final class OleEnumFORMATETC {
+
+ private COMObject iUnknown;
+ private COMObject iEnumFORMATETC;
+
+ private int refCount;
+ private int index;
+
+ private FORMATETC[] formats;
+
+OleEnumFORMATETC() {
+
+ createCOMInterfaces();
+
+}
+int AddRef() {
+ refCount++;
+ return refCount;
+}
+private void createCOMInterfaces() {
+ // register each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[] {2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+ iEnumFORMATETC = new COMObject(new int[] {2, 0, 0, 3, 1, 0, 1}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return Next(args[0], args[1], args[2]);}
+ public int method4(int[] args) {return Skip(args[0]);}
+ public int method5(int[] args) {return Reset();}
+ // method6 Clone - not implemented
+ };
+}
+private void disposeCOMInterfaces() {
+
+ if (iUnknown != null)
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iEnumFORMATETC != null)
+ iEnumFORMATETC.dispose();
+ iEnumFORMATETC = null;
+}
+int getAddress() {
+ return iEnumFORMATETC.getAddress();
+}
+private FORMATETC[] getNextItems(int numItems){
+
+ if (formats == null || numItems < 1) return null;
+
+ int endIndex = index + numItems - 1;
+ if (endIndex > (formats.length - 1)) endIndex = formats.length - 1;
+ if (index > endIndex) return null;
+
+ FORMATETC[] items = new FORMATETC[endIndex - index + 1];
+ for (int i = 0; i < items.length; i++){
+ items[i] = formats[index];
+ index++;
+ }
+
+ return items;
+}
+private int Next(int celt, int rgelt, int pceltFetched) {
+ /* Retrieves the next celt items in the enumeration sequence.
+ If there are fewer than the requested number of elements left in the sequence,
+ it retrieves the remaining elements.
+ The number of elements actually retrieved is returned through pceltFetched
+ (unless the caller passed in NULL for that parameter).
+ */
+
+ if (rgelt == 0) return COM.E_INVALIDARG;
+ if (pceltFetched == 0 && celt != 1) return COM.E_INVALIDARG;
+
+ FORMATETC[] nextItems = getNextItems(celt);
+ if (nextItems != null) {
+ for (int i = 0; i < nextItems.length; i++) {
+ COM.MoveMemory(rgelt + i*FORMATETC.sizeof, nextItems[i], FORMATETC.sizeof);
+ }
+
+ if (pceltFetched != 0)
+ COM.MoveMemory(pceltFetched, new int[] {nextItems.length}, 4);
+
+ if (nextItems.length == celt) return COM.S_OK;
+
+ } else {
+ if (pceltFetched != 0)
+ COM.MoveMemory(pceltFetched, new int[] {0}, 4);
+ COM.MoveMemory(rgelt, new FORMATETC(), FORMATETC.sizeof);
+
+ }
+ return COM.S_FALSE;
+}
+private int QueryInterface(int riid, int ppvObject) {
+
+ if (riid == 0 || ppvObject == 0) return COM.E_NOINTERFACE;
+
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIEnumFORMATETC)) {
+ COM.MoveMemory(ppvObject, new int[] {iEnumFORMATETC.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+int Release() {
+ refCount--;
+
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ COM.CoFreeUnusedLibraries();
+ }
+
+ return refCount;
+}
+private int Reset() {
+ //Resets the enumeration sequence to the beginning.
+ index = 0;
+ return COM.S_OK;
+}
+void setFormats(FORMATETC[] newFormats) {
+ formats = newFormats;
+ index = 0;
+}
+private int Skip(int celt) {
+ //Skips over the next specified number of elements in the enumeration sequence.
+ if (celt < 1 ) return COM.E_INVALIDARG;
+
+ index += celt;
+ if (index > (formats.length - 1)){
+ index = formats.length - 1;
+ return COM.S_FALSE;
+ }
+ return COM.S_OK;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java
new file mode 100755
index 0000000000..5abdf1088f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/RTFTransfer.java
@@ -0,0 +1,81 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/**
+ *
+ * The <code>RTFTransfer</code> class is used to transfer text with the RTF format
+ * in a drag and drop operation.
+ *
+ */
+public class RTFTransfer extends ByteArrayTransfer {
+
+ private static final String CF_RTF_NAME = "Rich Text Format";
+ private static final int CF_RTF = registerType(CF_RTF_NAME);
+ private static RTFTransfer _instance = new RTFTransfer();
+
+private RTFTransfer() {}
+/**
+ *
+ * Returns the singleton instance of the RTFTransfer class.
+ *
+ * @return the singleton instance of the RTFTransfer class
+ *
+ */
+public static RTFTransfer getInstance () {
+ return _instance;
+}
+/**
+ *
+ * Converts a Java String to a platform specific representation of the string.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set to OLE.S_OK.
+ * If this transfer agent is unable to perform the conversion, the transferData.result field
+ * will be set to the failure value of OLE.DV_E_TYMED.</p>
+ *
+ * @param object a Java String containing the data to be transferred
+ *
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specific format of the data
+ *
+ */
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ // CF_RTF is stored as a null terminated byte array
+ // create a byte array from object
+ String text = (String) object+'\0';
+ // pass byte array on to super to convert to native
+ super.javaToNative(text.getBytes(), transferData);
+}
+/**
+ *
+ * Converts a platform specific representation of a string to a Java String.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ *
+ * @return a Java String containing the transferred data if the conversion was successful; otherwise null
+ *
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ String string = new String(buffer);
+ // remove null terminator
+ int index = string.indexOf("\0");
+ string = string.substring(0, index);
+ return string;
+}
+protected int[] getTypeIds(){
+ return new int[] {CF_RTF};
+}
+protected String[] getTypeNames(){
+ return new String[] {"CF_RTF"};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java
new file mode 100755
index 0000000000..5cd21361d0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TableDragUnderEffect.java
@@ -0,0 +1,61 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.LVITEM;
+import org.eclipse.swt.internal.win32.OS;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TableDragUnderEffect extends DragUnderEffect {
+ private Table table;
+ private TableItem currentItem;
+
+TableDragUnderEffect(Table table) {
+ this.table = table;
+}
+void show(int effect, int x, int y) {
+ TableItem item = findItem(x, y);
+ if (item == null) {
+ effect = DND.FEEDBACK_NONE;
+ }
+ setDragUnderEffect(effect, item);
+}
+private TableItem findItem(int x, int y){
+ if (table == null) return null;
+ Point coordinates = new Point(x, y);
+ coordinates = table.toControl(coordinates);
+ TableItem item = table.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = table.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = table.toControl(coordinates);
+ item = table.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+
+}
+private void setDragUnderEffect(int effect, TableItem item) {
+ if (currentItem != item) {
+ setDropSelection(item);
+ currentItem = item;
+ }
+}
+private void setDropSelection (TableItem item) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.stateMask = OS.LVIS_DROPHILITED;
+ // remove all drop highlighting
+ OS.SendMessage (table.handle, OS.LVM_SETITEMSTATE, -1, lvItem);
+ if (item != null) {
+ lvItem.state = OS.LVIS_DROPHILITED;
+ int index = table.indexOf(item);
+ OS.SendMessage (table.handle, OS.LVM_SETITEMSTATE, index, lvItem);
+ }
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java
new file mode 100755
index 0000000000..85dbdfbbe2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TextTransfer.java
@@ -0,0 +1,78 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.ole.win32.COM;
+
+/**
+ *
+ * The <code>TextTransfer</code> class is used to transfer text in a drag and drop operation.
+ *
+ */
+public class TextTransfer extends ByteArrayTransfer {
+
+ private static TextTransfer _instance = new TextTransfer();
+private TextTransfer() {}
+/**
+ *
+ * Returns the singleton instance of the TextTransfer class.
+ *
+ * @return the singleton instance of the TextTransfer class
+ *
+ */
+public static TextTransfer getInstance () {
+ return _instance;
+}
+/**
+ *
+ * Converts a Java String to a platform specific representation of the string.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set to OLE.S_OK.
+ * If this transfer agent is unable to perform the conversion, the transferData.result field
+ * will be set to the failure value of OLE.DV_E_TYMED.</p>
+ *
+ * @param object a Java String containing the data to be transferred
+ *
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specific format of the data
+ *
+ */
+public void javaToNative (Object object, TransferData transferData){
+ if (object == null || !(object instanceof String)) return;
+
+ // CF_TEXT is stored as a null terminated byte array
+ // create a byte array from object
+ String text = (String) object+'\0';
+ // pass byte array on to super to convert to native
+ super.javaToNative(text.getBytes(), transferData);
+}
+/**
+ *
+ * Converts a platform specific representation of a string to a Java String.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ *
+ * @return a Java String containing the transferred data if the conversion was successful; otherwise null
+ *
+ */
+public Object nativeToJava(TransferData transferData){
+ // get byte array from super
+ byte[] buffer = (byte[])super.nativeToJava(transferData);
+ if (buffer == null) return null;
+ // convert byte array to a string
+ String string = new String(buffer);
+ // remove null terminator
+ int index = string.indexOf("\0");
+ string = string.substring(0, index);
+ return string;
+}
+protected int[] getTypeIds(){
+ return new int[] {COM.CF_TEXT};
+}
+protected String[] getTypeNames(){
+ return new String[] {"CF_TEXT"};
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java
new file mode 100755
index 0000000000..4556298271
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/Transfer.java
@@ -0,0 +1,87 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.ole.win32.COM;
+
+/**
+ * The class <code>Transfer</code> provides a mechanism for converting a Java object to a
+ * platform specific format that can be passed around in a Drag and Drop operation and vice versa.
+ *
+ * <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>
+ *
+ */
+public abstract class Transfer {
+/**
+ * Returns a list of the data types that can be transferred using this Transfer agent.
+ *
+ * <p>Only the data type fields of the TransferData Object are filled in.</p>
+ *
+ * @return a list of the data types that can be transferred using this Transfer agent
+ *
+ */
+abstract public TransferData[] getSupportedTypes();
+/**
+ * Returns true if the transferData data type can be transferred using this Transfer agent.
+ *
+ * @param transferData a platform specific description of a data type; only the data type fields
+ * of the TransferData Object need to be filled in
+ *
+ * @return true if the transferData data type can be transferred using this Transfer agent
+ *
+ */
+abstract public boolean isSupportedType(TransferData transferData);
+
+abstract protected int[] getTypeIds();
+abstract protected String[] getTypeNames();
+/**
+ * Converts a Java Object to a platform specific representation of the data.
+ *
+ * <p>On a successful conversion, the transferData.result field will be set to OLE.S_OK.
+ * If this transfer agent is unable to perform the conversion, the transferData.result field
+ * will be set to the failure value of OLE.DV_E_TYMED.</p>
+ *
+ * @param object a Java Object containing the data to be transferred
+ *
+ * @param transferData an empty TransferData object; this object will be filled in on return
+ * with the platform specfifc representation of the data
+ *
+ */
+
+ abstract protected void javaToNative (Object object, TransferData transferData);
+/**
+ * Converts a platform specific representation of data to a Java Object.
+ *
+ * @param transferData the platform specific representation of the data that has been transferred
+ *
+ * @return a Java Object containing the transferred data if the conversion was successful; otherwise null
+ *
+ */
+
+ 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: Do <b>not</b> call this method with pre-defined Clipboard Format types such as CF_TEXT
+ * or CF_BITMAP because the pre-defined value will not be returned</p>
+ *
+ * @param formatName the name of a data type
+ *
+ * @return the unique identifier associated with htis data type
+ *
+ */
+public static int registerType(String formatName){
+ // Look name up in the registry
+ // If name is not in registry, add it and return assigned value.
+ // If name already exists in registry, return its assigned value
+ byte[] chFormatName = (formatName+'\0').getBytes();
+ return COM.RegisterClipboardFormat(chFormatName);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java
new file mode 100755
index 0000000000..02a8c329fb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TransferData.java
@@ -0,0 +1,50 @@
+package org.eclipse.swt.dnd;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.ole.win32.*;
+
+/**
+ *
+ * The <code>TransferData</code> class is a platform specific data structure for describing the type and the
+ * contents of data being transferred in a Drag and Drop operation.
+ *
+ * <p>As an application writer, you do not need to know anything about the specifics of TransferData. You
+ * should just pass the TransferData instances to subclass of Transfer and let the Transfer objects deal
+ * with the platform specific issues. You can ask a Transfer subclass if it can handle this data by calling
+ * TextTransfer.isSupportedType(transferData). You can get a list of the types of TransferData supported by a
+ * Transfer object by calling TextTransfer.getSupportedTypes().</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>
+ *
+ */
+public class TransferData {
+ /**
+ * Data Type - a pre-defined clipboard format <b>or</b> the unique identifier of a user defined format
+ */
+ public int type;
+ /**
+ * Data Type - a Windows format structure which describes additional aspects of the type
+ */
+ public FORMATETC formatetc;
+
+ /**
+ * Set Data - a data storage structure which you update to contain the data to be transferred in the
+ * Windows specific format
+ */
+ public STGMEDIUM stgmedium;
+ /**
+ * Set Data - the result of converting a Java object into an stgmedium value
+ */
+ public int result = COM.E_FAIL;
+
+ /**
+ * Get Data - the address of an IDataObject OLE Interface which contains the data that was transferred
+ */
+ public int pIDataObject;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java
new file mode 100755
index 0000000000..5115aba9db
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/win32/org/eclipse/swt/dnd/TreeDragUnderEffect.java
@@ -0,0 +1,108 @@
+package org.eclipse.swt.dnd;
+
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.OS;
+import org.eclipse.swt.internal.win32.TVITEM;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class TreeDragUnderEffect extends DragUnderEffect {
+
+ private Tree tree;
+ private TreeItem currentItem = null;
+ private int currentEffect = DND.FEEDBACK_NONE;
+ private TreeItem[] selection = new TreeItem[0];
+
+TreeDragUnderEffect(Tree tree) {
+ this.tree = tree;
+}
+void show(int effect, int x, int y) {
+ TreeItem item = findItem(x, y);
+ if (item == null) {
+ effect = DND.FEEDBACK_NONE;
+ }
+ if (currentEffect != effect && currentEffect == DND.FEEDBACK_NONE) {
+ selection = tree.getSelection();
+ tree.setSelection(new TreeItem[0]);
+ }
+ boolean restoreSelection = currentEffect != effect && effect == DND.FEEDBACK_NONE;
+ setDragUnderEffect(effect, item);
+ if (restoreSelection) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ tvItem.state = OS.TVIS_SELECTED;
+ for (int i = 0; i < selection.length; i++) {
+ tvItem.hItem = selection[i].handle;
+ OS.SendMessage (tree.handle, OS.TVM_SETITEM, 0, tvItem);
+ OS.SendMessage (tree.handle, OS.TVM_ENSUREVISIBLE, 0, selection[i].handle);
+ }
+ selection = new TreeItem[0];
+ }
+}
+private TreeItem findItem(int x , int y){
+ Point coordinates = new Point(x, y);
+ coordinates = tree.toControl(coordinates);
+ TreeItem item = tree.getItem(coordinates);
+ if (item != null) return item;
+
+ Rectangle area = tree.getClientArea();
+ for (int x1 = area.x; x1 < area.x + area.width; x1++) {
+ coordinates = new Point(x1, y);
+ coordinates = tree.toControl(coordinates);
+ item = tree.getItem(coordinates);
+ if (item != null) return item;
+ }
+ return null;
+}
+private void setDragUnderEffect(int effect, TreeItem item) {
+ switch (effect) {
+ case DND.FEEDBACK_SELECT:
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ tree.setInsertMark(null, false);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ setDropSelection(item);
+ currentEffect = DND.FEEDBACK_SELECT;
+ currentItem = item;
+ }
+ break;
+ case DND.FEEDBACK_INSERT_AFTER:
+ case DND.FEEDBACK_INSERT_BEFORE:
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ }
+ if (currentEffect != effect || currentItem != item) {
+ tree.setInsertMark(item, effect == DND.FEEDBACK_INSERT_BEFORE);
+ currentEffect = effect;
+ currentItem = item;
+ }
+ break;
+ default :
+ if (currentEffect == DND.FEEDBACK_INSERT_AFTER ||
+ currentEffect == DND.FEEDBACK_INSERT_BEFORE) {
+ tree.setInsertMark(null, false);
+ }
+ if (currentEffect == DND.FEEDBACK_SELECT) {
+ setDropSelection(null);
+ }
+ currentEffect = DND.FEEDBACK_NONE;
+ currentItem = null;
+ break;
+ }
+}
+private void setDropSelection (TreeItem item) {
+ int hNewItem = 0;
+ if (item != null) hNewItem = item.handle;
+ OS.SendMessage (tree.handle, OS.TVM_SELECTITEM, OS.TVIS_DROPHILITED, hNewItem);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java
new file mode 100755
index 0000000000..1583e9dac0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CAUUID.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class CAUUID {
+
+ public int cElems;
+ public int pElems;
+
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java
new file mode 100755
index 0000000000..1d5bd02e7c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COM.java
@@ -0,0 +1,562 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class COM extends OS {
+
+ static {
+ /* Initialize OLE */
+ // OleInitialize Initializes the COM library on the current apartment
+ // and identifies the concurrency model as single-thread apartment (STA).
+ // To use any other threading model, you must call CoInitializeEx
+ OS.OleInitialize(0);
+ }
+
+ /* Constants */
+
+ // !!!! GUIDs for Home Page Browser !!!!
+ public static final GUID IIDIEditorSiteTime = IIDFromString("{6BD2AEFE-7876-45e6-A6E7-3BFCDF6540AA}");
+ public static final GUID IIDIEditorSiteProperty = IIDFromString("{D381A1F4-2326-4f3c-AFB9-B7537DB9E238}");
+ public static final GUID IIDIEditorBaseProperty = IIDFromString("{61E55B0B-2647-47c4-8C89-E736EF15D636}");
+ public static final GUID IIDIEditorSite = IIDFromString("{CDD88AB9-B01D-426E-B0F0-30973E9A074B}");
+ public static final GUID IIDIEditorService = IIDFromString("{BEE283FE-7B42-4FF3-8232-0F07D43ABCF1}");
+ public static final GUID IIDIEditorManager = IIDFromString("{EFDE08C4-BE87-4B1A-BF84-15FC30207180}");
+
+
+ public static final GUID IIDIAdviseSink = IIDFromString("{0000010F-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIAdviseSink2 = IIDFromString("{00000125-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIBindCtx = IIDFromString("{0000000E-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIClassFactory = IIDFromString("{00000001-0000-0000-C000-000000000046}");
+ public static final GUID IIDIClassFactory2 = IIDFromString("{B196B28F-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIConnectionPoint = IIDFromString("{B196B286-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIConnectionPointContainer = IIDFromString("{B196B284-BAB4-101A-B69C-00AA00341D07}");
+ //public static final GUID IIDICreateErrorInfo = IIDFromString("{22F03340-547D-101B-8E65-08002B2BD119}");
+ //public static final GUID IIDICreateTypeInfo = IIDFromString("{00020405-0000-0000-C000-000000000046}");
+ //public static final GUID IIDICreateTypeLib = IIDFromString("{00020406-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIDataAdviseHolder = IIDFromString("{00000110-0000-0000-C000-000000000046}");
+ public static final GUID IIDIDataObject = IIDFromString("{0000010E-0000-0000-C000-000000000046}");
+ public static final GUID IIDIDispatch = IIDFromString("{00020400-0000-0000-C000-000000000046}");
+ public static final GUID IIDIDropSource = IIDFromString("{00000121-0000-0000-C000-000000000046}");
+ public static final GUID IIDIDropTarget = IIDFromString("{00000122-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumConnectionPoints = IIDFromString("{B196B285-BAB4-101A-B69C-00AA00341D07}");
+ //public static final GUID IIDIEnumConnections = IIDFromString("{B196B287-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIEnumFORMATETC = IIDFromString("{00000103-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumMoniker = IIDFromString("{00000102-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumOLEVERB = IIDFromString("{00000104-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumSTATDATA = IIDFromString("{00000105-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumSTATSTG = IIDFromString("{0000000D-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumString = IIDFromString("{00000101-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumUnknown = IIDFromString("{00000100-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIEnumVARIANT = IIDFromString("{00020404-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIErrorInfo = IIDFromString("{1CF2B120-547D-101B-8E65-08002B2BD119}");
+ //public static final GUID IIDIErrorLog = IIDFromString("{3127CA40-446E-11CE-8135-00AA004BB851}");
+ //public static final GUID IIDIExternalConnection = IIDFromString("{00000019-0000-0000-C000-000000000046}");
+ public static final GUID IIDIFont = IIDFromString("{BEF6E002-A874-101A-8BBA-00AA00300CAB}");
+ //public static final GUID IIDIFontDisp = IIDFromString("{BEF6E003-A874-101A-8BBA-00AA00300CAB}");
+ //public static final GUID IIDILockBytes = IIDFromString("{0000000A-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIMalloc = IIDFromString("{00000002-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIMallocSpy = IIDFromString("{0000001D-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIMarshal = IIDFromString("{00000003-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIMessageFilter = IIDFromString("{00000016-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIMoniker = IIDFromString("{0000000F-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIOleAdviseHolder = IIDFromString("{00000111-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIOleCache = IIDFromString("{0000011E-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIOleCache2 = IIDFromString("{00000128-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIOleCacheControl = IIDFromString("{00000129-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleClientSite = IIDFromString("{00000118-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleCommandTarget = IIDFromString("{B722BCCB-4E68-101B-A2BC-00AA00404770}");
+ public static final GUID IIDIOleContainer = IIDFromString("{0000011B-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleControl = IIDFromString("{B196B288-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIOleControlSite = IIDFromString("{B196B289-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIOleInPlaceActiveObject = IIDFromString("{00000117-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleInPlaceFrame = IIDFromString("{00000116-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleInPlaceObject = IIDFromString("{00000113-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleInPlaceSite = IIDFromString("{00000119-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleInPlaceUIWindow = IIDFromString("{00000115-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIOleItemContainer = IIDFromString("{0000011C-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleLink = IIDFromString("{0000011D-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleObject = IIDFromString("{00000112-0000-0000-C000-000000000046}");
+ public static final GUID IIDIOleWindow = IIDFromString("{00000114-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIParseDisplayName = IIDFromString("{0000011A-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIPerPropertyBrowsing = IIDFromString("{376BD3AA-3845-101B-84ED-08002B2EC713}");
+ public static final GUID IIDIPersist = IIDFromString("{0000010C-0000-0000-C000-000000000046}");
+ public static final GUID IIDIPersistFile = IIDFromString("{0000010B-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIPersistMemory = IIDFromString("{BD1AE5E0-A6AE-11CE-BD37-504200C10000}");
+ //public static final GUID IIDIPersistPropertyBag = IIDFromString("{37D84F60-42CB-11CE-8135-00AA004BB851}");
+ public static final GUID IIDIPersistStorage = IIDFromString("{0000010A-0000-0000-C000-000000000046}");
+ public static final GUID IIDIPersistStream = IIDFromString("{00000109-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIPersistStreamInit = IIDFromString("{7FD52380-4E07-101B-AE2D-08002B2EC713}");
+ //public static final GUID IIDIPicture = IIDFromString("{7BF80980-BF32-101A-8BBB-00AA00300CAB}");
+ //public static final GUID IIDIPictureDisp = IIDFromString("{7BF80981-BF32-101A-8BBB-00AA00300CAB}");
+ //public static final GUID IIDIPropertyBag = IIDFromString("{55272A00-42CB-11CE-8135-00AA004BB851}");
+ public static final GUID IIDIPropertyNotifySink = IIDFromString("{9BFBBC02-EFF1-101A-84ED-00AA00341D07}");
+ //public static final GUID IIDIPropertyPage = IIDFromString("{B196B28D-BAB4-101A-B69C-00AA00341D07}");
+ //public static final GUID IIDIPropertyPage2 = IIDFromString("{01E44665-24AC-101B-84ED-08002B2EC713}");
+ //public static final GUID IIDIPropertyPageSite = IIDFromString("{B196B28C-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIProvideClassInfo = IIDFromString("{B196B283-BAB4-101A-B69C-00AA00341D07}");
+ public static final GUID IIDIProvideClassInfo2 = IIDFromString("{A6BC3AC0-DBAA-11CE-9DE3-00AA004BB851}");
+ //public static final GUID IIDIPSFactoryBuffer = IIDFromString("{D5F569D0-593B-101A-B569-08002B2DBF7A}");
+ //public static final GUID IIDIRootStorage = IIDFromString("{00000012-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIROTData = IIDFromString("{F29F6BC0-5021-11CE-AA15-00006901293F}");
+ //public static final GUID IIDIRpcChannelBuffer = IIDFromString("{D5F56B60-593B-101A-B569-08002B2DBF7A}");
+ //public static final GUID IIDIRpcProxyBuffer = IIDFromString("{D5F56A34-593B-101A-B569-08002B2DBF7A}");
+ //public static final GUID IIDIRpcStubBuffer = IIDFromString("{D5F56AFC-593B-101A-B569-08002B2DBF7A}");
+ //public static final GUID IIDIRunnableObject = IIDFromString("{00000126-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIRunningObjectTable = IIDFromString("{00000010-0000-0000-C000-000000000046}");
+ //public static final GUID IIDISimpleFrameSite = IIDFromString("{742B0E01-14E6-101B-914E-00AA00300CAB}");
+ public static final GUID IIDISpecifyPropertyPages = IIDFromString("{B196B28B-BAB4-101A-B69C-00AA00341D07}");
+ //public static final GUID IIDIStdMarshalInfo = IIDFromString("{00000018-0000-0000-C000-000000000046}");
+ public static final GUID IIDIStorage = IIDFromString("{0000000B-0000-0000-C000-000000000046}");
+ public static final GUID IIDIStream = IIDFromString("{0000000C-0000-0000-C000-000000000046}");
+ //public static final GUID IIDISupportErrorInfo = IIDFromString("{DF0B3D60-548F-101B-8E65-08002B2BD119}");
+ //public static final GUID IIDITypeComp = IIDFromString("{00020403-0000-0000-C000-000000000046}");
+ //public static final GUID IIDITypeLib = IIDFromString("{00020402-0000-0000-C000-000000000046}");
+ public static final GUID IIDIUnknown = IIDFromString("{00000000-0000-0000-C000-000000000046}");
+ //public static final GUID IIDIViewObject = IIDFromString("{0000010D-0000-0000-C000-000000000046}");
+ public static final GUID IIDIViewObject2 = IIDFromString("{00000127-0000-0000-C000-000000000046}");
+
+ //public static final int ADVF_DATAONSTOP = 64;
+ //public static final int ADVF_NODATA = 1;
+ //public static final int ADVF_ONLYONCE = 2;
+ //public static final int ADVF_PRIMEFIRST = 4;
+ //public static final int ADVFCACHE_FORCEBUILTIN = 16;
+ //public static final int ADVFCACHE_NOHANDLER = 8;
+ //public static final int ADVFCACHE_ONSAVE = 32;
+ public static final int CF_TEXT = 1;
+ public static final int CF_BITMAP = 2;
+ public static final int CF_METAFILEPICT = 3;
+ public static final int CF_SYLK = 4;
+ public static final int CF_DIF = 5;
+ public static final int CF_TIFF = 6;
+ public static final int CF_OEMTEXT = 7;
+ public static final int CF_DIB = 8;
+ public static final int CF_PALETTE = 9;
+ public static final int CF_PENDATA = 10;
+ public static final int CF_RIFF = 11;
+ public static final int CF_WAVE = 12;
+ public static final int CF_UNICODETEXT = 13;
+ public static final int CF_ENHMETAFILE = 14;
+ public static final int CF_HDROP = 15;
+ public static final int CF_LOCALE = 16;
+ public static final int CF_MAX = 17;
+ public static final int CLSCTX_INPROC_HANDLER = 2;
+ public static final int CLSCTX_INPROC_SERVER = 1;
+ public static final int CLSCTX_LOCAL_SERVER = 4;
+ public static final int CLSCTX_REMOTE_SERVER = 16;
+ public static final int CO_E_CLASSSTRING = -2147221005;
+ //public static final int COINIT_APARTMENTTHREADED = 2; Apartment model
+ //public static final int COINIT_DISABLE_OLE1DDE = 4; Don't use DDE for Ole1 support.
+ //public static final int COINIT_MULTITHREADED = 0; OLE calls objects on any thread.
+ //public static final int COINIT_SPEED_OVER_MEMORY = 8; Trade memory for speed.
+ public static final int DATADIR_GET = 1;
+ public static final int DATADIR_SET = 2;
+ public static final int DISP_E_EXCEPTION = 0x80020009;
+ public static final int DISP_E_MEMBERNOTFOUND = -2147352573;
+ public static final int DISP_E_UNKNOWNINTERFACE = 0x80020001;
+ //public static final int DISPID_AMBIENT_APPEARANCE = -716;
+ //public static final int DISPID_AMBIENT_AUTOCLIP = -715;
+ public static final int DISPID_AMBIENT_BACKCOLOR = -701;
+ //public static final int DISPID_AMBIENT_CHARSET = -727;
+ //public static final int DISPID_AMBIENT_CODEPAGE = -725;
+ //public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = -713;
+ //public static final int DISPID_AMBIENT_DISPLAYNAME = -702;
+ public static final int DISPID_AMBIENT_FONT = -703;
+ public static final int DISPID_AMBIENT_FORECOLOR = -704;
+ public static final int DISPID_AMBIENT_LOCALEID = -705;
+ public static final int DISPID_AMBIENT_MESSAGEREFLECT = -706;
+ public static final int DISPID_AMBIENT_OFFLINEIFNOTCONNECTED = -5501;
+ //public static final int DISPID_AMBIENT_PALETTE = -726;
+ //public static final int DISPID_AMBIENT_RIGHTTOLEFT = -732;
+ //public static final int DISPID_AMBIENT_SCALEUNITS = -707;
+ public static final int DISPID_AMBIENT_SHOWGRABHANDLES = -711;
+ public static final int DISPID_AMBIENT_SHOWHATCHING = -712;
+ public static final int DISPID_AMBIENT_SILENT = -5502;
+ public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = -714;
+ //public static final int DISPID_AMBIENT_TEXTALIGN = -708;
+ //public static final int DISPID_AMBIENT_TOPTOBOTTOM = -733;
+ //public static final int DISPID_AMBIENT_TRANSFERPRIORITY = -728;
+ public static final int DISPID_AMBIENT_UIDEAD = -710;
+ public static final int DISPID_AMBIENT_USERMODE = -709;
+ public static final int DISPID_BACKCOLOR = -501;
+ public static final int DISPID_FONT = -512;
+ public static final int DISPID_FONT_BOLD = 3;
+ public static final int DISPID_FONT_CHARSET = 8;
+ public static final int DISPID_FONT_ITALIC = 4;
+ public static final int DISPID_FONT_NAME = 0;
+ public static final int DISPID_FONT_SIZE = 2;
+ public static final int DISPID_FONT_STRIKE = 6;
+ public static final int DISPID_FONT_UNDER = 5;
+ public static final int DISPID_FONT_WEIGHT = 7;
+ public static final int DISPID_FORECOLOR = -513;
+ //public static final int DISPID_READYSTATE = -525;
+ //public static final int DISPID_READYSTATECHANGE = -609;
+ public static final int DRAGDROP_S_DROP = 0x00040100; //Successful drop took place
+ public static final int DRAGDROP_S_CANCEL = 0x00040101; // Drag-drop operation canceled
+ public static final int DRAGDROP_S_USEDEFAULTCURSORS = 0x00040102; // Use the default cursor
+ public static final int DROPEFFECT_NONE = 0; // Drop target cannot accept the data.
+ public static final int DROPEFFECT_COPY = 1; // Drop results in a copy. The original data is untouched by
+ // the drag source.
+ public static final int DROPEFFECT_MOVE = 2; // Drag source should remove the data.
+ public static final int DROPEFFECT_LINK = 4; // Drag source should create a link to the original data.
+ public static final int DROPEFFECT_SCROLL = 0x80000000; // Scrolling is about to start or is currently
+ // occurring in the target. This value is used in
+ // addition to the other values.
+ public static final int DV_E_FORMATETC = -2147221404;
+ public static final int DV_E_STGMEDIUM = -2147221402;
+ public static final int DV_E_TYMED = -2147221399;
+ public static final int DVASPECT_CONTENT = 1;
+ //public static final int DVASPECT_DOCPRINT = 8;
+ //public static final int DVASPECT_ICON = 4;
+ //public static final int DVASPECT_THUMBNAIL = 2;
+ public static final int E_FAIL = -2147467259; //Unspecified failure.
+ public static final int E_INVALIDARG = -2147024809;
+ public static final int E_NOINTERFACE = -2147467262; //QueryInterface did not recognize the requested interface.
+ public static final int E_NOTIMPL = -2147467263; //Member function contains no implementation.
+ //public static final int E_NOTLICENSED = -2147221230;
+ //public static final int E_OUTOFMEMORY = -2147024882; //Function failed to allocate necessary memory.
+ //public static final int E_POINTER = -2147467261;
+ public static final int GMEM_FIXED = 0; //Global Memory Constants
+ //public static final int GMEM_MOVABLE = 2;
+ //public static final int GMEM_NODISCARD = 32;
+ public static final int GMEM_ZEROINIT = 64;
+ public static final int GUIDKIND_DEFAULT_SOURCE_DISP_IID = 1;
+ public static final int IMPLTYPEFLAG_FDEFAULT = 1;
+ //public static final int IMPLTYPEFLAG_FDEFAULTVTABLE = 2048;
+ public static final int IMPLTYPEFLAG_FRESTRICTED = 4;
+ public static final int IMPLTYPEFLAG_FSOURCE = 2;
+ public static final int LOCALE_SYSTEM_DEFAULT = 1024; //Locale Constants
+ public static final int LOCALE_USER_DEFAULT = 2048;
+ //public static final int MEMCTX_TASK = 1; //dwMemContext values for COM's task memory allocation service
+ //public static final int OLEACTIVATEAUTO = 3; //Object is activated based on the object's default method of activation
+ //public static final int OLEACTIVATEDOUBLECLICK = 2; //Object is activated when the OLE container control is double-clicked
+ //public static final int OLEACTIVATEGETFOCUS = 1; //Object is activated when the OLE container control gets the focus
+ //public static final int OLEACTIVATEMANUAL = 0; //OLE object isn't automatically activated
+ //public static final int OLEAUTOMATIC = 0; //Object is updated each time the linked data changes
+ //public static final int OLECHANGED = 0; //Object's data has changed
+ public static final int OLECLOSE_NOSAVE = 1;
+ //public static final int OLECLOSE_PROMPTSAVE = 2;
+ public static final int OLECLOSE_SAVEIFDIRTY = 0;
+ //public static final int OLECLOSED = 2; //Application file containing the linked object's data has been closed
+ //public static final int OLECONTF_EMBEDDINGS = 1; //The OLECONTF enumeration indicates the kind of objects to be enumerated by the returned IEnumUnknown interface
+ //public static final int OLECONTF_LINKS = 2;
+ //public static final int OLECONTF_ONLYIFRUNNING = 16;
+ //public static final int OLECONTF_ONLYUSER = 8;
+ //public static final int OLECONTF_OTHERS = 4;
+ //public static final int OLEDEACTIVATEMANUAL = 1; //The OLE object can only be deactivated programatically via the #doVerb: method."
+ //public static final int OLEDEACTIVATEONLOSEFOCUS = 0; //The OLE object is deactivated whenever focus is given to another widget in the receiver's shell.
+ //public static final int OLEDECBORDER = 1; //a border is displayed around the receiver.
+ //public static final int OLEDECBORDERANDNIBS = 3; //border and resize nibs are displayed.
+ //public static final int OLEDECNIBS = 2; //resize nibs are displayed around the reciever.
+ //public static final int OLEDECNONE = 0; //no special trimmings are displayed around the receiver.
+ //public static final int OLEDISPLAYCONTENT = 0; //Object's data is displayed in the OLE container control
+ //public static final int OLEDISPLAYICON = 1; //Object's icon is displayed in the OLE container control
+ //public static final int OLEEITHER = 2; //OLE container control can contain either a linked or an embedded object
+ public static final int OLEEMBEDDED = 1; //OLE container control contains an embedded object
+ //public static final int OLEFROZEN = 1; //Object is updated whenever the user saves the linked document from within the application in which it was created
+ public static final int OLEIVERB_DISCARDUNDOSTATE = -6; //close the OLE object and discard the undo state
+ //public static final int OLEIVERB_HIDE = -3; //hide the OLE object
+ public static final int OLEIVERB_INPLACEACTIVATE = -5; //open the OLE for editing in-place
+ //public static final int OLEIVERB_OPEN = -2; //open the OLE object for editing in a separate window
+ public static final int OLEIVERB_PRIMARY = 0; //opens the OLE object for editing
+ //public static final int OLEIVERB_PROPERTIES = -7; //request the OLE object properties dialog
+ //public static final int OLEIVERB_SHOW = -1; //show the OLE object
+ //public static final int OLEIVERB_UIACTIVATE = -4; //activate the UI for the OLE object
+ public static final int OLELINKED = 0; //OLE container control contains a linked object
+ //public static final int OLEMANUAL = 2; //Object is updated only when the Action property is set to 6 (Update)
+ //public static final int OLEMISC_ACTIVATEWHENVISIBLE = 256;
+ //public static final int OLEMISC_ACTSLIKEBUTTON = 4096;
+ //public static final int OLEMISC_ACTSLIKELABEL = 8192;
+ //public static final int OLEMISC_ALIGNABLE = 32768;
+ //public static final int OLEMISC_ALWAYSRUN = 2048;
+ //public static final int OLEMISC_CANLINKBYOLE1 = 32;
+ //public static final int OLEMISC_CANTLINKINSIDE = 16;
+ //public static final int OLEMISC_IGNOREACTIVATEWHENVISIBLE = 524288;
+ //public static final int OLEMISC_IMEMODE = 262144;
+ //public static final int OLEMISC_INSERTNOTREPLACE = 4;
+ //public static final int OLEMISC_INSIDEOUT = 128;
+ //public static final int OLEMISC_INVISIBLEATRUNTIME = 1024;
+ //public static final int OLEMISC_ISLINKOBJECT = 64;
+ //public static final int OLEMISC_NOUIACTIVATE = 16384;
+ //public static final int OLEMISC_ONLYICONIC = 2;
+ //public static final int OLEMISC_RECOMPOSEONRESIZE = 1;
+ //public static final int OLEMISC_RENDERINGISDEVICEINDEPENDENT = 512;
+ //public static final int OLEMISC_SETCLIENTSITEFIRST = 131072;
+ //public static final int OLEMISC_SIMPLEFRAME = 65536;
+ //public static final int OLEMISC_STATIC = 8;
+ //public static final int OLEMISC_SUPPORTSMULTILEVELUNDO = 2097152;
+ //public static final int OLEMISC_WANTSTOMENUMERGE = 1048576;
+ //public static final int OLENONE = 3; //OLE container control doesn't contain an object
+ //public static final int OLERENAMED = 3; //Application file containing the linked object's data has been renamed
+ //public static final int OLERENDER_ASIS = 3; //Ole Create rendering formats
+ public static final int OLERENDER_DRAW = 1;
+ //public static final int OLERENDER_FORMAT = 2;
+ //public static final int OLERENDER_NONE = 0;
+ //public static final int OLESAVED = 1; //Object's data has been saved by the application that created the object
+ //public static final int OLESIZEAUTOSIZE = 2; //OLE container control is automatically resized to display the entire object
+ //public static final int OLESIZECLIP = 0; //Object's image is clipped by the OLE container control's borders
+ //public static final int OLESIZESTRETCH = 1; //Object's image is sized to fill the OLE container control
+ //public static final int OLESIZEZOOM = 3; //Object's image is stretched but in proportion
+ //public static final int OLEWHICHMK_CONTAINER = 1;
+ //public static final int OLEWHICHMK_OBJFULL = 3;
+ //public static final int OLEWHICHMK_OBJREL = 2;
+ public static final int S_FALSE = 1; //Used for functions that semantically return a Boolean FALSE result to indicate that the function succeeded.
+ public static final int S_OK = 0; //Function succeeded.
+ public static final int STG_E_FILENOTFOUND = 0x80030002;
+ public static final int STG_S_CONVERTED = 0x00030200;
+ //public static final int STGC_CONSOLIDATE = 8;
+ //public static final int STGC_DANGEROUSLYCOMMITMERELYTODISKCACHE = 4;
+ public static final int STGC_DEFAULT = 0;
+ //public static final int STGC_ONLYIFCURRENT = 2;
+ //public static final int STGC_OVERWRITE = 1;
+ public static final int STGM_CONVERT = 0x00020000;
+ public static final int STGM_CREATE = 0x00001000;
+ public static final int STGM_DELETEONRELEASE = 0x04000000;
+ public static final int STGM_DIRECT = 0x00000000;
+ public static final int STGM_DIRECT_SWMR = 0x00400000;
+ public static final int STGM_FAILIFTHERE = 0x00000000;
+ public static final int STGM_NOSCRATCH = 0x00100000;
+ public static final int STGM_NOSNAPSHOT = 0x00200000;
+ public static final int STGM_PRIORITY = 0x00040000;
+ public static final int STGM_READ = 0x00000000;
+ public static final int STGM_READWRITE = 0x00000002;
+ public static final int STGM_SHARE_DENY_NONE = 0x00000040;
+ public static final int STGM_SHARE_DENY_READ = 0x00000030;
+ public static final int STGM_SHARE_DENY_WRITE = 0x00000020;
+ public static final int STGM_SHARE_EXCLUSIVE = 0x00000010;
+ public static final int STGM_SIMPLE = 0x08000000;
+ public static final int STGM_TRANSACTED = 0x00010000;
+ public static final int STGM_WRITE = 0x00000001;
+ public static final int STGTY_STORAGE = 1;
+ public static final int STGTY_STREAM = 2;
+ public static final int STGTY_LOCKBYTES = 3;
+ public static final int STGTY_PROPERTY = 4;
+ //public static final int TYMED_ENHMF = 64; //Values for tymed
+ //public static final int TYMED_FILE = 2;
+ //public static final int TYMED_GDI = 16;
+ public static final int TYMED_HGLOBAL = 1;
+ //public static final int TYMED_ISTORAGE = 8;
+ //public static final int TYMED_ISTREAM = 4;
+ //public static final int TYMED_MFPICT = 32;
+ //public static final int TYMED_NULL = 0;
+
+ public static final short DISPATCH_METHOD = 0x1; //Dispatch Constants
+ public static final short DISPATCH_PROPERTYGET = 0x2;
+ public static final short DISPATCH_PROPERTYPUT = 0x4;
+ public static final short DISPATCH_PROPERTYPUTREF = 0x8;
+ //public static final short DISPID_CONSTRUCTOR = -6;
+ //public static final short DISPID_DESTRUCTOR = -7;
+ //public static final short DISPID_EVALUATE = -5;
+ //public static final short DISPID_NEWENUM = -4;
+ public static final short DISPID_PROPERTYPUT = -3;
+ //public static final short DISPID_UNKNOWN = -1;
+ //public static final short DISPID_VALUE = 0;
+
+ // Variant types
+ public static final short VT_BOOL = 11; // Boolean; True=-1, False=0.
+ public static final short VT_BSTR = 8; // Binary String.
+ public static final short VT_BYREF = 16384; // By reference - must be combined with one of the othre VT values
+ public static final short VT_CY = 6; // Currency.
+ public static final short VT_DATE = 7; // Date.
+ public static final short VT_DISPATCH = 9; // IDispatch
+ public static final short VT_EMPTY = 0; // Not specified.
+ public static final short VT_ERROR = 10; // Scodes.
+ public static final short VT_I2 = 2; // 2-byte signed int.
+ public static final short VT_I4 = 3; // 4-byte signed int.
+ public static final short VT_NULL = 1; // Null.
+ public static final short VT_R4 = 4; // 4-byte real.
+ public static final short VT_R8 = 5; // 8-byte real.
+ public static final short VT_UI1 = 17; // Unsigned char.
+ public static final short VT_UI4 = 19; // Unsigned int.
+ public static final short VT_UNKNOWN = 13; // IUnknown FAR*.
+ public static final short VT_VARIANT = 12; // VARIANT FAR*.
+
+public static final native int CLSIDFromProgID(char[] lpszProgID, GUID pclsid);
+public static final native int CLSIDFromString(char[] lpsz, GUID pclsid);
+public static final native int CoCreateInstance(
+ GUID rclsid,
+ int pUnkOuter,
+ int dwClsContext,
+ GUID riid,
+ int[] ppv
+);
+
+public static final native void CoFreeUnusedLibraries();
+public static final native int CoGetClassObject(GUID rclsid, int dwClsContext, int pServerInfo, GUID riid, int[] ppv);
+public static final native int CoLockObjectExternal(
+ int pUnk, //Pointer to object to be locked or unlocked
+ boolean fLock, //TRUE = lock, FALSE = unlock
+ boolean fLastUnlockReleases //TRUE = release all pointers to object
+);
+public static final native int CoTaskMemAlloc(int cb); //Size in bytes of memory block to be allocated
+public static final native void CoTaskMemFree(int pv);
+public static final native int DoDragDrop(
+ int pDataObject, //Pointer to the data object
+ int pDropSource, //Pointer to the source
+ int dwOKEffect, //Effects allowed by the source
+ int[] pdwEffect //Pointer to effects on the source
+);
+
+public static final native void DragFinish(int hDrop);
+
+public static final native int DragQueryFile(
+ int hDrop,
+ int iFile,
+ byte[] lpszFile,
+ int cch
+);
+
+public static final native int GetClassFile(
+ char[] szFileName, //Pointer to filename for which you are requesting a CLSID
+ GUID clsid //Pointer to location for returning the CLSID
+);
+public static final native int GetClipboardFormatName(
+ int format,
+ byte[] lpszFormatName,
+ int cchMaxCount);
+public static final native int IIDFromString(char[] lpsz, GUID lpiid);
+private static GUID IIDFromString(String lpsz) {
+ // create a null terminated array of char
+ char[] buffer = (lpsz +"\0").toCharArray();
+
+ // invoke system method
+ GUID lpiid = new GUID();
+ if (COM.IIDFromString(buffer, lpiid) == COM.S_OK)
+ return lpiid;
+ return null;
+}
+public static final native boolean IsEqualGUID(GUID rguid1, GUID rguid2);
+public static final native void MoveMemory( byte[] Destination, DROPFILES Source, int Length);
+public static final native void MoveMemory(char[] Destination, int SourcePtr, int Length);
+public static final native void MoveMemory(double[] Destination, int SourcePtr, int Length);
+public static final native void MoveMemory(float[] Destination, int SourcePtr, int Length);
+public static final native void MoveMemory(short[] Destination, int SourcePtr, int Length);
+public static final native void MoveMemory(int DestinationPtr, double[] Source, int Length);
+public static final native void MoveMemory(int DestinationPtr, float[] Source, int Length);
+public static final native void MoveMemory(int DestinationPtr, short[] Source, int Length);
+public static final native void MoveMemory( int Destination, FORMATETC Source, int Length);
+public static final native void MoveMemory(int DestinationPtr, GUID Source, int Length);
+public static final native void MoveMemory(int DestinationPtr, OLEINPLACEFRAMEINFO Source, int Length);
+public static final native void MoveMemory( int Destination, STATSTG Source, int Length);
+public static final native void MoveMemory( int Destination, STGMEDIUM Source, int Length);
+public static final native void MoveMemory(DISPPARAMS Destination, int SourcePtr, int Length);
+public static final native void MoveMemory(FORMATETC Destination, int Source, int Length);
+public static final native void MoveMemory(GUID Destination, int SourcePtr, int Length);
+public static final native void MoveMemory(STATSTG Destination, int Source, int Length);
+public static final native void MoveMemory(TYPEATTR Destination, int SourcePtr, int Length);
+public static final native void MoveMemory (RECT Destination, int Source, int Length);
+public static final native void MoveMemory (FUNCDESC1 Destination, int Source, int Length);
+public static final native void MoveMemory (VARDESC1 Destination, int Source, int Length);
+public static final native void MoveMemory (FUNCDESC2 Destination, int Source, int Length);
+public static final native void MoveMemory (VARDESC2 Destination, int Source, int Length);
+
+public static final native int OleCreate( GUID rclsid, GUID riid, int renderopt, FORMATETC pFormatEtc, int pClientSite, int pStg, int[] ppvObject);
+public static final native int OleCreateFromFile(
+ GUID rclsid, //Reserved. Must be CLSID_NULL
+ char[] lpszFileName, //Pointer to full path of file used to create object
+ GUID riid, //Reference to the identifier of the interface to be used to
+ // communicate with new object
+ int renderopt, //Value from OLERENDER
+ FORMATETC pFormatEtc, //Pointer to the FORMATETC structure
+ int pClientSite, //Pointer to an interface
+ int pStg, //Pointer tothe interface to be used as object storage
+ int[] ppvObj); //Address of output variable that receives the interface pointer
+ // requested in riid
+public static final native int OleCreatePropertyFrame(int hwndOwner,int x, int y, char[] lpszCaption, int cObjects, int[] lplpUnk, int cPages, int lpPageClsID, int lcid, int dwReserved, int lpvReserved);
+public static final native int OleDraw(int pUnk, //Pointer to the view object to be drawn
+ int dwAspect, //How the object is to be represented
+ int hdcDraw, //Device context on which to draw
+ int lprcBounds);//Pointer to the rectangle in which the object is drawn
+public static final native int OleFlushClipboard();
+public static final native int OleGetClipboard(int[] ppDataObject);
+public static final native int OleIsCurrentClipboard(int pDataObject);
+public static final native boolean OleIsRunning(int pObject);
+public static final native int OleLoad(
+ int pStg, //Pointer to the storage object from which to load
+ GUID riid, //Reference to the identifier of the interface
+ int pClientSite, //Pointer to the client site for the object
+ int[] ppvObj //Address of output variable that receives the interface pointer requested in riid
+);
+public static final native int OleRun(int pUnknown);
+public static final native int OleSave(int pPS, int pStg,boolean fSameAsLoad);
+public static final native int OleSetClipboard(int pDataObject);
+public static final native int OleSetContainedObject(int pUnk, boolean fContained);
+public static final native int OleSetMenuDescriptor(int holemenu, int hwndFrame, int hwndActiveObject, int lpFrame, int lpActiveObj);
+public static final native int OleTranslateColor(int clr, int hpal, int[] pcolorref);
+public static final native int ProgIDFromCLSID(
+ GUID clsid, //CLSID for which the ProgID is requested
+ int[] lplpszProgID //Address of output variable that receives a pointer to the requested ProgID string
+);
+public static final native int RegisterClipboardFormat(byte[] lpszFormat);
+public static final native int RegisterDragDrop(
+ int hwnd, //Handle to a window that can accept drops
+ int pDropTarget //Pointer to object that is to be target of drop
+);
+public static final native void ReleaseStgMedium(
+ STGMEDIUM pmedium //Pointer to storage medium to be freed
+);
+public static final native int RevokeDragDrop(
+ int hwnd //Handle to a window that can accept drops
+);
+public static final native int StgCreateDocfile(char[] pwcsName, int grfMode, int reserved, int[] ppstgOpen);
+public static final native int StgIsStorageFile(
+ char[] pwcsName //Points to a path of the file to check
+);
+public static final native int StgOpenStorage(
+ char[] pwcsName, //Points to the path of the file containing storage object
+ int pstgPriority, //Points to a previous opening of a root storage object
+ int grfMode, //Specifies the access mode for the object
+ int snbExclude, //Points to an SNB structure specifying elements to be excluded
+ int reserved, //Reserved; must be zero
+ int[] ppstgOpen //Address of output variable that receives the IStorage interface pointer
+);
+public static final native int SysAllocString(char [] sz);
+public static final native void SysFreeString(int bstr);
+public static final native int SysStringByteLen(int bstr);
+public static final native int VariantChangeType(int pvargDest, int pvarSrc, short wFlags, short vt);
+public static final native int VariantClear(int pvarg);
+public static final native void VariantInit(int pvarg);
+public static final native int VtblCall (int fnNumber, int ppVtbl);
+public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0);
+public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, char[] arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, int arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int[] arg4);
+public static final native int VtblCall (int fnNumber, int ppVtbl, char[] arg0, int arg1, int arg2, int arg3, int arg4, int[] arg5);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int[] arg0);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int[] arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, int[] arg2);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, int arg2);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, int arg2, int[] arg3);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, int arg1, DVTARGETDEVICE arg2, SIZE arg3);
+public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int arg1, GUID arg2, int arg3, int[] arg4);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, FORMATETC arg1, int[] arg2);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, GUID arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, GUID arg1, int arg2, int arg3);
+public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, GUID arg1, int arg2, int arg3, DISPPARAMS arg4, int arg5, EXCEPINFO arg6, int[] arg7);
+public static final native int VtblCall(int ppVtbl, int fnNumber, int arg0, STATSTG arg1, int[] arg2);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, MSG arg1, int arg2, int arg3, int arg4, RECT arg5);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, SIZE arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, int arg0, boolean arg1);
+public static final native int VtblCall(int fnNumber, int ppVtbl, CAUUID arg0);
+public static final native int VtblCall(int ppVtbl, int fnNumber, CONTROLINFO arg0);
+public static final native int VtblCall (int fnNumber, int ppVtbl, FORMATETC arg0);
+public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0, STGMEDIUM arg1);
+public static final native int VtblCall(int fnNumber, int ppVtbl, FORMATETC arg0, STGMEDIUM arg1, boolean arg2);
+public static final native int VtblCall (int ppVtbl, int fnNumber, GUID arg0);
+public static final native int VtblCall(int ppVtbl, int fnNumber, GUID arg0, int[] arg1);
+public static final native int VtblCall (int fnNumber, int ppVtbl, GUID arg0, int arg1, int arg2, int arg3, int[] arg4);
+public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, int arg2, int arg3, int arg4);
+public static final native int VtblCall(int fnNumber, int ppVtbl, GUID arg0, int arg1, OLECMD arg2, OLECMDTEXT arg3);
+public static final native int VtblCall(int fnNumber, int ppVtbl, LICINFO arg0);
+public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0, int arg1, boolean arg2);
+public static final native int VtblCall(int fnNumber, int ppVtbl, RECT arg0, RECT arg1);
+public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1, int[] arg2, int[] arg3, int[] arg4);
+public static final native int VtblCall(int fnNumber, int ppVtbl, int arg0, int[] arg1, int arg2, int[] arg3);
+
+public static final native int WriteClassStg(int pStg, GUID rclsid);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java
new file mode 100755
index 0000000000..bef6d7e995
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COMObject.java
@@ -0,0 +1,1024 @@
+package org.eclipse.swt.internal.ole.win32;
+
+import java.util.Hashtable;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class COMObject {
+
+ private int 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 COMObject(int[] argCounts) {
+ int[] callbackAddresses = new int[argCounts.length];
+ for (int i = 0, length = argCounts.length; i < length; i++){
+ if ((Callbacks[i][argCounts[i]]) == null) {
+ Callbacks[i][argCounts[i]] = new Callback(this.getClass(), "callback"+i, argCounts[i] + 1, true);
+ }
+ callbackAddresses[i] = Callbacks[i][argCounts[i]].getAddress();
+ }
+
+ int pVtable = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * argCounts.length);
+ COM.MoveMemory(pVtable, callbackAddresses, 4 * argCounts.length);
+ ppVtable = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4);
+ COM.MoveMemory(ppVtable, new int[] {pVtable}, 4);
+ ObjectMap.put(new Integer(ppVtable), this);
+}
+
+public static GUID IIDFromString(String lpsz) {
+ // create a null terminated array of char
+ char[] buffer = (lpsz +"\0").toCharArray();
+
+ // invoke system method
+ GUID lpiid = new GUID();
+ if (COM.IIDFromString(buffer, lpiid) == COM.S_OK)
+ return lpiid;
+ return null;
+}
+
+static int callback0(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method0(args);
+}
+static int callback1(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method1(args);
+}
+static int callback2(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method2(args);
+}
+static int callback3(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method3(args);
+}
+static int callback4(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method4(args);
+}
+static int callback5(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method5(args);
+}
+static int callback6(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method6(args);
+}
+static int callback7(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method7(args);
+}
+static int callback8(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method8(args);
+}
+static int callback9(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method9(args);
+}
+static int callback10(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method10(args);
+}
+static int callback11(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method11(args);
+}
+static int callback12(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method12(args);
+}
+static int callback13(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method13(args);
+}
+static int callback14(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method14(args);
+}
+static int callback15(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method15(args);
+}
+static int callback16(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method16(args);
+}
+static int callback17(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method17(args);
+}
+static int callback18(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method18(args);
+}
+static int callback19(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method19(args);
+}
+static int callback20(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method20(args);
+}
+static int callback21(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method21(args);
+}
+static int callback22(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method22(args);
+}
+static int callback23(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method23(args);
+}
+static int callback24(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method24(args);
+}
+static int callback25(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method25(args);
+}
+static int callback26(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method26(args);
+}
+static int callback27(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method27(args);
+}
+static int callback28(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method28(args);
+}
+static int callback29(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method29(args);
+}
+static int callback30(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method30(args);
+}
+static int callback31(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method31(args);
+}
+static int callback32(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method32(args);
+}
+static int callback33(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method33(args);
+}
+static int callback34(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method34(args);
+}
+static int callback35(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method35(args);
+}
+static int callback36(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method36(args);
+}
+static int callback37(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method37(args);
+}
+static int callback38(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method38(args);
+}
+static int callback39(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method39(args);
+}
+static int callback40(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method40(args);
+}
+static int callback41(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method41(args);
+}
+static int callback42(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method42(args);
+}
+static int callback43(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method43(args);
+}
+static int callback44(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method44(args);
+}
+static int callback45(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method45(args);
+}
+static int callback46(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method46(args);
+}
+static int callback47(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method47(args);
+}
+static int callback48(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method48(args);
+}
+static int callback49(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method49(args);
+}
+static int callback50(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method50(args);
+}
+static int callback51(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method51(args);
+}
+static int callback52(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method52(args);
+}
+static int callback53(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method53(args);
+}
+static int callback54(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method54(args);
+}
+static int callback55(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method55(args);
+}
+static int callback56(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method56(args);
+}
+static int callback57(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method57(args);
+}
+static int callback58(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method58(args);
+}
+static int callback59(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method59(args);
+}
+static int callback60(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method60(args);
+}
+static int callback61(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method61(args);
+}
+static int callback62(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method62(args);
+}
+static int callback63(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method63(args);
+}
+static int callback64(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method64(args);
+}
+static int callback65(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method65(args);
+}
+static int callback66(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method66(args);
+}
+static int callback67(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method67(args);
+}
+static int callback68(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method68(args);
+}
+static int callback69(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method69(args);
+}
+static int callback70(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method70(args);
+}
+static int callback71(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method71(args);
+}
+static int callback72(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method72(args);
+}
+static int callback73(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method73(args);
+}
+static int callback74(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method74(args);
+}
+static int callback75(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method75(args);
+}
+static int callback76(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method76(args);
+}
+static int callback77(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method77(args);
+}
+static int callback78(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method78(args);
+}
+static int callback79(int[] callbackArgs) {
+ // find the object on which this call was invoked
+ int address = callbackArgs[0];
+ Object object = ObjectMap.get(new Integer(address));
+ if (object == null) return COM.E_FAIL;
+ int[] args = new int[callbackArgs.length - 1];
+ System.arraycopy(callbackArgs, 1, args, 0, args.length);
+ return ((COMObject) object).method79(args);
+}
+public void dispose() {
+ // free the memory for this reference
+ int[] pVtable = new int[1];
+ OS.MoveMemory(pVtable, ppVtable, 4);
+ OS.GlobalFree(pVtable[0]);
+ OS.GlobalFree(ppVtable);
+
+ // remove this ppVtable from the list
+ ObjectMap.remove(new Integer(ppVtable));
+
+ ppVtable = 0;
+}
+public int getAddress () {
+ return ppVtable;
+}
+public int method0(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method1(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method2(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method3(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method4(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method5(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method6(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method7(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method8(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method9(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method10(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method11(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method12(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method13(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method14(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method15(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method16(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method17(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method18(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method19(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method20(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method21(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method22(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method23(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method24(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method25(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method26(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method27(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method28(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method29(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method30(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method31(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method32(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method33(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method34(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method35(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method36(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method37(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method38(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method39(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method40(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method41(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method42(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method43(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method44(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method45(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method46(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method47(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method48(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method49(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method50(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method51(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method52(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method53(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method54(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method55(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method56(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method57(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method58(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method59(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method60(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method61(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method62(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method63(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method64(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method65(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method66(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method67(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method68(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method69(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method70(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method71(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method72(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method73(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method74(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method75(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method76(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method77(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method78(int[] args) {
+ return COM.E_NOTIMPL;
+}
+public int method79(int[] args) {
+ return COM.E_NOTIMPL;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java
new file mode 100755
index 0000000000..08cfe9319a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/CONTROLINFO.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class CONTROLINFO
+{
+ public int cb;
+ public int hAccel;
+ public short cAccel;
+ public short filler;
+ public int dwFlags;
+
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java
new file mode 100755
index 0000000000..7177ca2654
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/COSERVERINFO.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class COSERVERINFO {
+ public int dwReserved1;
+ public int pwszName;
+ public int pAuthInfo;
+ public int dwReserved2;
+
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java
new file mode 100755
index 0000000000..e55bcb0030
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DISPPARAMS.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class DISPPARAMS
+{
+ public int rgvarg;
+ public int rgdispidNamedArgs;
+ public int cArgs;
+ public int cNamedArgs;
+
+ public static final int sizeof = 16;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java
new file mode 100755
index 0000000000..c34ffd0cbc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DROPFILES.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class DROPFILES {
+ public int pFiles; // Offset of the file list from the beginning of this structure, in bytes.
+ //public POINT pt; // Drop point. The coordinates depend on fNC.
+ public int pt_x;
+ public int pt_y;
+ public int fNC; // Nonclient area flag. If this member is TRUE, pt specifies the screen
+ // coordinates of a point in a window's nonclient area. If it is FALSE,
+ // pt specifies the client coordinates of a point in the client area.
+ public int fWide; // Value that indicates whether the file contains ANSI or Unicode
+ // characters. If it is zero, it contains ANSI characters. Otherwise, it
+ // contains Unicode characters.
+
+ public static final int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java
new file mode 100755
index 0000000000..f5ae048ad2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/DVTARGETDEVICE.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class DVTARGETDEVICE
+{
+ public int tdSize;
+ public short tdDriverNameOffset;
+ public short tdDeviceNameOffset;
+ public short tdPortNameOffset;
+ public short tdExtDevmodeOffset;
+ public byte tdData;
+
+ public static final int sizeof = 13;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java
new file mode 100755
index 0000000000..ed85c472da
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/EXCEPINFO.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class EXCEPINFO
+{
+ public short wCode;
+ public short wReserved;
+ public int bstrSource;
+ public int bstrDescription;
+ public int bstrHelpFile;
+ public int dwHelpContext;
+ public int pvReserved;
+ public int pfnDeferredFillIn;
+ public int scode;
+
+ public static final int sizeof = 32;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java
new file mode 100755
index 0000000000..1b177e7044
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FORMATETC.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class FORMATETC
+{
+ public int cfFormat;
+ public int ptd;
+ public int dwAspect;
+ public int lindex;
+ public int tymed;
+
+ public static final int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java
new file mode 100755
index 0000000000..50fddbb9cd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC1.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FUNCDESC1 {
+ public int memid;
+ public int lprgscode;
+ public int lprgelemdescParam;
+ public int funckind;
+ public int invkind;
+ public int callconv;
+ public short cParams;
+ public short cParamsOpt;
+ public short oVft;
+ public short cScodes;
+ //ELEMDESC elemdescFunc;
+ //TYPEDESC elemdescFunc.tdesc
+ public int elemdescFunc_tdesc_union;
+ public short elemdescFunc_tdesc_vt;
+ public short elemdescFunc_tdesc_filler;
+ //PARAMDESC elemdescFunc.paramdesc
+ public int elemdescFunc_paramdesc_pparamdescex;
+ public short elemdescFunc_paramdesc_wParamFlags;
+ public short elemdescFunc_paramdesc_filler;
+ public short wFuncFlags;
+
+ public static final int sizeof = 50;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java
new file mode 100755
index 0000000000..cba1125f53
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/FUNCDESC2.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class FUNCDESC2 {
+ public int memid;
+ public int lprgscode;
+ public int lprgelemdescParam;
+ public int funckind;
+ public int invkind;
+ public int callconv;
+ public short cParams;
+ public short cParamsOpt;
+ public short oVft;
+ public short cScodes;
+ //ELEMDESC elemdescFunc;
+ //TYPEDESC elemdescFunc.tdesc
+ public int elemdescFunc_tdesc_union;
+ public short elemdescFunc_tdesc_vt;
+ public short elemdescFunc_tdesc_filler;
+ //IDLDESC elemdescFunc.idldesc
+ public int elemdescFunc_idldesc_dwReserved;
+ public short elemdescFunc_idldesc_wIDLFlags;
+ public short elemdescFunc_idldesc_filler;
+ public short wFuncFlags;
+
+ public static final int sizeof = 50;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java
new file mode 100755
index 0000000000..2a3af7d23d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/GUID.java
@@ -0,0 +1,23 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class GUID
+{
+ public int data1;
+ public short data2;
+ public short data3;
+ public byte b0;
+ public byte b1;
+ public byte b2;
+ public byte b3;
+ public byte b4;
+ public byte b5;
+ public byte b6;
+ public byte b7;
+
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java
new file mode 100755
index 0000000000..ad71bed45f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IClassFactory2.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IClassFactory2 extends IUnknown
+{
+public IClassFactory2(int address) {
+ super(address);
+}
+public int CreateInstanceLic(int pUnkOuter, int pUnkReserved, GUID riid, int bstrKey, int ppvObject[]) {
+ return COM.VtblCall(7, address, pUnkOuter, pUnkReserved, riid, bstrKey, ppvObject);
+}
+public int GetLicInfo(LICINFO licInfo) {
+ return COM.VtblCall(5, address, licInfo);
+}
+public int RequestLicKey(int dwReserved, int[] pBstrKey) {
+ return COM.VtblCall(6, address, dwReserved, pBstrKey);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java
new file mode 100755
index 0000000000..ee7dd708ea
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPoint.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IConnectionPoint extends IUnknown
+{
+public IConnectionPoint(int address) {
+ super(address);
+}
+public int Advise(int pUnk, int[] pdwCookie) {
+ return COM.VtblCall(5, address, pUnk, pdwCookie);
+}
+public int Unadvise(int dwCookie) {
+ return COM.VtblCall(6, address, dwCookie);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java
new file mode 100755
index 0000000000..d4ce46a4d9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IConnectionPointContainer.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IConnectionPointContainer extends IUnknown
+{
+public IConnectionPointContainer(int address) {
+ super(address);
+}
+public int FindConnectionPoint(GUID riid, int[] ppCP) {
+ return COM.VtblCall(4, address, riid, ppCP);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java
new file mode 100755
index 0000000000..e513252fe1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDataObject.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IDataObject extends IUnknown {
+/**
+ * IDataObject constructor comment.
+ * @param address int
+ */
+public IDataObject(int address) {
+ super(address);
+}
+public int EnumFormatEtc(int dwDirection, int[] ppenumFormatetc) {
+ return COM.VtblCall(8, address, dwDirection, ppenumFormatetc);
+}
+public int GetData(FORMATETC pFormatetc, STGMEDIUM pmedium) {
+ //Called by a data consumer to obtain data from a source data object.
+ //The GetData method renders the data described in the specified FORMATETC
+ //structure and transfers it through the specified STGMEDIUM structure.
+ //The caller then assumes responsibility for releasing the STGMEDIUM structure.
+ return COM.VtblCall(3, address, pFormatetc, pmedium);
+}
+public int GetDataHere(FORMATETC pFormatetc, STGMEDIUM pmedium) {
+ //Called by a data consumer to obtain data from a source data object.
+ //This method differs from the GetData method in that the caller must
+ //allocate and free the specified storage medium.
+ return COM.VtblCall(4, address, pFormatetc, pmedium);
+}
+public int QueryGetData(FORMATETC pFormatetc) {
+ return COM.VtblCall(5, address, pFormatetc);
+}
+public int SetData(
+ FORMATETC pFormatetc, // Pointer to the FORMATETC structure
+ STGMEDIUM pmedium, // Pointer to STGMEDIUM structure
+ boolean fRelease // Indicates which object owns the storage medium after the call is completed
+ ){
+ return COM.VtblCall(7, address, pFormatetc, pmedium, fRelease);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java
new file mode 100755
index 0000000000..171ce98771
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IDispatch.java
@@ -0,0 +1,61 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class IDispatch extends IUnknown
+{
+public IDispatch(int address) {
+ super(address);
+}
+public int GetIDsOfNames(GUID riid, String[] rgszNames, int cNames, int lcid, int[] rgDispId) {
+
+ char[] buffer;
+ int size = rgszNames.length;
+
+ // create an array to hold the addresses
+ int hHeap = OS.GetProcessHeap();
+ int ppNames = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, size*4);
+ int[] memTracker = new int[size];
+
+ try {
+ // add the address of each string to the array
+
+ for (int i=0; i<size; i++){
+ // create a null terminated array of char for each String
+ int nameSize = rgszNames[i].length();
+ buffer = new char[nameSize +1];
+ rgszNames[i].getChars(0, nameSize, buffer, 0);
+ // get the address of the start of the array of char
+ int pName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length * 2);
+ OS.MoveMemory(pName, buffer, buffer.length * 2);
+ // copy the address to the array of addresses
+ COM.MoveMemory(ppNames + 4*i, new int[]{pName}, 4);
+ // keep track of the Global Memory so we can free it
+ memTracker[i] = pName;
+ }
+
+ return COM.VtblCall(5, address, new GUID(), ppNames, cNames, lcid, rgDispId);
+
+ } finally {
+ // free the memory
+ for (int i=0; i<memTracker.length; i++){
+ OS.HeapFree(hHeap, 0, memTracker[i]);
+ }
+ OS.HeapFree(hHeap, 0, ppNames);
+ }
+}
+public int GetTypeInfo(int iTInfo, int lcid, int[] ppTInfo ){
+ return COM.VtblCall(4, address, iTInfo, lcid, ppTInfo);
+}
+public int GetTypeInfoCount(int[] pctinfo ){
+ return COM.VtblCall(3, address, pctinfo);
+}
+public int Invoke(int dispIdMember, GUID riid, int lcid, int dwFlags, DISPPARAMS pDispParams, int pVarResult, EXCEPINFO pExcepInfo, int pArgErr[]) {
+ return COM.VtblCall(6, address, dispIdMember, riid, lcid, dwFlags, pDispParams, pVarResult, pExcepInfo, pArgErr);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnum.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnum.java
new file mode 100755
index 0000000000..eb1841b0cf
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnum.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IEnum extends IUnknown
+{
+public IEnum(int address) {
+ super(address);
+}
+public int Clone( int[] ppenum ){
+ return COM.VtblCall(6, address, ppenum);
+}
+public int Next(int celt, int rgelt, int[] pceltFetched ){
+ return COM.VtblCall(3, address, celt, rgelt, pceltFetched);
+}
+public int Reset() {
+ return COM.VtblCall(5, address);
+}
+public int Skip(int celt){
+ return COM.VtblCall(4, address, celt);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java
new file mode 100755
index 0000000000..7fb4fb70f4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumFORMATETC.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IEnumFORMATETC extends IEnum {
+public IEnumFORMATETC(int address) {
+ super(address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java
new file mode 100755
index 0000000000..3753815363
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IEnumSTATSTG.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IEnumSTATSTG extends IEnum {
+public IEnumSTATSTG(int address) {
+ super(address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IFont.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IFont.java
new file mode 100755
index 0000000000..e0422317f6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IFont.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IFont extends IUnknown {
+/**
+ * IFont constructor comment.
+ * @param address int
+ */
+public IFont(int address) {
+ super(address);
+}
+public int get_hFont(int[] phfont){
+ return COM.VtblCall(3, address, phfont);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java
new file mode 100755
index 0000000000..0fb02bb76d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IMoniker.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IMoniker extends IPersist
+{
+public IMoniker(int address) {
+ super(address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java
new file mode 100755
index 0000000000..be82303bfe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleCommandTarget.java
@@ -0,0 +1,35 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IOleCommandTarget extends IUnknown {
+/**
+ * IOleCommandTarget constructor comment.
+ * @param address int
+ */
+public IOleCommandTarget(int address) {
+ super(address);
+}
+public int Exec(
+ GUID pguidCmdGroup, // Pointer to command group
+ int nCmdID, // Identifier of command to execute
+ int nCmdExecOpt, // Options for executing the command
+ int pvaIn, // Pointer to input arguments
+ int pvaOut // Pointer to command output
+){
+ return COM.VtblCall(4, address, pguidCmdGroup, nCmdID, nCmdExecOpt, pvaIn, pvaOut);
+}
+public int QueryStatus(
+ GUID pguidCmdGroup, // Pointer to command group
+ int cCmds, // Number of commands in prgCmds array
+ OLECMD prgCmds, // Array of commands
+ OLECMDTEXT pCmdText // Pointer to name or status of command
+){
+ // we only support querying for one command at a time
+ if (cCmds > 1) return COM.E_INVALIDARG;
+ return COM.VtblCall(3, address, pguidCmdGroup, cCmds, prgCmds, pCmdText);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java
new file mode 100755
index 0000000000..169935b094
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleControl.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IOleControl extends IUnknown
+{
+public IOleControl(int address) {
+ super(address);
+}
+public int GetControlInfo(CONTROLINFO pCI) {
+ return COM.VtblCall(3, address, pCI);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java
new file mode 100755
index 0000000000..ef0defed9e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceActiveObject.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class IOleInPlaceActiveObject extends IOleWindow
+{
+public IOleInPlaceActiveObject(int address) {
+ super(address);
+}
+public int ResizeBorder(RECT prcBorder, int pUIWindow, boolean fFrameWindow) {
+ return COM.VtblCall(8, address, prcBorder, pUIWindow, fFrameWindow);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java
new file mode 100755
index 0000000000..5963096daa
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleInPlaceObject.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class IOleInPlaceObject extends IOleWindow
+{
+public IOleInPlaceObject(int address) {
+ super(address);
+}
+public int InPlaceDeactivate() {
+ return COM.VtblCall(5, address);
+}
+public int SetObjectRects(RECT lprcPosRect, RECT lprcClipRect) {
+ return COM.VtblCall(7, address, lprcPosRect, lprcClipRect);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java
new file mode 100755
index 0000000000..a84c3851a6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleLink.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IOleLink extends IUnknown
+{
+public IOleLink(int address) {
+ super(address);
+}
+public int BindIfRunning() {
+ return COM.VtblCall(10, address);
+}
+public int GetSourceMoniker(int[] ppmk) {
+ return COM.VtblCall(6, address, ppmk);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java
new file mode 100755
index 0000000000..1559123ad8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleObject.java
@@ -0,0 +1,55 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class IOleObject extends IUnknown
+{
+public IOleObject(int address) {
+ super(address);
+}
+public int Advise(int pAdvSink, int pdwConnection[]) {
+ return COM.VtblCall(19, address, pAdvSink, pdwConnection);
+}
+public int Close(int dwSaveOption) {
+ return COM.VtblCall(6, address, dwSaveOption);
+}
+public int DoVerb(int iVerb, MSG lpmsg, int pActiveSite, int lindex, int hwndParent, RECT lprcPosRect) {
+ return COM.VtblCall(11, address, iVerb, lpmsg, pActiveSite, lindex, hwndParent, lprcPosRect);
+}
+public int GetExtent(int dwDrawAspect, SIZE pSizel) {
+ return COM.VtblCall(18, address, dwDrawAspect, pSizel);
+}
+public int SetClientSite(int pClientSite) {
+ return COM.VtblCall(3, address, pClientSite);
+}
+public int SetExtent(int dwDrawAspect, SIZE pSizel) {
+ return COM.VtblCall(17, address, dwDrawAspect, pSizel);
+}
+public int SetHostNames(String szContainerApp, String szContainerObj) {
+
+ // create a null terminated array of char
+ char[] buffer1 = null;
+ if (szContainerApp != null) {
+ int count1 = szContainerApp.length();
+ buffer1 = new char[count1 + 1];
+ szContainerApp.getChars(0, count1, buffer1, 0);
+ }
+
+ // create a null terminated array of char
+ char[] buffer2 = null;
+ if (szContainerObj != null) {
+ int count2 = szContainerObj.length();
+ buffer2 = new char[count2 + 1];
+ szContainerObj.getChars(0, count2, buffer2, 0);
+ }
+ return COM.VtblCall(5, address, buffer1, buffer2);
+}
+public int Update() {
+ return COM.VtblCall(13, address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java
new file mode 100755
index 0000000000..1a7d21a3b5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IOleWindow.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IOleWindow extends IUnknown {
+/**
+ * ProxyIOleWindow constructor comment.
+ * @param address int
+ */
+public IOleWindow(int address) {
+ super(address);
+}
+public int GetWindow(int phwnd[]) {
+ return COM.VtblCall(3, address, phwnd);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersist.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersist.java
new file mode 100755
index 0000000000..a8ed520f9e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersist.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IPersist extends IUnknown
+{
+public IPersist(int address) {
+ super(address);
+}
+public int GetClassID(GUID pClassID) {
+ return COM.VtblCall(3, address, pClassID);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java
new file mode 100755
index 0000000000..e3a5f164ee
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IPersistStorage.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IPersistStorage extends IPersist
+{
+public IPersistStorage(int address) {
+ super(address);
+}
+public int IsDirty() {
+ return COM.VtblCall(4, address);
+}
+public int InitNew(int pStg) {
+ return COM.VtblCall(5, address, pStg);
+}
+public int Load(int pStg) {
+ return COM.VtblCall(6, address, pStg);
+}
+public int Save(int pStgSave, boolean fSameAsLoad) {
+ return COM.VtblCall(7, address, pStgSave, fSameAsLoad);
+}
+public int SaveCompleted(int pStgNew) {
+ return COM.VtblCall(8, address, pStgNew);
+}
+public int HandsOffStorage(){
+ return COM.VtblCall(9, address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java
new file mode 100755
index 0000000000..ecaa8db5dc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IProvideClassInfo extends IUnknown
+{
+public IProvideClassInfo(int address) {
+ super(address);
+}
+public int GetClassInfo(int[] ppTI) {
+ return COM.VtblCall(3, address, ppTI);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java
new file mode 100755
index 0000000000..d82afd0a23
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IProvideClassInfo2.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IProvideClassInfo2 extends IProvideClassInfo
+{
+public IProvideClassInfo2(int address) {
+ super(address);
+}
+public int GetGUID(int dwGuidKind, GUID pGUID) {
+ return COM.VtblCall(4, address, dwGuidKind, pGUID);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java
new file mode 100755
index 0000000000..667cc850d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ISpecifyPropertyPages.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class ISpecifyPropertyPages extends IUnknown {
+
+public ISpecifyPropertyPages(int address) {
+ super(address);
+}
+public int GetPages(CAUUID pPages){
+ return COM.VtblCall(3, address, pPages);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStorage.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStorage.java
new file mode 100755
index 0000000000..3324b33b4e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStorage.java
@@ -0,0 +1,144 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IStorage extends IUnknown
+{
+public IStorage(int address) {
+ super(address);
+}
+public int Commit(int grfCommitFlag) {
+ return COM.VtblCall(9, address, grfCommitFlag);
+}
+public int CopyTo(
+ int ciidExclude, //Number of elements in rgiidExclude
+ GUID rgiidExclude, //Array of interface identifiers (IIDs)
+ String[] snbExclude, //Points to a block of stream names in the storage object
+ int pstgDest //Points to destination storage object
+ ){
+ // we only support snbExclude = null
+ if (snbExclude != null) {
+ return COM.E_INVALIDARG;
+ }
+ return COM.VtblCall(7, address, ciidExclude, rgiidExclude, 0, pstgDest);
+}
+public int CreateStorage(
+ String pwcsName, //Pointer to the name of the new storage object
+ int grfMode, //Access mode for the new storage object
+ int reserved1, //Reserved; must be zero
+ int reserved2, //Reserved; must be zero
+ int[] ppStg //Pointer to new storage object
+){
+
+ // create a null terminated array of char
+ char[] buffer = null;
+ if (pwcsName != null) {
+ buffer = (pwcsName+"\0").toCharArray();
+ }
+
+ return COM.VtblCall(5, address, buffer, grfMode, reserved1, reserved2, ppStg);
+}
+public int CreateStream(
+ String pwcsName, //Pointer to the name of the new stream
+ int grfMode, //Access mode for the new stream
+ int reserved1, //Reserved; must be zero
+ int reserved2, //Reserved; must be zero
+ int[] ppStm //Pointer to new stream object
+){
+
+ // create a null terminated array of char
+ char[] buffer = null;
+ if (pwcsName != null) {
+ buffer = (pwcsName+"\0").toCharArray();
+ }
+
+ return COM.VtblCall(3, address, buffer, grfMode, reserved1, reserved2, ppStm);
+}
+public int DestroyElement(String pwcsName) {
+
+ // create a null terminated array of char
+ char[] buffer = null;
+ if (pwcsName != null) {
+ buffer = (pwcsName+"\0").toCharArray();
+ }
+ return COM.VtblCall(12, address, buffer);
+}
+public int EnumElements(
+ int reserved1, //Reserved; must be zero
+ int reserved2, //Reserved; must be NULL
+ int reserved3, //Reserved; must be zero
+ int[] ppenum //Pointer to output variable that
+ // receives the IEnumSTATSTG interface
+){
+ return COM.VtblCall(11, address, reserved1, reserved2, reserved3, ppenum);
+}
+public int OpenStorage(
+ String pwcsName, //Pointer to the name of the
+ // storage object to open
+ int pstgPriority, //Must be NULL.
+ int grfMode, //Access mode for the new storage object
+ String snbExclude[], //Must be NULL.
+ int reserved, //Reserved; must be zero
+ int[] ppStg //Pointer to opened storage object
+){
+
+ // create a null terminated array of char
+ char[] buffer = null;
+ if (pwcsName != null) {
+ buffer = (pwcsName+"\0").toCharArray();
+ }
+
+ // we only support the case where snbExclude = null
+ if (snbExclude != null) {
+ return COM.E_INVALIDARG;
+ }
+ return COM.VtblCall(6, address, buffer, pstgPriority, grfMode, 0, reserved, ppStg);
+}
+public int OpenStream(
+ String pwcsName, //Pointer to name of stream to open
+ int reserved1, //Reserved; must be NULL
+ int grfMode, //Access mode for the new stream
+ int reserved2, //Reserved; must be zero
+ int[] ppStm //Pointer to output variable
+ // that receives the IStream interface pointer
+) {
+
+ // create a null terminated array of char
+ char[] buffer = null;
+ if (pwcsName != null) {
+ buffer = (pwcsName+"\0").toCharArray();
+ }
+
+ return COM.VtblCall(4, address, buffer, reserved1, grfMode, reserved2, ppStm);
+}
+public int RenameElement(
+ String pwcsOldName, //Pointer to the name of the
+ // element to be changed
+ String pwcsNewName //Pointer to the new name for
+ // the specified element
+){
+
+ // create a null terminated array of char
+ char[] buffer1 = null;
+ if (pwcsOldName != null) {
+ buffer1 = (pwcsOldName+"\0").toCharArray();
+ }
+ // create a null terminated array of char
+ char[] buffer2 = null;
+ if (pwcsNewName != null) {
+ buffer2 = (pwcsNewName+"\0").toCharArray();
+ }
+ return COM.VtblCall(13, address, buffer1, buffer2);
+}
+public int Revert() {
+ return COM.VtblCall(10, address);
+}
+public int SetClass(
+ GUID clsid //CLSID to be assigned to the storage object
+){
+ return COM.VtblCall(15, address, clsid);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStream.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStream.java
new file mode 100755
index 0000000000..b4bff056b3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IStream.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IStream extends IUnknown {
+public IStream(int address) {
+ super(address);
+}
+public int Clone(
+ int[] ppstm //Pointer to location for pointer to the new stream object
+){
+ return COM.VtblCall(13, address, ppstm);
+}
+public int Commit( int grfCommitFlags //Specifies how changes are committed
+){
+ return COM.VtblCall(8, address, grfCommitFlags);
+}
+public int Read(int pv, int cb, int[] pcbWritten) {
+ return COM.VtblCall(3, address, pv, cb, pcbWritten);
+}
+public int Revert(){
+ return COM.VtblCall(9, address);
+}
+public int Write(int pv, int cb, int[] pcbWritten) {
+ return COM.VtblCall(4, address, pv, cb, pcbWritten);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
new file mode 100755
index 0000000000..9135807800
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/ITypeInfo.java
@@ -0,0 +1,155 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.internal.win32.OS;
+
+public class ITypeInfo extends IUnknown
+{
+
+public ITypeInfo(int address) {
+ super(address);
+}
+public int GetDocumentation(int index, String[] name, String[] docString, int[] pdwHelpContext, String[] helpFile ) {
+ int[] pBstrName = null;
+ if (name != null) pBstrName = new int[1];
+ int[] pBstrDocString = null;
+ if (docString != null) pBstrDocString = new int[1];
+ int[] pBstrHelpFile = null;
+ if (helpFile != null) pBstrHelpFile = new int[1];
+ int rc = COM.VtblCall(12, address, index, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
+ if (name != null && pBstrName[0] != 0) {
+ int size = COM.SysStringByteLen(pBstrName[0]);
+ if (size > 0){
+ // get the unicode character array from the global memory and create a String
+ char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
+ COM.MoveMemory(buffer, pBstrName[0], size);
+ name[0] = new String(buffer);
+ int subindex = name[0].indexOf("\0");
+ if (subindex > 0)
+ name[0] = name[0].substring(0, subindex);
+ }
+ COM.SysFreeString(pBstrName[0]);
+ }
+ if (docString != null && pBstrDocString[0] != 0) {
+ int size = COM.SysStringByteLen(pBstrDocString[0]);
+ if (size > 0){
+ // get the unicode character array from the global memory and create a String
+ char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
+ COM.MoveMemory(buffer, pBstrDocString[0], size);
+ docString[0] = new String(buffer);
+ int subindex = docString[0].indexOf("\0");
+ if (subindex > 0)
+ docString[0] = docString[0].substring(0, subindex);
+ }
+ COM.SysFreeString(pBstrDocString[0]);
+ }
+ if (helpFile != null && pBstrHelpFile[0] != 0) {
+ int size = COM.SysStringByteLen(pBstrHelpFile[0]);
+ if (size > 0){
+ // get the unicode character array from the global memory and create a String
+ char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
+ COM.MoveMemory(buffer, pBstrHelpFile[0], size);
+ helpFile[0] = new String(buffer);
+ int subindex = helpFile[0].indexOf("\0");
+ if (subindex > 0)
+ helpFile[0] = helpFile[0].substring(0, subindex);
+ }
+ COM.SysFreeString(pBstrHelpFile[0]);
+ }
+ return rc;
+}
+public int GetFuncDesc(int index, int[] ppFuncDesc) {
+ return COM.VtblCall(5, address, index, ppFuncDesc);
+}
+public int GetIDsOfNames(String[] rgszNames, int cNames, int[] pMemId) {
+
+ char[] buffer;
+ int size = rgszNames.length;
+
+ // create an array to hold the addresses
+ int hHeap = OS.GetProcessHeap();
+ int ppNames = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, size*4);
+ int[] memTracker = new int[size];
+
+ try {
+ // add the address of each string to the array
+
+ for (int i=0; i<size; i++){
+ // create a null terminated array of char for each String
+ int nameSize = rgszNames[i].length();
+ buffer = new char[nameSize +1];
+ rgszNames[i].getChars(0, nameSize, buffer, 0);
+ // get the address of the start of the array of char
+ int pName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length * 2);
+ OS.MoveMemory(pName, buffer, buffer.length * 2);
+ // copy the address to the array of addresses
+ COM.MoveMemory(ppNames + 4*i, new int[]{pName}, 4);
+ // keep track of the Global Memory so we can free it
+ memTracker[i] = pName;
+ }
+
+ return COM.VtblCall(10, address, ppNames, cNames, pMemId);
+
+ } finally {
+ // free the memory
+ for (int i=0; i<memTracker.length; i++){
+ OS.HeapFree(hHeap, 0, memTracker[i]);
+ }
+ OS.HeapFree(hHeap, 0, ppNames);
+ }
+}
+
+public int GetImplTypeFlags(int index, int[] pImplTypeFlags) {
+ return COM.VtblCall(9, address, index, pImplTypeFlags);
+}
+public int GetNames(int memid, String[] names, int cMaxNames, int[] pcNames){
+
+ int nameSize = names.length;
+ int[] rgBstrNames = new int[nameSize];
+ int rc = COM.VtblCall(7, address, memid, rgBstrNames, nameSize, pcNames);
+
+ if (rc == COM.S_OK) {
+ for (int i = 0; i < pcNames[0]; i++) {
+ int size = COM.SysStringByteLen(rgBstrNames[i]);
+ if (size > 0){
+ // get the unicode character array from the global memory and create a String
+ char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
+ COM.MoveMemory(buffer, rgBstrNames[i], size);
+ names[i] = new String(buffer);
+ int subindex = names[i].indexOf("\0");
+ if (subindex > 0)
+ names[i] = names[i].substring(0, subindex);
+ }
+ COM.SysFreeString(rgBstrNames[i]);
+ }
+ }
+
+ return rc;
+}
+public int GetRefTypeInfo(int hRefType, int[] ppTInfo) {
+ return COM.VtblCall(14, address, hRefType, ppTInfo);
+}
+public int GetRefTypeOfImplType(int index, int[] pRefType) {
+ return COM.VtblCall(8, address, index, pRefType);
+}
+public int GetTypeAttr(int[] ppTypeAttr) {
+ return COM.VtblCall(3, address, ppTypeAttr);
+}
+public int GetVarDesc(int index, int[] ppVarDesc ) {
+ return COM.VtblCall(6, address, index, ppVarDesc);
+}
+public int ReleaseFuncDesc(int pFuncDesc ) {
+ return COM.VtblCall(20, address, pFuncDesc);
+}
+public int ReleaseTypeAttr(int pTypeAttr) {
+ return COM.VtblCall(19, address, pTypeAttr);
+}
+public int ReleaseVarDesc(int pVarDesc ) {
+ return COM.VtblCall(21, address, pVarDesc);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java
new file mode 100755
index 0000000000..18e2e8df43
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IUnknown.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class IUnknown
+{
+ int address;
+public IUnknown(int address) {
+ this.address = address;
+}
+public int AddRef() {
+ return COM.VtblCall(1, address);
+}
+public int getAddress() {
+ return address;
+}
+public int QueryInterface(GUID riid, int ppvObject[]) {
+ return COM.VtblCall(0, address, riid, ppvObject);
+}
+public int Release() {
+ return COM.VtblCall(2, address);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java
new file mode 100755
index 0000000000..78c2f621b3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/IViewObject2.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.internal.win32.*;
+
+public class IViewObject2 extends IUnknown
+{
+public IViewObject2(int address) {
+ super(address);
+}
+public int GetExtent(int dwAspect, int lindex, DVTARGETDEVICE ptd, SIZE lpsizel) {
+ return COM.VtblCall(9, address, dwAspect, lindex, ptd, lpsizel);
+}
+public int SetAdvise(int dwAspects, int dwAdvf, int pIAdviseSink) {
+ return COM.VtblCall(7, address, dwAspects, dwAdvf, pIAdviseSink);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java
new file mode 100755
index 0000000000..a427edd1b1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/LICINFO.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class LICINFO
+{
+ public int cbLicInfo;
+ public int fRuntimeKeyAvail;
+ public int fLicVerified;
+
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java
new file mode 100755
index 0000000000..d51a8882e9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMD.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class OLECMD {
+ public int cmdID;
+ public int cmdf;
+
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java
new file mode 100755
index 0000000000..bfac57d0e2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLECMDTEXT.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class OLECMDTEXT {
+ public int cmdtextf;
+ public int cwActual;
+ public int cwBuf;
+ public short rgwz;
+
+ // Note: this is a variable sized struct. The last field rgwz can vary in size.
+ // Currently we do not use this field and do not support accessing anything more
+ // than the first char in the field.
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java
new file mode 100755
index 0000000000..cc0bf1c086
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class OLEINPLACEFRAMEINFO
+{
+
+ public int cb;
+ public int fMDIApp;
+ public int hwndFrame;
+ public int haccel;
+ public int cAccelEntries;
+
+ public static final int sizeof = 20;
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java
new file mode 100755
index 0000000000..76a3a7de8e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STATSTG.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class STATSTG {
+ public int pwcsName;
+ public int type;
+ public long cbSize;
+ //FILETIME mtime;
+ public int mtime_dwLowDateTime;
+ public int mtime_dwHighDateTime;
+ //FILETIME ctime;
+ public int ctime_dwLowDateTime;
+ public int ctime_dwHighDateTime;
+ //FILETIME atime;
+ public int atime_dwLowDateTime;
+ public int atime_dwHighDateTime;
+ public int grfMode;
+ public int grfLocksSupported;
+ //GUID clsid;
+ public int clsid_data1;
+ public short clsid_data2;
+ public short clsid_data3;
+ public byte clsid_b0;
+ public byte clsid_b1;
+ public byte clsid_b2;
+ public byte clsid_b3;
+ public byte clsid_b4;
+ public byte clsid_b5;
+ public byte clsid_b6;
+ public byte clsid_b7;
+ public int grfStateBits;
+ public int reserved;
+
+ public static final int sizeof = 72;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java
new file mode 100755
index 0000000000..cf9ecde696
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/STGMEDIUM.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class STGMEDIUM
+{
+ public int tymed;
+ public int unionField;
+ public int pUnkForRelease;
+
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java
new file mode 100755
index 0000000000..4055e2fbeb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/TYPEATTR.java
@@ -0,0 +1,50 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public final class TYPEATTR
+{
+ //public GUID guid
+ public int guid_data1;
+ public short guid_data2;
+ public short guid_data3;
+ public byte guid_b0;
+ public byte guid_b1;
+ public byte guid_b2;
+ public byte guid_b3;
+ public byte guid_b4;
+ public byte guid_b5;
+ public byte guid_b6;
+ public byte guid_b7;
+
+ public int lcid;
+ public int dwReserved;
+ public int memidConstructor;
+ public int memidDestructor;
+ public int lpstrSchema;
+ public int cbSizeInstance;
+ public int typekind;
+ public short cFuncs;
+ public short cVars;
+ public short cImplTypes;
+ public short cbSizeVft;
+ public short cbAlignment;
+ public short wTypeFlags;
+ public short wMajorVerNum;
+ public short wMinorVerNum;
+
+ // public TYPEDESC tdescAlias
+ public int tdescAlias_unionField;
+ public short tdescAlias_vt;
+ // this filler field is required for proper byte alignment
+ public short filler;
+
+ // public IDLDESC idldesctype
+ public int idldescType_dwReserved;
+ public short idldescType_wIDLFlags;
+
+ public static final int sizeof = 74;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java
new file mode 100755
index 0000000000..9d33d3f54a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC1.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class VARDESC1 {
+ public int memid;
+ public int lpstrSchema;
+ public int unionField;
+ //ELEMDESC elemdescVar
+ //TYPEDESC elemdescVar.tdesc
+ public int elemdescVar_tdesc_union;
+ public short elemdescVar_tdesc_vt;
+ public short elemdescVar_tdesc_filler;
+ //PARAMDESC elemdescFunc.paramdesc
+ public int elemdescVar_paramdesc_pparamdescex;
+ public short elemdescVar_paramdesc_wParamFlags;
+ public short elemdescVar_paramdesc_filler;
+ public short wVarFlags;
+ public short filler;
+ public int varkind;
+
+ public static final int sizeof = 36;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java
new file mode 100755
index 0000000000..7237ffce2d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/VARDESC2.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.internal.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class VARDESC2 {
+ public int memid;
+ public int lpstrSchema;
+ public int unionField;
+ //ELEMDESC elemdescVar
+ //TYPEDESC elemdescVar.tdesc
+ public int elemdescVar_tdesc_union;
+ public short elemdescVar_tdesc_vt;
+ public short elemdescVar_tdesc_filler;
+ //IDLDESC elemdescFunc.idldesc
+ public int elemdescFunc_idldesc_dwReserved;
+ public short elemdescFunc_idldesc_wIDLFlags;
+ public short elemdescFunc_idldesc_filler;
+ public short wVarFlags;
+ public short filler;
+ public int varkind;
+
+ public static final int sizeof = 36;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/internal/ole/win32/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
new file mode 100755
index 0000000000..2ad984837b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OLE.java
@@ -0,0 +1,420 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import java.io.File;
+import org.eclipse.swt.internal.ole.win32.COM;
+import org.eclipse.swt.internal.Converter;
+import org.eclipse.swt.internal.win32.OS;
+
+
+/**
+ *
+ * OLE contains all the constants used to create an ActiveX Control or an OLE Document.
+ *
+ * <p>Definitions for these constants can be found in MSDN.
+ *
+ */
+public class OLE extends SWT {
+
+ public static final int S_FALSE = 1; // Used for functions that semantically return a Boolean FALSE result to indicate that the function succeeded.
+ public static final int S_OK = 0; // Function succeeded.
+
+ // Verbs that can be invoked on this client
+ public static final int OLEIVERB_DISCARDUNDOSTATE = -6; // close the OLE object and discard the undo state
+ public static final int OLEIVERB_HIDE = -3; // hide the OLE object
+ public static final int OLEIVERB_INPLACEACTIVATE = -5; // open the OLE for editing in-place
+ public static final int OLEIVERB_OPEN = -2; // open the OLE object for editing in a separate window
+ public static final int OLEIVERB_PRIMARY = 0; // opens the OLE object for editing
+ public static final int OLEIVERB_PROPERTIES = -7; // request the OLE object properties dialog
+ public static final int OLEIVERB_SHOW = -1; // show the OLE object
+ public static final int OLEIVERB_UIACTIVATE = -4; // activate the UI for the OLE object
+
+ public static final int PROPERTY_CHANGING = 0;
+ public static final int PROPERTY_CHANGED = 1;
+
+ /**
+ * Error code for OleError - No specific error information available
+ */
+ public static final int HRESULT_UNSPECIFIED = 0;
+ /**
+ * Error code for OleError - Failed to create file
+ */
+ public static final int ERROR_CANNOT_CREATE_FILE = 1000;
+ /**
+ * Error code for OleError - Failed to create Ole Client
+ */
+ public static final int ERROR_CANNOT_CREATE_OBJECT = 1001;
+ /**
+ * Error code for OleError - File does not exist, is not accessible to user or does not have the correct format
+ */
+ public static final int ERROR_CANNOT_OPEN_FILE = 1002;
+ /**
+ * Error code for OleError - Failed to find requested interface on OLE Object
+ */
+ public static final int ERROR_INTERFACE_NOT_FOUND = 1003;
+ /**
+ * Error code for OleError - Class ID not found in registry
+ */
+ public static final int ERROR_INVALID_CLASSID = 1004;
+ /**
+ * Error code for OleError - Failed to get the class factory for the specified classID
+ */
+ public static final int ERROR_CANNOT_ACCESS_CLASSFACTORY = 1005;
+ /**
+ * Error code for OleError - Failed to create Licensed instance
+ */
+ public static final int ERROR_CANNOT_CREATE_LICENSED_OBJECT = 1006;
+ /**
+ * Error code for OleError - Out of Memory
+ */
+ public static final int ERROR_OUT_OF_MEMORY = 1007;
+ /**
+ * Error code for OleError - Failed to change Variant type
+ */
+ public static final int ERROR_CANNOT_CHANGE_VARIANT_TYPE = 1010;
+ /**
+ * Error code for OleError - Invalid address received for Ole Interface
+ */
+ public static final int ERROR_INVALID_INTERFACE_ADDRESS = 1011;
+ /**
+ * Error code for OleError - Unable to find Application
+ */
+ public static final int ERROR_APPLICATION_NOT_FOUND = 1013;
+ /**
+ * Error code for OleError - Action can not be performed
+ */
+ public static final int ERROR_ACTION_NOT_PERFORMED = 1014;
+
+ public static final int OLECMDF_SUPPORTED = 1;
+ public static final int OLECMDF_ENABLED = 2;
+ public static final int OLECMDF_LATCHED = 4;
+ public static final int OLECMDF_NINCHED = 8;
+
+ public static final int OLECMDTEXTF_NONE = 0;
+ public static final int OLECMDTEXTF_NAME = 1;
+ public static final int OLECMDTEXTF_STATUS = 2;
+
+ public static final int OLECMDEXECOPT_DODEFAULT = 0;
+ public static final int OLECMDEXECOPT_PROMPTUSER = 1;
+ public static final int OLECMDEXECOPT_DONTPROMPTUSER = 2;
+ public static final int OLECMDEXECOPT_SHOWHELP = 3;
+
+ public static final int OLECMDID_OPEN = 1;
+ public static final int OLECMDID_NEW = 2;
+ public static final int OLECMDID_SAVE = 3;
+ public static final int OLECMDID_SAVEAS = 4;
+ public static final int OLECMDID_SAVECOPYAS = 5;
+ public static final int OLECMDID_PRINT = 6;
+ public static final int OLECMDID_PRINTPREVIEW = 7;
+ public static final int OLECMDID_PAGESETUP = 8;
+ public static final int OLECMDID_SPELL = 9;
+ public static final int OLECMDID_PROPERTIES = 10;
+ public static final int OLECMDID_CUT = 11;
+ public static final int OLECMDID_COPY = 12;
+ public static final int OLECMDID_PASTE = 13;
+ public static final int OLECMDID_PASTESPECIAL = 14;
+ public static final int OLECMDID_UNDO = 15;
+ public static final int OLECMDID_REDO = 16;
+ public static final int OLECMDID_SELECTALL = 17;
+ public static final int OLECMDID_CLEARSELECTION = 18;
+ public static final int OLECMDID_ZOOM = 19;
+ public static final int OLECMDID_GETZOOMRANGE = 20;
+ public static final int OLECMDID_UPDATECOMMANDS = 21;
+ public static final int OLECMDID_REFRESH = 22;
+ public static final int OLECMDID_STOP = 23;
+ public static final int OLECMDID_HIDETOOLBARS = 24;
+ public static final int OLECMDID_SETPROGRESSMAX = 25;
+ public static final int OLECMDID_SETPROGRESSPOS = 26;
+ public static final int OLECMDID_SETPROGRESSTEXT = 27;
+ public static final int OLECMDID_SETTITLE = 28;
+ public static final int OLECMDID_SETDOWNLOADSTATE = 29;
+ public static final int OLECMDID_STOPDOWNLOAD = 30;
+
+ /* Ole Property Description flags */
+ public static int VARFLAG_FREADONLY = 0x1;
+ public static int VARFLAG_FSOURCE = 0x2;
+ public static int VARFLAG_FBINDABLE = 0x4;
+ public static int VARFLAG_FREQUESTEDIT = 0x8;
+ public static int VARFLAG_FDISPLAYBIND = 0x10;
+ public static int VARFLAG_FDEFAULTBIND = 0x20;
+ public static int VARFLAG_FHIDDEN = 0x40;
+ public static int VARFLAG_FRESTRICTED = 0x80;
+ public static int VARFLAG_FDEFAULTCOLLELEM = 0x100;
+ public static int VARFLAG_FUIDEFAULT = 0x200;
+ public static int VARFLAG_FNONBROWSABLE = 0x400;
+ public static int VARFLAG_FREPLACEABLE = 0x800;
+ public static int VARFLAG_FIMMEDIATEBIND = 0x1000;
+
+ /* Ole Property Description kind */
+ public static int VAR_PERINSTANCE = 0;
+ public static int VAR_STATIC = 1;
+ public static int VAR_CONST = 2;
+ public static int VAR_DISPATCH = 3;
+
+ /* Ole Parameter Description flags */
+ public static short IDLFLAG_NONE = 0;
+ public static short IDLFLAG_FIN = 1;
+ public static short IDLFLAG_FOUT = 2;
+ public static short IDLFLAG_FLCID = 4;
+ public static short IDLFLAG_FRETVAL = 8;
+
+ /* Ole Description types */
+ public static final short VT_BOOL = 11; // Boolean; True=-1, False=0.
+ public static final short VT_BSTR = 8; // Binary String.
+ public static final short VT_BYREF = 16384; // By reference - must be combined with one of the othre VT values
+ public static final short VT_CY = 6; // Currency.
+ public static final short VT_DATE = 7; // Date.
+ public static final short VT_DISPATCH = 9; // IDispatch
+ public static final short VT_EMPTY = 0; // Not specified.
+ public static final short VT_ERROR = 10; // Scodes.
+ public static final short VT_I2 = 2; // 2-byte signed int.
+ public static final short VT_I4 = 3; // 4-byte signed int.
+ public static final short VT_NULL = 1; // Null.
+ public static final short VT_R4 = 4; // 4-byte real.
+ public static final short VT_R8 = 5; // 8-byte real.
+ public static final short VT_UI1 = 17; // Unsigned char.
+ public static final short VT_UI4 = 19; // Unsigned int.
+ public static final short VT_UNKNOWN = 13; // IUnknown FAR*.
+ public static final short VT_VARIANT = 12; // VARIANT FAR*.
+ public static final short VT_PTR = 26;
+ public static final short VT_USERDEFINED = 29;
+ public static final short VT_HRESULT = 25;
+ public static final short VT_DECIMAL = 14;
+ public static final short VT_I1 = 16;
+ public static final short VT_UI2 = 18;
+ public static final short VT_I8 = 20;
+ public static final short VT_UI8 = 21;
+ public static final short VT_INT = 22;
+ public static final short VT_UINT = 23;
+ public static final short VT_VOID = 24;
+ public static final short VT_SAFEARRAY = 27;
+ public static final short VT_CARRAY = 28;
+ public static final short VT_LPSTR = 30;
+ public static final short VT_LPWSTR = 31;
+ public static final short VT_RECORD = 36;
+ public static final short VT_FILETIME = 64;
+ public static final short VT_BLOB = 65;
+ public static final short VT_STREAM = 66;
+ public static final short VT_STORAGE = 67;
+ public static final short VT_STREAMED_OBJECT = 68;
+ public static final short VT_STORED_OBJECT = 69;
+ public static final short VT_BLOB_OBJECT = 70;
+ public static final short VT_CF = 71;
+ public static final short VT_CLSID = 72;
+ public static final short VT_VERSIONED_STREAM = 73;
+ public static final short VT_BSTR_BLOB = 0xfff;
+ public static final short VT_VECTOR = 0x1000;
+ public static final short VT_ARRAY = 0x2000;
+
+ /* Ole Function Description Invoke Kind values */
+ public static final int INVOKE_FUNC = 1;
+ public static final int INVOKE_PROPERTYGET = 2;
+ public static final int INVOKE_PROPERTYPUT = 4;
+ public static final int INVOKE_PROPERTYPUTREF = 8;
+
+ /* Ole Function Description function kind */
+ public static final int FUNC_VIRTUAL = 0;
+ public static final int FUNC_PUREVIRTUAL = 1;
+ public static final int FUNC_NONVIRTUAL = 2;
+ public static final int FUNC_STATIC = 3;
+ public static final int FUNC_DISPATCH = 4;
+
+ /* Ole Function Description function flags */
+ public static final short FUNCFLAG_FRESTRICTED = 1;
+ public static final short FUNCFLAG_FSOURCE = 0x2;
+ public static final short FUNCFLAG_FBINDABLE = 0x4;
+ public static final short FUNCFLAG_FREQUESTEDIT = 0x8;
+ public static final short FUNCFLAG_FDISPLAYBIND = 0x10;
+ public static final short FUNCFLAG_FDEFAULTBIND = 0x20;
+ public static final short FUNCFLAG_FHIDDEN = 0x40;
+ public static final short FUNCFLAG_FUSESGETLASTERROR = 0x80;
+ public static final short FUNCFLAG_FDEFAULTCOLLELEM = 0x100;
+ public static final short FUNCFLAG_FUIDEFAULT = 0x200;
+ public static final short FUNCFLAG_FNONBROWSABLE = 0x400;
+ public static final short FUNCFLAG_FREPLACEABLE = 0x800;
+ public static final short FUNCFLAG_FIMMEDIATEBIND = 0x1000;
+
+ /* Ole Function Description calling convention */
+ public static final int CC_FASTCALL = 0;
+ public static final int CC_CDECL = 1;
+ public static final int CC_MSCPASCAL = 2;
+ public static final int CC_PASCAL = 2;
+ public static final int CC_MACPASCAL = 3;
+ public static final int CC_STDCALL = 4;
+ public static final int CC_FPFASTCALL = 5;
+ public static final int CC_SYSCALL = 6;
+ public static final int CC_MPWCDECL = 7;
+ public static final int CC_MPWPASCAL = 8;
+ public static final int CC_MAX = 9;
+
+ static final String ERROR_NOT_IMPLEMENTED_MSG = "Required functionality not currently supported.";
+ static final String ERROR_CANNOT_CREATE_FILE_MSG = "Failed to create file.";
+ static final String ERROR_CANNOT_CREATE_OBJECT_MSG = "Failed to create Ole Client.";
+ static final String ERROR_CANNOT_OPEN_FILE_MSG = "File does not exist, is not accessible to user or does not have the correct format.";
+ static final String ERROR_INTERFACE_NOT_FOUND_MSG = "Failed to find requested interface on OLE Object.";
+ static final String ERROR_INVALID_CLASSID_MSG = "Class ID not found in registry";
+ static final String ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG = "Failed to get the class factory for the specified classID";
+ static final String ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG = "Failed to create Licensed instance";
+ static final String ERROR_OUT_OF_MEMORY_MSG = "Out of Memory";
+ static final String ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG = "Failed to change Variant type";
+ static final String ERROR_INVALID_INTERFACE_ADDRESS_MSG = "Invalid address received for Ole Interface.";
+ static final String ERROR_APPLICATION_NOT_FOUND_MSG = "Unable to find Application.";
+ static final String ERROR_ACTION_NOT_PERFORMED_MSG = "Action can not be performed.";
+
+
+public static void error (int code) {
+ error (code, 0);
+}
+public static void error (int code, int hresult) {
+
+ switch (code) {
+ /* Illegal Arguments (non-fatal) */
+ case ERROR_INVALID_INTERFACE_ADDRESS :{
+ throw new IllegalArgumentException (ERROR_INVALID_INTERFACE_ADDRESS_MSG);
+ }
+
+ /* SWT Errors (non-fatal) */
+ case ERROR_CANNOT_CREATE_FILE : {
+ String msg = ERROR_CANNOT_CREATE_FILE_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_CREATE_OBJECT : {
+ String msg = ERROR_CANNOT_CREATE_OBJECT_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_OPEN_FILE : {
+ String msg = ERROR_CANNOT_OPEN_FILE_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_INTERFACE_NOT_FOUND : {
+ String msg = ERROR_INTERFACE_NOT_FOUND_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_INVALID_CLASSID : {
+ String msg = ERROR_INVALID_CLASSID_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_ACCESS_CLASSFACTORY : {
+ String msg = ERROR_CANNOT_ACCESS_CLASSFACTORY_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_CREATE_LICENSED_OBJECT : {
+ String msg = ERROR_CANNOT_CREATE_LICENSED_OBJECT_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_CANNOT_CHANGE_VARIANT_TYPE : {
+ String msg = ERROR_CANNOT_CHANGE_VARIANT_TYPE_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_APPLICATION_NOT_FOUND : {
+ String msg = ERROR_APPLICATION_NOT_FOUND_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+ case ERROR_ACTION_NOT_PERFORMED : {
+ String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTException (code, msg);
+ }
+
+ /* OS Failure/Limit (fatal, may occur only on some platforms) */
+ case ERROR_OUT_OF_MEMORY : {
+ String msg = ERROR_ACTION_NOT_PERFORMED_MSG;
+ if (hresult != 0) msg += " result = "+hresult;
+ throw new SWTError (code, msg);
+ }
+ }
+
+ /* Unknown/Undefined Error */
+ SWT.error(code);
+}
+
+/*
+ * Finds the OLE program id that is associated with an extension.
+ * The extension may or may not begin with a '.'. On platforms
+ * that do not support OLE, an empty string is returned.
+ *
+ * @param extension the program extension
+ * @return a string that is the OLE program id or an empty string
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when extension is null</li>
+ * </ul>
+ */
+public static String findProgramID (String extension) {
+ if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (extension.length () == 0) return "";
+
+ if (extension.charAt (0) != '.') extension = "." + extension;
+
+ byte[] extensionKey = Converter.wcsToMbcs(0, extension, true);
+ String result = getKeyValue(extensionKey);
+ if (result != null) {
+ // look for "<programID>\NotInsertable"
+ byte[] notInsertableKey = Converter.wcsToMbcs(0, result+"\\NotInsertable", true);
+ if (getKeyExists(notInsertableKey)) return "";
+ // look for "<programID>\Insertable"
+ byte[] insertableKey = Converter.wcsToMbcs(0, result+"\\Insertable", true);
+ if (getKeyExists(insertableKey)) return result;
+ // look for "<programID>\protocol\StdFileEditing\server"
+ byte[] serverKey = Converter.wcsToMbcs(0, result+"\\protocol\\StdFileEditing\\server", true);
+ if (getKeyExists(serverKey)) return result;
+ }
+
+ return "";
+}
+private static String getKeyValue (byte [] key) {
+ int [] phkResult = new int [1];
+ if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
+ return null;
+ }
+ String result = null;
+ int [] lpcbData = new int [1];
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {
+ byte [] lpData = new byte [lpcbData [0]];
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
+ char[] charArray = Converter.mbcsToWcs (0, lpData);
+ result = new String(charArray, 0, charArray.length - 1);
+ }
+ }
+ if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
+ return result;
+}
+private static boolean getKeyExists (byte [] key) {
+ int [] phkResult = new int [1];
+ if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
+ return false;
+ }
+ if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
+ return true;
+}
+/**
+ * Returns true if the specified file has an OLE Storage format.
+ *
+ * Note all empty files (regardless of extension) will return false.
+ *
+ * @param file the file to be checked
+ *
+ * @return true if this file has an OLE Storage format
+ */
+public static boolean isOleFile(File file) {
+ if (file == null || !file.exists() || file.isDirectory())
+ return false;
+
+ return (COM.StgIsStorageFile((file.getAbsolutePath()+"\0").toCharArray()) == COM.S_OK);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java
new file mode 100755
index 0000000000..1ac00551fe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleAutomation.java
@@ -0,0 +1,588 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+/**
+ * OleAutomation provides a generic mechanism for accessing functionality that is
+ * specific to a particular ActiveX Control or OLE Document.
+ *
+ * <p>The OLE Document or ActiveX Control must support the IDispatch interface in order to provide
+ * OleAutomation support. The additional functionality provided by the OLE Object is specified in
+ * its IDL file. The additional methods can either be to get property values (<code>getProperty</code>),
+ * to set property values (<code>setProperty</code>) or to invoke a method (<code>invoke</code> or
+ * <code>invokeNoReply</code>). Arguments are passed around in the form of <code>Variant</code>
+ * objects.
+ *
+ * <p>Here is a sample IDL fragment:
+ *
+ * <pre>
+ * interface IMyControl : IDispatch
+ * {
+ * [propget, id(0)] HRESULT maxFileCount([retval, out] int *c);
+ * [propput, id(0)] HRESULT maxFileCount([in] int c);
+ * [id(1)] HRESULT AddFile([in] BSTR fileName);
+ * };
+ * </pre>
+ *
+ * <p>An example of how to interact with this extended functionality is shown below:
+ *
+ * <code><pre>
+ * OleAutomation automation = new OleAutomation(myControlSite);
+ *
+ * // Look up the ID of the maxFileCount parameter
+ * int[] rgdispid = automation.getIDsOfNames(new String[]{"maxFileCount"});
+ * int maxFileCountID = rgdispid[0];
+ *
+ * // Set the property maxFileCount to 100:
+ * if (automation.setProperty(maxFileCountID, new Variant(100))) {
+ * System.out.println("Max File Count was successfully set.");
+ * }
+ *
+ * // Get the new value of the maxFileCount parameter:
+ * Variant pVarResult = automation.getProperty(maxFileCountID);
+ * if (pVarResult != null) {
+ * System.out.println("Max File Count is "+pVarResult.getInt());
+ * }
+ *
+ * // Invoke the AddFile method
+ * // Look up the IDs of the AddFile method and its parameter
+ * rgdispid = automation.getIDsOfNames(new String[]{"AddFile", "fileName"});
+ * int dispIdMember = rgdispid[0];
+ * int[] rgdispidNamedArgs = new int[] {rgdispid[1]};
+ *
+ * // Convert arguments to Variant objects
+ * Variant[] rgvarg = new Variant[1];
+ * String fileName = "C:\\testfile";
+ * rgvarg[0] = new Variant(fileName);
+ *
+ * // Call the method
+ * Variant pVarResult = automation.invoke(dispIdMember, rgvarg, rgdispidNamedArgs);
+ *
+ * // Check the return value
+ * if (pVarResult == null || pVarResult.getInt() != OLE.S_OK){
+ * System.out.println("Failed to add file "+fileName);
+ * }
+ *
+ * automation.dispose();
+ *
+ * </pre></code>
+ */
+public final class OleAutomation {
+ private IDispatch objIDispatch;
+ private String exceptionDescription;
+ private ITypeInfo objITypeInfo;
+
+OleAutomation(int address) {
+ if (address == 0) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
+ objIDispatch = new IDispatch(address);
+ objIDispatch.AddRef();
+}
+/**
+ * Creates an OleAutomation object for the specified client.
+ *
+ * @param clientSite the site for the OLE Document or ActiveX Control whose additional functionality
+ * you need to access
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_INVALID_INTERFACE_ADDRESS when called with an invalid client site
+ * </ul>
+ */
+ public OleAutomation(OleClientSite clientSite) {
+ if (clientSite == null) OLE.error(OLE.ERROR_INVALID_INTERFACE_ADDRESS);
+ objIDispatch = clientSite.getAutomationObject();
+
+ int[] ppv = new int[1];
+ int result = objIDispatch.GetTypeInfo(0, COM.LOCALE_USER_DEFAULT, ppv);
+ if (result == OLE.S_OK) {
+ objITypeInfo = new ITypeInfo(ppv[0]);
+ objITypeInfo.AddRef();
+ }
+ }
+/**
+ * Disposes the automation object.
+ * <p>
+ * This method releases the IDispatch interface on the OLE Document or ActiveX Control.
+ * Do not use the OleAutomation object after it has been disposed.
+ */
+public void dispose() {
+
+ if (objIDispatch != null){
+ objIDispatch.Release();
+ }
+ objIDispatch = null;
+
+ if (objITypeInfo != null){
+ objITypeInfo.Release();
+ }
+ objITypeInfo = null;
+
+}
+int getAddress() {
+ return objIDispatch.getAddress();
+}
+public String getHelpFile(int dispId) {
+ if (objITypeInfo == null) return null;
+ String[] file = new String[1];
+ int rc = objITypeInfo.GetDocumentation(dispId, null, null, null, file );
+ if (rc == OLE.S_OK) return file[0];
+ return null;
+}
+public String getDocumentation(int dispId) {
+ if (objITypeInfo == null) return null;
+ String[] doc = new String[1];
+ int rc = objITypeInfo.GetDocumentation(dispId, null, doc, null, null );
+ if (rc == OLE.S_OK) return doc[0];
+ return null;
+}
+public OlePropertyDescription getPropertyDescription(int index) {
+ if (objITypeInfo == null) return null;
+ int[] ppVarDesc = new int[1];
+ int rc = objITypeInfo.GetVarDesc(index, ppVarDesc);
+ if (rc != OLE.S_OK) return null;
+ VARDESC1 vardesc = new VARDESC1();
+ COM.MoveMemory(vardesc, ppVarDesc[0], VARDESC1.sizeof);
+
+ OlePropertyDescription data = new OlePropertyDescription();
+ data.id = vardesc.memid;
+ data.name = getName(vardesc.memid);
+ data.type = vardesc.elemdescVar_tdesc_vt;
+ if (data.type == OLE.VT_PTR) {
+ short[] vt = new short[1];
+ COM.MoveMemory(vt, vardesc.elemdescVar_tdesc_union + 4, 2);
+ data.type = vt[0];
+ }
+ data.flags = vardesc.wVarFlags;
+ data.kind = vardesc.varkind;
+ data.description = getDocumentation(vardesc.memid);
+ data.helpFile = getHelpFile(vardesc.memid);
+
+ objITypeInfo.ReleaseVarDesc(ppVarDesc[0]);
+ return data;
+}
+public OleFunctionDescription getFunctionDescription(int index) {
+ if (objITypeInfo == null) return null;
+ int[] ppFuncDesc = new int[1];
+ int rc = objITypeInfo.GetFuncDesc(index, ppFuncDesc);
+ if (rc != OLE.S_OK) return null;
+ FUNCDESC1 funcdesc = new FUNCDESC1();
+ COM.MoveMemory(funcdesc, ppFuncDesc[0], FUNCDESC1.sizeof);
+
+ OleFunctionDescription data = new OleFunctionDescription();
+
+ data.id = funcdesc.memid;
+ data.optionalArgCount = funcdesc.cParamsOpt;
+ data.invokeKind = funcdesc.invkind;
+ data.funcKind = funcdesc.funckind;
+ data.flags = funcdesc.wFuncFlags;
+ data.callingConvention = funcdesc.callconv;
+ data.documentation = getDocumentation(funcdesc.memid);
+ data.helpFile = getHelpFile(funcdesc.memid);
+
+ String[] names = getNames(funcdesc.memid, funcdesc.cParams + 1);
+ data.name = names[0];
+ data.args = new OleParameterDescription[funcdesc.cParams];
+ for (int i = 0; i < data.args.length; i++) {
+ data.args[i] = new OleParameterDescription();
+ data.args[i].name = names[i + 1];
+ short[] vt = new short[1];
+ COM.MoveMemory(vt, funcdesc.lprgelemdescParam + i * 16 + 4, 2);
+ if (vt[0] == OLE.VT_PTR) {
+ int[] pTypedesc = new int[1];
+ COM.MoveMemory(pTypedesc, funcdesc.lprgelemdescParam + i * 16, 4);
+ short[] vt2 = new short[1];
+ COM.MoveMemory(vt2, pTypedesc[0] + 4, 2);
+ vt[0] = (short)(vt2[0] | COM.VT_BYREF);
+ }
+ data.args[i].type = vt[0];
+ short[] wParamFlags = new short[1];
+ COM.MoveMemory(wParamFlags, funcdesc.lprgelemdescParam + i * 16 + 12, 2);
+ data.args[i].flags = wParamFlags[0];
+ }
+
+ data.returnType = funcdesc.elemdescFunc_tdesc_vt;
+ if (data.returnType == OLE.VT_PTR) {
+ short[] vt = new short[1];
+ COM.MoveMemory(vt, funcdesc.elemdescFunc_tdesc_union + 4, 2);
+ data.returnType = vt[0];
+ }
+
+ objITypeInfo.ReleaseFuncDesc(ppFuncDesc[0]);
+ return data;
+}
+public TYPEATTR getTypeInfoAttributes() {
+ if (objITypeInfo == null) return null;
+ int[] ppTypeAttr = new int[1];
+ int rc = objITypeInfo.GetTypeAttr(ppTypeAttr);
+ if (rc != OLE.S_OK) return null;
+ TYPEATTR typeattr = new TYPEATTR();
+ COM.MoveMemory(typeattr, ppTypeAttr[0], TYPEATTR.sizeof);
+ objITypeInfo.ReleaseTypeAttr(ppTypeAttr[0]);
+ return typeattr;
+}
+public String getName(int dispId) {
+ if (objITypeInfo == null) return null;
+ String[] name = new String[1];
+ int rc = objITypeInfo.GetDocumentation(dispId, name, null, null, null );
+ if (rc == OLE.S_OK) return name[0];
+ return null;
+}
+public String[] getNames(int dispId, int maxSize) {
+ if (objITypeInfo == null) return new String[0];
+ String[] names = new String[maxSize];
+ int[] count = new int[1];
+ int rc = objITypeInfo.GetNames(dispId, names, maxSize, count);
+ if (rc == OLE.S_OK) {
+ String[] newNames = new String[count[0]];
+ System.arraycopy(names, 0, newNames, 0, count[0]);
+ return newNames;
+ }
+ return new String[0];
+}
+/**
+ * Returns the positive integer values (IDs) that are associated with the specified names by the
+ * IDispatch implementor. If you are trying to get the names of the parameters in a method, the first
+ * String in the names array must be the name of the method followed by the names of the parameters.
+ *
+ * @param names an array of names for which you require the identifiers
+ *
+ * @return positive integer values that are associated with the specified names in the same
+ * order as the names where provided; or null if the names are unknown
+ */
+public int[] getIDsOfNames(String[] names) {
+
+ int[] rgdispid = new int[names.length];
+ int result = objIDispatch.GetIDsOfNames(new GUID(), names, names.length, COM.LOCALE_USER_DEFAULT, rgdispid);
+ if (result != COM.S_OK) return null;
+
+ return rgdispid;
+}
+/**
+ * Returns a description of the last error encountered.
+ *
+ * @return a description of the last error encountered
+ */
+public String getLastError() {
+
+ return exceptionDescription;
+
+}
+/**
+ * Returns the value of the property specified by the dispIdMember.
+ *
+ * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @return the value of the property specified by the dispIdMember
+ */
+public Variant getProperty(int dispIdMember) {
+ // get the IDispatch interface for the control
+ if (objIDispatch == null) return null;
+
+ DISPPARAMS pDispParams = new DISPPARAMS();
+ EXCEPINFO excepInfo = new EXCEPINFO();
+ int[] pArgErr = new int[1];
+ int pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, COM.DISPATCH_PROPERTYGET, pDispParams, pVarResultAddress, excepInfo, pArgErr);
+
+ // save error string and cleanup EXCEPINFO
+ manageExcepinfo(result, excepInfo);
+
+ Variant pVarResult = null;
+ if (result == COM.S_OK) {
+ pVarResult = new Variant();
+ pVarResult.setData(pVarResultAddress);
+ }
+
+ COM.VariantClear(pVarResultAddress);
+ OS.GlobalFree(pVarResultAddress);
+
+ return pVarResult;
+
+}
+/**
+ * Invokes a method on the OLE Object; the method has no parameters.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @return the result of the method or null if the method failed to give result information
+ */
+public Variant invoke(int dispIdMember) {
+
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, null, null, pVarResult);
+
+ if (result == COM.S_OK) return pVarResult;
+
+ return null;
+}
+/**
+ * Invokes a method on the OLE Object; the method has no optional parameters.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @return the result of the method or null if the method failed to give result information
+ */
+public Variant invoke(int dispIdMember, Variant[] rgvarg) {
+
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, rgvarg, null, pVarResult);
+
+ if (result == COM.S_OK) return pVarResult;
+
+ return null;
+}
+/**
+ * Invokes a method on the OLE Object; the method has optional parameters. It is not
+ * neccessary to specify all the optional parameters, only include the parameters for which
+ * you are providing values.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
+ * parameter IDs must be in the same order as their corresponding values;
+ * all arguments must have an identifier - identifiers can be obtained using
+ * OleAutomation.getIDsOfNames
+ *
+ * @return the result of the method or null if the method failed to give result information
+ */
+public Variant invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
+
+ Variant pVarResult = new Variant();
+ int result = invoke(dispIdMember, rgvarg, rgdispidNamedArgs, pVarResult);
+
+ if (result == COM.S_OK) return pVarResult;
+
+ return null;
+}
+private int invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs, Variant pVarResult) {
+
+ // get the IDispatch interface for the control
+ if (objIDispatch == null) return COM.E_FAIL;
+
+ // create a DISPPARAMS structure for the input parameters
+ DISPPARAMS pDispParams = new DISPPARAMS();
+ // store arguments in rgvarg
+ if (rgvarg != null && rgvarg.length > 0) {
+ pDispParams.cArgs = rgvarg.length;
+ pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, Variant.sizeof * rgvarg.length);
+ int offset = 0;
+ for (int i = rgvarg.length - 1; i >= 0 ; i--) {
+ rgvarg[i].getData(pDispParams.rgvarg + offset);
+ offset += Variant.sizeof;
+ }
+ }
+
+ // if arguments have ids, store the ids in rgdispidNamedArgs
+ if (rgdispidNamedArgs != null && rgdispidNamedArgs.length > 0) {
+ pDispParams.cNamedArgs = rgdispidNamedArgs.length;
+ pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4 * rgdispidNamedArgs.length);
+ int offset = 0;
+ for (int i = rgdispidNamedArgs.length; i > 0; i--) {
+ COM.MoveMemory(pDispParams.rgdispidNamedArgs + offset, new int[] {rgdispidNamedArgs[i-1]}, 4);
+ offset += 4;
+ }
+ }
+
+ // invoke the method
+ EXCEPINFO excepInfo = new EXCEPINFO();
+ int[] pArgErr = new int[1];
+ int pVarResultAddress = 0;
+ if (pVarResult != null) pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ int result = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, COM.DISPATCH_METHOD, pDispParams, pVarResultAddress, excepInfo, pArgErr);
+
+ if (pVarResultAddress != 0){
+ pVarResult.setData(pVarResultAddress);
+ COM.VariantClear(pVarResultAddress);
+ OS.GlobalFree(pVarResultAddress);
+ }
+
+ // free the Dispparams resources
+ if (pDispParams.rgdispidNamedArgs != 0){
+ OS.GlobalFree(pDispParams.rgdispidNamedArgs);
+ }
+ if (pDispParams.rgvarg != 0) {
+ int offset = 0;
+ for (int i = 0, length = rgvarg.length; i < length; i++){
+ COM.VariantClear(pDispParams.rgvarg + offset);
+ offset += Variant.sizeof;
+ }
+ OS.GlobalFree(pDispParams.rgvarg);
+ }
+
+ // save error string and cleanup EXCEPINFO
+ manageExcepinfo(result, excepInfo);
+
+ return result;
+}
+/**
+ * Invokes a method on the OLE Object; the method has no parameters. In the early days of OLE,
+ * the IDispatch interface was not well defined and some applications (mainly Word) did not support
+ * a return value. For these applications, call this method instead of calling
+ * <code>public void invoke(int dispIdMember)</code>.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
+ * </ul>
+ */
+public void invokeNoReply(int dispIdMember) {
+ int result = invoke(dispIdMember, null, null, null);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
+}
+/**
+ * Invokes a method on the OLE Object; the method has no optional parameters. In the early days of OLE,
+ * the IDispatch interface was not well defined and some applications (mainly Word) did not support
+ * a return value. For these applications, call this method instead of calling
+ * <code>public void invoke(int dispIdMember, Variant[] rgvarg)</code>.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
+ * </ul>
+ */
+public void invokeNoReply(int dispIdMember, Variant[] rgvarg) {
+ int result = invoke(dispIdMember, rgvarg, null, null);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
+}
+/**
+ * Invokes a method on the OLE Object; the method has optional parameters. It is not
+ * neccessary to specify all the optional parameters, only include the parameters for which
+ * you are providing values. In the early days of OLE, the IDispatch interface was not well
+ * defined and some applications (mainly Word) did not support a return value. For these
+ * applications, call this method instead of calling
+ * <code>public void invoke(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs)</code>.
+ *
+ * @param dispIdMember the ID of the method as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ *
+ * @param rgvarg an array of arguments for the method. All arguments are considered to be
+ * read only unless the Variant is a By Reference Variant type.
+ *
+ * @param rgdispidNamedArgs an array of identifiers for the arguments specified in rgvarg; the
+ * parameter IDs must be in the same order as their corresponding values;
+ * all arguments must have an identifier - identifiers can be obtained using
+ * OleAutomation.getIDsOfNames
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_ACTION_NOT_PERFORMED when method invocation fails
+ * </ul>
+ */
+public void invokeNoReply(int dispIdMember, Variant[] rgvarg, int[] rgdispidNamedArgs) {
+ int result = invoke(dispIdMember, rgvarg, rgdispidNamedArgs, null);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_ACTION_NOT_PERFORMED, result);
+}
+private void manageExcepinfo(int hResult, EXCEPINFO excepInfo) {
+
+ if (hResult == COM.S_OK){
+ exceptionDescription = new String("No Error");
+ return;
+ }
+
+ // extract exception info
+ if (hResult == COM.DISP_E_EXCEPTION) {
+ if (excepInfo.bstrDescription != 0){
+ int size = COM.SysStringByteLen(excepInfo.bstrDescription);
+ char[] buffer = new char[(size + 1) /2];
+ COM.MoveMemory(buffer, excepInfo.bstrDescription, size);
+ exceptionDescription = new String(buffer);
+ } else {
+ exceptionDescription = new String("OLE Automation Error Exception ");
+ if (excepInfo.wCode != 0){
+ exceptionDescription += "code = "+excepInfo.wCode;
+ } else if (excepInfo.scode != 0){
+ exceptionDescription += "code = "+excepInfo.scode;
+ }
+ }
+ } else {
+ exceptionDescription = new String("OLE Automation Error HResult : "+hResult);
+ }
+
+ // cleanup EXCEPINFO struct
+ if (excepInfo.bstrDescription != 0)
+ COM.SysFreeString(excepInfo.bstrDescription);
+ if (excepInfo.bstrHelpFile != 0)
+ COM.SysFreeString(excepInfo.bstrHelpFile);
+ if (excepInfo.bstrSource != 0)
+ COM.SysFreeString(excepInfo.bstrSource);
+}
+/**
+ * Sets the property specified by the dispIdMember to a new value.
+ *
+ * @param dispIdMember the ID of the property as specified by the IDL of the ActiveX Control; the
+ * value for the ID can be obtained using OleAutomation.getIDsOfNames
+ * @param rgvarg the new value of the property
+ *
+ * @return true if the operation was successful
+ */
+public boolean setProperty(int dispIdMember, Variant rgvarg) {
+
+ // get the IDispatch interface for the control
+ if (objIDispatch == null) return false;
+
+ // create Dispparams structure with input parameters
+ DISPPARAMS pDispParams = new DISPPARAMS();
+ pDispParams.cArgs = 1;
+ pDispParams.rgvarg = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, Variant.sizeof);
+ rgvarg.getData(pDispParams.rgvarg);
+
+ // add in information for named args
+ pDispParams.cNamedArgs = 1;
+ pDispParams.rgdispidNamedArgs = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, 4);
+ COM.MoveMemory(pDispParams.rgdispidNamedArgs, new int[] {COM.DISPID_PROPERTYPUT}, 4);
+
+ int pVarResultAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ EXCEPINFO excepInfo = new EXCEPINFO();
+ int[] pArgErr = new int[1];
+ int dwFlags = COM.DISPATCH_PROPERTYPUT;
+ if ((rgvarg.getType() & COM.VT_BYREF) == COM.VT_BYREF)
+ dwFlags = COM.DISPATCH_PROPERTYPUTREF;
+ int rc = objIDispatch.Invoke(dispIdMember, new GUID(), COM.LOCALE_USER_DEFAULT, dwFlags, pDispParams, pVarResultAddress, excepInfo, pArgErr);
+
+ // free the result
+ COM.VariantClear(pVarResultAddress);
+ OS.GlobalFree(pVarResultAddress);
+
+ // free the Dispparams resources
+ OS.GlobalFree(pDispParams.rgdispidNamedArgs);
+ COM.VariantClear(pDispParams.rgvarg);
+ OS.GlobalFree(pDispParams.rgvarg);
+
+ // save error string and cleanup EXCEPINFO
+ manageExcepinfo(rc, excepInfo);
+
+ return (rc == COM.S_OK);
+
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
new file mode 100755
index 0000000000..bf6dc38b03
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleClientSite.java
@@ -0,0 +1,1306 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Vector;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+/**
+ * OleClientSite provides a site to manage an embedded OLE Document within a container.
+ *
+ * <p>The OleClientSite provides the following capabilities:
+ * <ul>
+ * <li>creates the in-place editor for a blank document or opening an existing OLE Document
+ * <li>lays the editor out
+ * <li>provides a mechanism for activating and deactivating the Document
+ * <li>provides a mechanism for saving changes made to the document
+ * </ul>
+ *
+ * <p>This object implements the OLE Interfaces IUnknown, IOleClientSite, IAdviseSink,
+ * IOleInPlaceSite
+ *
+ * <dl>
+ * <dt><b>Styles</b> <dd>BORDER
+ * <dt><b>Events</b> <dd>Dispose, Move, Resize
+ * </dl>
+ *
+ */
+public class OleClientSite extends Composite {
+
+ // Interfaces for this Ole Client Container
+ private COMObject iUnknown;
+ private COMObject iOleClientSite;
+ private COMObject iAdviseSink;
+ private COMObject iOleInPlaceSite;
+
+ protected GUID appClsid;
+ private GUID objClsid;
+ private int refCount;
+
+ // References to the associated Frame.
+ protected OleFrame frame;
+
+ // Access to the embedded/linked Ole Object
+ protected IUnknown objIUnknown;
+ protected IOleObject objIOleObject;
+ protected IViewObject2 objIViewObject2;
+ protected IOleInPlaceObject objIOleInPlaceObject;
+ protected IOleCommandTarget objIOleCommandTarget;
+
+ // Related storage information
+ protected IStorage tempStorage; // IStorage interface of the receiver
+
+ // Internal state and style information
+ private boolean active; // Track whether the object is in place active
+ private int aspect; // the display aspect of the embedded object, e.g., DvaspectContent or DvaspectIcon
+ private int type; // Indicates the type of client that can be supported inside this container
+ private boolean isStatic; // Indicates item's display is static, i.e., a bitmap, metafile, etc.
+
+ private RECT borderWidths = new RECT();
+ private RECT indent = new RECT();
+ private boolean inUpdate = false;
+ private boolean inInit = true;
+
+ private static final String WORDPROGID = "Word.Document";
+
+ private Listener listener;
+
+protected OleClientSite(Composite parent, int style) {
+ // this constructor should never be used by itself because it does
+ // not create an Ole Object
+
+ super(parent, style);
+
+ createCOMInterfaces();
+
+ // install the Ole Frame for this Client Site
+ while (true) {
+ if (parent instanceof OleFrame){
+ frame = (OleFrame)parent;
+ break;
+ }
+ parent = parent.getParent();
+ if (parent == null) break;
+ }
+ if (frame == null) OLE.error(SWT.ERROR_INVALID_ARGUMENT);
+ frame.AddRef();
+
+ active = false;
+ aspect = COM.DVASPECT_CONTENT;
+ type = COM.OLEEMBEDDED;
+ isStatic = false;
+
+ listener = new Listener() {
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case SWT.Resize :
+ case SWT.Move :
+ onResize(e);
+ break;
+ case SWT.Dispose :
+ onDispose(e);
+ break;
+ case SWT.FocusIn:
+ onFocusIn();
+ break;
+ case SWT.Paint:
+ onPaint(e);
+ break;
+ default :
+ OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ }
+ };
+ this.addListener(SWT.Dispose, listener);
+ this.addListener(SWT.FocusIn, listener);
+ this.addListener(SWT.Paint, listener);
+ frame.addListener(SWT.Resize, listener);
+}
+/**
+ * Create an OleClientSite child widget using the OLE Document type associated with the
+ * specified file. The OLE Document type is determined either through header information in the file
+ * or through a Registry entry for the file extension. Use style bits to select a particular look
+ * or set of properties.
+ *
+ * @param parent a composite widget; must be an OleFrame
+ * @param style the bitwise OR'ing of widget styles
+ * @param file the file that is to be opened in this OLE Document
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_ERROR_NULL_ARGUMENT when the parent is null</ul>
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
+ * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame
+ * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
+ * <li>ERROR_INTERFACES_NOT_INITIALIZED when unable to create callbacks for OLE Interfaces</ul>
+ *
+ */
+public OleClientSite(Composite parent, int style, File file) {
+ this(parent, style);
+ try {
+
+ if (file == null || file.isDirectory() || !file.exists())
+ OLE.error(OLE.ERROR_INVALID_ARGUMENT);
+
+ // Is there an associated CLSID?
+ appClsid = new GUID();
+ char[] fileName = (file.getAbsolutePath()+"\0").toCharArray();
+ int result = COM.GetClassFile(fileName, appClsid);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+
+ // Open a temporary storage object
+ tempStorage = createTempStorage();
+
+ // Create ole object with storage object
+ int[] address = new int[1];
+ result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+
+ objIUnknown = new IUnknown(address[0]);
+
+ // Init sinks
+ addObjectReferences();
+
+ COM.OleRun(objIUnknown.getAddress());
+ } catch (SWTException e) {
+ disposeCOMInterfaces();
+ frame.Release();
+ throw e;
+ }
+}
+/**
+ * Create an OleClientSite child widget to edit a blank document using the specified OLE Document
+ * application. Use style bits to select a particular look or set of properties.
+ *
+ * @param parent a composite widget; must be an OleFrame
+ * @param style the bitwise OR'ing of widget styles
+ * @param progID the unique program identifier of am OLE Document application;
+ * the value of the ProgID key or the value of the VersionIndependentProgID key specified
+ * in the registry for the desired OLE Document (for example, the VersionIndependentProgID
+ * for Word is Word.Document)
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_ERROR_NULL_ARGUMENT when the parent is null
+ * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
+ * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame
+ * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
+ * <li>ERROR_INTERFACES_NOT_INITIALIZED when unable to create callbacks for OLE Interfaces</ul>
+ *
+ */
+public OleClientSite(Composite parent, int style, String progId) {
+ this(parent, style);
+ try {
+ appClsid = getClassID(progId);
+ if (appClsid == null)
+ OLE.error(OLE.ERROR_INVALID_CLASSID);
+
+ // Open a temporary storage object
+ tempStorage = createTempStorage();
+
+ // Create ole object with storage object
+ int[] address = new int[1];
+ int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+
+ objIUnknown = new IUnknown(address[0]);
+
+ // Init sinks
+ addObjectReferences();
+
+ COM.OleRun(objIUnknown.getAddress());
+
+ } catch (SWTException e) {
+ disposeCOMInterfaces();
+ frame.Release();
+ throw e;
+ }
+}
+/**
+ * @private
+ *
+ * Create an OleClientSite child widget to edit the specified file using the specified OLE Document
+ * application. Use style bits to select a particular look or set of properties.
+ *
+ * @param parent a composite widget; must be an OleFrame
+ * @param style the bitwise OR'ing of widget styles
+ * @param progID the unique program identifier of am OLE Document application;
+ * the value of the ProgID key or the value of the VersionIndependentProgID key specified
+ * in the registry for the desired OLE Document (for example, the VersionIndependentProgID
+ * for Word is Word.Document)
+ * @param file the file that is to be opened in this OLE Document
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_ERROR_NULL_ARGUMENT when the parent is null
+ * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
+ * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
+ * <li>ERROR_CANNOT_OPEN_FILE when failed to open file
+ * <li>ERROR_INVALID_ARGUMENT when the parent is not an OleFrame
+ * <li>ERROR_INTERFACES_NOT_INITIALIZED when unable to create callbacks for OLE Interfaces</ul>
+ *
+ */
+public OleClientSite(Composite parent, int style, String progId, File file) {
+ this(parent, style);
+
+ try {
+
+ if (file == null || file.isDirectory() || !file.exists())
+ OLE.error(OLE.ERROR_INVALID_ARGUMENT);
+
+ appClsid = getClassID(progId);
+
+ // Are we opening this file with the preferred OLE object?
+ char[] fileName = (file.getAbsolutePath()+"\0").toCharArray();
+ GUID fileClsid = new GUID();
+ COM.GetClassFile(fileName, fileClsid);
+
+ if (COM.IsEqualGUID(appClsid, fileClsid)){
+ // use default mechanism
+ // Open a temporary storage object
+ tempStorage = createTempStorage();
+
+ // Create ole object with storage object
+ int[] address = new int[1];
+ int result = COM.OleCreateFromFile(appClsid, fileName, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+
+ objIUnknown = new IUnknown(address[0]);
+ } else {
+ // use a conversion mechanism
+
+ // Word does not follow the standard and does not use "CONTENTS" as the name of
+ // its primary stream
+ String contentStream = "CONTENTS";
+ GUID wordGUID = getClassID(WORDPROGID);
+ if (COM.IsEqualGUID(appClsid, wordGUID)) contentStream = "WordDocument";
+
+ // Copy over the contents of the file into a new temporary storage object
+ OleFile oleFile = new OleFile(file, contentStream, OleFile.READ);
+ IStorage storage = oleFile.getRootStorage();
+ storage.AddRef();
+ // Open a temporary storage object
+ tempStorage = createTempStorage();
+ // Copy over contents of file
+ int result = storage.CopyTo(0, null, null, tempStorage.getAddress());
+ storage.Release();
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
+ oleFile.dispose();
+
+ // create ole client
+ int[] ppv = new int[1];
+ result = COM.CoCreateInstance(appClsid, 0, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, COM.IIDIUnknown, ppv);
+ if (result != COM.S_OK){
+ tempStorage.Release();
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+ }
+ objIUnknown = new IUnknown(ppv[0]);
+
+ // get the persistant storage of the ole client
+ ppv = new int[1];
+ result = objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv);
+ if (result != COM.S_OK){
+ tempStorage.Release();
+ objIUnknown.Release();
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+ }
+ IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]);
+
+ // load the contents of the file into the ole client site
+ result = iPersistStorage.Load(tempStorage.getAddress());
+ iPersistStorage.Release();
+ if (result != COM.S_OK){
+ tempStorage.Release();
+ tempStorage = null;
+ objIUnknown.Release();
+ objIUnknown = null;
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+ }
+ }
+
+ // Init sinks
+ addObjectReferences();
+
+ COM.OleRun(objIUnknown.getAddress());
+ } catch (SWTException e) {
+ disposeCOMInterfaces();
+ frame.Release();
+ throw e;
+ }
+}
+private void activateInPlaceClient() {
+ if (objIOleInPlaceObject == null) return;
+
+ // bring client window to foreground
+ int[] phwnd = new int[1];
+ if (objIOleInPlaceObject.GetWindow(phwnd) == COM.S_OK) {
+ OS.SetWindowPos(phwnd[0], OS.HWND_TOP, 0, 0, 0, 0, OS.SWP_NOSIZE | OS.SWP_NOMOVE);
+ }
+
+ frame.setCurrentDocument(this);
+
+ setFocus();
+}
+protected void addObjectReferences() {
+
+ //
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIPersist, ppvObject) == COM.S_OK) {
+ IPersist objIPersist = new IPersist(ppvObject[0]);
+ GUID tempid = new GUID();
+ if (objIPersist.GetClassID(tempid) == COM.S_OK)
+ objClsid = tempid;
+ objIPersist.Release();
+ }
+
+ //
+ ppvObject = new int[1];
+ int result = objIUnknown.QueryInterface(COM.IIDIViewObject2, ppvObject);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result);
+ objIViewObject2 = new IViewObject2(ppvObject[0]);
+ objIViewObject2.SetAdvise(aspect, 0, iAdviseSink.getAddress());
+
+ //
+ ppvObject = new int[1];
+ result = objIUnknown.QueryInterface(COM.IIDIOleObject, ppvObject);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_INTERFACE_NOT_FOUND, result);
+ objIOleObject = new IOleObject(ppvObject[0]);
+ objIOleObject.SetClientSite(iOleClientSite.getAddress());
+ int[] pdwConnection = new int[1];
+ objIOleObject.Advise(iAdviseSink.getAddress(), pdwConnection);
+ objIOleObject.SetHostNames("main", "main");
+
+ // Notify the control object that it is embedded in an OLE container
+ COM.OleSetContainedObject(objIUnknown.getAddress(), true);
+
+ // Is OLE object linked or embedded?
+ ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIOleLink, ppvObject) == COM.S_OK) {
+ IOleLink objIOleLink = new IOleLink(ppvObject[0]);
+ int[] ppmk = new int[1];
+ if (objIOleLink.GetSourceMoniker(ppmk) == COM.S_OK) {
+ IMoniker objIMoniker = new IMoniker(ppmk[0]);
+ objIMoniker.Release();
+ type = COM.OLELINKED;
+ objIOleLink.BindIfRunning();
+ } else {
+ isStatic = true;
+ }
+ objIOleLink.Release();
+ }
+}
+protected int AddRef() {
+ refCount++;
+ return refCount;
+}
+private int CanInPlaceActivate() {
+ if (aspect == COM.DVASPECT_CONTENT && type == COM.OLEEMBEDDED)
+ return COM.S_OK;
+
+ return COM.S_FALSE;
+}
+private int ContextSensitiveHelp(int fEnterMode) {
+ return COM.S_OK;
+}
+protected void createCOMInterfaces() {
+
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+
+ iOleClientSite = new COMObject(new int[]{2, 0, 0, 0, 3, 1, 0, 1, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return SaveObject();}
+ // method4 GetMoniker - not implemented
+ public int method5(int[] args) {return GetContainer(args[0]);}
+ public int method6(int[] args) {return ShowObject();}
+ public int method7(int[] args) {return OnShowWindow(args[0]);}
+ // method8 RequestNewObjectLayout - not implemented
+ };
+
+ iAdviseSink = new COMObject(new int[]{2, 0, 0, 2, 2, 1, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return OnDataChange(args[0], args[1]);}
+ public int method4(int[] args) {return OnViewChange(args[0], args[1]);}
+ //method5 OnRename - not implemented
+ public int method6(int[] args) {OnSave();return 0;}
+ public int method7(int[] args) {return OnClose();}
+ };
+
+ iOleInPlaceSite = new COMObject(new int[]{2, 0, 0, 1, 1, 0, 0, 0, 5, 1, 1, 0, 0, 0, 1}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return GetWindow(args[0]);}
+ public int method4(int[] args) {return ContextSensitiveHelp(args[0]);}
+ public int method5(int[] args) {return CanInPlaceActivate();}
+ public int method6(int[] args) {return OnInPlaceActivate();}
+ public int method7(int[] args) {return OnUIActivate();}
+ public int method8(int[] args) {return GetWindowContext(args[0], args[1], args[2], args[3], args[4]);}
+ public int method9(int[] args) {return Scroll(args[0]);}
+ public int method10(int[] args) {return OnUIDeactivate(args[0]);}
+ public int method11(int[] args) {return OnInPlaceDeactivate();}
+ // method12 DiscardUndoState - not implemented
+ // method13 DeactivateAndUndoChange - not implemented
+ public int method14(int[] args) {return OnPosRectChange(args[0]);}
+ };
+}
+protected IStorage createTempStorage() {
+ int[] tempStorage = new int[1];
+ int grfMode = COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_DELETEONRELEASE;
+ int result = COM.StgCreateDocfile(null, grfMode, 0, tempStorage);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_FILE, result);
+ return new IStorage(tempStorage[0]);
+}
+/**
+ * Deactivates an active in-place object and discards the object's undo state.
+ */
+public void deactivateInPlaceClient() {
+ if (active && objIOleInPlaceObject != null) {
+ objIOleInPlaceObject.InPlaceDeactivate();
+ }
+}
+private void deleteTempStorage() {
+ //Destroy this item's contents in the temp root IStorage.
+ if (tempStorage != null){
+ tempStorage.Release();
+ }
+
+ tempStorage = null;
+}
+protected void disposeCOMInterfaces() {
+
+ if (iUnknown != null)
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iOleClientSite != null)
+ iOleClientSite.dispose();
+ iOleClientSite = null;
+
+ if (iAdviseSink != null)
+ iAdviseSink.dispose();
+ iAdviseSink = null;
+
+ if (iOleInPlaceSite != null)
+ iOleInPlaceSite.dispose();
+ iOleInPlaceSite = null;
+}
+/**
+ * Requests that the OLE Document or ActiveX Control perform an action; actions are almost always
+ * changes to the activation state.
+ *
+ * @param verb the operation that is requested. This is one of the OLE.OLEIVERB_ values
+ *
+ * @return an HRESULT value indicating the success of the operation request; OLE.S_OK indicates
+ * success
+ */
+public int doVerb(int verb) {
+ if (objIOleObject == null || isStatic)
+ return COM.E_FAIL;
+ boolean wasActive = active;
+
+ int oleobject = objIOleObject.getAddress();
+ COM.OleRun(oleobject);
+
+ // See PR: 1FV9RZW
+ int result = objIOleObject.DoVerb(verb, null, iOleClientSite.getAddress(), 0, handle, null);
+
+ if (active) setObjectRects();
+
+ // synch up with state of object
+ if (wasActive != active){
+ if (active) {
+ activateInPlaceClient();
+ } else {
+ deactivateInPlaceClient();
+ }
+ }
+
+ if (active && inInit) {
+ updateStorage();
+ inInit = false;
+ }
+ return result;
+}
+/**
+ * Asks the OLE Document or ActiveX Control to execute a command from a standard
+ * list of commands. The OLE Document or ActiveX Control must support the IOleCommandTarget
+ * interface. The OLE Document or ActiveX Control does not have to support all the commands
+ * in the standard list. To check if a command is supported, you can call queryStatus with
+ * the cmdID.
+ *
+ * @param cmdID the ID of a command; these are the OLE.OLECMDID_ values - a small set of common
+ * commands
+ * @param options the optional flags; these are the OLE.OLECMDEXECOPT_ values
+ * @param in the argument for the command
+ * @param out the return value of the command
+ *
+ * @return an HRESULT value; OLE.S_OK is returned if successful
+ *
+ */
+public int exec(int cmdID, int options, Variant in, Variant out) {
+
+ if (objIOleCommandTarget == null) {
+ int[] address = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) != COM.S_OK)
+ return OLE.ERROR_INTERFACE_NOT_FOUND;
+ objIOleCommandTarget = new IOleCommandTarget(address[0]);
+ }
+
+ int inAddress = 0;
+ if (in != null){
+ inAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ in.getData(inAddress);
+ }
+ int outAddress = 0;
+ if (out != null){
+ outAddress = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ out.getData(outAddress);
+ }
+
+ int result = objIOleCommandTarget.Exec(null, cmdID, options, inAddress, outAddress);
+
+ if (inAddress != 0){
+ COM.VariantClear(inAddress);
+ OS.GlobalFree(inAddress);
+ }
+ if (outAddress != 0) {
+ out.setData(outAddress);
+ COM.VariantClear(outAddress);
+ OS.GlobalFree(outAddress);
+ }
+
+ return result;
+}
+IDispatch getAutomationObject() {
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIDispatch, ppvObject) != COM.S_OK)
+ return null;
+ return new IDispatch(ppvObject[0]);
+}
+protected GUID getClassID(String clientName) {
+ // create a GUID struct to hold the result
+ GUID guid = new GUID();
+
+ // create a null terminated array of char
+ char[] buffer = null;
+ if (clientName != null) {
+ int count = clientName.length();
+ buffer = new char[count + 1];
+ clientName.getChars(0, count, buffer, 0);
+ }
+ if (COM.CLSIDFromProgID(buffer, guid) != COM.S_OK){
+ int result = COM.CLSIDFromString(buffer, guid);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_INVALID_CLASSID, result);
+ }
+ return guid;
+}
+private int GetContainer(int ppContainer) {
+
+ /* Simple containers that do not support links to their embedded
+ objects probably do not need to implement this method. Instead,
+ they can return E_NOINTERFACE and set ppContainer to NULL.*/
+
+ if (ppContainer != 0)
+ COM.MoveMemory(ppContainer, new int[]{0}, 4);
+ return COM.E_NOINTERFACE;
+}
+private SIZE getExtent() {
+ SIZE sizel = new SIZE();
+ // get the current size of the embedded OLENatives object
+ if (objIOleObject != null) {
+ if ( objIViewObject2 != null && !COM.OleIsRunning(objIOleObject.getAddress())) {
+ objIViewObject2.GetExtent(aspect, -1, null, sizel);
+ } else {
+ objIOleObject.GetExtent(aspect, sizel);
+ }
+ }
+ return xFormHimetricToPixels(sizel);
+}
+public Rectangle getIndent() {
+ return new Rectangle(indent.left, indent.right, indent.top, indent.bottom);
+}
+/**
+ * Returns the program ID of the OLE Document or ActiveX Control.
+ *
+ * @return the program ID of the OLE Document or ActiveX Control
+ */
+public String getProgramID(){
+ if (appClsid != null){
+ int[] lplpszProgID = new int[1];
+ if (COM.ProgIDFromCLSID(appClsid, lplpszProgID) == COM.S_OK) {
+ int ptr = OS.GlobalLock(lplpszProgID[0]);
+ int length = OS.GlobalSize(ptr);
+ char[] buffer = new char[length];
+ COM.MoveMemory(buffer, lplpszProgID[0], length);
+ OS.GlobalUnlock(ptr);
+ OS.GlobalFree(lplpszProgID[0]);
+
+ String result = new String(buffer);
+ // remove null terminator
+ int index = result.indexOf("\0");
+ return result.substring(0, index);
+ }
+ }
+ return null;
+}
+protected int GetWindow(int phwnd) {
+
+ if (phwnd == 0)
+ return COM.E_INVALIDARG;
+ if (frame == null) {
+ COM.MoveMemory(phwnd, new int[] {0}, 4);
+ return COM.E_NOTIMPL;
+ }
+
+ // Copy the Window's handle into the memory passed in
+ COM.MoveMemory(phwnd, new int[] {frame.handle}, 4);
+ return COM.S_OK;
+}
+private int GetWindowContext(int ppFrame, int ppDoc, int lprcPosRect, int lprcClipRect, int lpFrameInfo) {
+
+ if (frame == null || ppFrame == 0)
+ return COM.E_NOTIMPL;
+
+ // fill in frame handle
+ int iOleInPlaceFrame = frame.getIOleInPlaceFrame();
+ COM.MoveMemory(ppFrame, new int[] {iOleInPlaceFrame}, 4);
+ frame.AddRef();
+
+ // null out document handle
+ if (ppDoc != 0) {
+ COM.MoveMemory(ppDoc, new int[] {0}, 4);
+ }
+
+ // fill in position and clipping info
+ Rectangle clientArea = this.getClientArea();
+ Point clientLocation = this.getLocation();
+ setExtent(clientArea.width - indent.left - indent.right, clientArea.height - indent.top - indent.bottom);
+
+ RECT posRect = new RECT();
+ posRect.left = clientLocation.x + indent.left;
+ posRect.top = clientLocation.y + indent.top;
+ posRect.right = clientLocation.x + clientArea.width - indent.right;
+ posRect.bottom = clientLocation.y + clientArea.height - indent.bottom;
+
+ RECT clipRect = new RECT();
+ Rectangle frameArea = frame.getClientArea();
+ clipRect.left = frameArea.x;
+ clipRect.top = frameArea.y;
+ clipRect.right = frameArea.x + frameArea.width;
+ clipRect.bottom = frameArea.y + frameArea.height;
+
+ if (lprcPosRect != 0) {
+ OS.MoveMemory(lprcPosRect, posRect, RECT.sizeof);
+ }
+ if (lprcClipRect != 0) {
+ OS.MoveMemory(lprcClipRect, clipRect, RECT.sizeof);
+ }
+
+ // get frame info
+ OLEINPLACEFRAMEINFO frameInfo = new OLEINPLACEFRAMEINFO();
+ frameInfo.cb = OLEINPLACEFRAMEINFO.sizeof;
+ frameInfo.fMDIApp = 0;
+ frameInfo.hwndFrame = frame.handle;
+ //frameInfo.cAccelEntries = ??;
+ //frameInfo.hAccel = ??;
+ COM.MoveMemory(lpFrameInfo, frameInfo, OLEINPLACEFRAMEINFO.sizeof);
+
+ return COM.S_OK;
+}
+public boolean isDirty() {
+ // Get access to the persistant storage mechanism
+ int[] address = new int[1];
+ if (objIOleObject.QueryInterface(COM.IIDIPersistFile, address) != COM.S_OK)
+ return false;
+ IPersistStorage permStorage = new IPersistStorage(address[0]);
+ // Are the contents of the permanent storage different from the file?
+ int result = permStorage.IsDirty();
+ permStorage.Release();
+ return (result == COM.S_OK);
+}
+public boolean isFocusControl () {
+ Control focus = getDisplay().getFocusControl();
+ if (focus == frame) {
+ return frame.getCurrentDocument() == this;
+ }
+ return false;
+}
+private int OnClose() {
+ return COM.S_OK;
+}
+private int OnDataChange(int pFormatetc, int pStgmed) {
+ return COM.S_OK;
+}
+private void onDispose(Event e) {
+
+ doVerb(OLE.OLEIVERB_DISCARDUNDOSTATE);
+
+ releaseObjectInterfaces(); // Note, must release object interfaces before releasing frame
+ deleteTempStorage();
+
+ // remove listeners
+ removeListener(SWT.Resize, listener);
+ removeListener(SWT.Move, listener);
+ removeListener(SWT.Dispose, listener);
+ frame.removeListener(SWT.Resize, listener);
+ frame.Release();
+ frame = null;
+}
+private void onFocusIn() {
+ setInplaceFocus();
+}
+private int OnInPlaceActivate() {
+ active = true;
+ if (objIOleObject == null)
+ return COM.S_OK;
+ int[] ppvObject = new int[1];
+ if (objIOleObject.QueryInterface(COM.IIDIOleInPlaceObject, ppvObject) == COM.S_OK) {
+ objIOleInPlaceObject = new IOleInPlaceObject(ppvObject[0]);
+ }
+ return COM.S_OK;
+}
+private int OnInPlaceDeactivate() {
+
+ if (objIOleInPlaceObject != null)
+ objIOleInPlaceObject.Release();
+ objIOleInPlaceObject = null;
+ active = false;
+ return COM.S_OK;
+}
+private int OnPosRectChange(int lprcPosRect) {
+
+ setObjectRects();
+
+ return COM.S_OK;
+}
+private void onPaint(Event e) {
+ if (!active && objIUnknown != null) {
+ SIZE size = getExtent();
+ RECT rect = new RECT();
+ rect.left = 0; rect.top = 0;
+ rect.right = size.cx; rect.bottom = size.cy;
+ int pArea = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, RECT.sizeof);
+ OS.MoveMemory(pArea, rect, RECT.sizeof);
+ COM.OleDraw(objIUnknown.getAddress(), aspect, e.gc.handle, pArea);
+ OS.GlobalFree(pArea);
+ }
+}
+private void onResize(Event e) {
+ Rectangle area = frame.getClientArea();
+ setBounds(borderWidths.left,
+ borderWidths.top,
+ area.width - borderWidths.left - borderWidths.right,
+ area.height - borderWidths.top - borderWidths.bottom);
+
+ setObjectRects();
+}
+private void OnSave() {
+}
+private int OnShowWindow(int fShow) {
+ boolean wasActive = active;
+ active = (fShow != 0);
+ if (wasActive != active){
+ if (active) {
+ activateInPlaceClient();
+ } else {
+ deactivateInPlaceClient();
+ }
+ }
+ return COM.S_OK;
+}
+private int OnUIActivate() {
+ return COM.S_OK;
+}
+private int OnUIDeactivate(int fUndoable) {
+
+ // currently, we are ignoring the fUndoable flag
+ if (frame == null || frame.isDisposed()) return COM.S_OK;
+
+ frame.SetActiveObject(0,0);
+
+ Menu menubar = frame.getMenubar();
+ if (menubar == null || menubar.isDisposed())
+ return COM.S_OK;
+
+ int shellHandle = menubar.getShell().handle;
+ OS.SetMenu(shellHandle, menubar.handle);
+ return COM.OleSetMenuDescriptor(0, shellHandle, 0, 0, 0);
+}
+private int OnViewChange(int dwAspect, int lindex) {
+ setObjectRects();
+ return COM.S_OK;
+}
+private IStorage openStorage(IStorage storage, String name) {
+ int mode = COM.STGM_TRANSACTED | COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE;
+ int[] ppStg = new int[1];
+ if (storage.OpenStorage(name, 0, mode, null, 0, ppStg) != COM.S_OK) {
+ // IStorage does not exist, so create one
+ mode = mode | COM.STGM_CREATE;
+ if (storage.CreateStorage(name, mode, 0, 0, ppStg) != COM.S_OK)
+ return null;
+ }
+ return new IStorage(ppStg[0]);
+}
+protected int QueryInterface(int riid, int ppvObject) {
+
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_NOINTERFACE;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIAdviseSink)) {
+ COM.MoveMemory(ppvObject, new int[] {iAdviseSink.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIOleClientSite)) {
+ COM.MoveMemory(ppvObject, new int[] {iOleClientSite.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIOleInPlaceSite)) {
+ COM.MoveMemory(ppvObject, new int[] {iOleInPlaceSite.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+/**
+ * Returns the status of the specified command. The status is any bitwise OR'd combination of
+ * SWTOLE.OLECMDF_SUPPORTED, SWTOLE.OLECMDF_ENABLED, SWTOLE.OLECMDF_LATCHED, SWTOLE.OLECMDF_NINCHED.
+ * You can query the status of a command before invoking it with OleClientSite.exec. The
+ * OLE Document or ActiveX Control must support the IOleCommandTarget to make use of this method.
+ *
+ * @param cmd the ID of a command; these are the OLE.OLECMDID_ values - a small set of common
+ * commands
+ *
+ * @return the status of the specified command or 0 if unable to query the OLE Object; these are the
+ * OLE.OLECMDF_ values
+ */
+public int queryStatus(int cmd) {
+
+ if (objIOleCommandTarget == null) {
+ int[] address = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIOleCommandTarget, address) != COM.S_OK)
+ return 0;
+ objIOleCommandTarget = new IOleCommandTarget(address[0]);
+ }
+
+ OLECMD olecmd = new OLECMD();
+ olecmd.cmdID = cmd;
+
+ int result = objIOleCommandTarget.QueryStatus(null, 1, olecmd, null);
+
+ if (result != COM.S_OK) return 0;
+
+ return olecmd.cmdf;
+}
+protected int Release() {
+ refCount--;
+
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ }
+ return refCount;
+}
+protected void releaseObjectInterfaces() {
+
+ if (objIOleInPlaceObject!= null)
+ objIOleInPlaceObject.Release();
+ objIOleInPlaceObject = null;
+
+ if (objIOleObject != null) {
+ objIOleObject.Close(COM.OLECLOSE_NOSAVE);
+ objIOleObject.Release();
+ }
+ objIOleObject = null;
+
+ if (objIViewObject2 != null) {
+ objIViewObject2.SetAdvise(aspect, 0, 0);
+ objIViewObject2.Release();
+ }
+ objIViewObject2 = null;
+
+ if (objIOleCommandTarget != null)
+ objIOleCommandTarget.Release();
+ objIOleCommandTarget = null;
+
+ if (objIUnknown != null){
+ objIUnknown.Release();
+ }
+ objIUnknown = null;
+
+ COM.CoFreeUnusedLibraries();
+}
+public boolean save(File file, boolean includeOleInfo) {
+ if (includeOleInfo)
+ return saveToStorageFile(file);
+ return saveToTraditionalFile(file);
+}
+private boolean saveFromContents(int address, File file) {
+
+ boolean success = false;
+
+ IStream tempContents = new IStream(address);
+ tempContents.AddRef();
+
+ try {
+ FileOutputStream writer = new FileOutputStream(file);
+
+ int increment = 1024 * 4;
+ int pv = COM.CoTaskMemAlloc(increment);
+ int[] pcbWritten = new int[1];
+ while (tempContents.Read(pv, increment, pcbWritten) == COM.S_OK && pcbWritten[0] > 0) {
+ byte[] buffer = new byte[ pcbWritten[0]];
+ OS.MoveMemory(buffer, pv, pcbWritten[0]);
+ writer.write(buffer); // Note: if file does not exist, this will create the file the
+ // first time it is called
+ success = true;
+ }
+ COM.CoTaskMemFree(pv);
+
+ writer.close();
+
+ } catch (IOException err) {
+ }
+
+ tempContents.Release();
+
+ return success;
+}
+private boolean saveFromOle10Native(int address, File file) {
+
+ boolean success = false;
+
+ IStream tempContents = new IStream(address);
+ tempContents.AddRef();
+
+ // The "\1Ole10Native" stream contains a DWORD header whose value is the length
+ // of the native data that follows.
+ int pv = COM.CoTaskMemAlloc(4);
+ int[] size = new int[1];
+ int rc = tempContents.Read(pv, 4, null);
+ OS.MoveMemory(size, pv, 4);
+ COM.CoTaskMemFree(pv);
+ if (rc == COM.S_OK && size[0] > 0) {
+
+ // Read the data
+ byte[] buffer = new byte[size[0]];
+ pv = COM.CoTaskMemAlloc(size[0]);
+ rc = tempContents.Read(pv, size[0], null);
+ OS.MoveMemory(buffer, pv, size[0]);
+ COM.CoTaskMemFree(pv);
+
+ // open the file and write data into it
+ try {
+ FileOutputStream writer = new FileOutputStream(file);
+ writer.write(buffer); // Note: if file does not exist, this will create the file
+ writer.close();
+
+ success = true;
+ } catch (IOException err) {
+ }
+ }
+ tempContents.Release();
+
+ return success;
+}
+private int SaveObject() {
+
+ updateStorage();
+
+ return COM.S_OK;
+}
+/**
+ * Saves the document to the specified file and includes OLE spcific inforrmation. This method
+ * must <b>only</b> be used for files that have an OLE Storage format. For example, a word file
+ * edited with Word.Document should be saved using this method because there is formating information
+ * that should be stored in the OLE specific Storage format.
+ *
+ * @param file the file to which the changes are to be saved
+ *
+ * @return true if the save was successful
+ */
+private boolean saveToStorageFile(File file) {
+ // Note: if the file already exists, some applications will not overwrite the file
+ // In these cases, you should delete the file first (probably save the contents of the file in case the
+ // save fails)
+ if (file == null || file.isDirectory())
+ return false;
+
+ if (!updateStorage())
+ return false;
+
+ // get access to the persistant storage mechanism
+ int[] address = new int[1];
+ if (objIOleObject.QueryInterface(COM.IIDIPersistStorage, address) != COM.S_OK)
+ return false;
+ IPersistStorage permStorage = new IPersistStorage(address[0]);
+
+ // The file will be saved using the formating of the current application - this
+ // may not be the format of the application that was originally used to create the file
+ // e.g. if an Excel file is opened in Word, the Word application will save the file in the
+ // Word format
+
+ boolean success = false;
+ OleFile oleFile = new OleFile(file, null, OleFile.WRITE);
+ IStorage storage = oleFile.getRootStorage();
+ storage.AddRef();
+ if (COM.OleSave(permStorage.getAddress(), storage.getAddress(), false) == COM.S_OK) {
+ if (storage.Commit(COM.STGC_DEFAULT) == COM.S_OK)
+ success = true;
+ }
+ storage.Release();
+ oleFile.dispose();
+ permStorage.Release();
+
+ return success;
+}
+/**
+ * Saves the document to the specified file. This method must be used for
+ * files that do not have an OLE Storage format. For example, a bitmap file edited with MSPaint
+ * should be saved using this method because bitmap is a standard format that does not include any
+ * OLE specific data.
+ *
+ * @param file the file to which the changes are to be saved
+ *
+ * @return true if the save was successful
+ */
+private boolean saveToTraditionalFile(File file) {
+ // Note: if the file already exists, some applications will not overwrite the file
+ // In these cases, you should delete the file first (probably save the contents of the file in case the
+ // save fails)
+ if (file == null || file.isDirectory())
+ return false;
+ if (!updateStorage())
+ return false;
+
+ int[] address = new int[1];
+ // Look for a CONTENTS stream
+ if (tempStorage.OpenStream("CONTENTS", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) == COM.S_OK)
+ return saveFromContents(address[0], file);
+
+ // Look for Ole 1.0 object stream
+ if (tempStorage.OpenStream("\1Ole10Native", 0, COM.STGM_DIRECT | COM.STGM_READ | COM.STGM_SHARE_EXCLUSIVE, 0, address) == COM.S_OK)
+ return saveFromOle10Native(address[0], file);
+
+ return false;
+}
+private int Scroll(int scrollExtant) {
+ return COM.S_OK;
+}
+void setBorderSpace(RECT newBorderwidth) {
+ borderWidths = newBorderwidth;
+
+ // readjust size and location of client site
+ Rectangle area = frame.getClientArea();
+ setBounds(borderWidths.left, borderWidths.top,
+ area.width - borderWidths.left - borderWidths.right,
+ area.height - borderWidths.top - borderWidths.bottom);
+
+ setObjectRects();
+}
+private void setExtent(int width, int height){
+ // Resize the width and height of the embedded/linked OLENatives object
+ // to the specified values.
+
+ if (objIOleObject == null || isStatic) return;
+
+ if (inUpdate) return;
+
+ SIZE currentExtent = getExtent();
+ if (width == currentExtent.cx && height == currentExtent.cy) return;
+
+ SIZE newExtent = new SIZE();
+ newExtent.cx = width; newExtent.cy = height;
+ newExtent = xFormPixelsToHimetric(newExtent);
+
+ // Get the server running first, then do a SetExtent, then show it
+ boolean alreadyRunning = COM.OleIsRunning(objIOleObject.getAddress());
+ if (!alreadyRunning)
+ COM.OleRun(objIOleObject.getAddress());
+
+ if (objIOleObject.SetExtent(aspect, newExtent) == COM.S_OK){
+ inUpdate = true;
+ objIOleObject.Update();
+ inUpdate = false;
+ if (!alreadyRunning)
+ // Close server if it wasn't already running upon entering this method.
+ objIOleObject.Close(COM.OLECLOSE_SAVEIFDIRTY);
+ }
+
+}
+public void setIndent(Rectangle newIndent) {
+ indent = new RECT();
+ indent.left = newIndent.x;
+ indent.right = newIndent.width;
+ indent.top = newIndent.y;
+ indent.bottom = newIndent.height;
+}
+private boolean setInplaceFocus() {
+ if (objIOleInPlaceObject == null) return false;
+ int[] phwnd = new int[1];
+ objIOleInPlaceObject.GetWindow(phwnd);
+ if (phwnd[0] == 0) return false;
+ return (OS.SetFocus(phwnd[0]) != 0);
+}
+public boolean forceFocus () {
+ if (!setInplaceFocus()) {
+ return super.forceFocus();
+ }
+ return true;
+}
+private void setObjectRects() {
+
+ if (objIOleInPlaceObject == null) return;
+
+ // size the object to fill the available space
+ // leave a border
+ Rectangle clientArea = this.getClientArea();
+ Point clientLocation = this.getLocation();
+ setExtent(clientArea.width - indent.left - indent.right, clientArea.height - indent.top - indent.bottom);
+
+ RECT posRect = new RECT();
+ posRect.left = clientLocation.x + indent.left;
+ posRect.top = clientLocation.y + indent.top;
+ posRect.right = clientLocation.x + clientArea.width - indent.right;
+ posRect.bottom = clientLocation.y + clientArea.height - indent.bottom;
+
+ RECT clipRect = new RECT();
+ Rectangle frameArea = frame.getClientArea();
+ clipRect.left = frameArea.x;
+ clipRect.top = frameArea.y;
+ clipRect.right = frameArea.x + frameArea.width;
+ clipRect.bottom = frameArea.y + frameArea.height;
+
+ objIOleInPlaceObject.SetObjectRects(posRect, clipRect);
+
+}
+
+private int ShowObject() {
+ /* Tells the container to position the object so it is visible to
+ * the user. This method ensures that the container itself is
+ * visible and not minimized.
+ */
+ return COM.S_OK;
+}
+/**
+ * Displays a dialog with the property information for this OLE Object. The OLE Document or
+ * ActiveX Control must support the ISpecifyPropertyPages interface.
+ *
+ * @param title the name that will appear in the titlebar of the dialog
+ */
+public void showProperties(String title) {
+
+ // Get the Property Page information from the OLE Object
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDISpecifyPropertyPages, ppvObject) != COM.S_OK) return;
+ ISpecifyPropertyPages objISPP = new ISpecifyPropertyPages(ppvObject[0]);
+ CAUUID caGUID = new CAUUID();
+ int result = objISPP.GetPages(caGUID);
+ objISPP.Release();
+ if (result != COM.S_OK) return;
+
+ // create a frame in which to display the pages
+ char[] chTitle = null;
+ if (title != null) {
+ chTitle = new char[title.length()];
+ title.getChars(0, title.length(), chTitle, 0);
+ }
+ result = COM.OleCreatePropertyFrame(frame.handle, 10, 10, chTitle, 1, new int[] {objIUnknown.getAddress()}, caGUID.cElems, caGUID.pElems, COM.LOCALE_USER_DEFAULT, 0, 0);
+
+ // free the property page information
+ COM.CoTaskMemFree(caGUID.pElems);
+}
+private boolean updateStorage() {
+
+ if (tempStorage == null) return false;
+
+ int[] ppv = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppv) != COM.S_OK) return false;
+ IPersistStorage iPersistStorage = new IPersistStorage(ppv[0]);
+
+ int result = COM.OleSave(iPersistStorage.getAddress(), tempStorage.getAddress(), true);
+
+ if (result != COM.S_OK){
+ // OleSave will fail for static objects, so do what OleSave does.
+ COM.WriteClassStg(tempStorage.getAddress(), objClsid);
+ result = iPersistStorage.Save(tempStorage.getAddress(), true);
+ }
+
+ tempStorage.Commit(COM.STGC_DEFAULT);
+ result = iPersistStorage.SaveCompleted(0);
+ iPersistStorage.Release();
+
+ return true;
+}
+private SIZE xFormHimetricToPixels(SIZE aSize) {
+ // Return a new Size which is the pixel transformation of a
+ // size in HIMETRIC units.
+
+ int hDC = OS.GetDC(0);
+ int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x
+ int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y
+ OS.ReleaseDC(0, hDC);
+ double tcx = Math.round( ((float)aSize.cx * (float)xppi) / 2540.0 ); // 2540 HIMETRIC units per inch
+ int cx = (int)tcx;
+ double tcy = Math.round( ((float)aSize.cy * (float)yppi) / 2540.0 );
+ int cy = (int)tcy;
+ SIZE size = new SIZE();
+ size.cx = cx;
+ size.cy = cy;
+ return size;
+}
+private SIZE xFormPixelsToHimetric(SIZE aSize) {
+ // Return a new size which is the HIMETRIC transformation of a
+ // size in pixel units.
+
+ int hDC = OS.GetDC(0);
+ int xppi = OS.GetDeviceCaps(hDC, 88); // logical pixels/inch in x
+ int yppi = OS.GetDeviceCaps(hDC, 90); // logical pixels/inch in y
+ OS.ReleaseDC(0, hDC);
+ double tcx = Math.round( ((float)aSize.cx * 2540.0) / (float)xppi ); // 2540 HIMETRIC units per inch
+ int cx = (int)tcx;
+ double tcy = Math.round( ((float)aSize.cy * 2540.0) / (float)yppi );
+ int cy = (int)tcy;
+ SIZE size = new SIZE();
+ size.cx = cx;
+ size.cy = cy;
+ return size;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
new file mode 100755
index 0000000000..42ed034b2f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleControlSite.java
@@ -0,0 +1,521 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * OleControlSite provides a site to manage an embedded ActiveX Control within a container.
+ *
+ * <p>In addition to the behaviour provided by OleClientSite, this object provides the following:
+ * <ul>
+ * <li>events from the ActiveX control
+ * <li>notification of property changes from the ActiveX control
+ * <li>simplified access to well known properties of the ActiveX Control (e.g. font, background color)
+ * <li>expose ambient properties of the container to the ActiveX Control
+ * </ul>
+ *
+ * <p>This object implements the OLE Interfaces IOleControlSite, IDispatch, and IPropertyNotifySink.
+ *
+ * <dl>
+ * <dt><b>Styles</b> <dd>BORDER
+ * <dt><b>Events</b> <dd>Dispose, Move, Resize
+ * </dl>
+ *
+ */
+public class OleControlSite extends OleClientSite
+{
+ // interfaces for this container
+ private COMObject iOleControlSite;
+ private COMObject iDispatch;
+
+ // supporting Property Change attributes
+ private OlePropertyChangeSink olePropertyChangeSink;
+
+ // supporting Event Sink attributes
+ private OleEventSink oleEventSink;
+
+ // supporting information for the Control COM object
+ private CONTROLINFO currentControlInfo;
+ private String licenseInfo;
+
+/**
+ * Create an OleControlSite child widget using style bits
+ * to select a particular look or set of properties.
+ *
+ * @param parent a composite widget; must be an OleFrame
+ * @param style the bitwise OR'ing of widget styles
+ * @param progID the unique program identifier which has been registered for this ActiveX Control;
+ * the value of the ProgID key or the value of the VersionIndependentProgID key specified
+ * in the registry for this Control (for example, the VersionIndependentProgID for
+ * Internet Explorer is Shell.Explorer)
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_ERROR_NULL_ARGUMENT when the parent is null
+ * <li>ERROR_INVALID_CLASSID when the progId does not map to a registered CLSID
+ * <li>ERROR_CANNOT_CREATE_OBJECT when failed to create OLE Object
+ * <li>ERROR_CANNOT_ACCESS_CLASSFACTORY when Class Factory could not be found
+ * <li>ERROR_CANNOT_CREATE_LICENSED_OBJECT when failed to create a licensed OLE Object
+ * <li>ERROR_INTERFACES_NOT_INITIALIZED when unable to create callbacks for OLE Interfaces</ul>
+ *
+ */
+public OleControlSite(Composite parent, int style, String progId) {
+ super(parent, style);
+
+ createCOMInterfaces();
+
+ // check for licensing
+ appClsid = getClassID(progId);
+ if (appClsid == null) OLE.error(OLE.ERROR_INVALID_CLASSID);
+
+ int licinfo = getLicenseInfo(appClsid);
+ if (licinfo == 0) {
+
+ // Open a storage object
+ tempStorage = createTempStorage();
+
+ // Create ole object with storage object
+ int[] address = new int[1];
+ int result = COM.OleCreate(appClsid, COM.IIDIUnknown, COM.OLERENDER_DRAW, null, 0, tempStorage.getAddress(), address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_OBJECT, result);
+
+ objIUnknown = new IUnknown(address[0]);
+
+ } else {
+ // Prepare the ClassFactory
+ int[] ppvObject = new int[1];
+ try {
+ int result = COM.CoGetClassObject(appClsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject);
+ if (result != COM.S_OK) {
+ OLE.error(OLE.ERROR_CANNOT_ACCESS_CLASSFACTORY, result);
+ }
+ IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]);
+ // Create Com Object
+ ppvObject = new int[1];
+ result = classFactory.CreateInstanceLic(0, 0, COM.IIDIUnknown, licinfo, ppvObject);
+ classFactory.Release();
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_LICENSED_OBJECT, result);
+ } finally {
+ COM.SysFreeString(licinfo);
+ }
+
+ objIUnknown = new IUnknown(ppvObject[0]);
+
+ // Prepare a storage medium
+ ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIPersistStorage, ppvObject) == COM.S_OK) {
+ IPersistStorage persist = new IPersistStorage(ppvObject[0]);
+ tempStorage = createTempStorage();
+ persist.InitNew(tempStorage.getAddress());
+ persist.Release();
+ }
+ }
+
+ // Init sinks
+ try {
+ addObjectReferences();
+ } catch (SWTError e) {
+ disposeCOMInterfaces();
+ frame.Release();
+ throw e;
+ }
+
+ COM.OleRun(objIUnknown.getAddress());
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param eventID the id of the event
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void addEventListener(int eventID, OleListener listener) {
+ if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ oleEventSink.addListener(eventID, listener);
+}
+protected void addObjectReferences() {
+
+ super.addObjectReferences();
+
+ // Get event notification from control
+ connectEventSink();
+ // Get property change notification from control
+ connectPropertyChangeSink();
+
+ // Get access to the Control object
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) == COM.S_OK) {
+ IOleControl objIOleControl = new IOleControl(ppvObject[0]);
+ // ask the control for its info in case users
+ // need to act on it
+ currentControlInfo = new CONTROLINFO();
+ objIOleControl.GetControlInfo(currentControlInfo);
+ objIOleControl.Release();
+ }
+}
+/**
+ * Adds the listener to receive events.
+ *
+ * @param propertyID the identifier of the property
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void addPropertyListener(int propertyID, OleListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ olePropertyChangeSink.addListener(propertyID, listener);
+}
+private void connectEventSink() {
+ oleEventSink = new OleEventSink(this);
+ oleEventSink.AddRef();
+ oleEventSink.connect(objIUnknown);
+}
+private void connectPropertyChangeSink() {
+ olePropertyChangeSink = new OlePropertyChangeSink(this);
+ olePropertyChangeSink.AddRef();
+ olePropertyChangeSink.connect(objIUnknown);
+}
+protected void createCOMInterfaces () {
+ super.createCOMInterfaces();
+
+ // register each of the interfaces that this object implements
+ iOleControlSite = new COMObject(new int[]{2, 0, 0, 0, 1, 1, 3, 2, 1, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return OnControlInfoChanged();}
+ // method4 LockInPlaceActive - not implemented
+ // method5 GetExtendedControl - not implemented
+ // method6 TransformCoords - not implemented
+ // method7 Translate Accelerator - not implemented
+ public int method8(int[] args) {return OnFocus(args[0]);}
+ // method9 ShowPropertyFrame - not implemented
+ };
+
+ iDispatch = new COMObject(new int[]{2, 0, 0, 1, 3, 4, 8}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ // method3 GetTypeInfoCount - not implemented
+ // method4 GetTypeInfo - not implemented
+ // method5 GetIDsOfNames - not implemented
+ public int method6(int[] args) {return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+ };
+}
+private void disconnectEventSink() {
+
+ if (oleEventSink != null) {
+ oleEventSink.disconnect(objIUnknown);
+ oleEventSink.Release();
+ }
+ oleEventSink = null;
+}
+private void disconnectPropertyChangeSink() {
+
+ if (olePropertyChangeSink != null) {
+ olePropertyChangeSink.disconnect(objIUnknown);
+ olePropertyChangeSink.Release();
+ }
+ olePropertyChangeSink = null;
+}
+protected void disposeCOMInterfaces() {
+ super.disposeCOMInterfaces();
+
+ if (iOleControlSite != null)
+ iOleControlSite.dispose();
+ iOleControlSite = null;
+
+ if (iDispatch != null)
+ iDispatch.dispose();
+ iDispatch = null;
+}
+public Color getBackground () {
+
+ if (objIUnknown != null) {
+ // !! We are getting the OLE_COLOR - should we change this to the COLORREF value?
+ OleAutomation oleObject= new OleAutomation(this);
+ Variant varBackColor = oleObject.getProperty(COM.DISPID_BACKCOLOR);
+ oleObject.dispose();
+
+ if (varBackColor != null){
+ int[] colorRef = new int[1];
+ if (COM.OleTranslateColor(varBackColor.getInt(), getDisplay().hPalette, colorRef) == COM.S_OK)
+ return Color.win32_new(getDisplay(), colorRef[0]);
+ }
+ }
+
+ return super.getBackground();
+}
+public Font getFont () {
+
+ if (objIUnknown != null) {
+ OleAutomation oleObject= new OleAutomation(this);
+ Variant varDispFont = oleObject.getProperty(COM.DISPID_FONT);
+ oleObject.dispose();
+
+ if (varDispFont != null){
+ OleAutomation iDispFont = varDispFont.getAutomation();
+ Variant lfFaceName = iDispFont.getProperty(COM.DISPID_FONT_NAME);
+ Variant lfHeight = iDispFont.getProperty(COM.DISPID_FONT_SIZE);
+ Variant lfItalic = iDispFont.getProperty(COM.DISPID_FONT_ITALIC);
+ //Variant lfCharSet = iDispFont.getProperty(COM.DISPID_FONT_CHARSET);
+ Variant lfBold = iDispFont.getProperty(COM.DISPID_FONT_BOLD);
+ iDispFont.dispose();
+
+ if (lfFaceName != null &&
+ lfHeight != null &&
+ lfItalic != null &&
+ lfBold != null){
+ int style = 3 * lfBold.getInt() + 2 * lfItalic.getInt();
+ Font font = new Font(getShell().getDisplay(), lfFaceName.getString(), lfHeight.getInt(), style);
+ return font;
+ }
+ }
+ }
+
+ return super.getFont();
+}
+public Color getForeground () {
+
+ if (objIUnknown != null) {
+ // !! We are getting the OLE_COLOR - should we change this to the COLORREF value?
+ OleAutomation oleObject= new OleAutomation(this);
+ Variant varForeColor = oleObject.getProperty(COM.DISPID_FORECOLOR);
+ oleObject.dispose();
+
+ if (varForeColor != null){
+ int[] colorRef = new int[1];
+ if (COM.OleTranslateColor(varForeColor.getInt(), getDisplay().hPalette, colorRef) == COM.S_OK)
+ return Color.win32_new(getDisplay(), colorRef[0]);
+ }
+ }
+
+ return super.getForeground();
+}
+protected int getLicenseInfo(GUID clsid) {
+ int[] ppvObject = new int[1];
+
+ if (COM.CoGetClassObject(clsid, COM.CLSCTX_INPROC_HANDLER | COM.CLSCTX_INPROC_SERVER, 0, COM.IIDIClassFactory2, ppvObject) != COM.S_OK) {
+ return 0;
+ }
+ IClassFactory2 classFactory = new IClassFactory2(ppvObject[0]);
+ LICINFO licinfo = new LICINFO();
+ if (classFactory.GetLicInfo(licinfo) != COM.S_OK) {
+ classFactory.Release();
+ return 0;
+ }
+ int[] pBstrKey = new int[1];
+ if (licinfo != null && licinfo.fRuntimeKeyAvail != 0) {
+ if (classFactory.RequestLicKey(0, pBstrKey) == COM.S_OK) {
+ classFactory.Release();
+ return pBstrKey[0];
+ }
+ }
+ classFactory.Release();
+ return 0;
+}
+protected int GetWindow(int phwnd) {
+
+ if (phwnd == 0)
+ return COM.E_INVALIDARG;
+ if (frame == null) {
+ COM.MoveMemory(phwnd, new int[] {0}, 4);
+ return COM.E_NOTIMPL;
+ }
+
+ // Copy the Window's handle into the memory passed in
+ COM.MoveMemory(phwnd, new int[] {handle}, 4);
+ return COM.S_OK;
+}
+private int Invoke(int dispIdMember, int riid, int lcid, int dwFlags, int pDispParams, int pVarResult, int pExcepInfo, int pArgErr) {
+ if (pVarResult == 0 || dwFlags != COM.DISPATCH_PROPERTYGET) {
+ if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4);
+ if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
+ return COM.DISP_E_MEMBERNOTFOUND;
+ }
+ switch (dispIdMember) {
+ case COM.DISPID_AMBIENT_USERMODE :
+ Variant usermode = new Variant(true);
+ if (pVarResult != 0) usermode.getData(pVarResult);
+ return COM.S_OK;
+
+ case COM.DISPID_AMBIENT_UIDEAD :
+ Variant uidead = new Variant(false);
+ if (pVarResult != 0) uidead.getData(pVarResult);
+ return COM.S_OK;
+
+ // indicate a false result
+ case COM.DISPID_AMBIENT_SUPPORTSMNEMONICS :
+ case COM.DISPID_AMBIENT_SHOWGRABHANDLES :
+ case COM.DISPID_AMBIENT_SHOWHATCHING :
+ if (pVarResult != 0) COM.MoveMemory(pVarResult, new int[] {0}, 4);
+ if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4);
+ if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
+ return COM.S_FALSE;
+
+ // not implemented
+ case COM.DISPID_AMBIENT_OFFLINEIFNOTCONNECTED :
+ case COM.DISPID_AMBIENT_BACKCOLOR :
+ case COM.DISPID_AMBIENT_FORECOLOR :
+ case COM.DISPID_AMBIENT_FONT :
+ case COM.DISPID_AMBIENT_LOCALEID :
+ case COM.DISPID_AMBIENT_SILENT :
+ case COM.DISPID_AMBIENT_MESSAGEREFLECT :
+ if (pVarResult != 0) COM.MoveMemory(pVarResult, new int[] {0}, 4);
+ if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4);
+ if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
+ return COM.E_NOTIMPL;
+
+ default :
+ if (pVarResult != 0) COM.MoveMemory(pVarResult, new int[] {0}, 4);
+ if (pExcepInfo != 0) COM.MoveMemory(pExcepInfo, new int[] {0}, 4);
+ if (pArgErr != 0) COM.MoveMemory(pArgErr, new int[] {0}, 4);
+ return COM.DISP_E_MEMBERNOTFOUND;
+ }
+}
+public boolean isFocusControl () {
+ return getDisplay().getFocusControl() == this;
+}
+private int OnControlInfoChanged() {
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIOleControl, ppvObject) == COM.S_OK) {
+ IOleControl objIOleControl = new IOleControl(ppvObject[0]);
+ // ask the control for its info in case users
+ // need to act on it
+ currentControlInfo = new CONTROLINFO();
+ objIOleControl.GetControlInfo(currentControlInfo);
+ objIOleControl.Release();
+ }
+ return COM.S_OK;
+}
+private int OnFocus(int fGotFocus) {
+ //if (frame == null) return COM.S_OK;
+
+ //if (fGotFocus != 0) {
+ // frame.setCurrentDocument(this);
+ //} else {
+ // frame.setCurrentDocument(null);
+ //}
+ return COM.S_OK;
+ //return COM.E_NOTIMPL;
+}
+protected int OnUIDeactivate(int fUndoable) {
+ // controls don't need to do anything for
+ // border space or menubars
+ return COM.S_OK;
+}
+protected int QueryInterface(int riid, int ppvObject) {
+ int result = super.QueryInterface(riid, ppvObject);
+ if (result == COM.S_OK)
+ return result;
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+ if (COM.IsEqualGUID(guid, COM.IIDIOleControlSite)) {
+ COM.MoveMemory(ppvObject, new int[] {iOleControlSite.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIDispatch)) {
+ COM.MoveMemory(ppvObject, new int[] {iDispatch.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+protected void releaseObjectInterfaces() {
+
+ disconnectEventSink();
+
+ disconnectPropertyChangeSink();
+
+ super.releaseObjectInterfaces();
+}
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removeEventListener(int eventID, OleListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ oleEventSink.removeListener(eventID, listener);
+}
+/**
+ * Removes the listener.
+ *
+ * @param listener the listener
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_NULL_ARGUMENT when listener is null</li></ul>
+ */
+public void removePropertyListener(int propertyID, OleListener listener) {
+ if (listener == null) throw new SWTError (SWT.ERROR_NULL_ARGUMENT);
+ olePropertyChangeSink.removeListener(propertyID, listener);
+}
+public void setBackground (Color color) {
+
+ super.setBackground(color);
+
+ //set the background of the ActiveX Control
+ if (objIUnknown != null) {
+ OleAutomation oleObject= new OleAutomation(this);
+ oleObject.setProperty(COM.DISPID_BACKCOLOR, new Variant(color.handle));
+ oleObject.dispose();
+ }
+}
+public void setFont (Font font) {
+
+ super.setFont(font);
+
+ //set the font of the ActiveX Control
+ if (objIUnknown != null) {
+
+ OleAutomation oleObject= new OleAutomation(this);
+ Variant varDispFont = oleObject.getProperty(COM.DISPID_FONT);
+ oleObject.dispose();
+
+ if (varDispFont != null){
+ OleAutomation iDispFont = varDispFont.getAutomation();
+ FontData[] fdata = font.getFontData();
+ iDispFont.setProperty(COM.DISPID_FONT_NAME, new Variant(fdata[0].getName()));
+ iDispFont.setProperty(COM.DISPID_FONT_SIZE, new Variant(fdata[0].getHeight()));
+ iDispFont.setProperty(COM.DISPID_FONT_ITALIC, new Variant(fdata[0].getStyle() & SWT.ITALIC));
+ //iDispFont.setProperty(COM.DISPID_FONT_CHARSET, new Variant(fdata[0].getCharset));
+ iDispFont.setProperty(COM.DISPID_FONT_BOLD, new Variant((fdata[0].getStyle() & SWT.BOLD)));
+ iDispFont.dispose();
+ }
+ }
+
+ return;
+}
+public void setForeground (Color color) {
+
+ super.setForeground(color);
+
+ //set the foreground of the ActiveX Control
+ if (objIUnknown != null) {
+ OleAutomation oleObject= new OleAutomation(this);
+ oleObject.setProperty(COM.DISPID_FORECOLOR, new Variant(color.handle));
+ oleObject.dispose();
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java
new file mode 100755
index 0000000000..b38fc1eda2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEvent.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.ole.win32;
+
+import org.eclipse.swt.widgets.Widget;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class OleEvent {
+ public int type;
+ public Widget widget;
+ public int detail;
+ public boolean doit = true;
+ public Variant[] arguments;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java
new file mode 100755
index 0000000000..0668e40c92
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventSink.java
@@ -0,0 +1,269 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+
+final class OleEventSink
+{
+ private OleControlSite controlSite;
+
+ private COMObject iUnknown;
+ private COMObject iDispatch;
+ private int refCount;
+
+ private int eventCookie;
+ private GUID eventSinkDispInterface;
+
+ private OleEventTable eventTable;
+
+OleEventSink(OleControlSite controlSite) {
+
+ this.controlSite = controlSite;
+
+ createCOMInterfaces();
+}
+void addListener(int eventID, OleListener listener) {
+ if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new OleEventTable ();
+ eventTable.hook(eventID, listener);
+}
+int AddRef() {
+ refCount++;
+ return refCount;
+}
+void connect(IUnknown objIUnknown) {
+
+ // What is the custom Event Sink interface?
+ eventSinkDispInterface = getEventSinkDispInterface(objIUnknown);
+
+ // It is possible that the Control does not have an Event sink.
+ // In this case, just carry on.
+ if (eventSinkDispInterface == null) return;
+
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
+ IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
+ int[] ppCP = new int[1];
+ if (cpc.FindConnectionPoint(eventSinkDispInterface, ppCP) == COM.S_OK) {
+ IConnectionPoint cp = new IConnectionPoint(ppCP[0]);
+ int[] pCookie = new int[1];
+ if (cp.Advise(iUnknown.getAddress(), pCookie) == COM.S_OK)
+ eventCookie = pCookie[0];
+ cp.Release();
+ }
+ cpc.Release();
+ }
+}
+private void createCOMInterfaces() {
+ // register each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+ iDispatch = new COMObject(new int[]{2, 0, 0, 1, 3, 4, 8}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ // method3 GetTypeInfoCount - not implemented
+ // method4 GetTypeInfo - not implemented
+ // method5 GetIDsOfNames - not implemented
+ public int method6(int[] args) {return Invoke(args[0], args[1], args[2], args[3], args[4], args[5], args[6], args[7]);}
+ };
+}
+void disconnect(IUnknown objIUnknown) {
+
+ // disconnect event sink
+ if (eventCookie != 0 && objIUnknown != null) {
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
+ IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
+ if (cpc.FindConnectionPoint(eventSinkDispInterface, ppvObject) == COM.S_OK) {
+ IConnectionPoint cp = new IConnectionPoint(ppvObject[0]);
+ if (cp.Unadvise(eventCookie) == COM.S_OK) {
+ eventCookie = 0;
+ }
+ cp.Release();
+ }
+ cpc.Release();
+ }
+ }
+}
+private void disposeCOMInterfaces() {
+
+ if (iUnknown != null);
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iDispatch != null)
+ iDispatch.dispose();
+ iDispatch = null;
+
+}
+private GUID getEventSinkDispInterface(IUnknown objIUnknown) {
+
+ // get Event Sink I/F from IProvideClassInfo2
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIProvideClassInfo2, ppvObject) == COM.S_OK) {
+ IProvideClassInfo2 pci2 = new IProvideClassInfo2(ppvObject[0]);
+ GUID eventsinkdisp = new GUID();
+ int result = pci2.GetGUID(COM.GUIDKIND_DEFAULT_SOURCE_DISP_IID, eventsinkdisp);
+ pci2.Release();
+ if (result == COM.S_OK) {
+ eventSinkDispInterface = eventsinkdisp;
+ return eventSinkDispInterface;
+ }
+
+ }
+
+ // get Event Sink I/F from IProvideClassInfo
+ if (objIUnknown.QueryInterface(COM.IIDIProvideClassInfo, ppvObject) == COM.S_OK) {
+ int[] ppTI = new int[1];
+ int[] ppEI = new int[1];
+ TYPEATTR typeAttribute = null;
+ IProvideClassInfo pci = new IProvideClassInfo(ppvObject[0]);
+ int result = pci.GetClassInfo(ppTI);
+ pci.Release();
+ if (result != COM.S_OK) return null;
+
+ if (ppTI != null && ppTI.length == 1) {
+ ITypeInfo classInfo = new ITypeInfo(ppTI[0]);
+ int[] ppTypeAttr = new int[1];
+ result = classInfo.GetTypeAttr(ppTypeAttr);
+ if (result != COM.S_OK) {
+ classInfo.Release();
+ return null;
+ }
+ typeAttribute = new TYPEATTR();
+ COM.MoveMemory(typeAttribute, ppTypeAttr[0], TYPEATTR.sizeof);
+ classInfo.ReleaseTypeAttr(ppTypeAttr[0]);
+ int implMask = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE | COM.IMPLTYPEFLAG_FRESTRICTED;
+ int implBits = COM.IMPLTYPEFLAG_FDEFAULT | COM.IMPLTYPEFLAG_FSOURCE;
+ for (int i = 0; i < typeAttribute.cImplTypes; i++) {
+ int[] pImplTypeFlags = new int[1];
+ if (classInfo.GetImplTypeFlags(i, pImplTypeFlags) == COM.S_OK) {
+ if ((pImplTypeFlags[0] & implMask) == implBits) {
+ int[] pRefType = new int[1];
+ if (classInfo.GetRefTypeOfImplType(i, pRefType) == COM.S_OK) {
+ classInfo.GetRefTypeInfo(pRefType[0], ppEI);
+ }
+ }
+ }
+ }
+ classInfo.Release();
+
+ //
+ if (ppEI != null && ppEI.length == 1) {
+ ppTypeAttr = new int[1];
+ ITypeInfo eventInfo = new ITypeInfo(ppEI[0]);
+ if (eventInfo.GetTypeAttr(ppTypeAttr) == COM.S_OK) {
+ typeAttribute = new TYPEATTR();
+ COM.MoveMemory(typeAttribute, ppTypeAttr[0], TYPEATTR.sizeof);
+ eventInfo.ReleaseTypeAttr(ppTypeAttr[0]);
+ if (ppTypeAttr != null && ppTypeAttr[0] != 0) {
+ eventSinkDispInterface = new GUID();
+ eventSinkDispInterface.data1 = typeAttribute.guid_data1;
+ eventSinkDispInterface.data2 = typeAttribute.guid_data2;
+ eventSinkDispInterface.data3 = typeAttribute.guid_data3;
+ eventSinkDispInterface.b0 = typeAttribute.guid_b0;
+ eventSinkDispInterface.b1 = typeAttribute.guid_b1;
+ eventSinkDispInterface.b2 = typeAttribute.guid_b2;
+ eventSinkDispInterface.b3 = typeAttribute.guid_b3;
+ eventSinkDispInterface.b4 = typeAttribute.guid_b4;
+ eventSinkDispInterface.b5 = typeAttribute.guid_b5;
+ eventSinkDispInterface.b6 = typeAttribute.guid_b6;
+ eventSinkDispInterface.b7 = typeAttribute.guid_b7;
+ }
+ }
+ eventInfo.Release();
+ }
+ }
+ }
+ return eventSinkDispInterface;
+}
+private int Invoke(int dispIdMember, int riid, int lcid, int dwFlags, int pDispParams, int pVarResult, int pExcepInfo, int pArgErr)
+{
+ if (eventTable == null || !eventTable.hooks(dispIdMember)) return COM.S_OK;
+
+ // Construct an array of the parameters that are passed in
+ // Note: parameters are passed in reverse order - here we will correct the order
+ Variant[] eventInfo = null;
+ if (pDispParams != 0) {
+ DISPPARAMS dispParams = new DISPPARAMS();
+ COM.MoveMemory(dispParams, pDispParams, DISPPARAMS.sizeof);
+ eventInfo = new Variant[dispParams.cArgs];
+ int size = Variant.sizeof;
+ int offset = (dispParams.cArgs - 1) * size;
+
+ for (int j = 0; j < dispParams.cArgs; j++){
+ eventInfo[j] = new Variant();
+ eventInfo[j].setData(dispParams.rgvarg + offset);
+ offset = offset - size;
+ }
+ }
+
+ OleEvent event = new OleEvent();
+ event.arguments = eventInfo;
+ notifyListener(dispIdMember,event);
+
+ return COM.S_OK;
+}
+/**
+* Notify listeners of an event.
+* <p>
+* This method notifies all listeners that an event
+* has occurred.
+*
+* @param eventType the desired SWT event
+* @param event the event data
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when handler is null</li>
+* </ul>
+*/
+private void notifyListener (int eventType, OleEvent event) {
+ if (event == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = controlSite;
+ eventTable.sendEvent (event);
+}
+private int QueryInterface(int riid, int ppvObject) {
+
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+
+ if ( COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIDispatch) ||
+ COM.IsEqualGUID(guid, eventSinkDispInterface)) {
+ COM.MoveMemory(ppvObject, new int[] {iDispatch.getAddress()}, 4);
+ AddRef();
+ return OLE.S_OK;
+ }
+
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+int Release() {
+ refCount--;
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ }
+
+ return refCount;
+}
+void removeListener(int eventID, OleListener listener) {
+ if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventID, listener);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java
new file mode 100755
index 0000000000..6318e9d1b0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleEventTable.java
@@ -0,0 +1,68 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import java.util.EventListener;
+
+/**
+* The OleEventTable class implements a simple
+* look up mechanism that maps an event type
+* to a listener. Muliple listeners for the
+* same event type are supported.
+*
+*/
+
+/* Class Definition */
+class OleEventTable {
+ int [] types;
+ OleListener [] handlers;
+void hook (int eventType, OleListener handler) {
+ if (types == null) types = new int [4];
+ if (handlers == null) handlers = new OleListener [4];
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == 0) {
+ types [i] = eventType;
+ handlers [i] = handler;
+ return;
+ }
+ }
+ int size = types.length;
+ int [] newTypes = new int [size + 4];
+ OleListener [] newHandlers = new OleListener [size + 4];
+ System.arraycopy (types, 0, newTypes, 0, size);
+ System.arraycopy (handlers, 0, newHandlers, 0, size);
+ types = newTypes; handlers = newHandlers;
+ types [size] = eventType; handlers [size] = handler;
+}
+boolean hooks (int eventType) {
+ if (handlers == null) return false;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == eventType) return true;
+ }
+ return false;
+}
+void sendEvent (OleEvent event) {
+ if (handlers == null) return;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == event.type) {
+ OleListener listener = handlers [i];
+ if (listener != null) listener.handleEvent (event);
+ }
+ }
+}
+void unhook (int eventType, OleListener handler) {
+ if (handlers == null) return;
+ for (int i=0; i<types.length; i++) {
+ if ((types [i] == eventType) && (handlers [i] == handler)) {
+ types [i] = 0;
+ handlers [i] = null;
+ return;
+ }
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFile.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFile.java
new file mode 100755
index 0000000000..8564bcea56
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFile.java
@@ -0,0 +1,128 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.internal.ole.win32.*;
+
+final class OleFile {
+ IStorage rootStorage;
+ File file;
+ String streamName;
+
+ static int READ = 0;
+ static int WRITE = 1;
+OleFile(File file, String streamName, int mode) {
+ if (file == null || file.isDirectory())
+ OLE.error(OLE.ERROR_INVALID_ARGUMENT);
+
+ this.file = file;
+ this.streamName = streamName;
+
+ if (mode == READ)
+ openForRead();
+ if (mode == WRITE)
+ openForWrite();
+}
+void dispose() {
+
+ rootStorage.Release();
+ rootStorage = null;
+ file = null;
+ streamName = null;
+}
+IStorage getRootStorage() {
+ return rootStorage;
+}
+private void openForRead() {
+
+ if (!file.exists()) return;
+
+ char[] path = (file.getAbsolutePath()+"\0").toCharArray();
+ if (COM.StgIsStorageFile(path) == COM.S_OK) {
+ readStorageFile(path);
+ } else {
+ readTraditionalFile(path);
+ }
+
+}
+private void openForWrite() {
+ char[] filePath = (file.getAbsolutePath()+"\0").toCharArray();
+ int[] address = new int[1];
+ int mode = COM.STGM_TRANSACTED | COM.STGM_READWRITE | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_CREATE;
+
+ int result = COM.StgCreateDocfile(filePath, mode, 0, address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CREATE_FILE, result);
+
+ IStorage storage = new IStorage(address[0]);
+
+ rootStorage = storage;
+}
+private void readStorageFile(char[] path) {
+
+ int mode = COM.STGM_READ | COM.STGM_TRANSACTED | COM.STGM_SHARE_EXCLUSIVE;
+ int[] address = new int[1];
+
+ int result = COM.StgOpenStorage(path, 0, mode, 0, 0, address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
+
+ rootStorage = new IStorage(address[0]);
+ rootStorage.AddRef();
+}
+private void readTraditionalFile(char[] path) {
+
+ if (streamName == null) OLE.error(OLE.ERROR_NULL_ARGUMENT);
+
+ int mode = COM.STGM_DIRECT | COM.STGM_SHARE_EXCLUSIVE | COM.STGM_READWRITE | COM.STGM_CREATE;
+
+ // Create a temporary storage object
+ int[] address = new int[1];
+ int result = COM.StgCreateDocfile(null, mode | COM.STGM_DELETEONRELEASE, 0, address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
+ rootStorage = new IStorage(address[0]);
+ rootStorage.AddRef();
+
+ // Create a stream on the storage object with the name specified in streamName
+ address = new int[1];
+ result = rootStorage.CreateStream(streamName, mode, 0, 0, address);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
+
+ // Copy over data in file to named stream
+ IStream stream = new IStream(address[0]);
+ stream.AddRef();
+ try {
+
+ FileInputStream fileInput = new FileInputStream(file);
+
+ int increment = 1024*4;
+ byte[] buffer = new byte[increment];
+ int count = 0;
+
+ while((count = fileInput.read(buffer)) > 0){
+ int pv = COM.CoTaskMemAlloc(count);
+ OS.MoveMemory(pv, buffer, count);
+ result = stream.Write(pv, count, null) ;
+ COM.CoTaskMemFree(pv);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_OPEN_FILE, result);
+ }
+ stream.Commit(COM.STGC_DEFAULT);
+
+ fileInput.close();
+ } catch (IOException err) {
+ OLE.error(OLE.ERROR_CANNOT_OPEN_FILE);
+ }
+
+ stream.Release();
+
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
new file mode 100755
index 0000000000..d36adaa5e2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFrame.java
@@ -0,0 +1,626 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+import java.util.Enumeration;
+import java.util.Vector;
+
+/**
+ *
+ * OleFrame is an OLE Container's top level frame.
+ *
+ * <p>This object implements the OLE Interfaces IUnknown and IOleInPlaceFrame
+ *
+ * <p>OleFrame allows the container to do the following: <ul>
+ * <li>position and size the ActiveX Control or OLE Document within the application
+ * <li>insert menu items from the application into the OLE Document's menu
+ * <li>activate and deactivate the OLE Document's menus
+ * <li>position the OLE Document's menu in the application
+ * <li>translate accelerator keystrokes intended for the container's frame</ul>
+ *
+ * <dl>
+ * <dt><b>Styles</b> <dd>BORDER
+ * <dt><b>Events</b> <dd>Dispose, Move, Resize
+ * </dl>
+ *
+ */
+final public class OleFrame extends Composite
+{
+ // Interfaces for this Ole Client Container
+ private COMObject iUnknown;
+ private COMObject iOleInPlaceFrame;
+
+ // Access to the embedded/linked Ole Object
+ private IOleInPlaceActiveObject objIOleInPlaceActiveObject;
+
+ private OleClientSite currentdoc;
+
+ private int refCount = 0;
+
+ private MenuItem[] fileMenuItems;
+ private MenuItem[] containerMenuItems;
+ private MenuItem[] windowMenuItems;
+ private Menu menubar;
+
+ private InternalListener listener;
+ private class InternalListener implements Listener {
+ public void handleEvent(Event e) {
+ switch (e.type) {
+ case SWT.Dispose :
+ onDispose(e);
+ break;
+ case SWT.Resize :
+ case SWT.Move :
+ onResize(e);
+ break;
+ default :
+ OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ }
+ }
+
+ private static String CHECK_FOCUS = "OLE_CHECK_FOCUS";
+
+/**
+ * Create an OleFrame child widget using style bits
+ * to select a particular look or set of properties.
+ *
+ * @param parent a composite widget (cannot be null)
+ * @param style the bitwise OR'ing of widget styles
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread
+ * <li>ERROR_ERROR_NULL_ARGUMENT when the parent is null
+ * <li>ERROR_INTERFACES_NOT_INITIALIZED when unable to create callbacks for OLE Interfaces</ul>
+ *
+ */
+public OleFrame(Composite parent, int style) {
+ // set up widget attributes
+ super(parent, style | SWT.CLIP_CHILDREN | SWT.CLIP_SIBLINGS);
+
+ createCOMInterfaces();
+
+ // setup cleanup proc
+ listener = new InternalListener();
+ addListener(SWT.Dispose, listener);
+
+ // inform inplaceactiveobject whenever frame resizes
+ addListener(SWT.Resize, listener);
+
+ // inform inplaceactiveobject whenever frame moves
+ addListener(SWT.Move, listener);
+
+ // By default, set the menubar to the current frame's menubar
+ menubar = getShell().getMenuBar();
+
+ // Maintain a reference to yourself so that when
+ // ClientSites close, they don't take the frame away
+ // with them.
+ this.AddRef();
+
+ // Check for focus change
+ checkFocus(getDisplay());
+}
+private static void checkFocus (final Display display) {
+ Object polling = display.getData(CHECK_FOCUS);
+ if (polling != null) return;
+ display.setData(CHECK_FOCUS, CHECK_FOCUS);
+ final int time = 50;
+ final Runnable[] timer = new Runnable[1];
+ final Control[] lastFocus = new Control[1];
+ timer[0] = new Runnable() {
+ public void run() {
+ Event event = new Event();
+ Control currentFocus = display.getFocusControl();
+ if (lastFocus[0] != currentFocus) {
+ if (lastFocus[0] instanceof OleFrame) {
+ if (!lastFocus [0].isDisposed()) {
+ OleFrame frame = (OleFrame) lastFocus[0];
+ OleClientSite client = frame.getCurrentDocument();
+ if (client != null) {
+ client.notifyListeners (SWT.FocusOut, event);
+ }
+ }
+ }
+ if (lastFocus [0] instanceof OleControlSite) {
+ if (!lastFocus[0].isDisposed()) {
+ lastFocus[0].notifyListeners (SWT.FocusOut, event);
+ }
+ }
+ if (currentFocus instanceof OleFrame) {
+ OleFrame frame = (OleFrame) currentFocus;
+ OleClientSite client = frame.getCurrentDocument();
+ if (client != null) {
+ client.notifyListeners (SWT.FocusIn, event);
+ }
+ }
+ if (currentFocus instanceof OleControlSite) {
+ currentFocus.notifyListeners(SWT.FocusIn, event);
+ }
+ }
+ lastFocus[0] = currentFocus;
+ display.timerExec(time, timer[0]);
+ }
+ };
+ display.timerExec(time, timer[0]);
+}
+/**
+ * Increment the count of references to this instance
+ *
+ * @return the current reference count
+ */
+int AddRef() {
+ refCount++;
+ return refCount;
+}
+private int ContextSensitiveHelp(int fEnterMode) {
+ return COM.S_OK;
+}
+private void createCOMInterfaces() {
+ // Create each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+
+ iOleInPlaceFrame = new COMObject(new int[]{2, 0, 0, 1, 1, 1, 1, 1, 2, 2, 3, 1, 1, 1, 2}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return GetWindow(args[0]);}
+ public int method4(int[] args) {return ContextSensitiveHelp(args[0]);}
+ public int method5(int[] args) {return GetBorder(args[0]);}
+ public int method6(int[] args) {return RequestBorderSpace(args[0]);}
+ public int method7(int[] args) {return SetBorderSpace(args[0]);}
+ public int method8(int[] args) {return SetActiveObject(args[0], args[1]);}
+ public int method9(int[] args) {return InsertMenus(args[0], args[1]);}
+ public int method10(int[] args) {return SetMenu(args[0], args[1], args[2]);}
+ public int method11(int[] args) {return RemoveMenus(args[0]);}
+ // method12 SetStatusText - not implemented
+ // method13 EnableModeless - not implemented
+ public int method14(int[] args) {return TranslateAccelerator(args[0], args[1]);}
+ };
+}
+private void disposeCOMInterfaces () {
+
+ if (iUnknown != null)
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iOleInPlaceFrame != null)
+ iOleInPlaceFrame.dispose();
+ iOleInPlaceFrame = null;
+}
+private int GetBorder(int lprectBorder) {
+ /*
+ The IOleInPlaceUIWindow::GetBorder function, when called on a document or frame window
+ object, returns the outer rectangle (relative to the window) where the object can put
+ toolbars or similar controls.
+ */
+ if (lprectBorder == 0) return COM.E_INVALIDARG;
+ RECT rectBorder = new RECT();
+ // Coordinates must be relative to the window
+ OS.GetClientRect(handle, rectBorder);
+ OS.MoveMemory(lprectBorder, rectBorder, RECT.sizeof);
+ return COM.S_OK;
+}
+/**
+ *
+ * Returns the application menu items that will appear in the Container location when an OLE Document
+ * is in-place activated.
+ *
+ * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
+ * is given the opportunity to merge some of its menus into the menubar. The application
+ * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
+ * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
+ * menu locations. Note that an application can insert more than one menu into a single location.
+ *
+ * @return the application menu items that will appear in the Container location when an OLE Document
+ * is in-place activated.
+ *
+ */
+public MenuItem[] getContainerMenus(){
+ return containerMenuItems;
+}
+/**
+ *
+ * Returns the application menu items that will appear in the File location when an OLE Document
+ * is in-place activated.
+ *
+ * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
+ * is given the opportunity to merge some of its menus into the menubar. The application
+ * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
+ * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
+ * menu locations. Note that an application can insert more than one menu into a single location.
+ *
+ * @return the application menu items that will appear in the File location when an OLE Document
+ * is in-place activated.
+ *
+ */
+public MenuItem[] getFileMenus(){
+ return fileMenuItems;
+}
+int getIOleInPlaceFrame() {
+ return iOleInPlaceFrame.getAddress();
+}
+Menu getMenubar(){
+ return menubar;
+}
+private int getMenuItemID(int hMenu, int index) {
+ int id = 0;
+ MENUITEMINFO lpmii = new MENUITEMINFO();
+ lpmii.cbSize = MENUITEMINFO.sizeof;
+ lpmii.fMask = OS.MIIM_STATE | OS.MIIM_SUBMENU | OS.MIIM_ID;
+ OS.GetMenuItemInfo(hMenu, index, true, lpmii);
+ if ((lpmii.fState & OS.MF_POPUP) == OS.MF_POPUP) {
+ id = lpmii.hSubMenu;
+ } else {
+ id = lpmii.wID;
+ }
+ return id;
+}
+private int GetWindow(int phwnd) {
+ if (phwnd != 0) {
+ COM.MoveMemory(phwnd, new int[] {handle}, 4);
+ }
+ return COM.S_OK;
+}
+/**
+ *
+ * Returns the application menu items that will appear in the Window location when an OLE Document
+ * is in-place activated.
+ *
+ * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
+ * is given the opportunity to merge some of its menus into the menubar. The application
+ * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
+ * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
+ * menu locations. Note that an application can insert more than one menu into a single location.
+ *
+ * @return the application menu items that will appear in the Window location when an OLE Document
+ * is in-place activated.
+ *
+ */
+public MenuItem[] getWindowMenus(){
+ return windowMenuItems;
+}
+private int InsertMenus(int hmenuShared, int lpMenuWidths) {
+ // locate menu bar
+ if (menubar == null || menubar.isDisposed()) {
+ COM.MoveMemory(lpMenuWidths, new int[] {0}, 4);
+ return COM.S_OK;
+ }
+ int hMenu = menubar.handle;
+
+ // Create a holder for menu information. This will be passed down to
+ // the OS and the OS will fill in the requested information for each menu.
+ MENUITEMINFO lpmii = new MENUITEMINFO();
+ int hHeap = OS.GetProcessHeap();
+ int maxTextLength = 128;
+ int pszText = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, maxTextLength);
+ lpmii.cbSize = MENUITEMINFO.sizeof;
+ lpmii.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE | OS.MIIM_SUBMENU;
+ lpmii.dwTypeData = pszText;
+ lpmii.cch = maxTextLength;
+
+ // Loop over all "File-like" menus in the menubar and get information about the
+ // item from the OS.
+ int fileMenuCount = 0;
+ int newindex = 0;
+ if (this.fileMenuItems != null) {
+ for (int i = 0; i < this.fileMenuItems.length; i++) {
+ MenuItem item = this.fileMenuItems[i];
+ if (item != null) {
+ int index = item.getParent().indexOf(item);
+ lpmii.cch = maxTextLength; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
+ // exact nuber of characters in name. Reset it to our max size
+ // before each call.
+ if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) {
+ if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) {
+ // keep track of the number of items
+ fileMenuCount++;
+ newindex++;
+ }
+ }
+ }
+ }
+ }
+
+ // copy the menu item count information to the pointer
+ COM.MoveMemory(lpMenuWidths, new int[] {fileMenuCount}, 4);
+
+ // Loop over all "Container-like" menus in the menubar and get information about the
+ // item from the OS.
+ int containerMenuCount = 0;
+ if (this.containerMenuItems != null) {
+ for (int i = 0; i < this.containerMenuItems.length; i++) {
+ MenuItem item = this.containerMenuItems[i];
+ if (item != null) {
+ int index = item.getParent().indexOf(item);
+ lpmii.cch = maxTextLength; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
+ // exact nuber of characters in name. Reset it to a large number
+ // before each call.
+ if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) {
+ if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) {
+ // keep track of the number of items
+ containerMenuCount++;
+ newindex++;
+ }
+ }
+ }
+ }
+ }
+
+ // copy the menu item count information to the pointer
+ COM.MoveMemory(lpMenuWidths + 8, new int[] {containerMenuCount}, 4);
+
+ // Loop over all "Window-like" menus in the menubar and get information about the
+ // item from the OS.
+ int windowMenuCount = 0;
+ if (this.windowMenuItems != null) {
+ for (int i = 0; i < this.windowMenuItems.length; i++) {
+ MenuItem item = this.windowMenuItems[i];
+ if (item != null) {
+ int index = item.getParent().indexOf(item);
+ lpmii.cch = maxTextLength; // lpmii.cch gets updated by GetMenuItemInfo to indicate the
+ // exact nuber of characters in name. Reset it to a large number
+ // before each call.
+ if (OS.GetMenuItemInfo(hMenu, index, true, lpmii)) {
+ if (OS.InsertMenuItem(hmenuShared, newindex, true, lpmii)) {
+ // keep track of the number of items
+ windowMenuCount++;
+ newindex++;
+ }
+ }
+ }
+ }
+ }
+
+ // copy the menu item count information to the pointer
+ COM.MoveMemory(lpMenuWidths + 16, new int[] {windowMenuCount}, 4);
+
+ // free resources used in querying the OS
+ if (pszText != 0)
+ OS.HeapFree(hHeap, 0, pszText);
+ return COM.S_OK;
+}
+private void onDispose(Event e) {
+
+ releaseObjectInterfaces();
+ currentdoc = null;
+
+ this.Release();
+}
+private void onResize(Event e) {
+ if (objIOleInPlaceActiveObject != null) {
+ RECT lpRect = new RECT();
+ OS.GetClientRect(handle, lpRect);
+ objIOleInPlaceActiveObject.ResizeBorder(lpRect, iOleInPlaceFrame.getAddress(), true);
+ }
+}
+private int QueryInterface(int riid, int ppvObject) {
+// implements IUnknown, IOleInPlaceFrame, IOleContainer, IOleInPlaceUIWindow
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown) || COM.IsEqualGUID(guid, COM.IIDIOleInPlaceFrame) ) {
+ COM.MoveMemory(ppvObject, new int[] {iOleInPlaceFrame.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+/**
+ * Decrement the count of references to this instance
+ *
+ * @return the current reference count
+ */
+int Release() {
+ refCount--;
+ if (refCount == 0){
+ disposeCOMInterfaces();
+ COM.CoFreeUnusedLibraries();
+ }
+ return refCount;
+}
+private void releaseObjectInterfaces() {
+ if (objIOleInPlaceActiveObject != null) {
+ objIOleInPlaceActiveObject.Release();
+ }
+ objIOleInPlaceActiveObject = null;
+}
+private int RemoveMenus(int hmenuShared) {
+
+ if (menubar == null || menubar.isDisposed()) return COM.S_FALSE;
+
+ int hMenu = menubar.handle;
+
+ Vector ids = new Vector();
+ if (this.fileMenuItems != null) {
+ for (int i = 0; i < this.fileMenuItems.length; i++) {
+ MenuItem item = this.fileMenuItems[i];
+ if (item != null && !item.isDisposed()) {
+ int index = item.getParent().indexOf(item);
+ // get Id from original menubar
+ int id = getMenuItemID(hMenu, index);
+ ids.addElement(new Integer(id));
+ }
+ }
+ }
+ if (this.containerMenuItems != null) {
+ for (int i = 0; i < this.containerMenuItems.length; i++) {
+ MenuItem item = this.containerMenuItems[i];
+ if (item != null && !item.isDisposed()) {
+ int index = item.getParent().indexOf(item);
+ int id = getMenuItemID(hMenu, index);
+ ids.addElement(new Integer(id));
+ }
+ }
+ }
+ if (this.windowMenuItems != null) {
+ for (int i = 0; i < this.windowMenuItems.length; i++) {
+ MenuItem item = this.windowMenuItems[i];
+ if (item != null && !item.isDisposed()) {
+ int index = item.getParent().indexOf(item);
+ int id = getMenuItemID(hMenu, index);
+ ids.addElement(new Integer(id));
+ }
+ }
+ }
+ int index = OS.GetMenuItemCount(hmenuShared) - 1;
+ for (int i = index; i >= 0; i--) {
+ int id = getMenuItemID(hmenuShared, i);
+ if (ids.contains(new Integer(id))){
+ OS.RemoveMenu(hmenuShared, i, OS.MF_BYPOSITION);
+ }
+ }
+ return COM.S_OK;
+}
+private int RequestBorderSpace(int pborderwidths) {
+ return COM.S_OK;
+}
+int SetActiveObject(int pActiveObject, int pszObjName) {
+ if (objIOleInPlaceActiveObject != null) {
+ objIOleInPlaceActiveObject.Release();
+ objIOleInPlaceActiveObject = null;
+ }
+ if (pActiveObject != 0) {
+ objIOleInPlaceActiveObject = new IOleInPlaceActiveObject(pActiveObject);
+ objIOleInPlaceActiveObject.AddRef();
+ }
+
+ return COM.S_OK;
+}
+private int SetBorderSpace(int pborderwidths) {
+ // A Control/Document can :
+ // Use its own toolbars, requesting border space of a specific size, or,
+ // Use no toolbars, but force the container to remove its toolbars by passing a
+ // valid BORDERWIDTHS structure containing nothing but zeros in the pborderwidths parameter, or,
+ // Use no toolbars but allow the in-place container to leave its toolbars up by
+ // passing NULL as the pborderwidths parameter.
+
+ RECT borderwidth = new RECT();
+ if (pborderwidths == 0 || currentdoc == null ) return COM.S_OK;
+
+ COM.MoveMemory(borderwidth, pborderwidths, RECT.sizeof);
+ currentdoc.setBorderSpace(borderwidth);
+
+ return COM.S_OK;
+}
+/**
+ *
+ * Specify the menu items that should appear in the Container location when an OLE Document
+ * is in-place activated.
+ *
+ * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
+ * is given the opportunity to merge some of its menus into the menubar. The application
+ * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
+ * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
+ * menu locations. Note that an application can insert more than one menu into a single location.
+ *
+ * <p>This method must be called before in place activation of the OLE Document. After the Document
+ * is activated, the menu bar will not be modified until a subsequent activation.
+ *
+ * @param containerMenus an array of top level MenuItems to be inserted into the Container location of
+ * the menubar
+ */
+public void setContainerMenus(MenuItem[] containerMenus){
+ containerMenuItems = containerMenus;
+}
+OleClientSite getCurrentDocument() {
+ return currentdoc;
+}
+void setCurrentDocument(OleClientSite doc) {
+ currentdoc = doc;
+
+ if (currentdoc != null && objIOleInPlaceActiveObject != null) {
+ RECT lpRect = new RECT();
+ OS.GetClientRect(handle, lpRect);
+ objIOleInPlaceActiveObject.ResizeBorder(lpRect, iOleInPlaceFrame.getAddress(), true);
+ }
+}
+/**
+ *
+ * Specify the menu items that should appear in the File location when an OLE Document
+ * is in-place activated.
+ *
+ * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
+ * is given the opportunity to merge some of its menus into the menubar. The application
+ * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
+ * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
+ * menu locations. Note that an application can insert more than one menu into a single location.
+ *
+ * <p>This method must be called before in place activation of the OLE Document. After the Document
+ * is activated, the menu bar will not be modified until a subsequent activation.
+ *
+ * @param fileMenus an array of top level MenuItems to be inserted into the Flie location of
+ * the menubar
+ */
+public void setFileMenus(MenuItem[] fileMenus){
+ fileMenuItems = fileMenus;
+}
+public boolean forceFocus () {
+ if (currentdoc == null) return super.forceFocus();
+ return currentdoc.forceFocus();
+}
+private int SetMenu(int hmenuShared, int holemenu, int hwndActiveObject) {
+
+ int inPlaceActiveObject = 0;
+ if (objIOleInPlaceActiveObject != null)
+ inPlaceActiveObject = objIOleInPlaceActiveObject.getAddress();
+
+ if (menubar == null || menubar.isDisposed()){
+ return COM.OleSetMenuDescriptor(0, getShell().handle, hwndActiveObject, iOleInPlaceFrame.getAddress(), inPlaceActiveObject);
+ }
+
+ int handle = menubar.getShell().handle;
+
+ if (hmenuShared == 0 && holemenu == 0) {
+ // re-instate the original menu - this occurs on deactivation
+ hmenuShared = menubar.handle;
+ }
+ if (hmenuShared == 0) return COM.E_FAIL;
+
+ OS.SetMenu(handle, hmenuShared);
+ OS.DrawMenuBar(handle);
+
+ return COM.OleSetMenuDescriptor(holemenu, handle, hwndActiveObject, iOleInPlaceFrame.getAddress(), inPlaceActiveObject);
+}
+private void setMenubar(Menu bar){
+ menubar = bar;
+}
+/**
+ *
+ * Set the menu items that should appear in the Window location when an OLE Document
+ * is in-place activated.
+ *
+ * <p>When an OLE Document is in-place active, the Document provides its own menus but the application
+ * is given the opportunity to merge some of its menus into the menubar. The application
+ * is allowed to insert its menus in three locations: File (far left), Container(middle) and Window
+ * (far right just before Help). The OLE Document retains control of the Edit, Object and Help
+ * menu locations. Note that an application can insert more than one menu into a single location.
+ *
+ * <p>This method must be called before in place activation of the OLE Document. After the Document
+ * is activated, the menu bar will not be modified until a subsequent activation.
+ *
+ * @param windowMenus an array of top level MenuItems to be inserted into the Window location of
+ * the menubar
+ */
+public void setWindowMenus(MenuItem[] windowMenus){
+ windowMenuItems = windowMenus;
+}
+private int TranslateAccelerator(int lpmsg, int wID){
+ return COM.E_NOTIMPL;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java
new file mode 100755
index 0000000000..6ea8d8b923
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleFunctionDescription.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.ole.win32;
+
+import org.eclipse.swt.internal.ole.win32.COM;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class OleFunctionDescription {
+
+ public int id;
+ public String name;
+ public OleParameterDescription[] args;
+ public int optionalArgCount;
+ public short returnType;
+ public int invokeKind;
+ public int funcKind;
+ public short flags;
+ public int callingConvention;
+ public String documentation;
+ public String helpFile;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java
new file mode 100755
index 0000000000..111bed3bc5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleListener.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/**
+ */
+public interface OleListener
+{
+/**
+ *
+ */
+public void handleEvent(OleEvent event);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java
new file mode 100755
index 0000000000..797c891085
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OleParameterDescription.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class OleParameterDescription {
+ public String name;
+ public short flags;
+ public short type;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java
new file mode 100755
index 0000000000..4a4a84b75a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyChangeSink.java
@@ -0,0 +1,179 @@
+package org.eclipse.swt.ole.win32;
+
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+final class OlePropertyChangeSink {
+
+ private OleControlSite controlSite;
+ //private IUnknown objIUnknown;
+
+ private COMObject iUnknown;
+ private COMObject iPropertyNotifySink;
+
+ private int refCount;
+
+ private int propertyCookie;
+
+ private OleEventTable eventTable;
+
+OlePropertyChangeSink(OleControlSite controlSite) {
+
+ this.controlSite = controlSite;
+
+ createCOMInterfaces();
+}
+void addListener(int propertyID, OleListener listener) {
+ if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new OleEventTable ();
+ eventTable.hook(propertyID, listener);
+}
+int AddRef() {
+ refCount++;
+ return refCount;
+}
+void connect(IUnknown objIUnknown) {
+
+ // Set up property change notification sink
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
+ IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
+ if (cpc.FindConnectionPoint(COM.IIDIPropertyNotifySink, ppvObject) == COM.S_OK) {
+ IConnectionPoint cp = new IConnectionPoint(ppvObject[0]);
+ int[] cookie = new int[1];
+ if (cp.Advise(iPropertyNotifySink.getAddress(), cookie) == COM.S_OK) {
+ propertyCookie = cookie[0];
+ }
+ cp.Release();
+ }
+ cpc.Release();
+ }
+}
+private void createCOMInterfaces() {
+ // register each of the interfaces that this object implements
+ iUnknown = new COMObject(new int[]{2, 0, 0}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ };
+
+ iPropertyNotifySink = new COMObject(new int[]{2, 0, 0, 1, 1}){
+ public int method0(int[] args) {return QueryInterface(args[0], args[1]);}
+ public int method1(int[] args) {return AddRef();}
+ public int method2(int[] args) {return Release();}
+ public int method3(int[] args) {return OnChanged(args[0]);}
+ public int method4(int[] args) {return OnRequestEdit(args[0]);}
+ };
+}
+void disconnect(IUnknown objIUnknown) {
+
+ // disconnect property notification sink
+ if (propertyCookie != 0 && objIUnknown != null) {
+ int[] ppvObject = new int[1];
+ if (objIUnknown.QueryInterface(COM.IIDIConnectionPointContainer, ppvObject) == COM.S_OK) {
+ IConnectionPointContainer cpc = new IConnectionPointContainer(ppvObject[0]);
+ if (cpc.FindConnectionPoint(COM.IIDIPropertyNotifySink, ppvObject) == COM.S_OK) {
+ IConnectionPoint cp = new IConnectionPoint(ppvObject[0]);
+ if (cp.Unadvise(propertyCookie) == COM.S_OK) {
+ propertyCookie = 0;
+ }
+ cp.Release();
+ }
+ cpc.Release();
+ }
+ }
+}
+private void disposeCOMInterfaces() {
+
+ if (iUnknown != null);
+ iUnknown.dispose();
+ iUnknown = null;
+
+ if (iPropertyNotifySink != null)
+ iPropertyNotifySink.dispose();
+ iPropertyNotifySink = null;
+
+}
+/**
+* Notify listeners of an event.
+* <p>
+* This method notifies all listeners that an event
+* has occurred.
+*
+* @param eventType the desired SWT event
+* @param event the event data
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when handler is null</li>
+* </ul>
+*/
+private void notifyListener (int eventType, OleEvent event) {
+ if (event == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = controlSite;
+ eventTable.sendEvent (event);
+}
+private int OnChanged(int dispID) {
+
+ if (eventTable == null || !eventTable.hooks(dispID)) return COM.S_OK;
+
+ OleEvent event = new OleEvent();
+ event.detail = OLE.PROPERTY_CHANGED;
+ notifyListener(dispID,event);
+
+ return COM.S_OK;
+}
+private int OnRequestEdit(int dispID) {
+
+ if (eventTable == null || !eventTable.hooks(dispID)) return COM.S_OK;
+
+ OleEvent event = new OleEvent();
+ event.doit = true;
+ event.detail = OLE.PROPERTY_CHANGING;
+
+ notifyListener(dispID,event);
+
+ if (event.doit) return COM.S_OK;
+
+ return COM.S_FALSE;
+}
+private int QueryInterface(int riid, int ppvObject) {
+ if (riid == 0 || ppvObject == 0)
+ return COM.E_INVALIDARG;
+ GUID guid = new GUID();
+ COM.MoveMemory(guid, riid, GUID.sizeof);
+ if (COM.IsEqualGUID(guid, COM.IIDIUnknown)) {
+ COM.MoveMemory(ppvObject, new int[] {iUnknown.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ if (COM.IsEqualGUID(guid, COM.IIDIPropertyNotifySink)) {
+ COM.MoveMemory(ppvObject, new int[] {iPropertyNotifySink.getAddress()}, 4);
+ AddRef();
+ return COM.S_OK;
+ }
+ COM.MoveMemory(ppvObject, new int[] {0}, 4);
+ return COM.E_NOINTERFACE;
+}
+int Release() {
+ refCount--;
+ if (refCount == 0) {
+ disposeCOMInterfaces();
+ }
+
+ return refCount;
+}
+void removeListener(int propertyID, OleListener listener) {
+ if (listener == null) OLE.error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (propertyID, listener);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java
new file mode 100755
index 0000000000..e07b151c78
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/OlePropertyDescription.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class OlePropertyDescription {
+ public int id;
+ public String name;
+ public int type;
+ public int flags;
+ public int kind;
+ public String description;
+ public String helpFile;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java
new file mode 100755
index 0000000000..e9a39b00c5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/Variant.java
@@ -0,0 +1,524 @@
+package org.eclipse.swt.ole.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.ole.win32.*;
+import org.eclipse.swt.internal.win32.*;
+/**
+ *
+ * A Variant is a generic OLE mechanism for passing data of different types via a common interface.
+ *
+ * <p>It is used within the OleAutomation object for getting a property, setting a property or invoking
+ * a method on an OLE Control or OLE Document.
+ *
+ */
+public final class Variant
+{
+ // A variant always takes up 16 bytes, no matter what you
+ // store in it. Objects, strings, and arrays are not physically
+ // stored in the Variant; in these cases, four bytes of the
+ // Variant are used to hold either an object reference, or a
+ // pointer to the string or array. The actual data are stored elsewhere.
+ public static final int sizeof = 16;
+
+ private short type; // OLE.VT_* type
+
+ private boolean booleanData;
+ private float floatData;
+ private int intData;
+ private short shortData;
+ private String stringData;
+ private int byRefPtr;
+ private OleAutomation dispatchData;
+ private IUnknown unknownData;
+Variant(){
+ type = COM.VT_EMPTY;
+}
+/**
+ * Create a Variant object which represents a Java float as a VT_R4.
+ *
+ * @param val the Java float value that this Variant represents
+ *
+ */
+public Variant(float val) {
+ type = COM.VT_R4;
+ floatData = val;
+
+}
+/**
+ * Create a Variant object which represents a Java int as a VT_I4.
+ *
+ * @param val the Java int value that this Variant represents
+ *
+ */
+ public Variant(int val) {
+
+ type = COM.VT_I4;
+ intData = val;
+}
+/**
+ * Create a Variant object which contains a reference to the data being transferred.
+ *
+ * <p>When creating a VT_BYREF Variant, you must give the full Variant type including VT_BYREF
+ * (such as <code>short byRefType = OLE.VT_BSTR | OLE.VT_BYREF</code>).
+ *
+ * @param ptr a pointer to the data being transferred.
+ * @param byRefType the type of the data being transferred such as OLE.VT_BSTR | OLE.VT_BYREF
+ *
+ */
+public Variant(int ptr, short byRefType) {
+ type = byRefType;
+ byRefPtr = ptr;
+}
+/**
+ * Create a Variant object which represents an IDispatch interface as a VT_Dispatch.
+ *
+ * @param automation the OleAutomation object that this Variant represents
+ *
+ */
+public Variant(OleAutomation automation) {
+ type = COM.VT_DISPATCH;
+ dispatchData = automation;
+}
+/**
+ * Create a Variant object which represents an IUnknown interface as a VT_UNKNOWN.
+ *
+ * <p>The caller is expected to have appropriately invoked unknown.AddRef() before creating
+ * this Variant.
+ *
+ * @param unknown the IUnknown object that this Variant represents
+ *
+ */
+public Variant(IUnknown unknown) {
+ type = COM.VT_UNKNOWN;
+ unknownData = unknown;
+}
+/**
+ * Create a Variant object which represents a Java String as a VT_BSTR.
+ *
+ * @param string the Java String value that this Variant represents
+ *
+ */
+public Variant(String string) {
+ type = COM.VT_BSTR;
+ stringData = string;
+}
+/**
+ * Create a Variant object which represents a Java short as a VT_I2.
+ *
+ * @param val the Java short value that this Variant represents
+ *
+ */
+public Variant(short val) {
+ type = COM.VT_I2;
+ shortData = val;
+}
+/**
+ * Create a Variant object which represents a Java boolean as a VT_BOOL.
+ *
+ * @param val the Java boolean value that this Variant represents
+ *
+ */
+public Variant(boolean val) {
+
+ type = COM.VT_BOOL;
+ booleanData = val;
+}
+/**
+ * Returns the OleAutomation object represented by this Variant.
+ *
+ * <p>If this Variant does not contain an OleAutomation object, an attempt is made to
+ * coerce the Variant type into an OleAutomation object. If this fails, an error is
+ * thrown.
+ *
+ * @return the OleAutomation object represented by this Variant
+ *
+ * @exception SWTError
+ * ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into an OleAutomation object
+ */
+public OleAutomation getAutomation() {
+ if (type == COM.VT_DISPATCH)
+ return dispatchData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_DISPATCH);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+ Variant autoVar = new Variant();
+ autoVar.setData(newPtr);
+ return autoVar.getAutomation();
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
+ // OleAutomation object is created as Variant Clear
+ // will result in a Release being performed on the
+ // Dispatch object
+ OS.GlobalFree(newPtr);
+ }
+}
+/**
+ * Returns the Java boolean represented by this Variant.
+ *
+ * <p>If this Variant does not contain a Java boolean, an attempt is made to
+ * coerce the Variant type into a Java boolean. If this fails, an error is thrown.
+ *
+ * @return the Java boolean represented by this Variant
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a boolean</ul>
+ *
+ */
+public boolean getBoolean() {
+ if (type == COM.VT_BOOL)
+ return booleanData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_BOOL);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+ Variant boolVar = new Variant();
+ boolVar.setData(newPtr);
+ return boolVar.getBoolean();
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr);
+ OS.GlobalFree(newPtr);
+ }
+}
+/**
+ * Returns a pointer to the referenced data represented by this Variant.
+ *
+ * <p>If this Variant does not contain a reference to data, zero is returned.
+ *
+ * @return a pointer to the referenced data represented by this Variant or 0
+ *
+ */
+public int getByRef() {
+ if ((type & COM.VT_BYREF)== COM.VT_BYREF)
+ return byRefPtr;
+
+ return 0;
+}
+void getData(int pData){
+ if (pData == 0) OLE.error(OLE.ERROR_OUT_OF_MEMORY);
+
+ COM.VariantInit(pData);
+
+ if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new int[]{byRefPtr}, 4);
+ return;
+ }
+
+ switch (type) {
+ case COM.VT_EMPTY :
+ break;
+ case COM.VT_BOOL :
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new short[]{(short)((booleanData) ? 1 : 0)}, 2);
+ break;
+ case COM.VT_R4 :
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new float[]{floatData}, 4);
+ break;
+ case COM.VT_I4 :
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new int[]{intData}, 4);
+ break;
+ case COM.VT_DISPATCH :
+ IDispatch dispatch = new IDispatch(dispatchData.getAddress());
+ dispatch.AddRef();
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new int[]{dispatch.getAddress()}, 4);
+ break;
+ case COM.VT_UNKNOWN :
+ unknownData.AddRef();
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new int[]{unknownData.getAddress()}, 4);
+ break;
+ case COM.VT_I2 :
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ COM.MoveMemory(pData + 8, new short[]{shortData}, 2);
+ break;
+ case COM.VT_BSTR :
+ COM.MoveMemory(pData, new short[] {type}, 2);
+ char[] data = (stringData+"\0").toCharArray();
+ int ptr = COM.SysAllocString(data);
+ COM.MoveMemory(pData + 8, new int[] {ptr}, 4);
+ break;
+
+ default :
+ OLE.error(SWT.ERROR_NOT_IMPLEMENTED);
+ }
+}
+/**
+ * Returns the Java float represented by this Variant.
+ *
+ * <p>If this Variant does not contain a Java float, an attempt is made to
+ * coerce the Variant type into a Java float. If this fails, an error is thrown.
+ *
+ * @return the Java float represented by this Variant
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a float</ul>
+ */
+public float getFloat() {
+ if (type == COM.VT_R4)
+ return floatData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_R4);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+ Variant floatVar = new Variant();
+ floatVar.setData(newPtr);
+ return floatVar.getFloat();
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr);
+ OS.GlobalFree(newPtr);
+ }
+
+}
+/**
+ * Returns the Java int represented by this Variant.
+ *
+ * <p>If this Variant does not contain a Java int, an attempt is made to
+ * coerce the Variant type into a Java int. If this fails, an error is thrown.
+ *
+ * @return the Java int represented by this Variant
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a int</ul>
+ */
+public int getInt() {
+ if (type == COM.VT_I4)
+ return intData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I4);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+ Variant intVar = new Variant();
+ intVar.setData(newPtr);
+ return intVar.getInt();
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr);
+ OS.GlobalFree(newPtr);
+ }
+}
+/**
+ * Returns the Java short represented by this Variant.
+ *
+ * <p>If this Variant does not contain a Java short, an attempt is made to
+ * coerce the Variant type into a Java short. If this fails, an error is thrown.
+ *
+ * @return the Java short represented by this Variant
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a short</ul>
+ */
+public short getShort() {
+ if (type == COM.VT_I2)
+ return shortData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_I2);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+ Variant shortVar = new Variant();
+ shortVar.setData(newPtr);
+ return shortVar.getShort();
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr);
+ OS.GlobalFree(newPtr);
+ }
+
+}
+/**
+ * Returns the Java String represented by this Variant.
+ *
+ * <p>If this Variant does not contain a Java String, an attempt is made to
+ * coerce the Variant type into a Java String. If this fails, an error is thrown.
+ *
+ * @return the Java String represented by this Variant
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into a String</ul>
+ */
+public String getString() {
+ if (type == COM.VT_BSTR)
+ return stringData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_BSTR);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+
+ Variant stringVar = new Variant();
+ stringVar.setData(newPtr);
+ return stringVar.getString();
+
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr);
+ OS.GlobalFree(newPtr);
+ }
+}
+short getType() {
+ return type;
+}
+/**
+ * Returns the IUnknown object represented by this Variant.
+ *
+ * <p>If this Variant does not contain an IUnknown object, an attempt is made to
+ * coerce the Variant type into an IUnknown object. If this fails, an error is
+ * thrown.
+ *
+ * @return the IUnknown object represented by this Variant
+ *
+ * @exception SWTError
+ * <ul><li>ERROR_CANNOT_CHANGE_VARIANT_TYPE when type of Variant can not be coerced into
+ * an IUnknown object</ul>
+ */
+public IUnknown getUnknown() {
+ if (type == COM.VT_UNKNOWN)
+ return unknownData;
+
+ // try to coerce the value to the desired type
+ int oldPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ int newPtr = OS.GlobalAlloc(COM.GMEM_FIXED | COM.GMEM_ZEROINIT, sizeof);
+ try {
+ getData(oldPtr);
+ int result = COM.VariantChangeType(newPtr, oldPtr, (short) 0, COM.VT_UNKNOWN);
+ if (result != COM.S_OK)
+ OLE.error(OLE.ERROR_CANNOT_CHANGE_VARIANT_TYPE, result);
+ Variant unknownVar = new Variant();
+ unknownVar.setData(newPtr);
+ return unknownVar.getUnknown();
+ } finally {
+ COM.VariantClear(oldPtr);
+ OS.GlobalFree(oldPtr);
+ COM.VariantClear(newPtr); // Note: This must absolutely be done AFTER the
+ // IUnknown object is created as Variant Clear
+ // will result in a Release being performed on the
+ // Dispatch object
+ OS.GlobalFree(newPtr);
+ }
+}
+void setData(int pData){
+ if (pData == 0) OLE.error(OLE.ERROR_INVALID_ARGUMENT);
+
+ short[] dataType = new short[1];
+ COM.MoveMemory(dataType, pData, 2);
+ type = dataType[0];
+
+ if ((type & COM.VT_BYREF) == COM.VT_BYREF) {
+ int[] newByRefPtr = new int[1];
+ OS.MoveMemory(newByRefPtr, pData + 8, 4);
+ byRefPtr = newByRefPtr[0];
+ return;
+ }
+
+ switch (type) {
+ case COM.VT_EMPTY :
+ break;
+ case COM.VT_BOOL :
+ short[] newBooleanData = new short[1];
+ COM.MoveMemory(newBooleanData, pData + 8, 2);
+ booleanData = (newBooleanData[0] != 0);
+ break;
+ case COM.VT_R4 :
+ float[] newFloatData = new float[1];
+ COM.MoveMemory(newFloatData, pData + 8, 4);
+ floatData = newFloatData[0];
+ break;
+ case COM.VT_I4 :
+ int[] newIntData = new int[1];
+ OS.MoveMemory(newIntData, pData + 8, 4);
+ intData = newIntData[0];
+ break;
+ case COM.VT_DISPATCH :
+ int[] newDispatchData = new int[1];
+ OS.MoveMemory(newDispatchData, pData + 8, 4);
+ dispatchData = new OleAutomation(newDispatchData[0]);
+ break;
+ case COM.VT_UNKNOWN :
+ int[] newUnknownData = new int[1];
+ OS.MoveMemory(newUnknownData, pData + 8, 4);
+ unknownData = new IUnknown(newUnknownData[0]);
+ unknownData.AddRef();
+ break;
+ case COM.VT_I2 :
+ short[] newShortData = new short[1];
+ COM.MoveMemory(newShortData, pData + 8, 2);
+ shortData = newShortData[0];
+ break;
+ case COM.VT_BSTR :
+ // get the address of the memory in which the string resides
+ int[] hMem = new int[1];
+ OS.MoveMemory(hMem, pData + 8, 4);
+
+ // Get the size of the string from the OS - the size is expressed in number
+ // of bytes - each unicode character is 2 bytes.
+ int size = COM.SysStringByteLen(hMem[0]);
+ if (size > 0){
+ // get the unicode character array from the global memory and create a String
+ char[] buffer = new char[(size + 1) /2]; // add one to avoid rounding errors
+ COM.MoveMemory(buffer, hMem[0], size);
+ stringData = new String(buffer);
+ }
+ break;
+
+ default :
+ // try coercing it into one of the known forms
+ int newPData = OS.GlobalAlloc(OS.GMEM_FIXED | OS.GMEM_ZEROINIT, Variant.sizeof);
+ if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_R4) == COM.S_OK) {
+ setData(newPData);
+ } else if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_I4) == COM.S_OK) {
+ setData(newPData);
+ } else if (COM.VariantChangeType(newPData, pData, (short) 0, COM.VT_BSTR) == COM.S_OK) {
+ setData(newPData);
+ }
+ COM.VariantClear(newPData);
+ OS.GlobalFree(newPData);
+ break;
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT OLE Win32/win32/org/eclipse/swt/ole/win32/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java
new file mode 100755
index 0000000000..95c9419789
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/PrinterData.java
@@ -0,0 +1,158 @@
+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
+ */
+
+public final class PrinterData extends DeviceData {
+
+ /**
+ * the printer driver
+ * On Windows systems, this is the name of the driver (often "winspool").
+ * On X/Window systems, this is the name of a display connection to the
+ * Xprt server (the default is ":1").
+ */
+ public String driver;
+
+ /**
+ * the name of the printer
+ * On Windows systems, this is the name of the 'device'.
+ * On X/Window systems, 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
+ */
+ public int startPage = 0;
+
+ /**
+ * the end page of a page range, used when scope is PAGE_RANGE
+ */
+ 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>.
+ * 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.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ */
+ public PrinterData() {
+ PrinterData data = Printer.getDefaultPrinterData();
+ this.driver = data.driver;
+ this.name = data.name;
+ }
+
+ /**
+ * 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
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @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 + "}";
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html b/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html
new file mode 100755
index 0000000000..52216655f0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/common/org/eclipse/swt/printing/package.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/PrintDialog.java
new file mode 100755
index 0000000000..0defeee996
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/PrintDialog.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.printing;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.motif.*;
+
+public class PrintDialog extends Dialog {
+ int scope = PrinterData.ALL_PAGES;
+ int startPage = -1, endPage = -1;
+ boolean printToFile = false;
+
+public PrintDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+public PrintDialog (Shell parent, int style) {
+ super (parent, style);
+}
+public PrinterData open() {
+ /* Return the first printer in the list */
+ PrinterData[] printers = Printer.getPrinterList();
+ if (printers.length > 0) return printers[0];
+ return null;
+}
+public int getScope() {
+ return scope;
+}
+public void setScope(int scope) {
+ this.scope = scope;
+}
+public int getStartPage() {
+ return startPage;
+}
+public void setStartPage(int startPage) {
+ this.startPage = startPage;
+}
+public int getEndPage() {
+ return endPage;
+}
+public void setEndPage(int endPage) {
+ this.endPage = endPage;
+}
+public boolean getPrintToFile() {
+ return printToFile;
+}
+public void setPrintToFile(boolean printToFile) {
+ this.printToFile = printToFile;
+}
+protected void checkSubclass() {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
new file mode 100755
index 0000000000..d5b306051a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/motif/org/eclipse/swt/printing/Printer.java
@@ -0,0 +1,261 @@
+package org.eclipse.swt.printing;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+public final class Printer extends Device {
+ PrinterData data;
+ int printContext, xScreen, xDrawable;
+ int defaultFontList;
+
+public static PrinterData[] getPrinterList() {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ /* Connect to the default X print server */
+ //byte [] buffer = Converter.wcsToMbcs(null, XDefaultPrintServer, true);
+ //int pdpy = OS.XOpenDisplay(buffer);
+ int pdpy = xPrinter;
+ if (pdpy == 0) {
+ /* no print server */
+ SWT.error(SWT.ERROR_IO);
+ }
+
+ /* Get the list of printers */
+ int [] listCount = new int[1];
+ int plist = OS.XpGetPrinterList(pdpy, null, listCount);
+ int printerCount = listCount[0];
+ if (plist == 0 || printerCount == 0) {
+ /* no printers */
+ //OS.XCloseDisplay(pdpy);
+ SWT.error(SWT.ERROR_IO);
+ }
+
+ /* Copy the printer names into PrinterData objects */
+ int [] stringPointers = new int [printerCount * 2];
+ OS.memmove(stringPointers, plist, printerCount * 2 * 4);
+ PrinterData printerList[] = new PrinterData[printerCount];
+ for (int i = 0; i < printerCount; i++) {
+ String name = "";
+ int address = stringPointers[i * 2];
+ if (address != 0) {
+ int length = OS.strlen(address);
+ byte[] buffer = new byte [length];
+ OS.memmove(buffer, address, length);
+ name = new String(Converter.mbcsToWcs(null, buffer));
+ }
+ printerList[i] = new PrinterData(Device.XDefaultPrintServer, name);
+ }
+ OS.XpFreePrinterList(plist);
+ //OS.XCloseDisplay(pdpy);
+ return printerList;
+}
+
+static PrinterData getDefaultPrinterData() {
+ /* Use the first printer in the list as the default */
+ PrinterData[] list = getPrinterList();
+ if (list.length == 0) {
+ /* no printers */
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ return list[0];
+}
+
+public Printer() {
+ this(getDefaultPrinterData());
+}
+
+public Printer(PrinterData data) {
+ super(data);
+}
+
+protected void create(DeviceData deviceData) {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ data = (PrinterData)deviceData;
+
+ /* Open the display for the X print server */
+ //byte[] displayName = Converter.wcsToMbcs(null, data.driver, true);
+ //xDisplay = OS.XOpenDisplay(displayName);
+ xDisplay = xPrinter;
+ if (xDisplay == 0) {
+ /* no print server */
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+}
+
+protected void init() {
+ super.init();
+
+ /* Create the printContext for the printer */
+ byte[] name = Converter.wcsToMbcs(null, data.name, true);
+ printContext = OS.XpCreateContext(xDisplay, name);
+ if (printContext == OS.None) {
+ /* can't create print context */
+ //OS.XCloseDisplay(xDisplay);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+
+ /* Set the printContext into the display */
+ OS.XpSetContext(xDisplay, printContext);
+
+ /* Get the printer's screen */
+ xScreen = OS.XpGetScreenOfContext(xDisplay, printContext);
+
+ /* Initialize Motif */
+ int widgetClass = OS.TopLevelShellWidgetClass();
+ int shellHandle = OS.XtAppCreateShell(null, null, widgetClass, xDisplay, null, 0);
+ OS.XtDestroyWidget(shellHandle);
+
+ /* Initialize the default font */
+ byte [] buffer = Converter.wcsToMbcs(null, "-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*", true);
+ int fontListEntry = OS.XmFontListEntryLoad(xDisplay, buffer, 0, OS.XmFONTLIST_DEFAULT_TAG);
+ if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ defaultFontList = OS.XmFontListAppendEntry(0, fontListEntry);
+ OS.XmFontListEntryFree(new int[]{fontListEntry});
+}
+
+protected void destroy() {
+ //if (xDisplay != 0) OS.XCloseDisplay(xDisplay);
+}
+
+public int internal_new_GC(GCData data) {
+ if (xDrawable == 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int xGC = OS.XCreateGC(xDisplay, xDrawable, 0, null);
+ if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ data.device = this;
+ data.display = xDisplay;
+ data.drawable = xDrawable; // not valid until after startJob
+ data.fontList = defaultFontList;
+ data.colormap = OS.XDefaultColormapOfScreen(xScreen);
+ }
+ return xGC;
+}
+
+public void internal_dispose_GC(int xGC, GCData data) {
+ OS.XFreeGC(xDisplay, xGC);
+}
+
+public boolean startJob(String jobName) {
+ checkDevice();
+ byte [] buffer = Converter.wcsToMbcs(null, "*job-name: " + jobName, true);
+ OS.XpSetAttributes(xDisplay, printContext, OS.XPJobAttr, buffer, OS.XPAttrMerge);
+ OS.XpStartJob(xDisplay, OS.XPSpool);
+
+ /* Create the xDrawable */
+ XRectangle rect = new XRectangle();
+ short [] width = new short [1];
+ short [] height = new short [1];
+ OS.XpGetPageDimensions(xDisplay, printContext, width, height, rect);
+ xDrawable = OS.XCreateWindow(xDisplay, OS.XRootWindowOfScreen(xScreen),
+ 0, 0, rect.width, rect.height, 0,
+ OS.CopyFromParent, OS.CopyFromParent, OS.CopyFromParent, 0, 0);
+ return true;
+}
+
+public void endJob() {
+ checkDevice();
+ OS.XpEndJob(xDisplay);
+ OS.XFlush(xDisplay);
+}
+
+public void cancelJob() {
+ checkDevice();
+ OS.XpCancelJob(xDisplay, true);
+}
+
+public boolean startPage() {
+ checkDevice();
+ OS.XpStartPage(xDisplay, xDrawable);
+ return true;
+}
+
+public void endPage() {
+ checkDevice();
+ OS.XpEndPage(xDisplay);
+}
+
+public Point getDPI() {
+ checkDevice();
+ byte [] buffer = Converter.wcsToMbcs(null, "default-printer-resolution", true);
+ int pool = OS.XpGetOneAttribute(xDisplay, printContext, OS.XPDocAttr, buffer);
+ int length = OS.strlen(pool);
+ buffer = new byte[length];
+ OS.memmove(buffer, pool, length);
+ OS.XtFree(pool);
+ String resolution = new String(buffer, 0, buffer.length);
+ int res = 300; // default
+ if (resolution.length() == 0) {
+ /* If we can't get the info from the DocAttrs, ask the printer. */
+ buffer = Converter.wcsToMbcs(null, "printer-resolutions-supported", true);
+ pool = OS.XpGetOneAttribute(xDisplay, printContext, OS.XPPrinterAttr, buffer);
+ length = OS.strlen(pool);
+ buffer = new byte[length];
+ OS.memmove(buffer, pool, length);
+ OS.XtFree(pool);
+ int n = 0;
+ while (!Character.isWhitespace((char)buffer[n]) && n < buffer.length) n++;
+ resolution = new String(buffer, 0, n);
+ }
+ if (resolution.length() != 0) {
+ try {
+ res = Integer.parseInt(resolution);
+ } catch (NumberFormatException ex) {}
+ }
+ return new Point(res, res);
+}
+
+public Rectangle getBounds() {
+ checkDevice();
+ XRectangle rect = new XRectangle();
+ short [] width = new short [1];
+ short [] height = new short [1];
+ OS.XpGetPageDimensions(xDisplay, printContext, width, height, rect);
+ return new Rectangle(0, 0, width[0], height[0]);
+}
+
+public Rectangle getClientArea() {
+ checkDevice();
+ XRectangle rect = new XRectangle();
+ OS.XpGetPageDimensions(xDisplay, printContext, new short [1], new short [1], rect);
+ return new Rectangle(0, 0, rect.width, rect.height);
+}
+
+public Rectangle computeTrim(int x, int y, int width, int height) {
+ checkDevice();
+ XRectangle rect = new XRectangle();
+ short [] paperWidth = new short [1];
+ short [] paperHeight = new short [1];
+ OS.XpGetPageDimensions(xDisplay, printContext, paperWidth, paperHeight, rect);
+ int hTrim = paperWidth[0] - rect.width;
+ int vTrim = paperHeight[0] - rect.height;
+ return new Rectangle(x - rect.x, y - rect.y, width + hTrim, height + vTrim);
+}
+
+public PrinterData getPrinterData() {
+ return data;
+}
+
+protected void checkDevice() {
+ if (xDisplay == 0) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+}
+
+protected void release() {
+ super.release();
+ if (defaultFontList != 0) {
+ OS.XmFontListFree(defaultFontList);
+ defaultFontList = 0;
+ }
+ if (printContext != 0) {
+ OS.XpDestroyContext(xDisplay, printContext);
+ printContext = 0;
+ }
+ if (xDrawable != 0) {
+ OS.XDestroyWindow(xDisplay, xDrawable);
+ xDrawable = 0;
+ }
+ xScreen = 0;
+ data = null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
new file mode 100755
index 0000000000..b85b43d811
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/PrintDialog.java
@@ -0,0 +1,254 @@
+package org.eclipse.swt.printing;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * 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>
+ */
+
+public class PrintDialog extends Dialog {
+ int scope = PrinterData.ALL_PAGES;
+ int startPage = -1, endPage = -1;
+ boolean printToFile = false;
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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, style);
+}
+
+/**
+ * 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>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>
+ *
+ * @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>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>
+ *
+ * @param int 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>
+ * Note that this value is only valid if the scope is <code>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.
+ *
+ * @param int 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>
+ * Note that this value is only valid if the scope is <code>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.
+ *
+ * @param int 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 boolean the 'Print to file' setting when the dialog is opened
+ */
+public void setPrintToFile(boolean printToFile) {
+ this.printToFile = printToFile;
+}
+
+protected void checkSubclass() {
+}
+
+/**
+ * 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() {
+ PRINTDLG pd = new PRINTDLG();
+ pd.lStructSize = PRINTDLG.sizeof;
+ pd.Flags = OS.PD_USEDEVMODECOPIESANDCOLLATE;
+ if (printToFile) pd.Flags |= OS.PD_PRINTTOFILE;
+ switch (scope) {
+ case PrinterData.PAGE_RANGE: pd.Flags |= OS.PD_PAGENUMS; break;
+ case PrinterData.SELECTION: pd.Flags |= OS.PD_SELECTION; break;
+ default: pd.Flags |= OS.PD_ALLPAGES;
+ }
+ pd.nMinPage = 1;
+ pd.nMaxPage = -1;
+ pd.nFromPage = (short) startPage;
+ pd.nToPage = (short) endPage;
+ if (OS.PrintDlg(pd)) {
+ /* Get driver and device from the DEVNAMES struct */
+ int ptr = OS.GlobalLock(pd.hDevNames);
+ int size = OS.GlobalSize(ptr);
+ byte [] DEVNAMES = new byte[size];
+ OS.MoveMemory(DEVNAMES, ptr, size);
+ OS.GlobalUnlock(ptr);
+ int driverOffset = (DEVNAMES[0] & 0xFF) | ((DEVNAMES[1] & 0xFF) << 8);
+ int i = 0;
+ while (driverOffset + i < size) {
+ if (DEVNAMES[driverOffset + i] == 0) break;
+ else i++;
+ }
+ String driver = new String(DEVNAMES, driverOffset, i);
+ int deviceOffset = (DEVNAMES[2] & 0xFF) | ((DEVNAMES[3] & 0xFF) << 8);
+ i = 0;
+ while (deviceOffset + i < size) {
+ if (DEVNAMES[deviceOffset + i] == 0) break;
+ else i++;
+ }
+ String device = new String(DEVNAMES, deviceOffset, i);
+
+ /* Create PrinterData object and set fields from PRINTDLG */
+ PrinterData data = new PrinterData(driver, device);
+ if ((pd.Flags & OS.PD_PAGENUMS) != 0) {
+ data.scope = PrinterData.PAGE_RANGE;
+ data.startPage = pd.nFromPage;
+ data.endPage = pd.nToPage;
+ } else if ((pd.Flags & OS.PD_SELECTION) != 0) {
+ data.scope = PrinterData.SELECTION;
+ }
+ data.printToFile = (pd.Flags & OS.PD_PRINTTOFILE) != 0;
+ data.copyCount = pd.nCopies;
+ data.collate = (pd.Flags & OS.PD_COLLATE) != 0;
+
+ /* Bulk-save the printer-specific settings in the DEVMODE struct */
+ ptr = OS.GlobalLock(pd.hDevMode);
+ size = OS.GlobalSize(ptr);
+ data.otherData = new byte[size];
+ OS.MoveMemory(data.otherData, ptr, size);
+ OS.GlobalUnlock(ptr);
+
+ return data;
+ }
+ return null;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
new file mode 100755
index 0000000000..0d6f3eadc7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Printing/win32/org/eclipse/swt/printing/Printer.java
@@ -0,0 +1,499 @@
+package org.eclipse.swt.printing;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * 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
+ */
+public final class Printer extends Device {
+ /**
+ * the handle to the printer DC
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the printer data describing this printer
+ */
+ PrinterData data;
+
+ /**
+ * whether or not a GC was created for this printer
+ */
+ boolean isGCCreated = false;
+
+ /**
+ * strings used to access the Windows registry
+ * (Warning: These fields are platform dependent)
+ */
+ static byte[] profile;
+ static byte[] appName;
+ static byte[] keyName;
+ static {
+ profile = Converter.wcsToMbcs(0, "PrinterPorts", true);
+ appName = Converter.wcsToMbcs(0, "windows", true);
+ keyName = Converter.wcsToMbcs(0, "device", true);
+ }
+
+/**
+ * Returns an array of <code>PrinterData</code> objects
+ * representing all available printers.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @return the list of available printers
+ */
+public static PrinterData[] getPrinterList() {
+ byte[] buf = new byte[1024];
+ int n = OS.GetProfileString(profile, null, new byte[] {0}, buf, buf.length);
+ if (n == 0) SWT.error(SWT.ERROR_UNSPECIFIED);
+ byte[][] deviceNames = new byte[5][];
+ int nameCount = 0;
+ int index = 0;
+ for (int i = 0; i < n; i++) {
+ if (buf[i] == 0) {
+ if (nameCount == deviceNames.length) {
+ byte[][] newNames = new byte[deviceNames.length + 5][];
+ System.arraycopy(deviceNames, 0, newNames, 0, deviceNames.length);
+ deviceNames = newNames;
+ }
+ deviceNames[nameCount] = new byte[i - index + 1];
+ System.arraycopy(buf, index, deviceNames[nameCount], 0, i - index);
+ nameCount++;
+ index = i + 1;
+ }
+ }
+ PrinterData printerList[] = new PrinterData[nameCount];
+ for (int p = 0; p < nameCount; p++) {
+ String device = new String(deviceNames[p], 0, deviceNames[p].length - 1);
+ String driver = "";
+ if (OS.GetProfileString(profile, deviceNames[p], new byte [] {0}, buf, buf.length) > 0) {
+ int commaIndex = 0;
+ while (buf[commaIndex] != ',' && commaIndex < buf.length) commaIndex++;
+ if (commaIndex < buf.length) {
+ byte[] driverName = new byte[commaIndex + 1];
+ System.arraycopy(buf, 0, driverName, 0, commaIndex);
+ driver = new String(driverName, 0, driverName.length - 1);
+ }
+ }
+ printerList[p] = new PrinterData(driver, device);
+ }
+ return printerList;
+}
+
+/**
+ * Returns a <code>PrinterData</code> object representing
+ * the default printer.
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @return the default printer
+ */
+static PrinterData getDefaultPrinterData() {
+ byte [] deviceName = null;
+ byte[] buf = new byte[1024];
+ int n = OS.GetProfileString(appName, keyName, new byte[] {0}, buf, buf.length);
+ if (n == 0) SWT.error(SWT.ERROR_UNSPECIFIED);
+ int commaIndex = 0;
+ while(buf[commaIndex] != ',' && commaIndex < buf.length) commaIndex++;
+ if (commaIndex < buf.length) {
+ deviceName = new byte[commaIndex + 1];
+ System.arraycopy(buf, 0, deviceName, 0, commaIndex);
+ }
+ String device = new String(deviceName, 0, deviceName.length - 1);
+ String driver = "";
+ if (OS.GetProfileString(profile, deviceName, new byte [] {0}, buf, buf.length) > 0) {
+ commaIndex = 0;
+ while (buf[commaIndex] != ',' && commaIndex < buf.length) commaIndex++;
+ if (commaIndex < buf.length) {
+ byte[] driverName = new byte[commaIndex + 1];
+ System.arraycopy(buf, 0, driverName, 0, commaIndex);
+ driver = new String(driverName, 0, driverName.length - 1);
+ }
+ }
+ return new PrinterData(driver, device);
+}
+
+/**
+ * Constructs a new printer representing the default printer.
+ * <p>
+ * You must dispose the printer when it is no longer required.
+ * </p>
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Printer() {
+ this(getDefaultPrinterData());
+}
+
+/**
+ * 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
+ * <li>ERROR_UNSPECIFIED - if there are no valid printers
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Printer(PrinterData data) {
+ super(data);
+}
+
+/**
+ * Creates the printer handle.
+ * This method is called internally by the instance creation
+ * mechanism of the <code>Device</code> class.
+ */
+protected void create(DeviceData deviceData) {
+ data = (PrinterData)deviceData;
+ byte[] driver = Converter.wcsToMbcs(0, data.driver, true);
+ byte[] device = Converter.wcsToMbcs(0, data.name, true);
+ int lpInitData = 0;
+ byte buffer [] = data.otherData;
+ int hHeap = OS.GetProcessHeap();
+ if (buffer != null && buffer.length != 0) {
+ lpInitData = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory(lpInitData, buffer, buffer.length);
+ }
+ handle = OS.CreateDC(driver, device, 0, lpInitData);
+ if (lpInitData != 0) OS.HeapFree(hHeap, 0, lpInitData);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+/**
+ * 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
+ *
+ * @private
+ */
+public int internal_new_GC(GCData data) {
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ if (isGCCreated) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.device = this;
+ data.hFont = OS.GetCurrentObject(handle, OS.OBJ_FONT);
+ isGCCreated = true;
+ }
+ return handle;
+}
+
+/**
+ * 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 handle the platform specific GC handle
+ * @param data the platform specific GC data
+ *
+ * @private
+ */
+public void internal_dispose_GC(int hDC, GCData data) {
+ if (data != null) isGCCreated = false;
+}
+
+/**
+ * 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>
+ *
+ * @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();
+ DOCINFO di = new DOCINFO();
+ di.cbSize = DOCINFO.sizeof;
+ int hHeap = OS.GetProcessHeap();
+ int lpszDocName = 0;
+ if (jobName != null && jobName.length() != 0) {
+ byte [] buffer = Converter.wcsToMbcs(0, jobName, true);
+ lpszDocName = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory(lpszDocName, buffer, buffer.length);
+ di.lpszDocName = lpszDocName;
+ }
+ int lpszOutput = 0;
+ if (data.printToFile && data.fileName != null) {
+ byte [] buffer = Converter.wcsToMbcs(0, data.fileName, true);
+ lpszOutput = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory(lpszOutput, buffer, buffer.length);
+ di.lpszOutput = lpszOutput;
+ }
+ int rc = OS.StartDoc(handle, di);
+ if (lpszDocName != 0) OS.HeapFree(hHeap, 0, lpszDocName);
+ if (lpszOutput != 0) OS.HeapFree(hHeap, 0, lpszOutput);
+ return rc > 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();
+ OS.EndDoc(handle);
+}
+
+/**
+ * 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();
+ OS.AbortDoc(handle);
+}
+
+/**
+ * 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();
+ int rc = OS.StartPage(handle);
+ if (rc <= 0) OS.AbortDoc(handle);
+ return rc > 0;
+}
+
+/**
+ * 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();
+ OS.EndPage(handle);
+}
+
+/**
+ * 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 dpiX = OS.GetDeviceCaps(handle, OS.LOGPIXELSX);
+ int dpiY = OS.GetDeviceCaps(handle, OS.LOGPIXELSY);
+ return new Point(dpiX, dpiY);
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ * For a printer, this is the size of a page, in pixels.
+ *
+ * @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();
+ int width = OS.GetDeviceCaps(handle, OS.PHYSICALWIDTH);
+ int height = OS.GetDeviceCaps(handle, OS.PHYSICALHEIGHT);
+ return new Rectangle(0, 0, width, height);
+}
+
+/**
+ * Returns a rectangle which describes the area of the
+ * receiver which is capable of displaying data.
+ * For a printer, this is the size of the printable area
+ * of a page, in pixels.
+ *
+ * @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();
+ int width = OS.GetDeviceCaps(handle, OS.HORZRES);
+ int height = OS.GetDeviceCaps(handle, OS.VERTRES);
+ return new Rectangle(0, 0, width, height);
+}
+
+/**
+ * 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>
+ * Note that there is no setBounds for a printer. This method
+ * is usually used by passing in the client area (the 'printable
+ * area') of the printer. It can also be useful to pass in 0, 0, 0, 0.
+ *
+ * @return the required bounds to produce the given client area
+ *
+ * @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();
+ int printX = -OS.GetDeviceCaps(handle, OS.PHYSICALOFFSETX);
+ int printY = -OS.GetDeviceCaps(handle, OS.PHYSICALOFFSETY);
+ int printWidth = OS.GetDeviceCaps(handle, OS.HORZRES);
+ int printHeight = OS.GetDeviceCaps(handle, OS.VERTRES);
+ int paperWidth = OS.GetDeviceCaps(handle, OS.PHYSICALWIDTH);
+ int paperHeight = OS.GetDeviceCaps(handle, OS.PHYSICALHEIGHT);
+ int hTrim = paperWidth - printWidth;
+ int vTrim = paperHeight - printHeight;
+ return new Rectangle(x + printX, y + printY, width + hTrim, height + vTrim);
+}
+
+/**
+ * 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
+ */
+public PrinterData getPrinterData() {
+ return data;
+}
+
+/**
+ * Checks the validity of this device.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+protected void checkDevice() {
+ if (handle == 0) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+}
+
+/**
+ * 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();
+ data = null;
+}
+
+/**
+ * Destroys the printer handle.
+ * This method is called internally by the dispose
+ * mechanism of the <code>Device</code> class.
+ */
+protected void destroy() {
+ if (handle != 0) OS.DeleteDC(handle);
+ handle = 0;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html b/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/common/org/eclipse/swt/program/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
new file mode 100755
index 0000000000..6c3ac83605
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/motif/org/eclipse/swt/program/Program.java
@@ -0,0 +1,698 @@
+package org.eclipse.swt.program;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+import org.eclipse.swt.widgets.Display;
+
+import java.io.*;
+import java.util.Iterator;
+import java.util.Hashtable;
+import java.util.Vector;
+
+/**
+ * Instances of this class represent programs and
+ * their assoicated file extensions in the operating
+ * system.
+ */
+public final class Program {
+ String name;
+ String extension;
+ String command;
+
+ static final int DESKTOP_UNKNOWN = 0;
+ static final int DESKTOP_KDE = 1;
+ static final int DESKTOP_GNOME = 2;
+ static final int Desktop = getDesktop ();
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Program () {
+}
+
+static int getDesktop () {
+ File root = new File ("/proc");
+ if (!root.exists () || !root.isDirectory ()) return DESKTOP_UNKNOWN;
+ File [] procDirs = root.listFiles ();
+ for (int i=0; i<procDirs.length; i++) {
+ String directory = procDirs [i].getAbsolutePath ();
+ File file = new File (directory + "/stat");
+ if (file.exists ()) {
+ String procName = getProcName (file);
+ if (procName.indexOf ("gnome") >= 0) {
+ return gnome_init() ? DESKTOP_GNOME : DESKTOP_UNKNOWN;
+ }
+ if (procName.indexOf ("kdeinit") >= 0) {
+ return kde_init () ? DESKTOP_KDE : DESKTOP_UNKNOWN;
+ }
+ }
+ }
+ return DESKTOP_UNKNOWN;
+}
+
+static String getProcName (File file) {
+ try {
+ FileInputStream stream = new FileInputStream (file);
+ while (true) {
+ char ch = (char) stream.read ();
+ if (ch < 0 || ch == 0xFF) return null;
+ if (ch == '(') break;
+ }
+ String name = "";
+ while (true) {
+ char ch = (char) stream.read ();
+ if (ch < 0 || ch == 0xFF) return null;
+ if (ch == ')') break;
+ name += ch;
+ }
+ stream.close ();
+ return name;
+ } catch (IOException e) {
+ return null;
+ }
+}
+/*
+ * Finds the program that is associated with an extension.
+ * The extension may or may not begin with a '.'.
+ *
+ * @param extension the program extension
+ * @return the program or nil
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when extension is null</li>
+ * </ul>
+ */
+public static Program findProgram (String extension) {
+ if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (extension.length () == 0) return null;
+ if (extension.charAt (0) != '.') extension = "." + extension;
+ String command = null;
+ String name = "";
+ switch (Desktop) {
+ case DESKTOP_KDE: {
+ String urlString = "file://any." + extension;
+ byte [] buffer = Converter.wcsToMbcs (null, urlString, true);
+ int qString = KDE.QString_new (buffer);
+ int url = KDE.KURL_new (qString);
+ KDE.QString_delete (qString);
+ int mimeType = KDE.KMimeType_findByURL (url);
+ int mimeName = KDE.KMimeType_name (mimeType);
+ int service = KDE.KServiceTypeProfile_preferredService (mimeName, 1);
+ if (service == 0) return null;
+ int execQString = KDE.KService_exec (service);
+ command = kde_convertQStringAndFree (execQString);
+ break;
+ }
+
+ case DESKTOP_GNOME: {
+ String fileName = "file" + extension;
+ String mimeType = gnome_getMimeType (fileName);
+ if (mimeType == null) return null;
+ command = gnome_getMimeValue (mimeType, "open");
+ if (command == null) return null;
+ name = mimeType;
+ break;
+ }
+
+ case DESKTOP_UNKNOWN:
+ return null;
+ }
+ Program program = new Program ();
+ program.name = name;
+ program.command = command;
+ program.extension = extension;
+ return program;
+}
+
+/*
+ * Answer all program extensions in the operating system.
+ *
+ * @return an array of extensions
+ */
+public static String [] getExtensions () {
+ switch (Desktop) {
+ case DESKTOP_KDE:
+ Vector names = new Vector ();
+ int serviceList = KDE.KService_allServices ();
+ int listBeginning = KDE.KServiceList_begin (serviceList);
+ int listEnd = KDE.KServiceList_end (serviceList);
+ int iterator = KDE.KServiceListIterator_new (listBeginning);
+ while (true) {
+ if (KDE.KServiceListIterator_equals (iterator, listEnd) != 0) break;
+ int kService = KDE.KServiceListIterator_dereference (iterator);
+ int serviceType = KDE.KService_type (kService);
+ byte [] applicationType = Converter.wcsToMbcs (null, "Application", true);
+ int appString = KDE.QString_new (applicationType);
+ if (KDE.QString_equals (serviceType, appString) != 0) {
+ int appName = KDE.KService_name (kService);
+ names.addElement (kde_convertQStringAndFree (appName));
+ }
+ KDE.QString_delete (appString);
+ KDE.KServiceListIterator_increment (iterator);
+ }
+ KDE.KServiceListIterator_delete (iterator);
+ KDE.KServiceList_delete (serviceList);
+ String[] appNames = new String [names.size ()];
+ for (int i=0; i <names.size (); i++) {
+ appNames [i] = (String) names.elementAt (i);
+ }
+ return appNames;
+
+ case DESKTOP_GNOME:
+ // Obtain the mime type/extension information.
+ Hashtable mimeInfo = gnome_getMimeInfo();
+ int index;
+
+ // Create a sorted set of the file extensions.
+ Vector extensions = new Vector();
+ Iterator keys = mimeInfo.keySet().iterator();
+ while (keys.hasNext()) {
+ String mimeType = (String) keys.next();
+ Vector mimeExts = (Vector) mimeInfo.get( mimeType );
+ for (index = 0; index < mimeExts.size(); index++){
+ if (!extensions.contains( mimeExts.elementAt( index ) )) {
+ extensions.add( mimeExts.elementAt( index ) );
+ }
+ }
+ }
+
+ // Return the list of extensions.
+ String[] extStrings = new String[ extensions.size() ];
+ for (index = 0; index < extensions.size(); index++) {
+ extStrings[ index ] = (String) extensions.elementAt( index );
+ }
+
+ return extStrings;
+ }
+ return new String[0];
+}
+
+/*
+ * Answers all available programs in the operating system.
+ *
+ * @return an array of programs
+ */
+public static Program [] getPrograms () {
+ switch (Desktop) {
+ case DESKTOP_KDE:
+ return new Program[0]; // TBD
+
+ case DESKTOP_GNOME:
+ // Obtain the mime type/extension information.
+ Hashtable mimeInfo = gnome_getMimeInfo();
+ Vector programs = new Vector();
+
+ // Create a list of programs with commands.
+ Iterator keys = mimeInfo.keySet().iterator();
+ while (keys.hasNext()) {
+ String mimeType = (String) keys.next();
+ String extension = "";
+ Vector mimeExts = (Vector) mimeInfo.get( mimeType );
+ if (mimeExts.size() > 0){
+ extension = (String) mimeExts.elementAt( 0 );
+ }
+ String command = gnome_getMimeValue( mimeType, "open" );
+ if (command != null) {
+ Program program = new Program ();
+ program.name = mimeType;
+ program.command = command;
+ program.extension = extension;
+ programs.add( program );
+ }
+ }
+
+ // Return the list of programs to the user.
+ Program[] programList = new Program[ programs.size() ];
+ for (int index = 0; index < programList.length; index++) {
+ programList[ index ] = (Program) programs.elementAt( index );
+ }
+ return programList;
+ }
+ return new Program[0];
+}
+
+/*
+ * 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.
+ */
+
+private static Hashtable gnome_getMimeInfo() {
+ Hashtable mimeInfo = new Hashtable();
+
+ // Extract the mime info from the system directory.
+ String mimeDirectory = gnome_getDataDirectory ("mime-info");
+ gnome_getMimeInfoFromDirectory( mimeInfo, new File( mimeDirectory ) );
+
+ // Append the mime info from the user's directory (if it exists).
+ String userDirectory = gnome_getHomeDirectory();
+ if (userDirectory != null) {
+ userDirectory = userDirectory + File.separator + ".gnome" + File.separator + "mime-info";
+ gnome_getMimeInfoFromDirectory( mimeInfo, new File( userDirectory ) );
+ }
+
+ return mimeInfo;
+}
+
+// Given a map and a directory, find all of the
+// mime information files (*.mime) and parse them for
+// relavent mime type information. Each entry in the
+// map corresponds to one mime type, and its
+// associated file extensions.
+
+private static void gnome_getMimeInfoFromDirectory( Hashtable info, File directory ) {
+ // For each entry in the given directory (if it exists)
+ if (directory.exists()) {
+ File[] files = directory.listFiles();
+ for (int i = 0; i < files.length; i++) {
+
+ // If the entry is a subdirectory, process it and
+ // merge the mime type into the given map.
+ if (files[i].isDirectory()) {
+ gnome_getMimeInfoFromDirectory( info, files[i] );
+ }
+
+ // else if the entry is a mime info file (*.mime)
+ else if (files[i].getName().endsWith(".mime")) {
+ try {
+ // Parse the mime file and merge the info
+ // into the given map.
+ FileReader in = new FileReader( files[i] );
+ BufferedReader reader = new BufferedReader( in );
+ gnome_parseMimeFile( info, reader );
+ reader.close();
+ in.close();
+ }
+ catch (IOException e) {
+ // Ignore file exceptions silently. If we
+ // can't read it, the info is not available.
+ }
+ }
+ }
+ }
+}
+
+private static void gnome_parseMimeFile( Hashtable info, BufferedReader reader ) {
+ Vector mimeExts = null;
+ String mimeType = null;
+ boolean saveType = false;
+ String line = "#";
+ while (line != null) {
+
+ // Determine if the line contains a mime type name.
+ boolean newType = (line.length() > 0 && Character.isLetter( line.charAt(0) ));
+
+ // If there is valid data on this line to be processed
+ String data = line.trim();
+ if (data.length() > 0 && data.charAt(0) != '#') {
+
+ // If this line defines a new mime type
+ if (newType) {
+
+ // If a previous mime type has not be saved yet
+ if (mimeType != null) {
+ // Save the type and process this line again.
+ saveType = true;
+ }
+ // else initialize the mime type info
+ else {
+ int colon = data.indexOf( ':' );
+ if (colon != -1) {
+ mimeType = data.substring( 0, colon );
+ }
+ else {
+ mimeType = data;
+ }
+ mimeExts = new Vector();
+ }
+ }
+
+ // else if the line defines a list of extensions
+ else if (data.indexOf( "ext" ) == 0 && mimeType != null) {
+
+ // Get the extensions defined on the line
+ String exts = "";
+ int colon = data.indexOf( ':' );
+ if ((colon != -1) && ((colon+1) < data.length())) {
+ exts = data.substring( (colon+1) ).trim();
+ }
+
+ // While there are extensions to be processed
+ exts = exts.replace( '\t', ' ' );
+ while (exts.length() != 0) {
+ // Extract the next entension from the list
+ String newExt;
+ int space = exts.indexOf( ' ' );
+ if (space != -1) {
+ newExt = exts.substring( 0, space );
+ exts = exts.substring( space ).trim();
+ }
+ else {
+ newExt = exts;
+ exts = "";
+ }
+
+ // Prefix an extension with a period.
+ if (newExt.charAt(0) != '.') {
+ newExt = "." + newExt;
+ }
+ mimeExts.add( newExt );
+ }
+ }
+
+ // else if the line defines a list of regular expressions
+ else if (data.indexOf( "regex" ) == 0 && mimeType != null) {
+ // Do nothing with these right now.
+ }
+ }
+
+
+ // If the current mime type is still being processed
+ if (!saveType) {
+ // Get the next line
+ try {
+ line = reader.readLine();
+ }
+ catch (IOException e) {
+ line = null;
+ }
+ }
+
+ // If the current type should be saved or if the end
+ // of the file was reached
+ if (saveType || (line == null)) {
+
+ // If there is a mime type to be saved
+ if (mimeType != null) {
+
+ // If the mime type does not exist in the map, add it.
+ Vector prevExts = (Vector) info.get( mimeType );
+ if (prevExts == null) {
+ info.put( mimeType, mimeExts );
+ }
+
+ // else append the new list of extensions.
+ else {
+ for (int i = 0; i < mimeExts.size(); i++) {
+ prevExts.add( mimeExts.elementAt( i ) );
+ }
+ }
+ mimeType = null;
+ mimeExts = null;
+ saveType = false;
+ }
+ }
+ }
+}
+
+// Private method for parsing a command line into its arguments.
+private 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() && Character.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.add( cmd.substring( sIndex, eIndex ) );
+ }
+ // else add the argument, trimming off the quotes.
+ else {
+ args.add( cmd.substring( sIndex+1, eIndex ) );
+ }
+ sIndex = eIndex + 1;
+ }
+
+ // else use white space for the delimiters.
+ else {
+ eIndex = sIndex;
+ while (eIndex < cmd.length() && !Character.isWhitespace( cmd.charAt(eIndex) )) {
+ eIndex++;
+ }
+ args.add( 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;
+}
+
+
+static String gnome_getDataDirectory(String dirName) {
+ byte [] nameBuffer = Converter.wcsToMbcs (null, dirName, true);
+ int ptr = GNOME.gnome_datadir_file(nameBuffer);
+ if (ptr == 0) return null;
+ int length = OS.strlen(ptr);
+ byte[] dirBuffer = new byte[length];
+ OS.memmove(dirBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, dirBuffer));
+}
+
+static String gnome_getHomeDirectory() {
+ int ptr = GNOME.g_get_home_dir();
+ if (ptr == 0) return null;
+ int length = OS.strlen(ptr);
+ byte[] homeDirBuffer = new byte[length];
+ OS.memmove(homeDirBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, homeDirBuffer));
+}
+
+static String gnome_getMimeType(String name) {
+ byte [] nameBuffer = Converter.wcsToMbcs (null, name, true);
+ int ptr = GNOME.gnome_mime_type(nameBuffer);
+ if (ptr == 0) return null;
+ int length = OS.strlen(ptr);
+ byte[] mimeBuffer = new byte[length];
+ OS.memmove(mimeBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, mimeBuffer));
+}
+
+static String gnome_getMimeValue(String mimeType, String key) {
+ byte [] typeBuffer = Converter.wcsToMbcs (null, mimeType, true);
+ byte [] keyBuffer = Converter.wcsToMbcs (null, key, true);
+ int ptr = GNOME.gnome_mime_get_value(typeBuffer, keyBuffer);
+ if (ptr == 0) return null;
+
+ StringBuffer stringBuffer = new StringBuffer();
+ int length = OS.strlen(ptr);
+ byte[] valueBuffer = new byte[length];
+ OS.memmove(valueBuffer, ptr, length);
+ return new String(Converter.mbcsToWcs(null, valueBuffer));
+}
+
+static boolean kde_init () {
+ try {
+ Callback.loadLibrary("swt-kde");
+ } catch (UnsatisfiedLinkError e) {
+ return false;
+ }
+ String appName = "KDE Platform Support";
+ byte [] nameBuffer = Converter.wcsToMbcs (null, appName, true);
+ int qcString = KDE.QCString_new (nameBuffer);
+ KDE.KApplication_new (qcString);
+ KDE.QCString_delete (qcString);
+ return true;
+}
+
+static String kde_convertQStringAndFree (int qString) {
+ int qCString = KDE.QString_utf8 (qString);
+ int charString = KDE.QCString_data (qCString);
+
+ StringBuffer stringBuffer = new StringBuffer ();
+ int length = KDE.strlen (charString);
+ byte[] buffer = new byte [length];
+ KDE.memmove (buffer, charString, length);
+ String answer = new String (Converter.mbcsToWcs (null, buffer));
+
+ KDE.QCString_delete (qCString);
+ KDE.QString_delete (qString);
+ return answer;
+}
+
+/*
+ * Launches the executable associated with the file in
+ * the operating system. If the file is an executable,
+ * then the executable is launched.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public static boolean launch (String fileName) {
+ if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+
+ // If the argument appears to be a data file (it has an extension)
+ int index = fileName.lastIndexOf (".");
+ if (index > 0) {
+
+ // Find the associated program, if one is defined.
+ String extension = fileName.substring (index);
+ Program program = Program.findProgram (extension);
+
+ // If the associated program is defined and can be executed, return.
+ if (program != null && program.execute (fileName)) return true;
+ }
+
+ // Otherwise, the argument was the program itself.
+ try {
+ Runtime.getRuntime().exec (fileName);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+}
+
+/*
+ * 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 is the argument (typically a file) for the program
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <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);
+
+ // Parse the command into its individual arguments.
+ String[] args = parseCommand( command );
+ int fileArg = -1;
+ int index;
+ for (index=0; index < args.length; index++) {
+ if (args[ index ].equals( "%f" )) {
+ fileArg = index;
+ args[ index ] = fileName;
+ }
+ }
+
+ // 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 {
+ Runtime.getRuntime().exec( args );
+ } catch (IOException e) {
+ return false;
+ }
+
+ return true;
+}
+
+/*
+ * Returns the receiver's image data. This is the icon
+ * that is associated with the reciever in the operating
+ * system.
+ *
+ * @return the image data for the program
+ */
+public ImageData getImageData () {
+ String iconPath = null;
+ switch (Desktop) {
+ case DESKTOP_KDE:
+ String urlString = "file://any." + extension;
+ byte [] buffer = Converter.wcsToMbcs (null, urlString, true);
+ int qString = KDE.QString_new(buffer);
+ int url = KDE.KURL_new(qString);
+ KDE.QString_delete(qString);
+ int mimeType = KDE.KMimeType_findByURL(url);
+ if (mimeType == 0) return null;
+ int mimeIcon = KDE.KMimeType_icon(mimeType, 0, 0);
+ int loader = KDE.KGlobal_iconLoader();
+ int path = KDE.KIconLoader_iconPath(loader, mimeIcon, KDE.KICON_SMALL, 1);
+ iconPath = kde_convertQStringAndFree(path);
+ break;
+ case DESKTOP_GNOME:
+ String fakeFileName = "file." + extension;
+ String mime = gnome_getMimeType(fakeFileName);
+ if (mime == null) return null;
+ iconPath = gnome_getMimeValue(mime, "icon-filename");
+ if (iconPath == null) return null;
+ break;
+ case DESKTOP_UNKNOWN:
+ return null;
+ }
+ if (iconPath.endsWith ("xpm")) {
+ //BAD
+ Display display = Display.getCurrent ();
+ int xDisplay = display.xDisplay;
+ int drawable = OS.XDefaultRootWindow (xDisplay);
+ int [] pixmap_ptr = new int [1], mask_ptr = new int [1];
+ byte [] buffer = Converter.wcsToMbcs (null, iconPath, true);
+ int result = OS.XpmReadFileToPixmap (xDisplay, drawable, buffer, pixmap_ptr, mask_ptr, 0);
+ if (result < 0) return null;
+ Image image = Image.motif_new (display, SWT.BITMAP, pixmap_ptr[0], mask_ptr [0]);
+ ImageData imageData = image.getImageData ();
+ image.dispose ();
+ return imageData;
+ }
+ try {
+ return new ImageData (iconPath);
+ } catch (Exception e) {
+ 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 an the name of the program
+ */
+public String getName () {
+ return name;
+}
+
+public String toString () {
+ return "Program {" + name + "}";
+}
+static boolean gnome_init () {
+ try {
+ Callback.loadLibrary("swt-gnome");
+ } catch (UnsatisfiedLinkError e) {
+ return false;
+ }
+ return true;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
new file mode 100755
index 0000000000..1756ecb143
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/Program.java
@@ -0,0 +1,169 @@
+package org.eclipse.swt.program;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+import org.eclipse.swt.widgets.Display;
+
+import java.util.Vector;
+import java.io.*;
+
+/**
+ * Instances of this class represent programs and
+ * their assoicated file extensions in the operating
+ * system.
+ */
+public final class Program {
+ String name;
+ String extension;
+ String command;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Program () {
+}
+
+/*
+ * Finds the program that is associated with an extension.
+ * The extension may or may not begin with a '.'.
+ *
+ * @param extension the program extension
+ * @return the program or nil
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when extension is null</li>
+ * </ul>
+ */
+public static Program findProgram (String extension) {
+ if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (extension.length () == 0) return null;
+ return null;
+}
+
+/*
+ * Answer all program extensions in the operating system.
+ *
+ * @return an array of extensions
+ */
+public static String [] getExtensions () {
+ return new String[0];
+}
+
+/*
+ * Answers all available programs in the operating system.
+ *
+ * @return an array of programs
+ */
+public static Program [] getPrograms () {
+ Program [] programs = new Program [1024];
+ byte [] key = new byte [1024];
+ int index = 0, count = 0;
+// while (OS.RegEnumKey (OS.HKEY_CLASSES_ROOT, index, key, key.length) != OS.ERROR_NO_MORE_ITEMS) {
+// Program program = getProgram (key);
+// if (program != null) {
+// if (count == programs.length) {
+// Program [] newPrograms = new Program [programs.length + 1024];
+// System.arraycopy (programs, 0, newPrograms, 0, programs.length);
+// programs = newPrograms;
+// }
+// programs [count++] = program;
+// }
+// index++;
+// }
+ if (count != programs.length) {
+ Program [] newPrograms = new Program [count];
+ System.arraycopy (programs, 0, newPrograms, 0, count);
+ programs = newPrograms;
+ }
+ return programs;
+}
+
+/*
+ * Launches the executable associated with the file in
+ * the operating system. If the file is an executable,
+ * then the executable is launched.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public static boolean launch (String fileName) {
+ if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int index = fileName.lastIndexOf (".");
+ if (index == -1) return false;
+ String extension = fileName.substring (index, fileName.length ());
+ Program program = Program.findProgram (extension);
+ if (program != null && program.execute (fileName)) return true;
+ try {
+ Runtime.getRuntime().exec (fileName);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+}
+
+/*
+ * 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
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <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 index = command.indexOf ("%f");
+ if (index == -1) return false;
+ String prefix = command.substring (0, index);
+ String suffix = command.substring (index + 2, command.length ());
+ try {
+ Runtime.getRuntime ().exec (prefix + '"' + fileName + '"' + suffix);
+ } catch (IOException e) {
+ return false;
+ }
+ return true;
+}
+
+/*
+ * Returns the receiver's image data. This is the icon
+ * that is associated with the reciever in the operating
+ * system.
+ *
+ * @return the image data for the program
+ */
+public ImageData 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 an the name of the program
+ */
+public String getName () {
+ return name;
+}
+
+public String toString () {
+ return "Program {" + name + "}";
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/ProgramSupport.java b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/ProgramSupport.java
new file mode 100755
index 0000000000..922bd382a0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/photon/org/eclipse/swt/program/ProgramSupport.java
@@ -0,0 +1,215 @@
+package org.eclipse.swt.program;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import java.io.*;
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+/**
+ * @deprecated see Java doc for Windows
+ *
+ * This class provides an OS independent interface to
+ * functionality that is OS dependent
+ */
+public final class ProgramSupport {
+
+static public String getWindowSystem() {
+ // Same name as org.eclipse.swt.internal.motif
+ return "motif";
+}
+
+/**
+ * Convenience method to determine whether the current platform
+ * has reparenting support.
+ * @return boolean is reparenting supported
+ */
+public static boolean isReparentable() {
+ return false;
+}
+
+/**
+ * Given a filename and registry index, this method will search
+ * the platform registry and return the registered large image
+ * associated with the filename. If the filename is not
+ * registered null is returned. Note: if the platform does not
+ * have registry support, null is always returned.
+ * The caller is responsible for destroying the Image.
+ * @param fileName name of exectuable file
+ * @param index registry index
+ * @return org.eclipse.swt.graphics.Image of registered icon or
+ * <code>null</code> if not present
+ */
+public static Image loadLargeIcon(Display display, String fileName, int index) {
+ return loadSmallIcon(display, fileName, index);
+}
+
+/**
+ * Given a filename and registry index, this method will search
+ * the platform registry and return the registered small image
+ * associated with the filename. If the filename is not
+ * registered null is returned. Note: if the platform does not
+ * have registry support, null is always returned.
+ * The caller is responsible for destroying the Image.
+ * @param fileName name of exectuable file
+ * @param index registry index
+ * @return org.eclipse.swt.graphics.Image of registered icon or
+ * <code>null</code> if not present
+ */
+public static Image loadSmallIcon(Display display, String fileName, int index) {
+ return null;
+}
+
+/**
+ * Given a RichText widget this method will attempt to print the
+ * contents of the editor.
+ * @param editor the widget that contains the text to be printed
+ */
+public static void print(org.eclipse.swt.widgets.Control editor) {
+
+}
+
+/**
+* Answer the path, name and command line parameters registered
+* for a given extension.
+* <p>
+*
+* @param extension the extension to query. Must provide leading '.'
+*
+* @return the path, name and command line parameters registered for
+* the extension. Empty string if the extension is not registered.
+*/
+public static String queryExtension(String extension) {
+ return null;
+}
+
+/**
+ * Given a file extension (something like .html ) the function
+ * returns the full path of the icon image registered to
+ * the extension. The file name has a comma and index appended
+ * to it. This is the offset into an icon registry of the image.
+ * @param extension the string that appears after the last dot
+ * of the file name
+ * @return String full path of executable file registered to the
+ * extension. If no extension has been registered an empty
+ * string is returned. Appended to the end after a comma
+ * is the offset of the image
+ */
+public static String queryExtensionIcon(String extension) {
+ return "";
+}
+
+/**
+ * This function querys the registery for a list of all the
+ * executable programs registered on the platform.
+ * @return String[] an array of strings. Each string contains the
+ * full path of the executable program. Duplicates may exist
+ * since multiple extensions may be registered to the same program.
+ */
+public static String[] queryRegisteredPrograms() {
+ return new String[0];
+}
+
+/**
+ * This method will change the parent of control to the composite.
+ * @param control org.eclipse.swt.widgets.Control - control with parent to be changed
+ * @param parent org.eclipse.swt.widgets.Widget - the new parent of control
+ */
+public static void setParent(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Composite parent) {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+}
+
+/**
+ * Attempts to open the specified file. The effect varies based on
+ * the file type and underlying operating system. On win32, the effect
+ * is to invoke the ShellExecute API with the command "open". On motif
+ * the effect is to lookup the command to invoke using the underlying
+ * o/s's mime table support.
+ *
+ * @param file String
+ * a file to open.
+ * @return boolean
+ * true if successful, false otherwise.
+ */
+public static boolean shellExecute(String file) {
+ return shellExecute(file, null);
+}
+
+/**
+ * Attempts to open the specified file. The effect varies based on
+ * the file type and underlying operating system. On win32, the effect
+ * is to invoke the ShellExecute API with the command "open". On motif
+ * the effect is to lookup the command to invoke using the underlying
+ * o/s's mime table support.
+ *
+ * Note: This method will be deprecated in the next release.
+ *
+ * @param file String
+ * a file to open.
+ * @param args String
+ * a String to be passed when the file is opened.
+ * @return boolean
+ * true if successful, false otherwise.
+ */
+public static boolean shellExecute(String file, String args) {
+// if (Desktop == DESKTOP_UNKNOWN) return false;
+
+ int startIndex = file.lastIndexOf('.');
+ if (startIndex > -1) {
+ String extension = file.substring(startIndex + 1);
+ String command = queryExtension(extension);
+ int index = command.indexOf("%f");
+ if (index > -1) {
+ command = command.substring(0, index) + file;
+ if (args != null) {
+ command += " "+args;
+ }
+ try {
+ Runtime.getRuntime().exec(command);
+ return true;
+ } catch (IOException e) {
+ return false;
+ }
+ }
+ }
+
+ return false;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+public static String getFriendlyName(String programId) {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ return null;
+}
+
+public static String queryExtensionProgramId(String extension) {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ return null;
+}
+
+public static String[] queryInsertables() {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ return null;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
new file mode 100755
index 0000000000..259670d42c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT Program/win32/org/eclipse/swt/program/Program.java
@@ -0,0 +1,259 @@
+package org.eclipse.swt.program;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+import java.io.IOException;
+
+/**
+ * Instances of this class represent programs and
+ * their assoicated file extensions in the operating
+ * system.
+ */
+public final class Program {
+ String name;
+ String command;
+ String iconName;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Program () {
+}
+
+/*
+ * Finds the program that is associated with an extension.
+ * The extension may or may not begin with a '.'.
+ *
+ * @param extension the program extension
+ * @return the program or nil
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when extension is null</li>
+ * </ul>
+ */
+public static Program findProgram (String extension) {
+ if (extension == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (extension.length () == 0) return null;
+ if (extension.charAt (0) != '.') extension = "." + extension;
+ byte [] key = Converter.wcsToMbcs (0, extension, true);
+ int [] phkResult = new int [1];
+ if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
+ return null;
+ }
+ int [] lpcbData = new int [] {256};
+ byte [] lpData = new byte [lpcbData [0]];
+ int result = OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData);
+ OS.RegCloseKey (phkResult [0]);
+ if (result != 0) return null;
+ return getProgram (lpData);
+}
+
+/*
+ * Answer all program extensions in the operating system.
+ *
+ * @return an array of extensions
+ */
+public static String [] getExtensions () {
+ String [] extensions = new String [1024];
+ byte [] key = new byte [1024];
+ int index = 0, count = 0;
+ while (OS.RegEnumKey (OS.HKEY_CLASSES_ROOT, index, key, key.length) != OS.ERROR_NO_MORE_ITEMS) {
+ if (key [0] == '.') {
+ int length = 0;
+ while (length < key.length && key [length] != 0) length++;
+ byte [] buffer = new byte [length];
+ System.arraycopy (key, 0, buffer, 0, length);
+ String extension = new String (Converter.mbcsToWcs (0, buffer));
+ if (count == extensions.length) {
+ String [] newExtensions = new String [extensions.length + 1024];
+ System.arraycopy (extensions, 0, newExtensions, 0, extensions.length);
+ extensions = newExtensions;
+ }
+ extensions [count++] = extension;
+ }
+ index++;
+ }
+ if (count != extensions.length) {
+ String [] newExtension = new String [count];
+ System.arraycopy (extensions, 0, newExtension, 0, count);
+ extensions = newExtension;
+ }
+ return extensions;
+}
+
+static String getKeyValue (byte [] key) {
+ int [] phkResult = new int [1];
+ if (OS.RegOpenKeyEx (OS.HKEY_CLASSES_ROOT, key, 0, OS.KEY_READ, phkResult) != 0) {
+ return null;
+ }
+ String result = null;
+ int [] lpcbData = new int [1];
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, null, lpcbData) == 0) {
+ byte [] lpData = new byte [lpcbData [0]];
+ if (OS.RegQueryValueEx (phkResult [0], null, 0, null, lpData, lpcbData) == 0) {
+ char [] charArray = Converter.mbcsToWcs (0, lpData);
+ result = new String (charArray, 0, charArray.length - 1);
+ }
+ }
+ if (phkResult [0] != 0) OS.RegCloseKey (phkResult [0]);
+ return result;
+}
+
+static Program getProgram (byte [] key) {
+
+ /* Command */
+ byte [] COMMAND = Converter.wcsToMbcs (0, "\\shell\\open\\command", true);
+ int length = 0;
+ while (length < key.length && key [length] != 0) length++;
+ for (int i=0; i<COMMAND.length; i++) key [length + i] = COMMAND [i];
+ key [length + COMMAND.length] = 0;
+ String command = getKeyValue (key);
+ if (command == null || command.length () == 0) return null;
+
+ /* Name */
+ key [length] = 0;
+ String name = getKeyValue (key);
+ if (name == null || name.length () == 0) return null;
+
+ /* Icon */
+ byte [] DEFAULT_ICON = Converter.wcsToMbcs (0, "\\DefaultIcon", true);
+ for (int i=0; i<DEFAULT_ICON.length; i++) key [length + i] = DEFAULT_ICON [i];
+ key [length + DEFAULT_ICON.length] = 0;
+ String iconName = getKeyValue (key);
+ if (iconName == null || iconName.length () == 0) return null;
+
+ Program program = new Program ();
+ program.name = name;
+ program.command = command;
+ program.iconName = iconName;
+ return program;
+}
+
+/*
+ * Answers all available programs in the operating system.
+ *
+ * @return an array of programs
+ */
+public static Program [] getPrograms () {
+ Program [] programs = new Program [1024];
+ byte [] key = new byte [1024];
+ int index = 0, count = 0;
+ while (OS.RegEnumKey (OS.HKEY_CLASSES_ROOT, index, key, key.length) != OS.ERROR_NO_MORE_ITEMS) {
+ Program program = getProgram (key);
+ if (program != null) {
+ if (count == programs.length) {
+ Program [] newPrograms = new Program [programs.length + 1024];
+ System.arraycopy (programs, 0, newPrograms, 0, programs.length);
+ programs = newPrograms;
+ }
+ programs [count++] = program;
+ }
+ index++;
+ }
+ if (count != programs.length) {
+ Program [] newPrograms = new Program [count];
+ System.arraycopy (programs, 0, newPrograms, 0, count);
+ programs = newPrograms;
+ }
+ return programs;
+}
+
+/*
+ * Launches the executable associated with the file in
+ * the operating system. If the file is an executable,
+ * then the executable is launched.
+ *
+ * @param fileName the file or program name
+ * @return <code>true</code> if the file is launched, otherwise <code>false</code>
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_NULL_ARGUMENT when fileName is null</li>
+ * </ul>
+ */
+public static boolean launch (String fileName) {
+ if (fileName == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] OPEN = Converter.wcsToMbcs (0, "open", true);
+ byte [] lpFile = Converter.wcsToMbcs (0, fileName, true);
+ return OS.ShellExecute (0, OPEN, lpFile, null, null, OS.SW_SHOW) > 32;
+}
+
+/*
+ * 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 SWTError <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 index = command.indexOf ("%1");
+ if (index == -1) return false;
+ String prefix = command.substring (0, index);
+ String suffix = command.substring (index + 2, command.length ());
+ try {
+ Runtime.getRuntime ().exec (prefix + '"' + fileName + '"' + suffix);
+ } catch (IOException e) {
+ return false;
+ }
+ return true;
+}
+
+/*
+ * Returns the receiver's image data. This is the icon
+ * that is associated with the reciever in the operating
+ * system.
+ *
+ * @return the image data for the program
+ */
+public ImageData getImageData () {
+ int nIconIndex = 0;
+ String fileName = iconName;
+ int index = iconName.indexOf (',');
+ if (index != -1) {
+ fileName = iconName.substring (0, index);
+ String iconIndex = iconName.substring (index + 1, iconName.length ()).trim ();
+ try {
+ nIconIndex = Integer.parseInt (iconIndex);
+ } catch (NumberFormatException e) {};
+ }
+ byte [] lpszFile = Converter.wcsToMbcs (0, fileName, true);
+ int [] phiconSmall = new int[1], phiconLarge = null;
+ OS.ExtractIconEx (lpszFile, nIconIndex, phiconLarge, phiconSmall, 1);
+ if (phiconSmall [0] == 0) return null;
+ Image image = Image.win32_new (null, SWT.ICON, phiconSmall[0]);
+ ImageData imageData = image.getImageData ();
+ image.dispose ();
+ return imageData;
+}
+
+/*
+ * 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 an the name of the program
+ */
+public String getName () {
+ return name;
+}
+
+public String toString () {
+ return "Program {" + name + "}";
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
new file mode 100755
index 0000000000..565483b589
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.c
@@ -0,0 +1,328 @@
+/**
+ * Callback implementation.
+ */
+#include "globals.h"
+#include "callback.h"
+
+/* --------------- 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 accordinglly.
+ */
+
+/* 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)(int p1) { return RETURN_CAST callback(index, p1); }
+
+/* Function template with 2 arguments */
+#define FN_2(index) RETURN_TYPE FN(index, 2)(int p1, int p2) { return RETURN_CAST callback(index, p1, p2); }
+
+/* Function template with 3 arguments */
+#define FN_3(index) RETURN_TYPE FN(index, 3)(int p1, int p2, int p3) { return RETURN_CAST callback(index, p1, p2, p3); }
+
+/* Function template with 4 arguments */
+#define FN_4(index) RETURN_TYPE FN(index, 4)(int p1, int p2, int p3, int p4) { return RETURN_CAST callback(index, p1, p2, p3, p4); }
+
+/* Function template with 5 arguments */
+#define FN_5(index) RETURN_TYPE FN(index, 5)(int p1, int p2, int p3, int p4, int 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)(int p1, int p2, int p3, int p4, int p5, int 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)(int p1, int p2, int p3, int p4, int p5, int p6, int 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)(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int 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)(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int 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) (int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int 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) (int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, int 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) (int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10, int p11, int 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.
+ */
+#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)
+
+/**
+ * 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.
+ */
+#define FN_A_BLOCK(args) {(int *)FN(0, args),(int *)FN(1, args),(int *)FN(2, args),(int *)FN(3, args),(int *)FN(4, args),(int *)FN(5, args),(int *)FN(6, args),(int *)FN(7, args),(int *)FN(8, args),(int *)FN(9, args),(int *)FN(10, args),(int *)FN(11, args),(int *)FN(12, args),(int *)FN(13, args),(int *)FN(14, args),(int *)FN(15, args),(int *)FN(16, args),(int *)FN(17, args),(int *)FN(18, args),(int *)FN(19, args),(int *)FN(20, args),(int *)FN(21, args),(int *)FN(22, args),(int *)FN(23, args),(int *)FN(24, args),(int *)FN(25, args),(int *)FN(26, args),(int *)FN(27, args),(int *)FN(28, args),(int *)FN(29, args),(int *)FN(30, args),(int *)FN(31, args),(int *)FN(32, args),(int *)FN(33, args),(int *)FN(34, args),(int *)FN(35, args),(int *)FN(36, args),(int *)FN(37, args),(int *)FN(38, args),(int *)FN(39, args),(int *)FN(40, args),(int *)FN(41, args),(int *)FN(42, args),(int *)FN(43, args),(int *)FN(44, args),(int *)FN(45, args),(int *)FN(46, args),(int *)FN(47, args),(int *)FN(48, args),(int *)FN(49, args),(int *)FN(50, args),(int *)FN(51, args),(int *)FN(52, args),(int *)FN(53, args),(int *)FN(54, args),(int *)FN(55, args),(int *)FN(56, args),(int *)FN(57, args),(int *)FN(58, args),(int *)FN(59, args),(int *)FN(60, args),(int *)FN(61, args),(int *)FN(62, args),(int *)FN(63, args),(int *)FN(64, args),(int *)FN(65, args),(int *)FN(66, args),(int *)FN(67, args),(int *)FN(68, args),(int *)FN(69, args),(int *)FN(70, args),(int *)FN(71, args),(int *)FN(72, args),(int *)FN(73, args),(int *)FN(74, args),(int *)FN(75, args),(int *)FN(76, args),(int *)FN(77, args),(int *)FN(78, args),(int *)FN(79, args),(int *)FN(80, args),(int *)FN(81, args),(int *)FN(82, args),(int *)FN(83, args),(int *)FN(84, args),(int *)FN(85, args),(int *)FN(86, args),(int *)FN(87, args),(int *)FN(88, args),(int *)FN(89, args),(int *)FN(90, args),(int *)FN(91, args),(int *)FN(92, args),(int *)FN(93, args),(int *)FN(94, args),(int *)FN(95, args),(int *)FN(96, args),(int *)FN(97, args),(int *)FN(98, args),(int *)FN(99, args),(int *)FN(100, args),(int *)FN(101, args),(int *)FN(102, args),(int *)FN(103, args),(int *)FN(104, args),(int *)FN(105, args),(int *)FN(106, args),(int *)FN(107, args),(int *)FN(108, args),(int *)FN(109, args),(int *)FN(110, args),(int *)FN(111, args),(int *)FN(112, args),(int *)FN(113, args),(int *)FN(114, args),(int *)FN(115, args),(int *)FN(116, args),(int *)FN(117, args),(int *)FN(118, args),(int *)FN(119, args),(int *)FN(120, args),(int *)FN(121, args),(int *)FN(122, args),(int *)FN(123, args),(int *)FN(124, args),(int *)FN(125, args),(int *)FN(126, args),(int *)FN(127, args)},
+
+int * 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)
+};
+
+
+/* --------------- callback class calls --------------- */
+
+/*
+ * Class: org_eclipse_swt_internal_Callback
+ * Method: bind
+ * Signature: (Lorg/eclipse/swt/internal/Callback;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_Callback_bind
+ (JNIEnv *env, jclass that, jobject lpCallback)
+/*
+** The methodID is computed once during the bind and will be valid
+** unless the Callback class is reloaded.
+*/
+{
+ DECL_GLOB(pGlob)
+ int i;
+ jclass javaClass;
+ jobject javaObject, javaMethod, javaSignature;
+ jboolean isStatic, isArrayBased;
+ jint argCount;
+ jmethodID mid;
+ const char *methodString, *sigString;
+
+ javaClass = that;
+ if (!PGLOB(callbackCached)) {
+ PGLOB(objectID) = (*env)->GetFieldID(env,javaClass,"object","Ljava/lang/Object;");
+ PGLOB(addressID) = (*env)->GetFieldID(env,javaClass,"address","I");
+ PGLOB(methodID) = (*env)->GetFieldID(env,javaClass,"method","Ljava/lang/String;");
+ PGLOB(signatureID) = (*env)->GetFieldID(env,javaClass,"signature","Ljava/lang/String;");
+ PGLOB(isStaticID) = (*env)->GetFieldID(env,javaClass,"isStatic","Z");
+ PGLOB(argCountID) = (*env)->GetFieldID(env,javaClass,"argCount","I");
+ PGLOB(isArrayBasedID) = (*env)->GetFieldID(env,javaClass,"isArrayBased","Z");
+ PGLOB(callbackCached) = 1;
+ }
+ javaObject = (*env)->GetObjectField(env,lpCallback,PGLOB(objectID));
+ javaMethod = (*env)->GetObjectField(env,lpCallback,PGLOB(methodID));
+ javaSignature = (*env)->GetObjectField(env,lpCallback,PGLOB(signatureID));
+ isStatic = (*env)->GetBooleanField(env,lpCallback,PGLOB(isStaticID));
+ argCount = (*env)->GetIntField(env,lpCallback,PGLOB(argCountID));
+ isArrayBased = (*env)->GetBooleanField(env,lpCallback,PGLOB(isArrayBasedID));
+ methodString = (*env)->GetStringUTFChars(env, javaMethod, NULL);
+ sigString = (*env)->GetStringUTFChars(env, javaSignature, NULL);
+ if (isStatic) {
+ mid = (*env)->GetStaticMethodID(env, javaObject, methodString, sigString);
+ } else {
+ javaClass = (*env)->GetObjectClass(env,javaObject);
+ /* note that this call is reusing javaClass */
+ mid = (*env)->GetMethodID(env, javaClass, methodString, sigString);
+ }
+ (*env)->ReleaseStringUTFChars(env, javaMethod, methodString);
+ (*env)->ReleaseStringUTFChars(env, javaSignature, sigString);
+ if (PGLOB(initialized)==0) {
+ memset((void *)&PGLOB(dllCallbackInfo), 0, sizeof(PGLOB(dllCallbackInfo)));
+ PGLOB(initialized) = 1;
+ }
+ for (i=0; i<MAX_CALLBACKS; i++) {
+ if (!PGLOB(dllCallbackInfo)[i].callin) {
+ PGLOB(dllCallbackInfo)[i].callin = (*env)->NewGlobalRef(env,lpCallback);
+ PGLOB(dllCallbackInfo)[i].env = env;
+ PGLOB(dllCallbackInfo)[i].methodID = mid;
+
+ return (jint) fnx_array[argCount][i];
+ }
+ }
+ fprintf(stderr, "bind fail, no free callback slot ******* \n");
+ return 0; /* this means there was no free callback slot */
+}
+
+/*
+ * Class: org_eclipse_swt_internal_Callback
+ * Method: unbind
+ * Signature: (Lorg/eclipse/swt/internal/Callback;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_Callback_unbind
+ (JNIEnv *env, jclass that, jobject lpCallback)
+{
+ DECL_GLOB(pGlob)
+ int i, address, argCount;
+ if (!PGLOB(callbackCached)) return;
+
+ address = (*env)->GetIntField(env,lpCallback,PGLOB(addressID));
+ argCount = (*env)->GetIntField(env,lpCallback,PGLOB(argCountID));
+
+ for (i=0; i<MAX_CALLBACKS; i++) {
+ if ((int)fnx_array[argCount][i] == address) {
+ (*env)->DeleteGlobalRef(env, PGLOB(dllCallbackInfo)[i].callin);
+ PGLOB(dllCallbackInfo)[i].callin = 0;
+ PGLOB(dllCallbackInfo)[i].env = 0;
+ PGLOB(dllCallbackInfo)[i].methodID = 0;
+ }
+ }
+}
+
+/*
+ * Indicates wheter callbacks should be fired.
+ *
+ * WARNING - This var has to be a global. Do not multidata enable it.
+ */
+static int CallbacksEnabled = 1;
+
+/*
+ * Class: org_eclipse_swt_internal_Callback
+ * Method: setEnabled
+ * Signature: (Z)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_Callback_setEnabled
+ (JNIEnv *env, jclass that, jboolean enable)
+{
+ CallbacksEnabled = enable;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_Callback
+ * Method: getEnabled
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_Callback_getEnabled
+ (JNIEnv *env, jclass that, jboolean enable)
+{
+ return (jboolean)CallbacksEnabled;
+}
+
+int callback(int index, ...)
+{
+ if (!CallbacksEnabled) {
+ return 0;
+ } else {
+ DECL_GLOB(pGlob)
+ jobject callback = PGLOB(dllCallbackInfo)[index].callin;
+ JNIEnv *env = PGLOB(dllCallbackInfo)[index].env;
+ jmethodID mid = PGLOB(dllCallbackInfo)[index].methodID;
+ jobject javaObject;
+ jboolean isStatic, isArrayBased;
+
+ int result = 0;
+ va_list vl;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "* callback starting %d\n", PGLOB(counter)++);
+#endif
+
+ /* An exception has already occurred. Allow the stack to unwind so that
+ the exception will be thrown in Java */
+ if ((*env)->ExceptionOccurred(env)) {
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "************ java exception occurred\n");
+#endif
+
+ return 0;
+ }
+
+ javaObject = (*env)->GetObjectField(env,callback,PGLOB(objectID));
+ isStatic = ((*env)->GetBooleanField(env,callback,PGLOB(isStaticID))) != 0;
+ isArrayBased = ((*env)->GetBooleanField(env,callback,PGLOB(isArrayBasedID))) != 0;
+
+ va_start(vl, index);
+ if (isArrayBased) {
+ int i;
+ jint argCount = (*env)->GetIntField(env,callback,PGLOB(argCountID));
+ jintArray javaArray = (*env)->NewIntArray(env,argCount);
+ jint *elements = (*env)->GetIntArrayElements(env,javaArray,NULL);
+ for (i=0; i<argCount; i++) {
+ elements[i] = va_arg(vl, jint);
+ }
+ (*env)->ReleaseIntArrayElements(env, javaArray, elements, 0);
+ if (isStatic) {
+ result = (*env)->CallStaticIntMethod(env, javaObject, mid, javaArray);
+ } else {
+ result = (*env)->CallIntMethod(env, javaObject, mid, javaArray);
+ }
+ (*env)->DeleteLocalRef(env, javaArray);
+ } else {
+ if (isStatic) {
+ result = (*env)->CallStaticIntMethodV(env, javaObject, mid, vl);
+ } else {
+ result = (*env)->CallIntMethodV(env, javaObject, mid, vl);
+ }
+ }
+ va_end(vl);
+ /* This call may be called many times before we return to Java.
+ We have to explicitly delete local references to avoid GP's
+ in the JDK and IBM Hursley VM.
+ */
+ (*env)->DeleteLocalRef(env,javaObject);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "* callback exiting %d\n", --PGLOB(counter));
+#endif
+ return result;
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_Callback
+ * Method: reset
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_Callback_reset
+ (JNIEnv *env, jclass that)
+{
+ DECL_GLOB(pGlob)
+ memset((void *)&PGLOB(dllCallbackInfo), 0, sizeof(PGLOB(dllCallbackInfo)));
+}
+
+/*
+ * Class: org_eclipse_swt_internal_Callback
+ * Method: getPlatform
+ * Signature: ()Ljava/lang/String;
+ */
+JNIEXPORT jstring JNICALL Java_org_eclipse_swt_internal_Callback_getPlatform
+ (JNIEnv *env, jclass that)
+{
+ return (*env)->NewStringUTF(env, PLATFORM);
+}
+
+/* ------------- callback class calls end --------------- */
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.h b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.h
new file mode 100755
index 0000000000..9c0e042ca8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/callback.h
@@ -0,0 +1,49 @@
+/**
+ * Callback implementation.
+ */
+#ifndef INC_callback_H
+#define INC_callback_H
+
+int callback(int index, ...);
+
+#ifdef WIN32
+#define PLATFORM "win32"
+#define RETURN_TYPE LRESULT CALLBACK
+#define RETURN_CAST (LRESULT)
+#endif
+
+#ifdef MOTIF
+#define PLATFORM "motif"
+#endif
+
+#ifdef GTK
+#define PLATFORM "gtk"
+#endif
+
+#ifdef PHOTON
+#define PLATFORM "photon"
+#endif
+
+#ifndef PLATFORM
+#define PLATFORM "unknown"
+#endif
+
+#ifndef RETURN_TYPE
+#define RETURN_TYPE int
+#endif
+
+#ifndef RETURN_CAST
+#define RETURN_CAST
+#endif
+
+#define MAX_CALLBACKS 128
+#define MAX_ARGS 12
+
+typedef struct SWT_CALLBACKINFO {
+ jobject callin;
+ JNIEnv *env;
+ jmethodID methodID;
+} SWT_CALLBACKINFO;
+
+#endif /* ifndef INC_callback_H */
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.c b/bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.c
new file mode 100755
index 0000000000..066c1d7052
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.c
@@ -0,0 +1,122 @@
+/**
+ * globals.c
+ *
+ * This file contains the global struct allocation routines for the
+ * SWT library.
+ *
+ */
+
+#include <malloc.h>
+#include <assert.h>
+#include <memory.h>
+#include <jni.h>
+#include "globals.h"
+#include "library.h"
+
+static void CreateLibGlobals(JNIEnv * env);
+static void DestroyLibGlobals(JNIEnv * env);
+static GLOBAL_TABLE * JNICALL GetGlobals(void);
+
+/* Place holder for all globals */
+GLOBALS globals = {0};
+GLOBAL_TABLE globals_table = {{
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 8 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 16 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 24 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 32 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 40 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 48 */
+ 0, 0, 0, 0, 0, 0, 0, 0, /* 56 */
+ 0, 0, 0, 0, 0, 0, 0, &globals, /* 64 */
+}};
+GetGlobalsFunc getGlobals = &GetGlobals;
+unsigned int vm_library = 0;
+
+/*
+ * Hook the library load.
+ */
+JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved)
+{
+ JNIEnv * env;
+
+ (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2);
+ vm_library = OpenLibrary("jvm");
+ DEBUG_PRINTF(("VM Shared library -> %d\n", vm_library));
+
+ if (vm_library != 0) {
+ unsigned int func = LibraryLookupName(vm_library, "MdCurrentJNIGlobals");
+ if (func == 0) func = LibraryLookupName(vm_library, "_MdCurrentJNIGlobals@0");
+
+ DEBUG_PRINTF(("Function address -> %x\n", func));
+ if (func != 0) getGlobals = (GetGlobalsFunc)func;
+ }
+ CreateLibGlobals(env);
+ return JNI_VERSION_1_2;
+}
+
+/*
+ * Hook the library unload.
+ */
+JNIEXPORT void JNICALL JNI_OnUnload(JavaVM *vm, void *reserved)
+{
+ JNIEnv * env;
+
+ (*vm)->GetEnv(vm, (void **)&env, JNI_VERSION_1_2);
+ DestroyLibGlobals(env);
+ CloseLibrary(vm_library);
+}
+
+/*
+ * Allocate and initialize a SWT GLOBALS struct.
+ */
+static void CreateLibGlobals(JNIEnv * env)
+{
+ GLOBALS * globs = GET_GLOBALS();
+ if (globs != NULL && globs == &globals) return;
+
+ globs = (GLOBALS *)malloc(sizeof(GLOBALS));
+ if (!globs)
+ {
+ jclass hExcClass = (*env)->FindClass(env, "java/lang/OutOfMemoryError");
+ assert(hExcClass);
+ (*env)->ThrowNew(env, hExcClass, "Unable to allocate globals in onLoad");
+ return;
+ }
+ memset(globs, 0, sizeof(GLOBALS));
+
+ /* Start of initialization code. */
+ globs->multidata = 1;
+ globs->vajava = vm_library != 0 &&
+ (LibraryLookupName(vm_library, "_MdCurrentJavaVM@0") != 0 ||
+ LibraryLookupName(vm_library, "MdCurrentJavaVM") != 0);
+ /* End of initialization code. */
+
+ SET_GLOBALS(globs);
+}
+
+/*
+ * Free a SWT GLOBALS struct.
+ */
+static void DestroyLibGlobals(JNIEnv * env)
+{
+ GLOBALS * globs = GET_GLOBALS();
+ if (globs && (globs != &globals))
+ {
+ /* Start of cleanup code. */
+ /* End of cleanup code. */
+
+ free(globs);
+
+ SET_GLOBALS(NULL);
+ }
+}
+
+/* Note that the function below do not make
+ * the vm reentrant but allow the multidata code
+ * to work in non reentrant VMs.
+ */
+/* Answer the table of globals associated with the current. */
+static GLOBAL_TABLE * JNICALL GetGlobals(void)
+{
+ return &globals_table;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.h b/bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.h
new file mode 100755
index 0000000000..8cae65979b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/globals.h
@@ -0,0 +1,71 @@
+/**
+ * globals.h
+ *
+ * This file contains the global struct declaration for the
+ * SWT library.
+ *
+ */
+
+#ifndef INC_globals_H
+#define INC_globals_H
+
+#include "jni.h"
+#include "structs.h"
+#include "callback.h"
+
+/* For debugging */
+#define DEBUG_PRINTF(x)
+/*#define DEBUG_PRINTF(x) printf x; */
+
+/* define this to print out debug statements */
+/* #define DEBUG_CALL_PRINTS */
+
+/* Define the current lib ID. */
+/* A unique constant is required for each lib.*/
+#define ID_LIB_SWT 63
+#define ID_CURR_LIB ID_LIB_SWT
+
+typedef struct
+{
+ int multidata;
+ int vajava;
+
+ /* Shared globals */
+ SWT_CALLBACKINFO dllCallbackInfo[MAX_CALLBACKS];
+ jfieldID objectID;
+ jfieldID addressID;
+ jfieldID methodID;
+ jfieldID signatureID;
+ jfieldID isStaticID;
+ jfieldID argCountID;
+ jfieldID isArrayBasedID;
+ int callbackCached;
+ int initialized;
+ int counter;
+
+ FID_CACHE_GLOBALS
+}
+GLOBALS;
+
+/*
+ * The GLOB_VAR_TABLE contains the global vars for an entire VM. Each library has
+ * a unique predefined slot within it.
+ */
+typedef struct
+{
+ void * table[64]; /* The size is ignored. There is a page of memory to play with. */
+}
+GLOBAL_TABLE;
+typedef GLOBAL_TABLE * (JNICALL *GetGlobalsFunc)();
+extern GetGlobalsFunc getGlobals;
+/*
+ * Any function which uses the global variables in a lib can use
+ * GET_GLOBALS to get the global data.
+ */
+#define GET_GLOBALS() ((*getGlobals)()->table[ID_CURR_LIB])
+#define SET_GLOBALS(pMem) (*getGlobals)()->table[ID_CURR_LIB] = (void *)pMem
+#define DECL_GLOB(pSym) GLOBALS * pSym = GET_GLOBALS();
+
+#define PGLOB(x) pGlob->x
+
+#endif /* ifndef INC_globals_H */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/library/library.h b/bundles/org.eclipse.swt/Eclipse SWT/common/library/library.h
new file mode 100755
index 0000000000..31f7bb92a4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/library/library.h
@@ -0,0 +1,18 @@
+/**
+ * library.h
+ *
+ * This file contains helpers to open, close and lookup
+ * symbol addresses in shared librares.
+ *
+ */
+
+#ifndef INC_library_H
+#define INC_library_H
+
+unsigned int OpenLibrary(char *name);
+
+unsigned int LibraryLookupName(unsigned int handle, char *name);
+
+void CloseLibrary(unsigned int handle);
+
+#endif /* INC_library_H */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
new file mode 100755
index 0000000000..1ace85cf6c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -0,0 +1,1810 @@
+package org.eclipse.swt;
+
+import org.eclipse.swt.internal.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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>
+ */
+
+/* NOTE:
+ * Good javadoc coding style is to put the values of static final
+ * constants in the comments. This re-inforces 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 */
+
+ /**
+ * key down event type (value is 1)
+ */
+ public static final int KeyDown = 1;
+
+ /**
+ * key up event type (value is 2)
+ */
+ public static final int KeyUp = 2;
+
+ /**
+ * mouse down event type (value is 3)
+ */
+ public static final int MouseDown = 3;
+
+ /**
+ * mouse up event type (value is 4)
+ */
+ public static final int MouseUp = 4;
+
+ /**
+ * mouse move event type (value is 5)
+ */
+ public static final int MouseMove = 5;
+
+ /**
+ * mouse enter event type (value is 6)
+ */
+ public static final int MouseEnter = 6;
+
+ /**
+ * Mouse exit event type (value is 7)
+ */
+ public static final int MouseExit = 7;
+
+ /**
+ * mouse double click event type (value is 8)
+ */
+ public static final int MouseDoubleClick = 8;
+
+ /**
+ * paint event type (value is 9)
+ */
+ public static final int Paint = 9;
+
+ /**
+ * pove event type (value is 10)
+ */
+ public static final int Move = 10;
+
+ /**
+ * resize event type (value is 11)
+ */
+ public static final int Resize = 11;
+
+ /**
+ * dispose event type (value is 12)
+ */
+ public static final int Dispose = 12;
+
+ /**
+ * selection event type (value is 13)
+ */
+ public static final int Selection = 13;
+
+ /**
+ * default selection event type (value is 14)
+ */
+ public static final int DefaultSelection = 14;
+
+ /**
+ * focus in event type (value is 15)
+ */
+ public static final int FocusIn = 15;
+
+ /**
+ * focus out event type (value is 16)
+ */
+ public static final int FocusOut = 16;
+
+ /**
+ * expand event type (value is 17)
+ */
+ public static final int Expand = 17;
+
+ /**
+ * collapse event type (value is 18)
+ */
+ public static final int Collapse = 18;
+
+ /**
+ * iconify event type (value is 19)
+ */
+ public static final int Iconify = 19;
+
+ /**
+ * de-iconify event type (value is 20)
+ */
+ public static final int Deiconify = 20;
+
+ /**
+ * close event type (value is 21)
+ */
+ public static final int Close = 21;
+
+ /**
+ * show event type (value is 22)
+ */
+ public static final int Show = 22;
+
+ /**
+ * hide event type (value is 23)
+ */
+ public static final int Hide = 23;
+
+ /**
+ * modify event type (value is 24)
+ */
+ public static final int Modify = 24;
+
+ /**
+ * verify event type (value is 25)
+ */
+ public static final int Verify = 25;
+
+ /**
+ * activate event type (value is 26)
+ */
+ public static final int Activate = 26;
+
+ /**
+ * deactivate event type (value is 27)
+ */
+ public static final int Deactivate = 27;
+
+ /**
+ * help event type (value is 28)
+ */
+ public static final int Help = 28;
+
+ /**
+ * drag detect event type (value is 29)
+ */
+ public static final int DragDetect = 29;
+
+ /**
+ * arm event type (value is 30)
+ */
+ public static final int Arm = 30;
+
+ /**
+ * traverse event type (value is 31)
+ */
+ public static final int Traverse = 31;
+
+ /**
+ * mouse hover event type (value is 32)
+ */
+ public static final int MouseHover = 32;
+
+ /* Event Details */
+
+ /**
+ * a constant known to be zero (0), used in operations which
+ * take bit flags to indicate that "no bits are set"
+ */
+ public static final int NONE = 0;
+
+ /**
+ * 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;
+
+ /**
+ * 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;
+
+ /**
+ * <code>Menu</code> style constant for menu bar behavior (value is 1<<1)
+ */
+ public static final int BAR = 1 << 1;
+
+ /**
+ * <code>Menu</code> style constant for drop down menu behavior (value is 1<<2)
+ */
+ public static final int DROP_DOWN = 1 << 2;
+
+ /**
+ * <code>Menu</code> style constant for pop up menu behavior (value is 1<<3)
+ */
+ public static final int POP_UP = 1 << 3;
+
+ /**
+ * <code>MenuItem</code> style constant for line separator behavior (value is 1<<1)
+ */
+ public static final int SEPARATOR = 1 << 1;
+
+ /* Button, MenuItem Constants */
+
+ /**
+ * <code>Button</code> style constant for toggle button behavior (value is 1<<1)
+ */
+ public static final int TOGGLE = 1 << 1;
+
+ /**
+ * <code>Button</code> style constant for arrow button behavior (value is 1<<2)
+ */
+ public static final int ARROW = 1 << 2;
+
+ /**
+ * <code>Button</code> and <code>MenuItem</code>
+ * style constant for push button behavior (value is 1<<3)
+ */
+ public static final int PUSH = 1 << 3;
+
+ /**
+ * <code>Button</code> and <code>MenuItem</code>
+ * style constant for radio button behavior (value is 1<<4)
+ */
+ public static final int RADIO = 1 << 4;
+
+ /**
+ * <code>Button</code> and <code>MenuItem</code>
+ * style constant for check box behavior (value is 1<<5)
+ */
+ public static final int CHECK = 1 << 5;
+
+ /**
+ * <code>MenuItem</code> style constant for cascade behavior (value is 1<<6)
+ */
+ public static final int CASCADE = 1 << 6;
+
+ /**
+ * <code>Text</code> and <code>List</code>
+ * style constant for multi-selection behavior in lists
+ * and multiple line support on text fields (value is 1<<1)
+ */
+ public static final int MULTI = 1 << 1;
+
+ /**
+ * <code>Text</code> and <code>List</code>
+ * style constant for single selection behavior in lists
+ * and single line support on text fields (value is 1<<2)
+ */
+ public static final int SINGLE = 1 << 2;
+
+ /**
+ * <code>Text</code> style constant for read-only behavior (value is 1<<3)
+ */
+ public static final int READ_ONLY = 1 << 3;
+
+ /**
+ * <code>Text</code> style constant for auto-line wrap behavior (value is 1<<6)
+ */
+ public static final int WRAP = 1 << 6;
+
+ /**
+ * <code>Combo</code> style constant for simple (not drop down) behavior (value is 1<<6)
+ */
+ public static final int SIMPLE = 1 << 6;
+
+ /**
+ * <code>Group</code> and <code>Label</code>
+ * style constant for shadow in behavior (value is 1<<2)
+ */
+ public static final int SHADOW_IN = 1 << 2;
+
+ /**
+ * <code>Group</code>, <code>Label</code> and <code>CustomLabel</code>
+ * style constant for shadow out behavior (value is 1<<3)
+ */
+ public static final int SHADOW_OUT = 1 << 3;
+
+ /**
+ * <code>Group</code> style constant for shadow etched in behavior (value is 1<<4)
+ * NOTE: This style is ignored on all platforms except Motif
+ */
+ public static final int SHADOW_ETCHED_IN = 1 << 4;
+
+ /**
+ * <code>Label</code> style constant for no shadow behavior (value is 1<<5)
+ */
+ public static final int SHADOW_NONE = 1 << 5;
+
+ /**
+ * <code>Group</code> style constant for shadow etched out behavior (value is 1<<6)
+ * NOTE: This style is ignored on all platforms except Motif
+ */
+ public static final int SHADOW_ETCHED_OUT = 1 << 6;
+
+ /**
+ * <code>Shell</code> style constant for tool window behavior (value is 1<<2)
+ */
+ public static final int TOOL = 1 << 2;
+
+ /**
+ * <code>Shell</code> style constant to ensure no trimmings are used.
+ * This overrides all other trim styles (value is 1<<3)
+ */
+ public static final int NO_TRIM = 1 << 3;
+
+ /**
+ * <code>Shell</code> style constant for resize box trim (value is 1<<4)
+ */
+ public static final int RESIZE = 1 << 4;
+
+ /**
+ * <code>Shell</code> style constant for title area trim (value is 1<<5)
+ */
+ public static final int TITLE = 1 << 5;
+
+ /**
+ * <code>Shell</code> style constant for close box trim (value is 1<<6,
+ * since we do not distinguish between CLOSE style and MENU style)
+ */
+ public static final int CLOSE = 1 << 6;
+
+ /**
+ * <code>Shell</code> style constant for shell menu trim (value is 1<<6,
+ * since we do not distinguish between CLOSE style and MENU style)
+ */
+ public static final int MENU = CLOSE;
+
+ /**
+ * <code>Shell</code> style constant for minimize box trim (value is 1<<7)
+ */
+ public static final int MIN = 1 << 7;
+
+ /* ScrollBar, Composite, Shell Constants */
+
+ /**
+ * <code>ScrollBar</code>, <code>Composite</code> and <code>Shell</code>
+ * style constant for horizontal scrollbar behavior (value is 1<<8)
+ */
+ public static final int H_SCROLL = 1 << 8;
+
+ /**
+ * <code>ScrollBar</code>, <code>Composite</code> and <code>Shell</code>
+ * style constant for vertical scrollbar behavior (value is 1<<9)
+ */
+ public static final int V_SCROLL = 1 << 9;
+
+ /**
+ * <code>Shell</code> style constant for maximize box trim (value is 1<<10)
+ */
+ public static final int MAX = 1 << 10;
+
+ /**
+ * all <code>Widget</code> style constant for bordered behavior (value is 1<<11)
+ */
+ public static final int BORDER = 1 << 11;
+
+ /**
+ * all <code>Widget</code> style constant indicating that the window
+ * manager should clip a widget's children with respect to its viewable
+ * area. Note that this is a <em>HINT</em>. (value is 1<<12)
+ */
+ public static final int CLIP_CHILDREN = 1 << 12;
+
+ /**
+ * all <code>Widget</code> style constant indicating that the window
+ * manager should clip a widget's siblings with respect to its viewable
+ * area. Note that this is a <em>HINT</em>. (value is 1<<13)
+ */
+ public static final int CLIP_SIBLINGS = 1 << 13;
+
+ /**
+ * <code>Shell</code> style constant for always on top behavior (value is 1<<14)
+ */
+ public static final int ON_TOP = 1 << 14;
+
+ /**
+ * <code>Shell</code> trim style convenience constant for the
+ * most common top level shell appearance
+ * (value is CLOSE|TITLE|MIN|MAX|RESIZE)
+ */
+ public static final int SHELL_TRIM = CLOSE | TITLE | MIN | MAX | RESIZE;
+
+ /**
+ * <code>Shell</code> trim style convenience constant for the
+ * most common dialog shell appearance
+ * (value is CLOSE|TITLE|BORDER)
+ */
+ public static final int DIALOG_TRIM = TITLE | CLOSE | BORDER;
+
+ /**
+ * <code>Shell</code> style constant for modeless behavior (value is 0)
+ */
+ public static final int MODELESS = 0;
+
+ /**
+ * <code>Shell</code> style constant for primary modal behavior (value is 1<<15)
+ */
+ public static final int PRIMARY_MODAL = 1 << 15;
+
+ /**
+ * <code>Shell</code> style constant for application modal behavior (value is 1<<16)
+ */
+ public static final int APPLICATION_MODAL = 1 << 16;
+
+ /**
+ * <code>Shell</code> style constant for system modal behavior (value is 1<<17)
+ */
+ public static final int SYSTEM_MODAL = 1 << 17;
+
+ /**
+ * all <code>Widget</code> style constant for selection hiding
+ * behavior. Note that this is a <em>HINT</em>. (value is 1<<15)
+ */
+ public static final int HIDE_SELECTION = 1 << 15;
+
+ /**
+ * all <code>Widget</code> style constant for full row selection
+ * behavior. Note that this is a <em>HINT</em>. (value is 1<<16 since
+ * FULL_SELECTION and SMOOTH share the same value, but are
+ * implemented on non-intersecting sets of widgets)
+ */
+ public static final int FULL_SELECTION = 1 << 16;
+
+ /**
+ * all <code>Widget</code> style constant for flat appearance.
+ * Note that this is a <em>HINT</em>. (value is 1<<23)
+ */
+ public static final int FLAT = 1 << 23;
+
+ /**
+ * all <code>Widget</code> style constant for flat appearance.
+ * Note that this is a <em>HINT</em>. (value is 1<<16 since
+ * FULL_SELECTION and SMOOTH share the same value, but are
+ * implemented on non-intersecting sets of widgets)
+ */
+ public static final int SMOOTH = FULL_SELECTION;
+
+ /**
+ * <code>Canvas</code> style constant for no background behavior (value is 1<<18)
+ */
+ public static final int NO_BACKGROUND = 1 << 18;
+
+ /**
+ * <code>Canvas</code> style constant for does not take focus behavior (value is 1<<19)
+ */
+ public static final int NO_FOCUS = 1 << 19;
+
+ /**
+ * <code>Canvas</code> style constant for no redraw on resize behavior (value is 1<<20)
+ */
+ public static final int NO_REDRAW_RESIZE = 1 << 20;
+
+ /**
+ * <code>Canvas</code> style constant for no paint event merging
+ * behavior (value is 1<<21)
+ */
+ public static final int NO_MERGE_PAINTS = 1 << 21;
+
+ /**
+ * <code>Canvas</code> style constant for preventing child radio group
+ * behavior (value is 1<<22)
+ */
+ public static final int NO_RADIO_GROUP = 1 << 22;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align up behavior (value is 1<<7, since
+ * align UP and align TOP are considered the same)
+ */
+ public static final int UP = 1 << 7;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align top behavior (value is 1<<7, since
+ * align UP and align TOP are considered the same)
+ */
+ public static final int TOP = UP;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align down behavior (value is 1<<10, since
+ * align DOWN and align BOTTOM are considered the same)
+ */
+ public static final int DOWN = 1 << 10;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align bottom behavior (value is 1<<10, since
+ * align DOWN and align BOTTOM are considered the same)
+ */
+ public static final int BOTTOM = DOWN;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align left behavior (value is 1<<14)
+ */
+ public static final int LEFT = 1 << 14;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align right behavior (value is 1<<17)
+ */
+ public static final int RIGHT = 1 << 17;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align center behavior (value is 1<<24)
+ */
+ public static final int CENTER = 1 << 24;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align horizontal behavior (value is 1<<8)
+ */
+ public static final int HORIZONTAL = H_SCROLL;
+
+ /**
+ * various <code>Widget</code> and <code>Layout</code>
+ * style constant for align vertical behavior (value is 1<<9)
+ */
+ public static final int VERTICAL = V_SCROLL;
+
+ /**
+ * Input Method Editor style constant for double byte
+ * input behavior (value is 1<<1)
+ */
+ public static final int DBCS = 1 << 1;
+
+ /**
+ * Input Method Editor style constant for alpha
+ * input behavior (value is 1<<2)
+ */
+ public static final int ALPHA = 1 << 2;
+
+ /**
+ * Input Method Editor style constant for native
+ * input behavior (value is 1<<3)
+ */
+ public static final int NATIVE = 1 << 3;
+
+ /**
+ * Input Method Editor style constant for phonetic
+ * input behavior (value is 1<<4)
+ */
+ public static final int PHONETIC = 1 << 4;
+
+ /**
+ * Input Method Editor style constant for romanicized
+ * input behavior (value is 1<<5)
+ */
+ public static final int ROMAN = 1 << 5;
+
+ /**
+ * ASCII character convenience constant for the escape character
+ * (value is the <code>char</code> with value 27)
+ */
+ public static final char ESC = 27;
+
+ /**
+ * 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 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 line feed character
+ * (value is the <code>char</code> '\n')
+ */
+ public static final char LF = '\n';
+
+ /**
+ * keyboard and/or mouse event mask indicating that the ALT key
+ * was pushed on the keyboard when the event was generated
+ * (value is 1<<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<<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<<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<<18)
+ */
+ public static final int CONTROL = CTRL;
+
+ /**
+ * keyboard and/or mouse event mask indicating that mouse button one
+ * was pushed when the event was generated. (value is 1<<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<<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<<21)
+ */
+ public static final int BUTTON3 = 1 << 21;
+
+ /**
+ * keyboard event constant representing the UP ARROW key
+ * (value is (1<<24)+1)
+ */
+ public static final int ARROW_UP = (1 << 24) + 1;
+
+ /**
+ * keyboard event constant representing the DOWN ARROW key
+ * (value is (1<<24)+2)
+ */
+ public static final int ARROW_DOWN = (1 << 24) + 2;
+
+ /**
+ * keyboard event constant representing the LEFT ARROW key
+ * (value is (1<<24)+3)
+ */
+ public static final int ARROW_LEFT = (1 << 24) + 3;
+
+ /**
+ * keyboard event constant representing the RIGHT ARROW key
+ * (value is (1<<24)+4)
+ */
+ public static final int ARROW_RIGHT = (1 << 24) + 4;
+
+ /**
+ * keyboard event constant representing the PAGE UP key
+ * (value is (1<<24)+5)
+ */
+ public static final int PAGE_UP = (1 << 24) + 5;
+
+ /**
+ * keyboard event constant representing the PAGE DOWN key
+ * (value is (1<<24)+6)
+ */
+ public static final int PAGE_DOWN = (1 << 24) + 6;
+
+ /**
+ * keyboard event constant representing the HOME key
+ * (value is (1<<24)+7)
+ */
+ public static final int HOME = (1 << 24) + 7;
+
+ /**
+ * keyboard event constant representing the END key
+ * (value is (1<<24)+8)
+ */
+ public static final int END = (1 << 24) + 8;
+
+ /**
+ * keyboard event constant representing the INSERT key
+ * (value is (1<<24)+9)
+ */
+ public static final int INSERT = (1 << 24) + 9;
+
+ /**
+ * keyboard event constant representing the F1 key
+ * (value is (1<<24)+10)
+ */
+ public static final int F1 = (1 << 24) + 10;
+
+ /**
+ * keyboard event constant representing the F2 key
+ * (value is (1<<24)+11)
+ */
+ public static final int F2 = (1 << 24) + 11;
+
+ /**
+ * keyboard event constant representing the F3 key
+ * (value is (1<<24)+12)
+ */
+ public static final int F3 = (1 << 24) + 12;
+
+ /**
+ * keyboard event constant representing the F4 key
+ * (value is (1<<24)+13)
+ */
+ public static final int F4 = (1 << 24) + 13;
+
+ /**
+ * keyboard event constant representing the F5 key
+ * (value is (1<<24)+14)
+ */
+ public static final int F5 = (1 << 24) + 14;
+
+ /**
+ * keyboard event constant representing the F6 key
+ * (value is (1<<24)+15)
+ */
+ public static final int F6 = (1 << 24) + 15;
+
+ /**
+ * keyboard event constant representing the F7 key
+ * (value is (1<<24)+16)
+ */
+ public static final int F7 = (1 << 24) + 16;
+
+ /**
+ * keyboard event constant representing the F8 key
+ * (value is (1<<24)+17)
+ */
+ public static final int F8 = (1 << 24) + 17;
+
+ /**
+ * keyboard event constant representing the F9 key
+ * (value is (1<<24)+18)
+ */
+ public static final int F9 = (1 << 24) + 18;
+
+ /**
+ * keyboard event constant representing the F10 key
+ * (value is (1<<24)+19)
+ */
+ public static final int F10 = (1 << 24) + 19;
+
+ /**
+ * keyboard event constant representing the F11 key
+ * (value is (1<<24)+20)
+ */
+ public static final int F11 = (1 << 24) + 20;
+
+ /**
+ * keyboard event constant representing the F12 key
+ * (value is (1<<24)+21)
+ */
+ public static final int F12 = (1 << 24) + 21;
+
+ /**
+ * <code>MessageBox</code> style constant for error icon
+ * behavior (value is 1)
+ */
+ public static final int ICON_ERROR = 1;
+
+ /**
+ * <code>MessageBox</code> style constant for information icon
+ * behavior (value is 1<<1)
+ */
+ public static final int ICON_INFORMATION = 1 << 1;
+
+ /**
+ * <code>MessageBox</code> style constant for question icon
+ * behavior (value is 1<<2)
+ */
+ public static final int ICON_QUESTION = 1 << 2;
+
+ /**
+ * <code>MessageBox</code> style constant for warning icon
+ * behavior (value is 1<<3)
+ */
+ public static final int ICON_WARNING = 1 << 3;
+
+ /**
+ * <code>MessageBox</code> style constant for "working" icon
+ * behavior (value is 1<<1)
+ */
+ public static final int ICON_WORKING = 1 << 4;
+
+ /**
+ * <code>MessageBox</code> style constant for an OK button.
+ * Valid combinations are OK, OK|CANCEL
+ * (value is 1<<5)
+ */
+ public static final int OK = 1 << 5;
+
+ /**
+ * <code>MessageBox</code> style constant for YES button.
+ * Valid combinations are YES|NO, YES|NO|CANCEL
+ * (value is 1<<6)
+ */
+ public static final int YES = 1 << 6;
+
+ /**
+ * <code>MessageBox</code> style constant for NO button.
+ * Valid combinations are YES|NO, YES|NO|CANCEL
+ * (value is 1<<7)
+ */
+ public static final int NO = 1 << 7;
+
+ /**
+ * <code>MessageBox</code> style constant for a CANCEL button.
+ * Valid combinations are OK|CANCEL, YES|NO|CANCEL, RETRY|CANCEL
+ * (value is 1<<8)
+ */
+ public static final int CANCEL = 1 << 8;
+
+ /**
+ * <code>MessageBox</code> style constant for an ABORT button.
+ * The only valid combination is ABORT|RETRY|IGNORE
+ * (value is 1<<9)
+ */
+ public static final int ABORT = 1 << 9;
+
+ /**
+ * <code>MessageBox</code> style constant for a RETRY button.
+ * Valid combinations are ABORT|RETRY|IGNORE, RETRY|CANCEL
+ * (value is 1<<10)
+ */
+ public static final int RETRY = 1 << 10;
+
+ /**
+ * <code>MessageBox</code> style constant for an IGNORE button.
+ * The only valid combination is ABORT|RETRY|IGNORE
+ * (value is 1<<11)
+ */
+ public static final int IGNORE = 1 << 11;
+
+ /**
+ * <code>FileDialog</code> style constant for open file dialog behavior
+ * (value is 1<<12)
+ */
+ public static final int OPEN = 1 << 12;
+
+ /**
+ * <code>FileDialog</code> style constant for save file dialog behavior
+ * (value is 1<<13)
+ */
+ public static final int SAVE = 1 << 13;
+
+ /**
+ * 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 yello (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;
+
+ /**
+ * 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 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 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. For additional
+ * information see the comment in <code>Widget.checkSubclass()</code>
+ * (value is 43)
+ *
+ * @see 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;
+
+ /**
+ * traversal event detail field value indicating that the ESC
+ * key was pressed (value is 1<<1)
+ */
+ public static final int TRAVERSE_ESCAPE = 1 << 1;
+
+ /**
+ * traversal event detail field value indicating that the ENTER
+ * key was pressed (value is 1<<2)
+ */
+ public static final int TRAVERSE_RETURN = 1 << 2;
+
+ /**
+ * traversal event detail field value indicating that the SHIFT-TAB
+ * key was pressed (value is 1<<3)
+ */
+ public static final int TRAVERSE_TAB_PREVIOUS = 1 << 3;
+
+ /**
+ * traversal event detail field value indicating that the TAB
+ * key was pressed (value is 1<<4)
+ */
+ public static final int TRAVERSE_TAB_NEXT = 1 << 4;
+
+ /**
+ * traversal event detail field value indicating that the LEFT-ARROW
+ * or UP-ARROW keys was pressed (value is 1<<5)
+ */
+ public static final int TRAVERSE_ARROW_PREVIOUS = 1 << 5;
+
+ /**
+ * traversal event detail field value indicating that the RIGHT-ARROW
+ * or DOWN-ARROW keys was pressed (value is 1<<6)
+ */
+ public static final int TRAVERSE_ARROW_NEXT = 1 << 6;
+
+ /**
+ * 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;
+
+ /**
+ * <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;
+
+ /**
+ * <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;
+
+ /**
+ * <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;
+
+ /**
+ * font style constant indicating a normal weight, non-italic font
+ * (value is 0)
+ */
+ public static final int NORMAL = 0;
+
+ /**
+ * font style constant indicating a bold weight font
+ * (value is 1<<0)
+ */
+ public static final int BOLD = 1 << 0;
+
+ /**
+ * font style constant indicating an italic font
+ * (value is 1<<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 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;
+
+ /**
+ * 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;
+
+ /**
+ * 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 no transparency information (value is 1<<0)
+ */
+ public static final int TRANSPARENCY_ALPHA = 1 << 0;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains no transparency information (value is 1<<1)
+ */
+ public static final int TRANSPARENCY_MASK = 1 << 1;
+
+ /**
+ * image transparency constant indicating that the image
+ * contains no transparency information (value is 1<<2)
+ */
+ public static final int TRANSPARENCY_PIXEL = 1 << 2;
+
+/**
+ * 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";
+ case ERROR_NO_HANDLES: return "No more handles";
+ case ERROR_NO_MORE_CALLBACKS: return "No more callbacks";
+ case ERROR_NULL_ARGUMENT: return "Argument cannot be null";
+ case ERROR_INVALID_ARGUMENT: return "Argument not valid";
+ case ERROR_INVALID_RANGE: return "Index out of bounds";
+ case ERROR_CANNOT_BE_ZERO: return "Argument cannot be zero";
+ case ERROR_CANNOT_GET_ITEM: return "Cannot get item";
+ case ERROR_CANNOT_GET_SELECTION: return "Cannot get selection";
+ case ERROR_CANNOT_GET_ITEM_HEIGHT: return "Cannot get item height";
+ case ERROR_CANNOT_GET_TEXT: return "Cannot get text";
+ case ERROR_CANNOT_SET_TEXT: return "Cannot set text";
+ case ERROR_ITEM_NOT_ADDED: return "Item not added";
+ case ERROR_ITEM_NOT_REMOVED: return "Item not removed";
+ case ERROR_NOT_IMPLEMENTED: return "Not implemented";
+ case ERROR_MENU_NOT_DROP_DOWN: return "Menu must be a drop down";
+ case ERROR_THREAD_INVALID_ACCESS: return "Invalid thread access";
+ case ERROR_WIDGET_DISPOSED: return "Widget is disposed";
+ case ERROR_MENUITEM_NOT_CASCADE: return "Menu item is not a CASCADE";
+ case ERROR_CANNOT_SET_SELECTION: return "Cannot set selection";
+ case ERROR_CANNOT_SET_MENU: return "Cannot set menu";
+ case ERROR_CANNOT_SET_ENABLED: return "Cannot set the enabled state";
+ case ERROR_CANNOT_GET_ENABLED: return "Cannot get the enabled state";
+ case ERROR_INVALID_PARENT: return "Widget has the wrong parent";
+ case ERROR_MENU_NOT_BAR: return "Menu is not a BAR";
+ case ERROR_CANNOT_GET_COUNT: return "Cannot get count";
+ case ERROR_MENU_NOT_POP_UP: return "Menu is not a POP_UP";
+ case ERROR_UNSUPPORTED_DEPTH: return "Unsupported color depth";
+ case ERROR_IO: return "i/o error";
+ case ERROR_INVALID_IMAGE: return "Invalid image";
+ case ERROR_UNSUPPORTED_FORMAT: return "Unsupported or unrecognized format";
+ case ERROR_INVALID_SUBCLASS: return "Subclassing not allowed";
+ case ERROR_GRAPHIC_DISPOSED: return "Graphic is disposed";
+ case ERROR_DEVICE_DISPOSED: return "Device is disposed";
+ }
+ return "Unknown error";
+}
+
+/**
+ * Answers the SWT platform name.
+ * Examples: "win32", "motif", "gtk", "photon"
+ *
+ * @return the SWT version number
+ */
+public static String getPlatform () {
+ return Callback.getPlatform ();
+}
+
+/**
+ * Answers the SWT version number as an integer.
+ * Example: "SWT051" == 51
+ *
+ * @return the SWT version number
+ */
+public static int getVersion () {
+ return Callback.getVersion ();
+}
+
+/**
+ * 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) {
+
+ // 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.
+ if (throwable instanceof SWTError) throw (SWTError) throwable;
+ if (throwable instanceof SWTException) throw (SWTException) throwable;
+
+ 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 (findErrorText (code));
+ }
+
+ // SWT Errors (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_IO: {
+ SWTException exception = new SWTException (code);
+ exception.throwable = throwable;
+ throw exception;
+ }
+
+ // OS Failure/Limit (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 Failure/Limit (fatal, may occur only on some platforms)
+ case ERROR_NO_MORE_CALLBACKS:
+ case ERROR_NOT_IMPLEMENTED:
+ case ERROR_UNSPECIFIED: {
+ SWTError error = new SWTError (code);
+ error.throwable = throwable;
+ throw error;
+ }
+ }
+
+ // Unknown/Undefined Error
+ SWTError error = new SWTError (code);
+ error.throwable = throwable;
+ throw error;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java
new file mode 100755
index 0000000000..5dd494f2db
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTError.java
@@ -0,0 +1,80 @@
+package org.eclipse.swt;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+
+public class SWTError extends Error {
+ public int code;
+ public Throwable throwable;
+
+/**
+ * Constructs a new instance of this class with its
+ * walkback 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
+ * walkback and message filled in. The error code is
+ * set to an unspecified value.
+ *
+ * @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
+ * walkback 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
+ * walkback, error code and message filled in.
+ *
+ * @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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java
new file mode 100755
index 0000000000..7f04b7c9fd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWTException.java
@@ -0,0 +1,73 @@
+package org.eclipse.swt;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+
+public class SWTException extends RuntimeException {
+ public int code;
+ public Throwable throwable;
+
+/**
+ * Constructs a new instance of this class with its
+ * walkback 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
+ * walkback and message filled in. The error code is
+ * set to an unspecified value.
+ *
+ * @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
+ * walkback 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
+ * walkback, error code and message filled in.
+ *
+ * @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;
+}
+
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java
new file mode 100755
index 0000000000..339b4de0c2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmEvent.java
@@ -0,0 +1,29 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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
+ */
+
+public final class ArmEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java
new file mode 100755
index 0000000000..44dda803cc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ArmListener.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlAdapter.java
new file mode 100755
index 0000000000..231baa31fb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlAdapter.java
@@ -0,0 +1,40 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java
new file mode 100755
index 0000000000..22af9a8e0f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlEvent.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * controls being moved or resized.
+ *
+ * @see ControlListener
+ */
+
+public final class ControlEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java
new file mode 100755
index 0000000000..63ca027961
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ControlListener.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java
new file mode 100755
index 0000000000..2bcac89d4e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets being disposed.
+ *
+ * @see DisposeListener
+ */
+
+public final class DisposeEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java
new file mode 100755
index 0000000000..586a3f467f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/DisposeListener.java
@@ -0,0 +1,33 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * Sent when the widget is disposed.
+ *
+ * @param e an event containing information about the dispose
+ */
+public void widgetDisposed(DisposeEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusAdapter.java
new file mode 100755
index 0000000000..d3e04295ec
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusAdapter.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusEvent.java
new file mode 100755
index 0000000000..997d6d81fa
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets gaining and losing focus.
+ *
+ * @see FocusListener
+ */
+
+public final class FocusEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusListener.java
new file mode 100755
index 0000000000..d0c16d1244
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/FocusListener.java
@@ -0,0 +1,42 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpEvent.java
new file mode 100755
index 0000000000..d8a1666022
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * help being requested for a widget.
+ *
+ * @see HelpListener
+ */
+
+public final class HelpEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpListener.java
new file mode 100755
index 0000000000..bfd2c6587f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/HelpListener.java
@@ -0,0 +1,34 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyAdapter.java
new file mode 100755
index 0000000000..fda909927f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyAdapter.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyEvent.java
new file mode 100755
index 0000000000..876c9a50c4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyEvent.java
@@ -0,0 +1,48 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * keys being pressed and released on the keyboard
+ *
+ * @see KeyListener
+ */
+
+public class KeyEvent extends TypedEvent {
+
+ /**
+ * the character represented by the key that was typed
+ */
+ public char character;
+
+ /**
+ * the key code of the key that was typed
+ */
+ public int keyCode;
+
+ /**
+ * the state of the keyboard modifier keys at the time
+ * the event was generated
+ */
+ public int stateMask;
+
+/**
+ * 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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyListener.java
new file mode 100755
index 0000000000..84b4cd1219
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/KeyListener.java
@@ -0,0 +1,41 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuAdapter.java
new file mode 100755
index 0000000000..14fe8a5f32
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuAdapter.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuEvent.java
new file mode 100755
index 0000000000..c0a144000f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * menus being shown and hidden.
+ *
+ * @see MenuListener
+ */
+
+public final class MenuEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuListener.java
new file mode 100755
index 0000000000..d88f93245d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MenuListener.java
@@ -0,0 +1,40 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 control using the
+ * <code>addMenuListener</code> method and removed using
+ * the <code>removeMenuListener</code> method. When a
+ * menu is hidden or shown, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see MenuAdapter
+ * @see MenuEvent
+ */
+public interface MenuListener extends EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyEvent.java
new file mode 100755
index 0000000000..b71249856a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * text being modified.
+ *
+ * @see ModifyListener
+ */
+
+public final class ModifyEvent extends TypedEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyListener.java
new file mode 100755
index 0000000000..e95b010440
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ModifyListener.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * Sent when the text is modified.
+ *
+ * @param e an event containing information about the modify
+ */
+public void modifyText(ModifyEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseAdapter.java
new file mode 100755
index 0000000000..3b10ac7b45
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseAdapter.java
@@ -0,0 +1,52 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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 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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseEvent.java
new file mode 100755
index 0000000000..eed4fbf8cc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseEvent.java
@@ -0,0 +1,68 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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
+ */
+
+public final 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;
+
+/**
+ * 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;
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseListener.java
new file mode 100755
index 0000000000..dc86605ff6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseListener.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseMoveListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseMoveListener.java
new file mode 100755
index 0000000000..39a07d16f5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseMoveListener.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * Sent when the mouse moves.
+ *
+ * @param e an event containing information about the mouse move
+ */
+public void mouseMove(MouseEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackAdapter.java
new file mode 100755
index 0000000000..40e7e21888
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackAdapter.java
@@ -0,0 +1,53 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+public 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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackListener.java
new file mode 100755
index 0000000000..6ed12dbfbe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/MouseTrackListener.java
@@ -0,0 +1,53 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintEvent.java
new file mode 100755
index 0000000000..2d25d9d2d2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintEvent.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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
+ */
+
+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;
+
+/**
+ * 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;
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintListener.java
new file mode 100755
index 0000000000..af30ca399d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/PaintListener.java
@@ -0,0 +1,33 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * Sent when a paint event occurs for the control.
+ *
+ * @param e an event containing information about the paint
+ */
+public void paintControl(PaintEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionAdapter.java
new file mode 100755
index 0000000000..7dec1624a1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionAdapter.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionEvent.java
new file mode 100755
index 0000000000..d86a6dbf66
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionEvent.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Widget;
+
+/**
+ * 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
+ */
+
+public class SelectionEvent extends TypedEvent {
+
+ /**
+ * the item that was selected
+ */
+ public Widget item;
+
+ /**
+ * extra detail information about the selection
+ */
+ 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;
+
+ /**
+ * a flag indicating whether the operation should be allowed
+ */
+ public boolean doit;
+
+/**
+ * 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.doit = e.doit;
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java
new file mode 100755
index 0000000000..a65a2fc88b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/SelectionListener.java
@@ -0,0 +1,50 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * Sent when selection occurs in the control.
+ * <p>
+ * For example, on some platforms selection occurs in
+ * a List when the user selects an item or items.
+ * </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.
+ * </p>
+ *
+ * @param e an event containing information about the default selection
+ */
+public void widgetDefaultSelected(SelectionEvent e);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java
new file mode 100755
index 0000000000..567187ff2d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellAdapter.java
@@ -0,0 +1,66 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellEvent.java
new file mode 100755
index 0000000000..c73d2a067b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * operations being performed on shells.
+ *
+ * @see ShellListener
+ */
+
+public final class ShellEvent extends TypedEvent {
+
+ /**
+ * a flag indicating whether the operation should be allowed
+ */
+ public boolean doit;
+
+public ShellEvent(Event e) {
+ super(e);
+ this.doit = e.doit;
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellListener.java
new file mode 100755
index 0000000000..ee4f76cca6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/ShellListener.java
@@ -0,0 +1,61 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 control using the
+ * <code>addShellListener</code> method and removed using
+ * the <code>removeShellListener</code> method. When the
+ * state of a shell changes, the appropriate method will
+ * be invoked.
+ * </p>
+ *
+ * @see ShellAdapter
+ * @see ShellEvent
+ */
+public interface ShellListener extends EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseEvent.java
new file mode 100755
index 0000000000..26e378a961
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseEvent.java
@@ -0,0 +1,41 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widget traversal actions.
+ *
+ * @see TraverseListener
+ */
+
+public class TraverseEvent extends KeyEvent {
+
+ /**
+ * the type of traversal
+ */
+ public int detail;
+
+ /**
+ * a flag indicating whether the operation should be allowed
+ */
+ public boolean doit;
+
+/**
+ * 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.doit = e.doit;
+ this.detail = e.detail;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseListener.java
new file mode 100755
index 0000000000..f78fcdb0eb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TraverseListener.java
@@ -0,0 +1,40 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeAdapter.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeAdapter.java
new file mode 100755
index 0000000000..f6c6d6867d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeAdapter.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+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) {
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeEvent.java
new file mode 100755
index 0000000000..eb64963477
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeEvent.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * trees being expanded and collapsed.
+ *
+ * @see TreeListener
+ */
+
+public final class TreeEvent extends SelectionEvent {
+
+/**
+ * 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);
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeListener.java
new file mode 100755
index 0000000000..77b0cdce84
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TreeListener.java
@@ -0,0 +1,41 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 control using the
+ * <code>addTreeListener</code> method and removed using
+ * the <code>removeTreeListener</code> method. When a branch
+ * of a tree is expanded or collapsed, the appropriate method
+ * will be invoked.
+ * </p>
+ *
+ * @see TreeAdapter
+ * @see TreeEvent
+ */
+public interface TreeListener extends EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TypedEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TypedEvent.java
new file mode 100755
index 0000000000..19b53c21ef
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/TypedEvent.java
@@ -0,0 +1,56 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.*;
+import java.util.EventObject;
+
+/**
+ * This is the super class for all typed event classes provided
+ * by SWT. Typed events contain particular information which is
+ * applicable to the event occurance.
+ *
+ * @see org.eclipse.swt.widgets.Event
+ */
+public class TypedEvent extends EventObject {
+
+ /**
+ * the widget that issued the event
+ */
+ public Widget widget;
+
+ /**
+ * the time that the event occurred
+ */
+ public int time;
+
+ /**
+ * a field for application use
+ */
+ public Object data;
+
+/**
+ * Constructs a new instance of this class.
+ *
+ * @param source 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.widget = e.widget;
+ this.time = e.time;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyEvent.java
new file mode 100755
index 0000000000..40aaa43e8d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyEvent.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.widgets.Event;
+
+/**
+ * Instances of this class are sent as a result of
+ * widgets handling keyboard events
+ *
+ * @see VerifyListener
+ */
+
+public final class VerifyEvent extends KeyEvent {
+
+ /**
+ * the range of text being modified
+ */
+ public int start, end;
+
+ /**
+ * the new text that will be inserted
+ */
+ public String text;
+
+ /**
+ * a flag indicating whether the operation should be allowed
+ */
+ public boolean doit;
+
+/**
+ * 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.character = e.character;
+ this.keyCode = e.keyCode;
+ this.stateMask = e.stateMask;
+ this.start = e.start;
+ this.end = e.end;
+ this.text = e.text;
+ this.doit = e.doit;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyListener.java
new file mode 100755
index 0000000000..b2d18ad8fc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/VerifyListener.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.events;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 widget 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 EventListener {
+
+/**
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html
new file mode 100755
index 0000000000..6cb72031fc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/events/package.html
@@ -0,0 +1,22 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT <em>typed listener</em> support.
+<h2>
+Package Specification</h2>
+This package provides the typed events and listener interfaces and,
+where appropriate, matching adapter classes which make up the
+"high level" <em>typed listener</em> support provided by SWT.
+<p>
+For contrast, see also the <em>untyped listener</em> support provided
+by class <code>org.eclipse.swt.widgets.Event</code> and interface
+<code>org.eclipse.swt.widgets.Listener</code>, and the
+<code>addListener</code> and <code>removeListener</code> methods in
+class <code>org.eclipse.swt.widgets.Widget</code>.
+</p>
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java
new file mode 100755
index 0000000000..08a180c95e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Drawable.java
@@ -0,0 +1,45 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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
+ *
+ * @private
+ */
+
+public int 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
+ *
+ * @private
+ */
+public void internal_dispose_GC (int handle, GCData data);
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
new file mode 100755
index 0000000000..cc455ff417
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageData.java
@@ -0,0 +1,3451 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+import java.io.*;
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.image.*;
+
+/**
+ * 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.
+ *
+ * @see Image
+ * @see ImageLoader
+ */
+
+public final class ImageData implements Cloneable {
+
+ /**
+ * 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
+ */
+ public int depth;
+
+ /**
+ * the scanline padding. If one scanline of the image
+ * is not a multiple of this number, it will be padded
+ * with zeros until it is
+ */
+ public int scanlinePad;
+
+ /**
+ * the number of bytes per scanline. This is a multiple
+ * of the scanline padding
+ */
+ public int bytesPerLine;
+
+ /**
+ * the pixel data of the image
+ */
+ public byte[] data;
+
+ /**
+ * the color table for the image
+ */
+ public PaletteData palette;
+
+ /**
+ * the transparent pixel. Pixels with this value are transparent.
+ * The default is -1 which means 'no transparency'
+ */
+ public int transparentPixel;
+
+ /**
+ * icon-specific field containing the data from the icon mask
+ */
+ public byte[] maskData;
+
+ /**
+ * icon-specific field containing the scanline pad of the mask
+ */
+ public int maskPad;
+
+ /**
+ * the alpha data of the image. Every pixel can have an
+ * <em>alpha blending</em> value that varies from 0, meaning
+ * fully transparent, to 255 meaning fully opaque
+ */
+ public byte[] alphaData;
+
+ /**
+ * the global alpha value to be used for every pixel.
+ * If this value is set the <code>alphaData</code> field
+ * is ignored. The default is -1 which means 'no global alpha
+ * value'
+ */
+ public int alpha;
+
+ /**
+ * the type of file that the image was read in from,
+ * 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, 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;
+
+/**
+ * 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</li>
+ * <li>ERROR_NULL_ARGUMENT - if the palette is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH - if the depth argument is not one of 1, 2, 4, 8, 16, 24 or 32</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</li>
+ * <li>ERROR_NULL_ARGUMENT - if the palette or data is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_UNSUPPORTED_DEPTH - if the depth argument is not one of 1, 2, 4, 8, 16, 24 or 32</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.
+ * <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>
+ *
+ * @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_INVALID_IMAGE - if the image file contains invalid data</li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ *
+ * @see ImageLoader#load
+ */
+public ImageData(InputStream stream) {
+ ImageData[] data = new ImageLoader().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_INVALID_IMAGE - if the image file contains invalid data</li>
+ * <li>ERROR_IO if an IO error occurs while reading data</li>
+ * </ul>
+ */
+public ImageData(String filename) {
+ ImageData[] data = new ImageLoader().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);
+ }
+ int bytesPerLine = (((width * depth + 7) / 8) + (scanlinePad - 1))
+ / scanlinePad * scanlinePad;
+ 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>
+ *
+ * @private
+ */
+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(),
+ Image.DEFAULT_SCANLINE_PAD, 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.
+ *
+ * @param x the x coodinate 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>.
+ *
+ * @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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if <code>x</code> or <code>y</code> is out of bounds</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) return;
+ if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ if (alphaData == null) {
+ int endIndex = startIndex + getWidth;
+ for (int i = startIndex; i < endIndex; i++) {
+ alphas[i] = (byte)255;
+ }
+ return;
+ }
+ 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;
+ if (depth == 1) {
+ index = (y * bytesPerLine) + (x >> 3);
+ theByte = data[index] & 0xFF;
+ mask = 1 << (7 - (x & 0x7));
+ if ((theByte & mask) == 0) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ if (depth == 2) {
+ index = (y * bytesPerLine) + (x >> 2);
+ theByte = data[index] & 0xFF;
+ int offset = 3 - (x % 4);
+ mask = 3 << (offset * 2);
+ return (theByte & mask) >> (offset * 2);
+ }
+ if (depth == 4) {
+ index = (y * bytesPerLine) + (x >> 1);
+ theByte = data[index] & 0xFF;
+ if ((x & 0x1) == 0) {
+ return theByte >> 4;
+ } else {
+ return theByte & 0x0F;
+ }
+ }
+ if (depth == 8) {
+ index = (y * bytesPerLine) + x ;
+ return data[index] & 0xFF;
+ }
+ if (depth == 16) {
+ index = (y * bytesPerLine) + (x * 2);
+ return ((data[index+1] & 0xFF) << 8) + (data[index] & 0xFF);
+ }
+ if (depth == 24) {
+ index = (y * bytesPerLine) + (x * 3);
+ return ((data[index] & 0xFF) << 16) + ((data[index+1] & 0xFF) << 8) +
+ (data[index+2] & 0xFF);
+ }
+ if (depth == 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);
+ }
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <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 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) return;
+ if (x >= width || y >= height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int index;
+ int theByte;
+ int mask = 0;
+ int n = getWidth;
+ int i = startIndex;
+ int srcX = x, srcY = y;
+ if (depth == 1) {
+ index = (y * bytesPerLine) + (x >> 3);
+ theByte = data[index] & 0xFF;
+ while (n > 1) {
+ 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <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 getPixels(int x, int y, int getWidth, int[] pixels, int startIndex) {
+ if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (getWidth <= 0) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int index;
+ int theByte;
+ int mask;
+ int n = getWidth;
+ int i = startIndex;
+ int srcX = x, srcY = y;
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ 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, or null if the
+ * receiver has no transparency and is not an icon.
+ *
+ * @return the transparency mask or null if none exists
+ */
+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.
+ *
+ * @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 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,
+ * and then scale all of the data. */
+ ImageData destImage = new ImageData(
+ width, height, depth, palette,
+ scanlinePad, null, 0, null,
+ null, -1, transparentPixel, type,
+ x, y, disposalMethod, delayTime);
+ scaleImage(destImage, 0, 0, this.width, this.height, 0, 0, width, height);
+ return destImage;
+}
+
+void scaleImage(ImageData destImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ boolean flipX, flipY;
+ /* Flip rects if necessary so that src width and height are positive. */
+ if (srcWidth < 0) {
+ srcWidth = -srcWidth;
+ srcX = srcX - srcWidth;
+ destWidth = -destWidth;
+ destX = destX - destWidth;
+ }
+ if (srcHeight < 0) {
+ srcHeight = -srcHeight;
+ srcY = srcY - srcHeight;
+ destHeight = -destHeight;
+ destY = destY - destHeight;
+ }
+ /* Ensure dest width and height are positive, remembering whether to flip. */
+ flipX = destWidth < 0;
+ if (flipX) {
+ destWidth = -destWidth;
+ destX = destX - destWidth;
+ }
+ flipY = destHeight < 0;
+ if (flipY) {
+ destHeight = -destHeight;
+ destY = destY - destHeight;
+ }
+ /* Check source rect bounds. Succeed with 0 if out of bounds, rather
+ * than failing.
+ */
+ if (srcX < 0 || srcY < 0 || (srcX + srcWidth > width) ||
+ (srcY + srcHeight > height)) {
+ return;
+ }
+ if (destX < 0 || destY < 0 || (destX + destWidth > destImage.width) ||
+ (destY + destHeight > destImage.height)) {
+ return;
+ }
+ /* If dest rect is 0, there is nothing to do. */
+ if (destWidth == 0 || destHeight == 0) {
+ return;
+ }
+ switch (depth) {
+ case 1:
+ stretch1(data, bytesPerLine, MSB_FIRST, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, MSB_FIRST, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 2:
+ stretch2(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ break;
+ case 4:
+ stretch4(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ break;
+ case 8:
+ stretch8(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ break;
+ case 16:
+ stretch16(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 24:
+ stretch24(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 32:
+ stretch32(data, bytesPerLine, srcX, srcY, srcWidth, srcHeight, destImage.data, destImage.bytesPerLine, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ if (getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ destImage.maskPad = maskPad;
+ int destBpl = (destWidth + 7) / 8;
+ destBpl = (destBpl + (maskPad - 1)) / maskPad * maskPad;
+ destImage.maskData = new byte[destBpl * destHeight];
+ int srcBpl = (srcWidth + 7) / 8;
+ srcBpl = (srcBpl + (maskPad - 1)) / maskPad * maskPad;
+ stretch1(maskData, srcBpl, MSB_FIRST, srcX, srcY, srcWidth, srcHeight, destImage.maskData, destBpl, MSB_FIRST, destX, destY, destWidth, destHeight, flipX, flipY);
+ } else if (alpha != -1) {
+ destImage.alpha = alpha;
+ } else if (alphaData != null) {
+ destImage.alphaData = new byte[destImage.width * destImage.height];
+ stretch8(alphaData, width, srcX, srcY, srcWidth, srcHeight, destImage.alphaData, destImage.width, destX, destY, destWidth, destHeight, null, flipX, flipY);
+ }
+}
+
+/**
+ * Sets the alpha value at offset <code>x</code> in
+ * scanline <code>y</code> in the receiver's alpha data.
+ *
+ * @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>.
+ *
+ * @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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <li>ERROR_INVALID_ARGUMENT - if x or y is out of bounds</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) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ if (alphaData == null) alphaData = new byte[width * height];
+ 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;
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 8) {
+ index = (y * bytesPerLine) + x ;
+ data[index] = (byte)(pixelValue & 0xFF);
+ return;
+ }
+ if (depth == 16) {
+ index = (y * bytesPerLine) + (x * 2);
+ data[index + 1] = (byte)((pixelValue >> 8) & 0xFF);
+ data[index] = (byte)(pixelValue & 0xFF);
+ return;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <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
+ * (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) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int index;
+ int theByte;
+ int mask;
+ int n = putWidth;
+ int i = startIndex;
+ int pixel;
+ int srcX = x, srcY = y;
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ 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 IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if pixels is null</li>
+ * <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 setPixels(int x, int y, int putWidth, int[] pixels, int startIndex) {
+ if (pixels == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (putWidth <= 0) return;
+ if (x > width || y > height || x < 0 || y < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int index;
+ int theByte;
+ int mask;
+ int n = putWidth;
+ int i = startIndex;
+ int pixel;
+ int srcX = x, srcY = y;
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ if (depth == 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;
+ }
+ 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)});
+}
+
+/**
+ * Blit operations.
+ */
+static final int BLIT_SRC = 1;
+static final int BLIT_ALPHA = 2;
+/**
+ * Byte and bit order constants.
+ */
+static final int MSB_FIRST = 1;
+static final int LSB_FIRST = 2;
+
+/**
+ * Masks for blitting.
+ */
+static final byte[] msbMasks1 = {
+ (byte)0x80, (byte)0x40, (byte)0x20, (byte)0x10,
+ (byte)0x08, (byte)0x04, (byte)0x02, (byte)0x01
+};
+static final byte[] lsbMasks1 = {
+ (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x08,
+ (byte)0x10, (byte)0x20, (byte)0x40, (byte)0x80
+};
+static final byte[] msbInverseMasks1 = {
+ (byte)0x7F, (byte)0xBF, (byte)0xDF, (byte)0xEF,
+ (byte)0xF7, (byte)0xFB, (byte)0xFD, (byte)0xFE
+};
+static final byte[] lsbInverseMasks1 = {
+ (byte)0xFE, (byte)0xFD, (byte)0xFB, (byte)0xF7,
+ (byte)0xEF, (byte)0xDF, (byte)0xBF, (byte)0x7F
+};
+static final byte[] masks2 = {
+ (byte)0x03, (byte)0x0C, (byte)0x30, (byte)0xC0
+};
+static final byte[] inverseMasks2 = {
+ (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F
+};
+
+/**
+ * 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;
+}
+
+/**
+ * Blits a direct palette image into a direct palette image.
+ */
+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 srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, 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) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ short so0 = 0, so1 = 1, so2 = 2, so3 = 3;
+ short do0 = 0, do1 = 1, do2 = 2, do3 = 3;
+ int srcRedShift, srcGreenShift, srcBlueShift;
+ int destRedShift, destGreenShift, destBlueShift;
+
+ if (op == BLIT_SRC && srcDepth == destDepth &&
+ srcRedMask == destRedMask &&
+ srcGreenMask == destGreenMask &&
+ srcBlueMask == destBlueMask)
+ {
+ switch (srcDepth) {
+ case 16:
+ stretch16(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 24:
+ stretch24(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 32:
+ stretch32(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ }
+ return;
+ }
+
+ srcRedShift = 32 - getMSBOffset(srcRedMask);
+ srcGreenShift = 32 - getMSBOffset(srcGreenMask);
+ srcBlueShift = 32 - getMSBOffset(srcBlueMask);
+ destRedShift = 32 - getMSBOffset(destRedMask);
+ destGreenShift = 32 - getMSBOffset(destGreenMask);
+ destBlueShift = 32 - getMSBOffset(destBlueMask);
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 16: so0 = 1; so1 = 0; break;
+ case 24: so0 = 2; so1 = 1; so2 = 0; break;
+ case 32: so0 = 3; so1 = 2; so2 = 1; so3 = 0; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 16: do0 = 1; do1 = 0; break;
+ case 24: do0 = 2; do1 = 1; do2 = 0; break;
+ case 32: do0 = 3; do1 = 2; do2 = 1; do3 = 0; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ sxs *= srcDepth / 8;
+ xs1 *= srcDepth / 8;
+ sxd *= destDepth / 8;
+ xd1 *= destDepth / 8;
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride + xd1;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
+ break;
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
+ break;
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
+ break;
+ }
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
+ break;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
+ break;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
+ break;
+ }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ destPixel =
+ (((dr << 24) >> destRedShift) & destRedMask) |
+ (((dg << 24) >> destGreenShift) & destGreenMask) |
+ (((db << 24) >> destBlueShift) & destBlueMask);
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ dp += sxd;
+ ex += dxs2;
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
+ break;
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
+ break;
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
+ break;
+ }
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
+ break;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
+ break;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
+ break;
+ }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ destPixel =
+ (((dr << 24) >> destRedShift) & destRedMask) |
+ (((dg << 24) >> destGreenShift) & destGreenMask) |
+ (((db << 24) >> destBlueShift) & destBlueMask);
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Blits an index palette image into a direct palette image.
+ */
+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 srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, 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) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ short do0 = 0, do1 = 1, do2 = 2, do3 = 3;
+ int destRedShift, destGreenShift, destBlueShift;
+ int i, offset = 0;
+ byte[] srcMasks = null;
+ int srcN = 1 << srcDepth;
+ int[] mapping = null;
+
+ destRedShift = 32 - getMSBOffset(destRedMask);
+ destGreenShift = 32 - getMSBOffset(destGreenMask);
+ destBlueShift = 32 - getMSBOffset(destBlueMask);
+ if (srcReds != null && srcN > srcReds.length) srcN = srcReds.length;
+ if (op == BLIT_SRC) {
+ mapping = new int[srcN];
+ for (i = 0; i < srcN; i++) {
+ dr = srcReds[i] & 0xFF;
+ dg = srcGreens[i] & 0xFF;
+ db = srcBlues[i] & 0xFF;
+ mapping[i] =
+ (((dr << 24) >>> destRedShift) & destRedMask) |
+ (((dg << 24) >>> destGreenShift) & destGreenMask) |
+ (((db << 24) >>> destBlueShift) & destBlueMask);
+ }
+ }
+ switch (srcDepth) {
+ case 1: srcMasks = msbMasks1; break;
+ case 2: srcMasks = masks2; break;
+ }
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 1: srcMasks = lsbMasks1; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 16: do0 = 1; do1 = 0; break;
+ case 24: do0 = 2; do1 = 1; do2 = 0; break;
+ case 32: do0 = 3; do1 = 2; do2 = 1; do3 = 0; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ sxd *= destDepth / 8;
+ xd1 *= destDepth / 8;
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xs = xs1;
+ sp = ys * srcStride;
+ dp = yd * destStride + xd1;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
+ break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
+ }
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
+ break;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
+ break;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
+ break;
+ }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ destPixel =
+ (((dr << 24) >>> destRedShift) & destRedMask) |
+ (((dg << 24) >>> destGreenShift) & destGreenMask) |
+ (((db << 24) >>> destBlueShift) & destBlueMask);
+ }
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ xs += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ dp += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
+ break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
+ }
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 16:
+ destPixel = ((destData[dp+do0] & 0xFF) << 8) | (destData[dp+do1] & 0xFF);
+ break;
+ case 24:
+ destPixel = ((destData[dp+do0] & 0xFF) << 16) | ((destData[dp+do1] & 0xFF) << 8) |
+ (destData[dp+do2] & 0xFF);
+ break;
+ case 32:
+ destPixel = ((destData[dp+do0] & 0xFF) << 24) | ((destData[dp+do1] & 0xFF) << 16) |
+ ((destData[dp+do2] & 0xFF) << 8) | (destData[dp+do3] & 0xFF);
+ break;
+ }
+ dr = ((destPixel & destRedMask) << destRedShift) >>> 24;
+ dg = ((destPixel & destGreenMask) << destGreenShift) >>> 24;
+ db = ((destPixel & destBlueMask) << destBlueShift) >>> 24;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ destPixel =
+ (((dr << 24) >>> destRedShift) & destRedMask) |
+ (((dg << 24) >>> destGreenShift) & destGreenMask) |
+ (((db << 24) >>> destBlueShift) & destBlueMask);
+ }
+ switch (destDepth) {
+ case 16:
+ destData[dp + do0] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do1] = (byte)(destPixel & 0xFF);
+ break;
+ case 24:
+ destData[dp + do0] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do2] = (byte)(destPixel & 0xFF);
+ break;
+ case 32:
+ destData[dp + do0] = (byte)((destPixel >> 24) & 0xFF);
+ destData[dp + do1] = (byte)((destPixel >> 16) & 0xFF);
+ destData[dp + do2] = (byte)((destPixel >> 8) & 0xFF);
+ destData[dp + do3] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Blits an index palette image into an index palette image.
+ */
+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 srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, 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) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ int i, j, offset = 0;
+ byte[] srcMasks = null, destMasks = null, destInverseMasks = null;
+ int destN = 1 << destDepth, srcN = 1 << srcDepth;
+ int r, g, b, nearestPixel = 0, lastPixel = -1;
+ int distance, minDistance;
+ int[] mapping = null;
+ boolean samePalette = srcReds == destReds && srcGreens == destGreens && srcBlues == srcBlues;
+ boolean sameAsSrc = op == BLIT_SRC && samePalette && srcDepth <= destDepth;
+
+ if (srcReds != null && srcN > srcReds.length) srcN = srcReds.length;
+ if (destReds != null && destN > destReds.length) destN = destReds.length;
+ if (op == BLIT_SRC && srcReds != null) {
+ mapping = new int[srcN];
+ for (i = 0; i < srcN; i++) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - (srcReds[i] & 0xFF);
+ g = (destGreens[j] & 0xFF) - (srcGreens[i] & 0xFF);
+ b = (destBlues[j] & 0xFF) - (srcBlues[i] & 0xFF);
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ mapping[i] = nearestPixel;
+ }
+ }
+ if (op == BLIT_SRC && srcDepth == destDepth && (mapping != null || samePalette))
+ {
+ switch (srcDepth) {
+ case 1:
+ stretch1(srcData, srcStride, srcOrder, srcX, srcY, srcWidth, srcHeight, destData, destStride, destOrder, destX, destY, destWidth, destHeight, flipX, flipY);
+ break;
+ case 2:
+ stretch2(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);
+ break;
+ case 4:
+ stretch4(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);
+ break;
+ case 8:
+ stretch8(srcData, srcStride, srcX, srcY, srcWidth, srcHeight, destData, destStride, destX, destY, destWidth, destHeight, mapping, flipX, flipY);
+ break;
+ }
+ return;
+ }
+ switch (srcDepth) {
+ case 1: srcMasks = msbMasks1; break;
+ case 2: srcMasks = masks2; break;
+ }
+ switch (destDepth) {
+ case 1: destMasks = msbMasks1; destInverseMasks = msbInverseMasks1; break;
+ case 2: destMasks = masks2; destInverseMasks = inverseMasks2; break;
+ }
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 1: srcMasks = lsbMasks1; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 1: destMasks = lsbMasks1; destInverseMasks = lsbInverseMasks1; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
+ break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
+ }
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else if (sameAsSrc) {
+ destPixel = srcPixel;
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ }
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
+ break;
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
+ break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ xs += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ xd += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 1:
+ srcPixel = (srcData[sp + (xs >> 3)] & srcMasks[xs & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ srcPixel = ((srcData[sp + (xs >> 2)] & srcMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ srcPixel = srcData[sp + (xs >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ srcPixel = srcPixel >> 4;
+ } else {
+ srcPixel = srcPixel & 0x0F;
+ }
+ break;
+ case 8:
+ srcPixel = srcData[sp + xs] & 0xFF;
+ break;
+ }
+ if (mapping != null) {
+ destPixel = mapping[srcPixel];
+ } else if (sameAsSrc) {
+ destPixel = srcPixel;
+ } else {
+ dr = sr = srcReds[srcPixel] & 0xFF;
+ dg = sg = srcGreens[srcPixel] & 0xFF;
+ db = sb = srcBlues[srcPixel] & 0xFF;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xs & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ }
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
+ break;
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
+ break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Blits a direct palette image into an index palette image.
+ */
+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 srcGlobalAlpha, byte[] srcAlphaData, int srcAlphaStride, 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) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xd;
+ short sxd, sxs, sas;
+ int sp, dp, sap = 0;
+ int sr = 0, sg = 0, sb = 0, sa = 0, dr = 0, dg = 0, db = 0, da = 0;
+ int srcPixel = 0, destPixel = 0;
+ short so0 = 0, so1 = 1, so2 = 2, so3 = 3;
+ int srcRedShift, srcGreenShift, srcBlueShift;
+ int j, offset = 0;
+ byte[] destMasks = null, destInverseMasks = null;
+ int destN = 1 << destDepth;
+ int r, g, b, nearestPixel = 0, lastPixel = -1;
+ int distance, minDistance;
+
+ srcRedShift = 32 - getMSBOffset(srcRedMask);
+ srcGreenShift = 32 - getMSBOffset(srcGreenMask);
+ srcBlueShift = 32 - getMSBOffset(srcBlueMask);
+ if (destReds != null && destN > destReds.length) destN = destReds.length;
+ switch (destDepth) {
+ case 1: destMasks = msbMasks1; destInverseMasks = msbInverseMasks1; break;
+ case 2: destMasks = masks2; destInverseMasks = inverseMasks2; break;
+ }
+ if (srcOrder == LSB_FIRST) {
+ switch (srcDepth) {
+ case 16: so0 = 1; so1 = 0; break;
+ case 24: so0 = 2; so1 = 1; so2 = 0; break;
+ case 32: so0 = 3; so1 = 2; so2 = 1; so3 = 0; break;
+ }
+ }
+ if (destOrder == LSB_FIRST) {
+ switch (destDepth) {
+ case 1: destMasks = lsbMasks1; destInverseMasks = lsbInverseMasks1; break;
+ }
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxs2 = dxs << 1;
+ dxd2 = dxd << 1;
+ sxs = sas = (short)((xs2 - xs1) > 0 ? 1 : -1);
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+
+ sxs *= srcDepth / 8;
+ xs1 *= srcDepth / 8;
+
+ if (srcGlobalAlpha != -1) srcAlphaData = null;
+ sa = srcGlobalAlpha;
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xd = xd1;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride;
+ if (srcAlphaData != null) sap = ys * srcAlphaStride + xs1;
+ for (dx = 0; dx < dxd; dx++) {
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
+ break;
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
+ break;
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
+ break;
+ }
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xd & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
+ break;
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
+ break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ if (srcAlphaData != null) sap += sas;
+ }
+ xd += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+
+ if (srcAlphaData != null) sa = srcAlphaData[sap] & 0xFF;
+ switch (srcDepth) {
+ case 16:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 8) | (srcData[sp+so1] & 0xFF);
+ break;
+ case 24:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 16) | ((srcData[sp+so1] & 0xFF) << 8) |
+ (srcData[sp+so2] & 0xFF);
+ break;
+ case 32:
+ srcPixel = ((srcData[sp+so0] & 0xFF) << 24) | ((srcData[sp+so1] & 0xFF) << 16) |
+ ((srcData[sp+so2] & 0xFF) << 8) | (srcData[sp+so3] & 0xFF);
+ break;
+ }
+ dr = sr = ((srcPixel & srcRedMask) << srcRedShift) >>> 24;
+ dg = sg = ((srcPixel & srcGreenMask) << srcGreenShift) >>> 24;
+ db = sb = ((srcPixel & srcBlueMask) << srcBlueShift) >>> 24;
+ if (op != BLIT_SRC) {
+ switch (destDepth) {
+ case 1:
+ destPixel = (destData[dp + (xd >> 3)] & destMasks[xd & 7]) == 0 ? 0 : 1;
+ break;
+ case 2:
+ destPixel = ((destData[dp + (xd >> 2)] & destMasks[offset]) & 0xFF) >> (offset * 2);
+ break;
+ case 4:
+ destPixel = destData[dp + (xd >> 1)] & 0xFF;
+ if ((xd & 0x1) == 0) {
+ destPixel = destPixel >> 4;
+ } else {
+ destPixel = destPixel & 0x0F;
+ }
+ break;
+ case 8:
+ destPixel = destData[dp + xd] & 0xFF;
+ break;
+ }
+ dr = destReds[destPixel] & 0xFF;
+ dg = destGreens[destPixel] & 0xFF;
+ db = destBlues[destPixel] & 0xFF;
+ switch (op) {
+ case BLIT_ALPHA:
+ dr += (sr - dr) * sa / 255;
+ dg += (sg - dg) * sa / 255;
+ db += (sb - db) * sa / 255;
+ break;
+ }
+ }
+ if (lastPixel == -1 || lastPixel != srcPixel) {
+ minDistance = 0x7FFFFFFF;
+ nearestPixel = 0;
+ for (j = 0; j < destN; j++) {
+ r = (destReds[j] & 0xFF) - dr;
+ g = (destGreens[j] & 0xFF) - dg;
+ b = (destBlues[j] & 0xFF) - db;
+ distance = r*r + g*g + b*b;
+ if (distance < minDistance) {
+ nearestPixel = j;
+ if (distance == 0) break;
+ minDistance = distance;
+ }
+ }
+ lastPixel = srcPixel;
+ }
+ destPixel = nearestPixel;
+ switch (destDepth) {
+ case 1:
+ if ((destPixel & 0x1) == 1) {
+ destData[dp + (xd >> 3)] |= destInverseMasks[xd & 7];
+ } else {
+ destData[dp + (xd >> 3)] &= destInverseMasks[xd & 7] ^ -1;
+ }
+ break;
+ case 2:
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & destInverseMasks[offset]) | (destPixel << (offset * 2)));
+ break;
+ case 4:
+ if ((xd & 0x1) == 0) {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | ((destPixel & 0x0F) << 4));
+ } else {
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | (destPixel & 0x0F));
+ }
+ break;
+ case 8:
+ destData[dp + xd] = (byte)(destPixel & 0xFF);
+ break;
+ }
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, a 1-bit image, into the destination, a 1-bit image.
+ */
+static void stretch1(byte[] srcData, int srcStride, int srcOrder, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destOrder, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp;
+ byte[] masks, inverseMasks;
+
+ if (srcOrder == LSB_FIRST) {
+ masks = lsbMasks1;
+ } else {
+ masks = msbMasks1;
+ }
+ if (destOrder == LSB_FIRST) {
+ inverseMasks = lsbInverseMasks1;
+ } else {
+ inverseMasks = msbInverseMasks1;
+ }
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ pixel = (byte)(srcData[sp + (xs >> 3)] & masks[xs & 7]);
+ for (dx = 0; dx < dxd; dx++) {
+ if (pixel != 0)
+ destData[dp + (xd >> 3)] |= masks[xd & 7];
+ else
+ destData[dp + (xd >> 3)] &= inverseMasks[xd & 7];
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ pixel = (byte)(srcData[sp + (xs >> 3)] & masks[xs & 7]);
+ }
+ xd += sxd;
+ ex += dxs2;
+ }
+ if (pixel != 0)
+ destData[dp + (xd >> 3)] |= masks[xd & 7];
+ else
+ destData[dp + (xd >> 3)] &= inverseMasks[xd & 7];
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, a 16-bit image, into the destination, a 16-bit image.
+ * The images are assumed to have the same red, green, and blue masks.
+ *
+ * Untested - would need an X server with the same red, green and blue
+ * masks as the file has, namely, 0x7C00, 0x3E0, 0x1F. Most 16-bit X servers
+ * have masks of 0xF800, 0x7E0, 0x1F.
+ */
+static void stretch16(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel0, pixel1;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ pixel0 = srcData[sp + xs];
+ pixel1 = srcData[sp + xs + 1];
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp + xd] = pixel0;
+ destData[dp + xd + 1] = pixel1;
+ if (ex >= 0) {
+ do {
+ xs += (sxs << 1);
+ ex -= dxd2;
+ } while (ex >= 0);
+ pixel0 = srcData[sp + xs];
+ pixel1 = srcData[sp + xs + 1];
+ }
+ xd += (sxd << 1);
+ ex += dxs2;
+ }
+ destData[dp + xd] = pixel0;
+ destData[dp + xd + 1] = pixel1;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, a 2-bit image, into the destination, a 2-bit image.
+ */
+static void stretch2(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp, x;
+ byte [] masks = { (byte)0x03, (byte)0x0C, (byte)0x30, (byte)0xC0 };
+ byte [] inverseMasks = { (byte)0xFC, (byte)0xF3, (byte)0xCF, (byte)0x3F };
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ int offset = 3 - (srcX % 4);
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ x = (byte)(((srcData[sp + (xs >> 2)] & masks[offset]) & 0xFF) >> (offset * 2));
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & inverseMasks[offset]) | (pixel << (offset * 2)));
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ x = (byte)(((srcData[sp + (xs >> 2)] & masks[offset]) & 0xFF) >> (offset * 2));
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ }
+ xd += sxd;
+ ex += dxs2;
+ if (offset == 0) {
+ offset = 3;
+ } else {
+ offset--;
+ }
+ }
+ destData[dp + (xd >> 2)] = (byte)((destData[dp + (xd >> 2)] & inverseMasks[offset]) | (pixel << (offset * 2)));
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, a 24-bit image, into the destination, a 24-bit image.
+ * The images must have the same red, green, and blue masks.
+ * The image are assumed to have 24 bits per pixel; many 24-bit images
+ * use 32 bits per pixel.
+ *
+ * Untested. Would require an X server with a depth of 24 which has 24 bits per
+ * pixel. Most X servers with depth 24 actually have 32 bits per pixel.
+ */
+static void stretch24(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2;
+ short sxd, sxs;
+ byte r, g, b;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 3 : -3);
+ sxs = (short)((xs2 - xs1) > 0 ? 3 : -3);
+ xs1 *= 3;
+ xd1 *= 3;
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride + xd1;
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ if (ex >= 0) {
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ }
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ }
+ dp += sxd;
+ ex += dxs2;
+ }
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, a 32-bit image, into the destination, a 32-bit image.
+ * The images must have the same red, green, and blue masks.
+ */
+static void stretch32(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, ys, yd;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2;
+ short sxd, sxs;
+ byte r, g, b, a;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 4 : -4);
+ sxs = (short)((xs2 - xs1) > 0 ? 4 : -4);
+ xs1 *= 4;
+ xd1 *= 4;
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ sp = ys * srcStride + xs1;
+ dp = yd * destStride + xd1;
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ a = srcData[sp + 3];
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ destData[dp + 3] = a;
+ if (ex >= 0) {
+ while (ex >= 0) {
+ sp += sxs;
+ ex -= dxd2;
+ }
+ r = srcData[sp];
+ g = srcData[sp + 1];
+ b = srcData[sp + 2];
+ a = srcData[sp + 3];
+ }
+ dp += sxd;
+ ex += dxs2;
+ }
+ destData[dp] = r;
+ destData[dp + 1] = g;
+ destData[dp + 2] = b;
+ destData[dp + 3] = a;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, a 4-bit image, into the destination, a 4-bit image.
+ */
+static void stretch4(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ int x = srcData[sp + (xs >> 1)];
+ if ((xs & 1) != 0) {
+ pixel = (byte)((mapping == null) ? (x & 0x0F) : (mapping[x & 0x0F] & 0x0F));
+ } else {
+ pixel = (byte)((mapping == null) ? (x >> 4) : (mapping[x >> 4] & 0x0F));
+ }
+ for (dx = 0; dx < dxd; dx++) {
+ if ((xd & 1) != 0)
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | pixel);
+ else
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | (pixel << 4));
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ x = srcData[sp + (xs >> 1)];
+ if ((xd & 1) != 0) {
+ pixel = (byte)((mapping == null) ? (x & 0x0F) : (mapping[x & 0x0F] & 0x0F));
+ } else {
+ pixel = (byte)((mapping == null) ? ((x >> 4) & 0x0F) : (mapping[x >> 4] & 0x0F));
+ }
+ }
+ xd += sxd;
+ ex += dxs2;
+ }
+ if ((xd & 1) != 0)
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0xF0) | pixel);
+ else
+ destData[dp + (xd >> 1)] = (byte)((destData[dp + (xd >> 1)] & 0x0F) | (pixel << 4));
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+/**
+ * Stretches the source, an 8-bit image, into the destination, an 8-bit image.
+ */
+static void stretch8(byte[] srcData, int srcStride, int srcX, int srcY, int srcWidth, int srcHeight, byte[] destData, int destStride, int destX, int destY, int destWidth, int destHeight, int[] mapping, boolean flipX, boolean flipY) {
+ int xs1, ys1, xs2, ys2, xd1, yd1, xd2, yd2;
+ int dyd, dys, ey, dy, dyd2, dys2, yd, ys;
+ short syd, sys;
+ int dxd, dxs, ex, dx, dxd2, dxs2, xs, xd;
+ short sxd, sxs;
+ byte pixel;
+ int sp, dp, x;
+
+ xs1 = srcX; xs2 = srcX + srcWidth - 1;
+ ys1 = srcY; ys2 = srcY + srcHeight - 1;
+ if (flipX) {
+ xd1 = destX + destWidth - 1;
+ xd2 = destX;
+ } else {
+ xd1 = destX;
+ xd2 = destX + destWidth - 1;
+ }
+ if (flipY) {
+ yd1 = destY + destHeight - 1;
+ yd2 = destY;
+ } else {
+ yd1 = destY;
+ yd2 = destY + destHeight - 1;
+ }
+
+ /* Y preliminary calculations */
+ dyd = yd2 - yd1;
+ if (dyd < 0) dyd = -dyd;
+ dys = ys2 - ys1;
+ if (dys < 0) dys = -dys;
+ dyd2 = dyd << 1;
+ dys2 = dys << 1;
+ syd = (short)((yd2 - yd1) > 0 ? 1 : -1);
+ sys = (short)((ys2 - ys1) > 0 ? 1 : -1);
+ ey = dys2 - dyd;
+ ys = ys1;
+ yd = yd1;
+ /* X preliminary calculations */
+ dxd = xd2 - xd1;
+ if (dxd < 0) dxd = -dxd;
+ dxs = xs2 - xs1;
+ if (dxs < 0) dxs = -dxs;
+ dxd2 = dxd << 1;
+ dxs2 = dxs << 1;
+ sxd = (short)((xd2 - xd1) > 0 ? 1 : -1);
+ sxs = (short)((xs2 - xs1) > 0 ? 1 : -1);
+
+ for (dy = 0; dy <= dyd; dy++) {
+ /* X stretch starts here */
+ ex = dxs2 - dxd;
+ xs = xs1;
+ xd = xd1;
+ sp = ys * srcStride;
+ dp = yd * destStride;
+ x = srcData[sp + xs] & 0xFF;
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ for (dx = 0; dx < dxd; dx++) {
+ destData[dp + xd] = pixel;
+ if (ex >= 0) {
+ do {
+ xs += sxs;
+ ex -= dxd2;
+ } while (ex >= 0);
+ x = srcData[sp + xs] & 0xFF;
+ pixel = (byte)(mapping == null ? x : mapping[x]);
+ }
+ xd += sxd;
+ ex += dxs2;
+ }
+ destData[dp + xd] = pixel;
+ /* X stretch ends here */
+ if (dy == dyd)
+ break;
+ while (ey >= 0) {
+ ys += sys;
+ ey -= dyd2;
+ }
+ yd += syd;
+ ey += dys2;
+ }
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
new file mode 100755
index 0000000000..c76db0d497
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoader.java
@@ -0,0 +1,284 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+import java.io.*;
+import java.util.*;
+import org.eclipse.swt.*;
+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 Bitmap)</li>
+ * <li>ICO (Windows Icon)</li>
+ * <li>JPEG</li>
+ * <li>GIF</li>
+ * <li>PNG</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)</li>
+ * <li>load/save animated GIF images</li>
+ * <li>load interlaced GIF/PNG images</li>
+ * <li>load progressive JPEG images</li>
+ * </ul>
+ */
+
+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")
+ */
+ 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_INVALID_IMAGE - if the image file contains invalid data</li>
+ * <li>ERROR_IO - if an input/output error occurs while reading data</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_INVALID_IMAGE - if the image file contains invalid data</li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ */
+public ImageData[] load(String filename) {
+ if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ InputStream stream = null;
+ try {
+ stream = new FileInputStream(filename);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ return load(stream);
+}
+
+/**
+ * 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_INVALID_IMAGE if the image data contains invalid data</li>
+ * <li>ERROR_IO if an IO error occurs while writing to the stream</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_INVALID_IMAGE if the image data contains invalid data</li>
+ * <li>ERROR_IO if an IO error occurs while writing to the file</li>
+ * </ul>
+ */
+public void save(String filename, int format) {
+ if (filename == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ OutputStream stream = null;
+ try {
+ stream = new FileOutputStream(filename);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ save(stream, format);
+}
+
+/**
+ * Adds a listener to receive image loader events.
+ * <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 ImageLoaderListener to add
+ *
+ * @see ImageLoaderListener
+ * @see ImageLoaderEvent
+ */
+public void addImageLoaderListener(ImageLoaderListener listener) {
+ if (imageLoaderListeners == null) {
+ imageLoaderListeners = new Vector();
+ }
+ imageLoaderListeners.addElement(listener);
+}
+
+/**
+ * Removes a listener that was receiving image loader events.
+ *
+ * @param listener the ImageLoaderListener to remove
+ *
+ * @see #addImageLoaderListener
+ */
+public void removeImageLoaderListener(ImageLoaderListener listener) {
+ 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
+ * @see #removeImageLoaderListener
+ */
+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);
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java
new file mode 100755
index 0000000000..737582344c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderEvent.java
@@ -0,0 +1,78 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+import java.util.*;
+
+/**
+ * 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
+ */
+
+public class ImageLoaderEvent extends EventObject {
+
+ /**
+ * 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;
+
+/**
+ * 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 point
+ */
+public String toString () {
+ return "ImageLoaderEvent {source=" + source + " imageData=" + imageData + " incrementCount=" + incrementCount + " endOfImage=" + endOfImage + "}";
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java
new file mode 100755
index 0000000000..a1ba7f2727
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/ImageLoaderListener.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * 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 EventListener {
+
+/**
+ * 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);
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java
new file mode 100755
index 0000000000..91ef2bb4fe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/PaletteData.java
@@ -0,0 +1,205 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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
+ */
+
+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>RBG</code>.
+ *
+ * @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.
+ *
+ * @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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
new file mode 100755
index 0000000000..64251fec65
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Point.java
@@ -0,0 +1,93 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.io.Serializable;
+
+/**
+ * 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>
+ * 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
+ */
+
+public final class Point implements Serializable {
+
+ /**
+ * the x coordinate of the point
+ */
+ public int x;
+
+ /**
+ * the y coordinate of the point
+ */
+ public int y;
+
+/**
+ * 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 which 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 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 + "}";
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java
new file mode 100755
index 0000000000..7437c7c4d7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/RGB.java
@@ -0,0 +1,108 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.io.Serializable;
+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>
+ * 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
+ */
+
+public final class RGB implements Serializable {
+
+ /**
+ * 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;
+
+/**
+ * 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;
+}
+
+/**
+ * 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 which 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 (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 + "}";
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
new file mode 100755
index 0000000000..42b2f030cc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/Rectangle.java
@@ -0,0 +1,264 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.io.Serializable;
+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>
+ * 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
+ */
+
+public final class Rectangle implements Serializable {
+
+ /**
+ * 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;
+
+/**
+ * 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 which 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 x ^ y ^ width ^ height;
+}
+
+/**
+ * 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 (left, top, right - left, bottom - top);
+}
+
+/**
+ * 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
+ * @see #isEmpty
+ */
+public boolean intersects (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return (rect == this) || (rect.x < x + width) && (rect.y < y + height) &&
+ (rect.x + rect.width > x) && (rect.y + rect.height > y);
+}
+
+/**
+ * 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 + "}";
+}
+
+/**
+ * Returns a new rectangle which represents the union of
+ * the receiver and the given rectangle.
+ *
+ * @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
+ */
+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);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html
new file mode 100755
index 0000000000..c6a867e380
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/graphics/package.html
@@ -0,0 +1,17 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT graphics classes.
+<h2>
+Package Specification</h2>
+This package provides the classes which implement points, rectangles,
+regions, colors, cursors, fonts, graphics contexts (that is, <code>GC</code>s)
+where most of the primitive drawing operations are implemented, and
+images including both the code for displaying them and the public API for
+loading/saving them.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
new file mode 100755
index 0000000000..3dc9ef89d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/Callback.java
@@ -0,0 +1,270 @@
+package org.eclipse.swt.internal;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+
+/**
+ * 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, address;
+ boolean isStatic, isArrayBased;
+
+ /* SWT Version - Mmmm (M=major, mmm=minor) */
+
+ /**
+ * SWT Major version number (must be >= 0)
+ */
+ public static int MAJOR_VERSION = 0;
+
+ /**
+ * SWT Minor version number (must be in the range 0..999)
+ */
+ public static int MINOR_VERSION = 105;
+
+ /**
+ * SWT revision number (must be >= 0)
+ */
+ public static int REVISION = 0;
+
+ /* Load the SWT library */
+ static {
+ loadLibrary ("swt");
+ }
+
+/**
+ * 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) {
+
+ /* Set the callback fields */
+ this.object = object;
+ this.method = method;
+ this.argCount = argCount;
+ isStatic = object instanceof Class;
+ this.isArrayBased = isArrayBased;
+
+ /* Inline the common cases */
+ if (isArrayBased) {
+ signature = "([I)I";
+ } else {
+ switch (argCount) {
+ case 0: signature = "()I"; break;
+ case 1: signature = "(I)I"; break;
+ case 2: signature = "(II)I"; break;
+ case 3: signature = "(III)I"; break;
+ case 4: signature = "(IIII)I"; break;
+ default:
+ signature = "(";
+ for (int i=0; i<argCount; i++) signature += "I";
+ signature += ")I";
+ }
+ }
+
+ /* Bind the address */
+ address = bind (this);
+}
+
+/**
+ * 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
+ */
+static native synchronized int bind (Callback callback);
+
+/**
+ * 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 getAddress () {
+ return address;
+}
+
+/**
+ * Returns the SWT version as an integer in the standard format
+ * <em>Mmmm</em> where <em>M</em> is the major version number
+ * and <em>mmm</em> is the minor version number.
+ *
+ * @return the version of the currently running SWT
+ */
+public static int getVersion () {
+ return MAJOR_VERSION * 1000 + MINOR_VERSION;
+}
+
+/**
+ * Returns the SWT platform name.
+ *
+ * @return the platform name of the currently running SWT
+ */
+public static native String getPlatform ();
+
+/**
+ * Returns the SWT revision number as an integer. Revision changes
+ * occur as a result of non-API breaking bug fixes.
+ *
+ * @return the revision number of the currently running SWT
+ */
+public static int getRevision () {
+ return REVISION;
+}
+
+/**
+ * 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 ignore true if callbacks should not 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);
+}
+
+/*
+ * Loads the SWT shared library that matches the version
+ * of the Java code which is currently running.
+ */
+public static void loadLibrary () {
+ loadLibrary ("swt");
+}
+
+/**
+ * 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) {
+ String newName = name + MAJOR_VERSION;
+
+ /* Force 3 digits in minor version number */
+ if (MINOR_VERSION < 10) {
+ newName += "00";
+ } else {
+ if (MINOR_VERSION < 100) newName += "0";
+ }
+ newName += MINOR_VERSION;
+
+ /* No "r" until first revision */
+ if (REVISION > 0) newName += "r" + REVISION;
+ try {
+ System.loadLibrary (newName);
+ } catch (UnsatisfiedLinkError e) {
+ try {
+ System.loadLibrary (name);
+ } catch (UnsatisfiedLinkError e2) {
+ throw e;
+ }
+ }
+}
+
+/**
+ * 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);
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
new file mode 100755
index 0000000000..1bf2ae1d80
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/FileFormat.java
@@ -0,0 +1,108 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import java.io.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/* Class Definition */
+public abstract class FileFormat {
+ LEDataInputStream inputStream;
+ LEDataOutputStream outputStream;
+ ImageLoader loader;
+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;
+}
+
+abstract ImageData[] loadFromByteStream();
+
+public ImageData[] loadFromStream(LEDataInputStream stream) {
+ try {
+ inputStream = stream;
+ return loadFromByteStream();
+ } catch (Exception e) {
+ SWT.error(SWT.ERROR_IO, e);
+ return null;
+ }
+}
+public static ImageData[] load(InputStream is, ImageLoader loader) {
+ FileFormat fileFormat = null;
+ LEDataInputStream stream = new LEDataInputStream(is);
+ if (GIFFileFormat.isGIFFile(stream)) {
+ fileFormat = new GIFFileFormat();
+ } else if (WinBMPFileFormat.isBMPFile(stream)) {
+ fileFormat = new WinBMPFileFormat();
+ } else if (WinICOFileFormat.isICOFile(stream)) {
+ fileFormat = new WinICOFileFormat();
+ } else if (JPEGFileFormat.isJPEGFile(stream)) {
+ fileFormat = new JPEGFileFormat();
+ } else if (PNGFileFormat.isPNGFile(stream)) {
+ fileFormat = new PNGFileFormat();
+ } else {
+ SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ }
+ fileFormat.loader = loader;
+ return fileFormat.loadFromStream(stream);
+}
+public static void save(OutputStream os, int format, ImageLoader loader) {
+ /* We do not currently support writing multi-image files,
+ * so we use the first image data in the loader's array. */
+ ImageData data = loader.data[0];
+ LEDataOutputStream stream = new LEDataOutputStream(os);
+ switch (format) {
+ case SWT.IMAGE_BMP:
+ WinBMPFileFormat f = new WinBMPFileFormat();
+ f.unloadIntoStream(data, stream);
+ break;
+ case SWT.IMAGE_BMP_RLE:
+ f = new WinBMPFileFormat();
+ if (data.depth == 8)
+ f.compression = 1;
+ if (data.depth == 4)
+ f.compression = 2;
+ f.unloadIntoStream(data, stream);
+ break;
+ case SWT.IMAGE_GIF:
+ GIFFileFormat g = new GIFFileFormat();
+ g.unloadIntoStream(data, stream);
+ break;
+ case SWT.IMAGE_ICO:
+ WinICOFileFormat i = new WinICOFileFormat();
+ i.unloadIntoStream(data, stream);
+ break;
+ case SWT.IMAGE_JPEG:
+ JPEGFileFormat j = new JPEGFileFormat();
+ j.unloadIntoStream(data, stream);
+ break;
+ case SWT.IMAGE_PNG:
+ PNGFileFormat p = new PNGFileFormat();
+ p.unloadIntoStream(data, stream);
+ break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
+abstract void unloadIntoByteStream(ImageData image);
+
+public void unloadIntoStream(ImageData image, LEDataOutputStream stream) {
+ try {
+ outputStream = stream;
+ unloadIntoByteStream(image);
+ outputStream.close();
+ } catch (Exception e) {
+ try {outputStream.close();} catch (Exception f) {}
+ SWT.error(SWT.ERROR_IO, e);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java
new file mode 100755
index 0000000000..5951beb747
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/GIFFileFormat.java
@@ -0,0 +1,522 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+final class GIFFileFormat extends FileFormat {
+ String signature, version;
+ boolean sorted;
+ int screenWidth, screenHeight, backgroundPixel, aspect, bitsPerPixel;
+ boolean userInput = false;
+ 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;
+
+ /**
+ * Return whether or not the specified input stream
+ * represents a GIF file.
+ */
+ public static boolean isGIFFile(LEDataInputStream stream) {
+ try {
+ byte[] signature = new byte[3];
+ stream.read(signature);
+ stream.unread(signature);
+ return new String(signature).equals("GIF");
+ } catch (Exception e) {
+ return false;
+ }
+ }
+
+ /**
+ * 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);
+ }
+
+ /**
+ * Load the GIF image(s) stored in the input stream.
+ * Return an array of ImageData representing the image(s).
+ */
+ ImageData[] loadFromByteStream() {
+ byte[] signatureBytes = new byte[3];
+ byte[] versionBytes = new byte[3];
+ byte[] block = new byte[7];
+ try {
+ inputStream.read(signatureBytes);
+ signature = new String(signatureBytes);
+ if (!signature.equals("GIF"))
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+
+ inputStream.read(versionBytes);
+ version = new String(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;
+ int depth = (bitField & 0x7) + 1;
+ PaletteData palette = null;
+ if ((bitField & 0x80) != 0) {
+ // Global palette.
+ sorted = (bitField & 0x8) != 0;
+ palette = readPalette(1 << depth);
+ } else {
+ // No global palette.
+ sorted = false;
+ backgroundPixel = -1;
+ depth = bitsPerPixel;
+ }
+ loader.backgroundPixel = backgroundPixel;
+
+ getExtensions();
+ int id = readID();
+ ImageData[] images = new ImageData[0];
+ while (id == GIF_IMAGE_BLOCK_ID) {
+ ImageData image = readImageBlock(depth, 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) {
+ 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[] applicationBytes = new byte[8];
+ inputStream.read(applicationBytes);
+ String application = new String(applicationBytes);
+ // Read authentication code.
+ byte[] authenticationBytes = new byte[3];
+ inputStream.read(authenticationBytes);
+ String authentication = new String(authenticationBytes);
+ // 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.
+ if (application.equals("NETSCAPE") && authentication.equals("2.0") && data[0] == 01) {
+ 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(int defaultDepth, 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;
+ }
+ // 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);
+ }
+
+ /**
+ * Write the specified device independent image
+ * to the output stream.
+ */
+ void unloadIntoByteStream(ImageData image) {
+ if (!((image.depth == 1) || (image.depth == 4) || (image.depth == 8))) {
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ byte bitField = (byte)((0x80 & 0xF8 & 0xF7 & 0x8F) + (image.depth - 1) + ((image.depth - 1) * 16));
+ try {
+ outputStream.write(new byte[] { (byte)'G', (byte)'I', (byte)'F' });
+ outputStream.write(new byte[] { (byte)'8', (byte)'9', (byte)'a' });
+ outputStream.writeShort((short)image.width);
+ outputStream.writeShort((short)image.height);
+ outputStream.writeByte(bitField);
+ outputStream.writeByte((byte)0);
+ outputStream.writeByte((byte)0);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ writePalette(image.palette, image.depth);
+ if (image.transparentPixel != -1 || image.disposalMethod != 0 || image.delayTime != 0) {
+ writeGraphicsControlBlock(image);
+ }
+ writeImageBlock(image);
+ }
+
+ /**
+ * 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);
+ outputStream.write(0x04); // size of block
+ byte[] gcBlock = new byte[4];
+ gcBlock[0] = (byte)0xFD;
+ gcBlock[1] = 0;
+ gcBlock[2] = 0;
+ gcBlock[3] = 0;
+ if (image.transparentPixel == -1) {
+ gcBlock[0] = (byte)(gcBlock[0] & 0xFE);
+ } else {
+ gcBlock[0] = (byte)(gcBlock[0] | 0x01);
+ gcBlock[3] = (byte)image.transparentPixel;
+ }
+ if (image.disposalMethod != 0) {
+ gcBlock[0] = (byte)(gcBlock[0] | ((image.disposalMethod & 0x07) << 2));
+ }
+ if (image.delayTime != 0) {
+ gcBlock[1] = (byte)(image.delayTime & 0xFF);
+ gcBlock[2] = (byte)((image.delayTime >> 8) & 0xFF);
+ }
+ outputStream.write(gcBlock);
+ outputStream.write(0); // block terminator
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ }
+
+ /**
+ * Write the specified device independent image
+ * to the current position in the output stream.
+ */
+ void writeImageBlock(ImageData image) {
+ try {
+ outputStream.write(GIF_IMAGE_BLOCK_ID);
+ byte[] block = new byte[9];
+ block[0] = (byte)(image.x & 0xFF);
+ block[1] = (byte)((image.x >> 8) & 0xFF);
+ block[2] = (byte)(image.y & 0xFF);
+ block[3] = (byte)((image.y >> 8) & 0xFF);
+ block[4] = (byte)(image.width & 0xFF);
+ block[5] = (byte)((image.width >> 8) & 0xFF);
+ block[6] = (byte)(image.height & 0xFF);
+ block[7] = (byte)((image.height >> 8) & 0xFF);
+ block[8] = 0; // no interlace, no sort, no local palette
+ outputStream.write(block);
+ outputStream.write(image.depth);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+ new LZWCodec().encode(outputStream, image);
+ }
+
+ /**
+ * 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);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGAppn.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGAppn.java
new file mode 100755
index 0000000000..f211bfd3ca
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGAppn.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+
+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;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java
new file mode 100755
index 0000000000..689ba2c5a8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGArithmeticConditioningTable.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+final class JPEGArithmeticConditioningTable extends JPEGVariableSizeSegment {
+
+ public JPEGArithmeticConditioningTable(LEDataInputStream byteStream) {
+ super(byteStream);
+ }
+
+ public int signature() {
+ return JPEGFileFormat.DAC;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGComment.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGComment.java
new file mode 100755
index 0000000000..7c2e186df0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGComment.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+final class JPEGComment extends JPEGVariableSizeSegment {
+
+ public JPEGComment(byte[] reference) {
+ super(reference);
+ }
+
+ public JPEGComment(LEDataInputStream byteStream) {
+ super(byteStream);
+ }
+
+ public int signature() {
+ return JPEGFileFormat.COM;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGEndOfImage.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGEndOfImage.java
new file mode 100755
index 0000000000..2937a7cbe2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGEndOfImage.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFileFormat.java
new file mode 100755
index 0000000000..6650760172
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFileFormat.java
@@ -0,0 +1,1891 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+/* Class Definition */
+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;
+ byte[][] imageComponents;
+ int[] dataUnit;
+ int[][][] dataUnits;
+ int[] precedingDCs;
+ JPEGScanHeader scanHeader;
+ byte[] dataBuffer;
+ int currentBitCount;
+ int bufferCurrentPosition;
+ int restartsToGo;
+ int nextRestartNumber;
+ JPEGArithmeticConditioningTable arithmeticTables;
+ JPEGHuffmanTable[] acHuffmanTables;
+ JPEGHuffmanTable[] dcHuffmanTables;
+ int[][] quantizationTables;
+ int currentByte;
+ int decoderQFactor;
+ 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;
+
+ 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 int[] CrRTable, CbBTable, CrGTable, CbGTable;
+ public static int[] RYTable, GYTable, BYTable,
+ RCbTable, GCbTable, BCbTable, RCrTable, GCrTable, BCrTable, NBitsTable;
+ static {
+ initialize();
+ }
+void compress(ImageData image, byte[] dataYComp, byte[] dataCbComp, byte[] dataCrComp) {
+ int srcWidth = image.width;
+ int srcHeight = image.height;
+ int vhFactor = maxV * maxH;
+ int[] frameComponent;
+ byte[][] imageComponents = new byte[nComponents][];
+ for (int i = 0; i < nComponents; i++) {
+ frameComponent = frameComponents[i];
+ imageComponents[i] = new byte[frameComponent[CW] * frameComponent[CH]];
+ }
+ frameComponent = frameComponents[0];
+ for (int yPos = 0; yPos < srcHeight; yPos++) {
+ int srcOfs = yPos * srcWidth;
+ int dstOfs = yPos * frameComponent[CW];
+ System.arraycopy(dataYComp, srcOfs, imageComponents[0], dstOfs, srcWidth);
+ }
+ frameComponent = frameComponents[1];
+ 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[1][destRowIndex + xPos] = (byte)(sum / vhFactor);
+ }
+ }
+ frameComponent = frameComponents[2];
+ 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[2][destRowIndex + xPos] = (byte)(sum / vhFactor);
+ }
+ }
+ for (int iComp = 0; iComp < nComponents; iComp++) {
+ byte[] imageComponent = imageComponents[iComp];
+ frameComponent = frameComponents[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 - 1] & 0xFF;
+ for (int i = 0; i < delta; i++) {
+ imageComponent[dstOfs + i] = (byte)dataValue;
+ }
+ }
+ }
+ if (compressedHeight < componentHeight) {
+ int srcOfs = (compressedHeight - 1) * componentWidth;
+ for (int yPos = compressedHeight; 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 / 65536);
+ if ((n < 0) && (n % 65536 != 0)) yComp[i]--;
+ n = RCbTable[r] + GCbTable[g] + BCbTable[b];
+ cbComp[i] = (byte)(n / 65536);
+ if ((n < 0) && (n % 65536 != 0)) cbComp[i]--;
+ n = RCrTable[r] + GCrTable[g] + BCrTable[b];
+ crComp[i] = (byte)(n / 65536);
+ if ((n < 0) && (n % 65536 != 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;
+ for (int yPos = 0; yPos < srcHeight; yPos++) {
+ for (int xPos = 0; xPos < srcWidth / 2; xPos++) {
+ int srcIndex = yPos * (srcWidth / 2) + xPos;
+ int dstIndex = yPos * srcWidth + (xPos * 2);
+ int value2 = origData[srcIndex] & 0xFF;
+ int value1 = value2 / 16;
+ value2 = value2 % 16;
+ 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 / 65536);
+ if ((n < 0) && (n % 65536 != 0)) yComp[i]--;
+ n = RCbTable[r] + GCbTable[g] + BCbTable[b];
+ cbComp[i] = (byte)(n / 65536);
+ if ((n < 0) && (n % 65536 != 0)) cbComp[i]--;
+ n = RCrTable[r] + GCrTable[g] + BCrTable[b];
+ crComp[i] = (byte)(n / 65536);
+ if ((n < 0) && (n % 65536 != 0)) crComp[i]--;
+ }
+ int dstWidth = image.width;
+ int dstHeight = srcHeight;
+ int stride = (srcWidth + 3) / 4 * 4;
+ 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:
+ 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];
+ byte[] origData = image.data;
+ 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]) / 65536);
+ dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) / 65536);
+ dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) / 65536);
+ }
+ }
+ } 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]) / 65536);
+ dataCbComp[dstDataIndex] = (byte)((RCbTable[r] + GCbTable[g] + BCbTable[b]) / 65536);
+ dataCrComp[dstDataIndex] = (byte)((RCrTable[r] + GCrTable[g] + BCrTable[b]) / 65536);
+ }
+ }
+ }
+ compress(image, dataYComp, dataCbComp, dataCrComp);
+}
+byte[] convertYToRGB() {
+ int compWidth = frameHeader.componentParameters[0][3];
+ int bytesPerLine = (((imageWidth * 8 + 7) / 8) + 3) / 4 * 4;
+ byte[] data = new byte[bytesPerLine * imageHeight];
+ byte[] yComp = imageComponents[0];
+ 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[0];
+ byte[] cbComp = imageComponents[1];
+ byte[] crComp = imageComponents[2];
+ int compWidth = frameHeader.componentParameters[0][3];
+ 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]) / 65536);
+ 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;
+}
+byte[] convertYIQToRGB() {
+ /* Unsupported CMYK format. Answer an empty byte array. */
+ return new byte[0];
+}
+void decodeACCoefficients(int[] dataUnit, int iComp) {
+ int[] sParams = scanHeader.componentParameters[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[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[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 = ac + (1 << approxBit);
+ }
+ } else if (ac < 0) {
+ int bit = nextBit();
+ if (bit != 0) {
+ ac = ac + (-1 << approxBit);
+ }
+ }
+ return ac;
+}
+void decodeDCCoefficient(int[] dataUnit, int iComp, boolean first, int approxBit) {
+ int[] sParams = scanHeader.componentParameters[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 = lastDC + diff;
+ precedingDCs[iComp] = lastDC;
+ }
+ if (progressive) {
+ lastDC = lastDC << approxBit;
+ }
+ }
+ dataUnit[0] = lastDC;
+}
+void dequantize(int[] dataUnit, int iComp) {
+ int[] qTable = quantizationTables[frameComponents[iComp][TQI]];
+ for (int i = 0; i < dataUnit.length; i++) {
+ int zzIndex = ZigZag8x8[i];
+ dataUnit[zzIndex] = dataUnit[zzIndex] * qTable[i];
+ }
+}
+byte[] decodeImageComponents() {
+ int[] compIds = new int[nComponents];
+ int compIdsIndex = 0;
+ for (int i = 0; i < nComponents; i++) {
+ compIds[compIdsIndex] = i + 1;
+ compIdsIndex++;
+ }
+ if ((compIds.length == 3) &&
+ (compIds[0] == 1) &&
+ (compIds[1] == 2) &&
+ (compIds[2] == 3)) {
+ return convertYCbCrToRGB();
+ }
+ if ((compIds.length == 3) &&
+ (compIds[0] == 1) &&
+ (compIds[1] == 4) &&
+ (compIds[2] == 5)) {
+ return convertYIQToRGB();
+ }
+ if (compIds.length == 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[scanComponent] == null) {
+ scanComponent++;
+ }
+ int[] frameComponent = frameComponents[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 iComp = 0;
+ while (scanHeader.componentParameters[iComp] == null) {
+ iComp++;
+ }
+ int[] frameComponent = frameComponents[iComp];
+ 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];
+ j = j + 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 % 256);
+ codeBuffer[1] = (byte)((code / 256) % 256);
+ codeBuffer[2] = (byte)((code / 65536) % 256);
+ codeBuffer[3] = (byte)((code / 16777216) % 256);
+ int abs = nBits - (8 - currentBitCount);
+ if (abs < 0) abs = -abs;
+ if ((abs / 8) > 0) {
+ currentByte += codeBuffer[2];
+ emitByte((byte)currentByte);
+ emitByte((byte)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[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[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;
+ RGB[] rgbs = 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),
+ };
+ ImageData src = new ImageData(compWidth, compHeight, 8, new PaletteData(rgbs), 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[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 scaleFactor1 = ExtendTest[11];
+ int scaleFactor2 = ExtendTest[12];
+ int n = z1 + (tmp13 * FIX_0_765366865) + scaleFactor1;
+ dataUnit[rIndex + 2] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[rIndex + 2]--;
+ n = z1 + (tmp12 * (0 - FIX_1_847759065)) + scaleFactor1;
+ dataUnit[rIndex + 6] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 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 = tmp4 * FIX_0_298631336; // sqrt(2) * (-c1+c3+c5-c7)
+ tmp5 = tmp5 * FIX_2_053119869; // sqrt(2) * ( c1+c3-c5+c7)
+ tmp6 = tmp6 * FIX_3_072711026; // sqrt(2) * ( c1+c3+c5-c7)
+ tmp7 = tmp7 * FIX_1_501321110; // sqrt(2) * ( c1+c3-c5-c7)
+ z1 = z1 * (0 - FIX_0_899976223); // sqrt(2) * (c7-c3)
+ z2 = z2 * (0 - FIX_2_562915447); // sqrt(2) * (-c1-c3)
+ z3 = z3 * (0 - FIX_1_961570560); // sqrt(2) * (-c3-c5)
+ z4 = z4 * (0 - FIX_0_390180644); // sqrt(2) * (c5-c3)
+
+ z3 = z3 + z5;
+ z4 = z4 + z5;
+
+ n = tmp4 + z1 + z3 + scaleFactor1;
+ dataUnit[rIndex + 7] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[rIndex + 7]--;
+ n = tmp5 + z2 + z4 + scaleFactor1;
+ dataUnit[rIndex + 5] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[rIndex + 5]--;
+ n = tmp6 + z2 + z3 + scaleFactor1;
+ dataUnit[rIndex + 3] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[rIndex + 3]--;
+ n = tmp7 + z1 + z4 + scaleFactor1;
+ dataUnit[rIndex + 1] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 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 scaleFactor1 = ExtendTest[5];
+ int scaleFactor2 = ExtendTest[6];
+ int n = tmp10 + tmp11 + scaleFactor1;
+ dataUnit[c0] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[c0]--;
+ n = tmp10 - tmp11 + scaleFactor1;
+ dataUnit[c4] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[c4]--;
+
+ int z1 = (tmp12 + tmp13) * FIX_0_541196100;
+ scaleFactor1 = ExtendTest[18];
+ scaleFactor2 = ExtendTest[19];
+ n = z1 + (tmp13 * FIX_0_765366865) + scaleFactor1;
+ dataUnit[c2] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[c2]--;
+ n = z1 + (tmp12 * (0 - FIX_1_847759065)) + scaleFactor1;
+ dataUnit[c6] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 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 = tmp4 * FIX_0_298631336; // sqrt(2) * (-c1+c3+c5-c7)
+ tmp5 = tmp5 * FIX_2_053119869; // sqrt(2) * ( c1+c3-c5+c7)
+ tmp6 = tmp6 * FIX_3_072711026; // sqrt(2) * ( c1+c3+c5-c7)
+ tmp7 = tmp7 * FIX_1_501321110; // sqrt(2) * ( c1+c3-c5-c7)
+ z1 = z1 * (0 - FIX_0_899976223); // sqrt(2) * (c7-c3)
+ z2 = z2 * (0 - FIX_2_562915447); // sqrt(2) * (-c1-c3)
+ z3 = z3 * (0 - FIX_1_961570560); // sqrt(2) * (-c3-c5)
+ z4 = z4 * (0 - FIX_0_390180644); // sqrt(2) * (c5-c3)
+
+ z3 = z3 + z5;
+ z4 = z4 + z5;
+
+ n = tmp4 + z1 + z3 + scaleFactor1;
+ dataUnit[c7] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[c7]--;
+ n = tmp5 + z2 + z4 + scaleFactor1;
+ dataUnit[c5] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[c5]--;
+ n = tmp6 + z2 + z3 + scaleFactor1;
+ dataUnit[c3] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 0)) dataUnit[c3]--;
+ n = tmp7 + z1 + z4 + scaleFactor1;
+ dataUnit[c1] = n / scaleFactor2;
+ if ((n < 0) && (n % scaleFactor2 != 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() {
+ JPEGArithmeticConditioningTable dac = new JPEGArithmeticConditioningTable(inputStream);
+ arithmeticTables = dac;
+}
+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();
+}
+static void initialize() {
+ initializeRGBYCbCrTables();
+ initializeYCbCrRGBTables();
+ initializeBitCountTable();
+}
+static void initializeBitCountTable() {
+ int nBits = 1;
+ int count = 0;
+ int power2 = 2;
+ NBitsTable = new int[2048];
+ NBitsTable[0] = 0;
+ for (int i = 1; i < NBitsTable.length; i++) {
+ if (!(i < power2)) {
+ nBits++;
+ power2 *= 2;
+ }
+ NBitsTable[i] = nBits;
+ }
+}
+static void initializeRGBYCbCrTables() {
+ RYTable = new int[256];
+ GYTable = new int[256];
+ BYTable = new int[256];
+ RCbTable = new int[256];
+ GCbTable = new int[256];
+ BCbTable = new int[256];
+ RCrTable = BCbTable;
+ GCrTable = new int[256];
+ 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;
+ }
+}
+static void initializeYCbCrRGBTables() {
+ CrRTable = new int[256];
+ CbBTable = new int[256];
+ CrGTable = new int[256];
+ CbGTable = new int[256];
+ for (int i = 0; i < 256; i++) {
+ int x2 = 2 * i - 255;
+ CrRTable[i] = (45941 * x2 + 32768) / 65536;
+ CbBTable[i] = (58065 * x2 + 32768) / 65536;
+ CrGTable[i] = -23401 * x2;
+ CbGTable[i] = -11277 * x2 + 32768;
+ }
+}
+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] * 4;
+ for (int i = rIndex; i < rIndex + 8; 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]) * 8192;
+ int tmp1 = (dataUnit[rIndex] - dataUnit[rIndex + 4]) * 8192;
+ 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 = tmp0 * FIX_0_298631336; /* sqrt(2) * (-c1+c3+c5-c7) */
+ tmp1 = tmp1 * FIX_2_053119869; /* sqrt(2) * ( c1+c3-c5+c7) */
+ tmp2 = tmp2 * FIX_3_072711026; /* sqrt(2) * ( c1+c3+c5-c7) */
+ tmp3 = tmp3 * FIX_1_501321110; /* sqrt(2) * ( c1+c3-c5-c7) */
+ z1 = z1 * (0 - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
+ z2 = z2 * (0 - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
+ z3 = z3 * (0 - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
+ z4 = z4 * (0 - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
+
+ z3 = z3 + z5;
+ z4 = z4 + z5;
+ tmp0 = tmp0 + z1 + z3;
+ tmp1 = tmp1 + z2 + z4;
+ tmp2 = tmp2 + z2 + z3;
+ tmp3 = tmp3 + z1 + z4;
+
+ int descaleFactor1 = ExtendTest[11];
+ int descaleFactor2 = ExtendTest[12];
+ dataUnit[rIndex] = (tmp10 + tmp3 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 7] = (tmp10 - tmp3 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 1] = (tmp11 + tmp2 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 6] = (tmp11 - tmp2 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 2] = (tmp12 + tmp1 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 5] = (tmp12 - tmp1 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 3] = (tmp13 + tmp0 + descaleFactor1) / descaleFactor2;
+ dataUnit[rIndex + 4] = (tmp13 - tmp0 + descaleFactor1) / descaleFactor2;
+ }
+ }
+ /**
+ * 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) / 32;
+ 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 z2 = dataUnit[c2];
+ int z3 = dataUnit[c6];
+ 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[c0] + dataUnit[c4]) * 8192;
+ int tmp1 = (dataUnit[c0] - dataUnit[c4]) * 8192;
+ 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;
+ int z4 = tmp1 + tmp3;
+ int z5 = (z3 + z4) * FIX_1_175875602; /* sqrt(2) * c3 */
+
+ tmp0 = tmp0 * FIX_0_298631336; /* sqrt(2) * (-c1+c3+c5-c7) */
+ tmp1 = tmp1 * FIX_2_053119869; /* sqrt(2) * ( c1+c3-c5+c7) */
+ tmp2 = tmp2 * FIX_3_072711026; /* sqrt(2) * ( c1+c3+c5-c7) */
+ tmp3 = tmp3 * FIX_1_501321110; /* sqrt(2) * ( c1+c3-c5-c7) */
+ z1 = z1 * (0 - FIX_0_899976223); /* sqrt(2) * (c7-c3) */
+ z2 = z2 * (0 - FIX_2_562915447); /* sqrt(2) * (-c1-c3) */
+ z3 = z3 * (0 - FIX_1_961570560); /* sqrt(2) * (-c3-c5) */
+ z4 = z4 * (0 - FIX_0_390180644); /* sqrt(2) * (c5-c3) */
+
+ z3 = z3 + z5;
+ z4 = z4 + z5;
+
+ tmp0 = tmp0 + z1 + z3;
+ tmp1 = tmp1 + z2 + z4;
+ tmp2 = tmp2 + z2 + z3;
+ tmp3 = tmp3 + z1 + z4;
+
+ /* Final output stage: inputs are tmp10..tmp13, tmp0..tmp3 */
+ int descaleFactor1 = ExtendTest[18];
+ int descaleFactor2 = ExtendTest[19];
+ dataUnit[c0] = (tmp10 + tmp3 + descaleFactor1) / descaleFactor2;
+ dataUnit[c7] = (tmp10 - tmp3 + descaleFactor1) / descaleFactor2;
+ dataUnit[c1] = (tmp11 + tmp2 + descaleFactor1) / descaleFactor2;
+ dataUnit[c6] = (tmp11 - tmp2 + descaleFactor1) / descaleFactor2;
+ dataUnit[c2] = (tmp12 + tmp1 + descaleFactor1) / descaleFactor2;
+ dataUnit[c5] = (tmp12 - tmp1 + descaleFactor1) / descaleFactor2;
+ dataUnit[c3] = (tmp13 + tmp0 + descaleFactor1) / descaleFactor2;
+ dataUnit[c4] = (tmp13 - tmp0 + descaleFactor1) / descaleFactor2;
+ }
+ }
+}
+public static boolean isJPEGFile(LEDataInputStream stream) {
+ try {
+ JPEGStartOfImage soi = new JPEGStartOfImage(stream);
+ byte[] header = new byte[16];
+ stream.read(header);
+ JPEGAppn appn = new JPEGAppn(header);
+ stream.unread(appn.reference);
+ stream.unread(soi.reference);
+ return soi.verify() && appn.verify();
+ // && appn.getSegmentMarker() == APP0; doesn't have to be app0
+ } catch (Exception e) {
+ return false;
+ }
+}
+boolean isZeroInColumn(int[] dataUnit, int col) {
+ return (dataUnit[col + 8] + dataUnit[col + 16] +
+ dataUnit[col + 24] + dataUnit[col + 32] +
+ dataUnit[col + 40] + dataUnit[col + 48] +
+ dataUnit[col + 56]) == 0;
+}
+boolean isZeroInRow(int[] dataUnit, int rIndex) {
+ return (dataUnit[rIndex + 1] + dataUnit[rIndex + 2] +
+ dataUnit[rIndex + 3] + dataUnit[rIndex + 4] +
+ dataUnit[rIndex + 5] + dataUnit[rIndex + 6] +
+ dataUnit[rIndex + 7]) == 0;
+}
+ImageData[] loadFromByteStream() {
+ 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;
+ 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[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[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);
+ }
+ }
+ }
+ }
+ }
+ }
+ 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) % 256)) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ bufferCurrentPosition++;
+ if (bufferCurrentPosition > 511) {
+ resetInputBuffer();
+ bufferCurrentPosition = 0;
+ }
+ currentByte = dataBuffer[bufferCurrentPosition] & 0xFF;
+ currentBitCount = 8;
+ restartsToGo = restartInterval;
+ nextRestartNumber = (nextRestartNumber + 1) % 8;
+ 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[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 / 2;
+ 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) {
+ throw new SWTError(SWT.ERROR_INVALID_IMAGE);
+ }
+ if (!(byteArray[0] == -1 && byteArray[1] != 0 && byteArray[1] != -1)) {
+ throw new SWTError(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[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(ImageData image) {
+ 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.initializeContents();
+ if (!frameHeader.writeToStream(outputStream)) {
+ SWT.error(SWT.ERROR_IO);
+ }
+ frameComponents = frameParams;
+ maxH = frameHeader.getMaxHFactor();
+ maxV = frameHeader.getMaxVFactor();
+ int mcuWidth = maxH * DCTSIZE;
+ int mcuHeight = maxV * DCTSIZE;
+ interleavedMcuCols = (imageWidth + mcuWidth - 1) / mcuWidth;
+ interleavedMcuRows = (imageHeight + mcuHeight - 1) / mcuHeight;
+ JPEGHuffmanTable[] acHuffmanTables = new JPEGHuffmanTable[4];
+ JPEGHuffmanTable[] 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);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java
new file mode 100755
index 0000000000..9bf9191e51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFixedSizeSegment.java
@@ -0,0 +1,38 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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) {
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFrameHeader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFrameHeader.java
new file mode 100755
index 0000000000..be2cf6c6d3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGFrameHeader.java
@@ -0,0 +1,203 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+
+final class JPEGFrameHeader extends JPEGVariableSizeSegment {
+ int maxVFactor;
+ int maxHFactor;
+ 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;
+ }
+
+ void initializeComponentParameters() {
+ int nf = getNumberOfImageComponents();
+ 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;
+ int hi = (reference[ofs + 1] & 0xFF) / 16;
+ int vi = (reference[ofs + 1] & 0xFF) % 16;
+ 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][];
+ System.arraycopy(compSpecParams, 0, newParams, 0, compSpecParams.length);
+ compSpecParams = newParams;
+ }
+ compSpecParams[ci - 1] = compParam;
+ }
+ int x = getSamplesPerLine();
+ int y = getNumberOfLines();
+ int[] multiples = new int[] { 8, 16, 24, 32 };
+ for (int i = 0; i < compSpecParams.length; i++) {
+ int[] compParam = compSpecParams[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;
+ }
+
+ 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[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 < compSpecParams.length; i++) {
+ int[] compParam = compSpecParams[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;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGHuffmanTable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGHuffmanTable.java
new file mode 100755
index 0000000000..fc50d691e9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGHuffmanTable.java
@@ -0,0 +1,262 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+/**
+ * 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[] dhCodes;
+ int[] dhCodeLengths;
+ 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) / 16; // table class: AC (1) or DC (0)
+ int tid = (reference[ofs] & 0xFF) % 16; // 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.dhCodes = huffCodes;
+ dhtTable.dhCodeLengths = huffCodeLengths;
+ 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;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGQuantizationTable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGQuantizationTable.java
new file mode 100755
index 0000000000..47405a44c6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGQuantizationTable.java
@@ -0,0 +1,159 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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] & 0xFF) % 16;
+ int pq = (reference[ofs] & 0xFF) / 16;
+ 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) / 16;
+ if (pq == 0) {
+ for (int i = 0; i < qk.length; i++) {
+ qk[i] = reference[ofs + i + 1];
+ }
+ 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) % 16;
+ int pq = (reference[ofs] & 0xFF) / 16;
+ 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 / 256);
+ reference[i + 1] = (byte)(temp % 256);
+ }
+ ofs += 129;
+ totalLength -= 129;
+ }
+ }
+}
+
+public int signature() {
+ return JPEGFileFormat.DQT;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGRestartInterval.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGRestartInterval.java
new file mode 100755
index 0000000000..242d5d924d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGRestartInterval.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGScanHeader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGScanHeader.java
new file mode 100755
index 0000000000..4e087fb951
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGScanHeader.java
@@ -0,0 +1,117 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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] & 0xFF) / 16;
+}
+
+public int getApproxBitPositionLow() {
+ return (reference[(2 * getNumberOfImageComponents()) + 7] & 0xFF) % 16;
+}
+
+public int getEndOfSpectralSelection() {
+ return (reference[(2 * getNumberOfImageComponents()) + 6] & 0xFF);
+}
+
+public int getNumberOfImageComponents() {
+ return (reference[4] & 0xFF);
+}
+
+public int getStartOfSpectralSelection() {
+ return (reference[(2 * getNumberOfImageComponents()) + 5] & 0xFF);
+}
+
+/* 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) / 16;
+ int ac = (reference[ofs + 1] & 0xFF) % 16;
+ if (componentParameters.length < cid) {
+ int[][] newParams = new int[cid][];
+ System.arraycopy(componentParameters, 0, newParams, 0, componentParameters.length);
+ componentParameters = newParams;
+ }
+ componentParameters[cid - 1] = 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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGSegment.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGSegment.java
new file mode 100755
index 0000000000..4f41a6a98b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGSegment.java
@@ -0,0 +1,54 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.*;
+
+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;
+ }
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGStartOfImage.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGStartOfImage.java
new file mode 100755
index 0000000000..4a487d421b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGStartOfImage.java
@@ -0,0 +1,29 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java
new file mode 100755
index 0000000000..7b96ed1aac
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/JPEGVariableSizeSegment.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+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);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataInputStream.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataInputStream.java
new file mode 100755
index 0000000000..46e843d4c0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataInputStream.java
@@ -0,0 +1,88 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+import java.io.*;
+
+final class LEDataInputStream extends InputStream {
+ int position;
+ PushbackInputStream in;
+
+ public LEDataInputStream(InputStream input) {
+ this(input, 512);
+ }
+
+ public LEDataInputStream(InputStream input, int bufferSize) {
+ this.in = new PushbackInputStream(input, bufferSize);
+ }
+
+ public void close() throws IOException {
+ in.close();
+ }
+
+ /**
+ * Answer how many bytes were read.
+ */
+ public int getPosition() {
+ return position;
+ }
+
+ /**
+ * Answer the next byte of the input stream.
+ */
+ public int read() throws IOException {
+ position++;
+ return in.read();
+ }
+
+ /**
+ * 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 result;
+ int left = len;
+ result = in.read(b, off, len);
+ while (true) {
+ if (result == -1)
+ return -1;
+ position += result;
+ if (result == left)
+ return len;
+ left -= result;
+ off += result;
+ result = in.read(b, off, left);
+ }
+ }
+
+ /**
+ * 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) << 8) |
+ (buf[2] & 0xFF)) << 8) |
+ (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));
+ }
+
+ public void unread(byte[] b) throws IOException {
+ position -= b.length;
+ in.unread(b);
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataOutputStream.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataOutputStream.java
new file mode 100755
index 0000000000..7859012ca8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LEDataOutputStream.java
@@ -0,0 +1,54 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import java.io.*;
+
+/* Class Definition */
+final class LEDataOutputStream extends OutputStream {
+ OutputStream out;
+public LEDataOutputStream(OutputStream output) {
+ this.out = output;
+}
+public void close() throws IOException {
+ out.close();
+}
+public void write(byte b[], int off, int len) throws IOException {
+ out.write(b, off, len);
+}
+/**
+ * Answer the next byte of the input stream.
+ */
+public void write(int b) throws IOException {
+ out.write(b);
+}
+/**
+ * Answer the next byte of the input stream.
+ */
+public void writeByte(byte b) throws IOException {
+ out.write(b & 0xFF);
+}
+/**
+ * Answer an integer comprised of the next
+ * four bytes of the input 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);
+}
+/**
+ * Answer an integer comprised of the next
+ * two bytes of the input stream.
+ */
+public void writeShort(int theShort) throws IOException {
+ out.write(theShort & 0xFF);
+ out.write((theShort >> 8) & 0xFF);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java
new file mode 100755
index 0000000000..fcf71f81a9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWCodec.java
@@ -0,0 +1,479 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/* Class Definition */
+final class LZWCodec {
+ int bitsPerPixel, blockSize, blockIndex, currentByte, bitsLeft,
+ codeSize, clearCode, endCode, newCodes, topSlot, currentSlot,
+ imageWidth, imageHeight, imageX, imageY, pass, line, codeMask, buffer;
+ byte[] block, lineArray;
+ int[] maskTable, stack, suffix, prefix;
+ LZWNode[] nodeStack;
+ LEDataInputStream inputStream;
+ LEDataOutputStream outputStream;
+ ImageData image;
+ ImageLoader loader;
+ boolean interlaced;
+/**
+ * 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 = maskTable[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) {
+ if (code > currentSlot)
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ 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 = maskTable[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 = maskTable[codeSize - 1];
+ topSlot *= 2;
+ }
+ } else {
+ nextPutCode(clearCode);
+ for (int i = 0; i < nodeStack.length; i++)
+ nodeStack[i].children = null;
+ codeSize = bitsPerPixel + 1;
+ codeMask = maskTable[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;
+ maskTable = new int[] {
+ 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F,
+ 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF
+ };
+ codeMask = maskTable[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);
+ maskTable = new int[] {
+ 0x1, 0x3, 0x7, 0xF, 0x1F, 0x3F, 0x7F,
+ 0xFF, 0x1FF, 0x3FF, 0x7FF, 0xFFF
+ };
+ 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 & maskTable[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);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWNode.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWNode.java
new file mode 100755
index 0000000000..d4d3d4b680
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/LZWNode.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Class Definition */
+final class LZWNode {
+ public LZWNode left, right, children;
+ public int code, prefix, suffix;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java
new file mode 100755
index 0000000000..6a9413bdb9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PNGFileFormat.java
@@ -0,0 +1,525 @@
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+import java.util.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class PNGFileFormat extends FileFormat {
+ static final int SIGNATURE_LENGTH = 8;
+ PngDecodingDataStream decodingStream;
+ PngIhdrChunk headerChunk;
+ PngPlteChunk paletteChunk;
+ PngTrnsChunk trnsChunk;
+ ImageData imageData;
+ byte[] data;
+ byte[] alphaPalette;
+
+/**
+ * Skip over signature data. This has already been
+ * verified in isPNGFile().
+ */
+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 imageSize = getAlignedBytesPerRow() * headerChunk.getHeight();
+ data = new byte[imageSize];
+ imageData = ImageData.internal_new(
+ headerChunk.getWidth(),
+ headerChunk.getHeight(),
+ 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) {
+ 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);
+ }
+ 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(ImageData p1) {
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+}
+/**
+ * Answer whether the specified input stream
+ * contains a PNG image.
+ */
+public static boolean isPNGFile(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;
+ int srcBytesPerLine = width * 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();
+ 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) {
+ decodingStream = new PngDecodingDataStream(chunk, chunkReader);
+ int interlaceMethod = headerChunk.getInterlaceMethod();
+ if (interlaceMethod == PngIhdrChunk.INTERLACE_METHOD_NONE) {
+ readNonInterlacedImage();
+ } else {
+ readInterlacedImage();
+ }
+ decodingStream.assertImageDataAtEnd();
+ decodingStream.checkAdler();
+}
+/**
+ * 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(
+ int rowInterval,
+ int columnInterval,
+ int startRow,
+ int startColumn,
+ int frameCount)
+{
+ 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 = decodingStream.getNextDecodedByte();
+ for (int col = 0; col < bytesPerRow; col++) {
+ currentRow[col] = decodingStream.getNextDecodedByte();
+ }
+ 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() {
+ readInterlaceFrame(8, 8, 0, 0, 0);
+ readInterlaceFrame(8, 8, 0, 4, 1);
+ readInterlaceFrame(8, 4, 4, 0, 2);
+ readInterlaceFrame(4, 4, 0, 2, 3);
+ readInterlaceFrame(4, 2, 2, 0, 4);
+ readInterlaceFrame(2, 2, 0, 1, 5);
+ readInterlaceFrame(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() {
+ 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;
+ for (int row = 0; row < headerChunk.getHeight(); row++) {
+ byte filterType = decodingStream.getNextDecodedByte();
+ for (int col = 0; col < bytesPerRow; col++) {
+ currentRow[col] = decodingStream.getNextDecodedByte();
+ }
+ 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 = (Math.pow(2, 8) - 1) / (Math.pow(2, 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 = (Math.pow(2, 8) - 1) / (Math.pow(2, 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
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java
new file mode 100755
index 0000000000..1715ebccb1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunk.java
@@ -0,0 +1,333 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+import java.io.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+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 int[] crcTable;
+
+ 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'};
+
+/**
+ * Construct a PngChunk using the reference bytes
+ * given.
+ */
+PngChunk(byte[] reference) {
+ super();
+ setReference(reference);
+}
+
+/**
+ * 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 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 getInt32(LENGTH_OFFSET);
+}
+
+/**
+ * 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);
+}
+
+/**
+ * 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) {
+ throw new SWTException(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) {
+ throw new SWTException(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() {
+ if (crcTable == null) {
+ crcTable = new int[256];
+ for (int i = 0; i < 256; i++) {
+ crcTable[i] = i;
+ for (int j = 0; j < 8; j++) {
+ if ((crcTable[i] & 0x1) == 0) {
+ crcTable[i] = (crcTable[i] >> 1) & 0x7FFFFFFF;
+ } else {
+ crcTable[i] = 0xEDB88320 ^ ((crcTable[i] >> 1) & 0x7FFFFFFF);
+ }
+ }
+ }
+ }
+ 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 = crcTable[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() {
+ return Character.isUpperCase((char) getTypeBytes()[0]);
+}
+
+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.
+ if (!Character.isUpperCase((char) type[2])) SWT.error(SWT.ERROR_INVALID_IMAGE);
+
+ // All characters must be letters.
+ for (int i = 0; i < TYPE_FIELD_LENGTH; i++) {
+ if (!Character.isLetter((char) type[i])) 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) {}
+
+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();
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunkReader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunkReader.java
new file mode 100755
index 0000000000..f93b716697
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngChunkReader.java
@@ -0,0 +1,64 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+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);
+ 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);
+ 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;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngDecodingDataStream.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngDecodingDataStream.java
new file mode 100755
index 0000000000..1800a2415b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngDecodingDataStream.java
@@ -0,0 +1,131 @@
+package org.eclipse.swt.internal.image;
+
+import java.io.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class PngDecodingDataStream {
+ PngIdatChunk currentChunk;
+ PngChunkReader chunkReader;
+ byte currentByte;
+ int nextByteIndex;
+ int nextBitIndex;
+
+ PngLzBlockReader lzBlockReader;
+ int adlerValue;
+
+ static final int PRIME = 65521;
+ static final int MAX_BIT = 7;
+
+PngDecodingDataStream(PngIdatChunk idatChunk, PngChunkReader chunkReader) {
+ super();
+ this.currentChunk = idatChunk;
+ this.chunkReader = chunkReader;
+ nextByteIndex = 0;
+ 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() {
+ lzBlockReader.assertCompressedDataAtEnd();
+}
+
+int getNextIdatBits(int length) {
+ int value = 0;
+ for (int i = 0; i < length; i++) {
+ value |= (getNextIdatBit() << i);
+ }
+ return value;
+}
+
+byte getNextIdatBit() {
+ if (nextBitIndex > MAX_BIT) {
+ currentByte = getNextIdatByte();
+ nextBitIndex = 0;
+ }
+ int mask = 1 << nextBitIndex;
+ nextBitIndex++;
+ return ((currentByte & mask) > 0) ? (byte) 1 : (byte) 0;
+}
+
+private PngIdatChunk getNextChunk() {
+ PngChunk chunk = chunkReader.readNextChunk();
+ if (chunk == null) error();
+ if (chunk.getChunkType() != PngChunk.CHUNK_IDAT) error();
+ return (PngIdatChunk) chunk;
+}
+
+byte getNextIdatByte() {
+ if (nextByteIndex > currentChunk.getLength() - 1) {
+ currentChunk = getNextChunk();
+ nextByteIndex = 0;
+ }
+ byte nextByte = currentChunk.getDataByteAtOffset(nextByteIndex);
+ nextByteIndex++;
+ nextBitIndex = MAX_BIT + 1;
+ return nextByte;
+}
+
+private 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;
+}
+
+byte getNextDecodedByte() {
+ byte nextDecodedByte = lzBlockReader.getNextByte();
+ updateAdler(nextDecodedByte);
+ return nextDecodedByte;
+}
+
+void error() {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+private void readCompressedDataHeader() {
+ byte headerByte1 = getNextIdatByte();
+ byte headerByte2 = getNextIdatByte();
+
+ int number = (headerByte1 << 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() {
+ int storedAdler = ((getNextIdatByte() & 0xFF) << 24)
+ | ((getNextIdatByte() & 0xFF) << 16)
+ | ((getNextIdatByte() & 0xFF) << 8)
+ | (getNextIdatByte() & 0xFF);
+ if (storedAdler != adlerValue) error();
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngFileReadState.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngFileReadState.java
new file mode 100755
index 0000000000..13e23783f3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngFileReadState.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class PngFileReadState extends Object {
+ boolean readIHDR;
+ boolean readPLTE;
+ boolean readIDAT;
+ boolean readIEND;
+
+ // Non - critical chunks
+ boolean readBKGD;
+ boolean readTRNS;
+
+ // Set to true after IDATs have been read.
+ boolean readPixelData;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTable.java
new file mode 100755
index 0000000000..5c5eafa9a7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTable.java
@@ -0,0 +1,122 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class PngHuffmanTable {
+ CodeLengthInfo[] codeLengthInfo;
+ int[] codeValues;
+
+ static final int MAX_CODE_LENGTH = 15;
+ static final int BAD_CODE = 0xFFFFFFF;
+
+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. Primary key is code size. Secondary key is value.
+ for (int i = 0; i < lengths.length - 1; i++) {
+ for (int j = i + 1; j < lengths.length; j++) {
+ if (lengths[j] < lengths[i]
+ || (lengths[j] == lengths[i]
+ && codeValues[j] < codeValues[i]))
+ {
+ int tmp;
+ tmp = lengths[j];
+ lengths[j] = lengths[i];
+ lengths[i] = tmp;
+ tmp = codeValues[j];
+ codeValues[j] = codeValues[i];
+ codeValues[i] = tmp;
+ }
+ }
+ }
+
+ // 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) {
+ 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 (code > codeLengthInfo[codelength].max && codelength < MAX_CODE_LENGTH) {
+ 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];
+}
+
+class CodeValuePair {
+ int value;
+ int code;
+}
+class CodeLengthInfo {
+ int length;
+ int max;
+ int min;
+ int baseIndex;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTables.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTables.java
new file mode 100755
index 0000000000..383323da97
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngHuffmanTables.java
@@ -0,0 +1,156 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+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){
+ 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 () {
+ super();
+ literalTable = getFixedLiteralTable();
+ distanceTable = getFixedDistanceTable();
+}
+
+private PngHuffmanTables (PngDecodingDataStream stream) {
+ super();
+
+ 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)
+{
+ 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) {
+ return literalTable.getNextValue(stream);
+}
+
+int getNextDistanceValue(PngDecodingDataStream stream) {
+ return distanceTable.getNextValue(stream);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIdatChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIdatChunk.java
new file mode 100755
index 0000000000..883326ebe3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIdatChunk.java
@@ -0,0 +1,36 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class PngIdatChunk extends PngChunk {
+
+PngIdatChunk(byte[] reference){
+ super(reference);
+}
+
+/**
+ * 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];
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIendChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIendChunk.java
new file mode 100755
index 0000000000..189cf8f7a3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIendChunk.java
@@ -0,0 +1,39 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class PngIendChunk extends PngChunk {
+
+PngIendChunk(byte[] reference){
+ super(reference);
+}
+
+/**
+ * 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);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java
new file mode 100755
index 0000000000..00f3cec52e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngIhdrChunk.java
@@ -0,0 +1,372 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class PngIhdrChunk extends PngChunk {
+ static final int EXPECTED_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 int COLOR_TYPE_GRAYSCALE = 0;
+ static final int COLOR_TYPE_RGB = 2;
+ static final int COLOR_TYPE_PALETTE = 3;
+ static final int COLOR_TYPE_GRAYSCALE_WITH_ALPHA = 4;
+ static final int 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};
+
+/**
+ * Construct a PNGChunk using the reference bytes
+ * given.
+ */
+PngIhdrChunk(byte[] reference) {
+ super(reference);
+}
+
+/**
+ * Get the image's width in pixels.
+ */
+int getWidth() {
+ return getInt32(WIDTH_DATA_OFFSET);
+}
+
+/**
+ * Set the image's width in pixels.
+ */
+void setWidth(int value) {
+ setInt32(WIDTH_DATA_OFFSET, value);
+}
+
+/**
+ * Get the image's height in pixels.
+ */
+int getHeight() {
+ return getInt32(HEIGHT_DATA_OFFSET);
+}
+
+/**
+ * Set the image's height in pixels.
+ */
+void setHeight(int value) {
+ setInt32(HEIGHT_DATA_OFFSET, value);
+}
+
+/**
+ * Get the image's bit depth.
+ * This is limited to the values 1, 2, 4, 8, or 16.
+ */
+byte getBitDepth() {
+ return reference[BIT_DEPTH_OFFSET];
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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 reference[COLOR_TYPE_OFFSET];
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Get the image's compression method.
+ * This value must be 0.
+ */
+byte getCompressionMethod() {
+ return reference[COMPRESSION_METHOD_OFFSET];
+}
+
+/**
+ * Set the image's compression method.
+ * This value must be 0.
+ */
+void setCompressionMethod(byte value) {
+ reference[COMPRESSION_METHOD_OFFSET] = value;
+}
+
+/**
+ * Get the image's filter method.
+ * This value must be 0.
+ */
+byte getFilterMethod() {
+ return reference[FILTER_METHOD_OFFSET];
+}
+
+/**
+ * Set the image's filter method.
+ * This value must be 0.
+ */
+void setFilterMethod(byte value) {
+ reference[FILTER_METHOD_OFFSET] = value;
+}
+
+/**
+ * Get the image's interlace method.
+ * This value is limited to:
+ * 0 - No interlacing used.
+ * 1 - Adam7 interlacing used.
+ */
+byte getInterlaceMethod() {
+ return reference[INTERLACE_METHOD_OFFSET];
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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 (getLength() != EXPECTED_DATA_LENGTH) SWT.error(SWT.ERROR_INVALID_IMAGE);
+ if (getCompressionMethod() != 0) SWT.error(SWT.ERROR_INVALID_IMAGE);
+ if (getInterlaceMethod() != INTERLACE_METHOD_NONE &&
+ getInterlaceMethod() != INTERLACE_METHOD_ADAM7) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+
+ boolean colorTypeIsValid = false;
+ byte colorType = getColorType();
+ 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;
+ byte bitDepth = getBitDepth();
+ 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 (getColorType()) {
+ 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 - " + getColorType();
+ }
+}
+
+String getFilterMethodString() {
+ switch (getFilterMethod()) {
+ 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 (getInterlaceMethod()) {
+ 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(getWidth());
+ buffer.append("\n\tHeight: ");
+ buffer.append(getHeight());
+ buffer.append("\n\tBit Depth: ");
+ buffer.append(getBitDepth());
+ buffer.append("\n\tColor Type: ");
+ buffer.append(getColorTypeString());
+ buffer.append("\n\tCompression Method: ");
+ buffer.append(getCompressionMethod());
+ buffer.append("\n\tFilter Method: ");
+ buffer.append(getFilterMethodString());
+ buffer.append("\n\tInterlace Method: ");
+ buffer.append(getInterlaceMethodString());
+}
+
+boolean getMustHavePalette() {
+ return getColorType() == COLOR_TYPE_PALETTE;
+}
+
+boolean getCanHavePalette() {
+ int colorType = getColorType();
+ 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() {
+ int bitDepth = getBitDepth();
+ switch (getColorType()) {
+ 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() {
+ int bitDepth = getBitDepth();
+ switch (getColorType()) {
+ 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 (getBitDepth() < 8) return 1;
+ return getBitsPerPixel() / 8;
+}
+
+boolean usesDirectColor() {
+ switch (getColorType()) {
+ 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 bitDepth = Math.min(getBitDepth(), 8);
+ int max = (int) (Math.pow(2, bitDepth) - 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 (getColorType()) {
+ 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;
+ }
+}
+
+
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngLzBlockReader.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngLzBlockReader.java
new file mode 100755
index 0000000000..eab8cdfa7b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngLzBlockReader.java
@@ -0,0 +1,169 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class PngLzBlockReader {
+ boolean readHeader;
+ 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;
+ readHeader = false;
+ isLastBlock = false;
+}
+
+void setWindowSize(int windowSize) {
+ window = new byte[windowSize];
+}
+
+void readNextBlockHeader() {
+ isLastBlock = stream.getNextIdatBit() != 0;
+ compressionType = (byte)(stream.getNextIdatBits(2) & 0xFF);
+ if (compressionType > 2) stream.error();
+
+ if (compressionType == UNCOMPRESSED) {
+ int length = stream.getNextIdatByte()
+ | (stream.getNextIdatByte() << 8);
+ int testValue = stream.getNextIdatByte()
+ | (stream.getNextIdatByte() << 8);
+ if (length != ~testValue) stream.error();
+ uncompressedBytesRemaining = length;
+ } else if (compressionType == COMPRESSED_DYNAMIC) {
+ huffmanTables = PngHuffmanTables.getDynamicTables(stream);
+ } else {
+ huffmanTables = PngHuffmanTables.getFixedTables();
+ }
+}
+
+byte getNextByte() {
+ 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() {
+ if (compressionType == UNCOMPRESSED) {
+ if (uncompressedBytesRemaining > 0) stream.error();
+ } else if (copyBytesRemaining > 0 ||
+ (huffmanTables.getNextLiteralValue(stream) != END_OF_COMPRESSED_BLOCK))
+ {
+ stream.error();
+ }
+}
+void assertCompressedDataAtEnd() {
+ assertBlockAtEnd();
+ while (!isLastBlock) {
+ readNextBlockHeader();
+ assertBlockAtEnd();
+ }
+}
+
+private byte getNextCompressedByte() {
+ if (copyBytesRemaining > 0) {
+ byte value = window[copyIndex];
+ byte temp = (byte) (value & 0xFF);
+ 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) {
+ byte temp = (byte) (value & 0xFF);
+ 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 getNextCompressedByte();
+ } 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;
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java
new file mode 100755
index 0000000000..8c41b83d22
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngPlteChunk.java
@@ -0,0 +1,87 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class PngPlteChunk extends PngChunk {
+
+PngPlteChunk(byte[] reference){
+ super(reference);
+}
+
+/**
+ * Get the number of colors in this palette.
+ */
+int getPaletteSize() {
+ return getLength() / 3;
+}
+
+/**
+ * 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[getPaletteSize()];
+ int start = DATA_OFFSET;
+ int end = DATA_OFFSET + getLength();
+ 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);
+}
+
+/**
+ * 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.readBKGD
+ || 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.
+ 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 (Math.pow(2, headerChunk.getBitDepth()) < getPaletteSize()) {
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+
+ // Palettes cannot have more than 256 entries.
+ if (256 < getPaletteSize()) SWT.error(SWT.ERROR_INVALID_IMAGE);
+}
+
+void contributeToString(StringBuffer buffer) {
+ buffer.append("\n\tPalette size:");
+ buffer.append(getPaletteSize());
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngTrnsChunk.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngTrnsChunk.java
new file mode 100755
index 0000000000..a1910bade6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/PngTrnsChunk.java
@@ -0,0 +1,133 @@
+package org.eclipse.swt.internal.image;
+
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class PngTrnsChunk extends PngChunk {
+ static final int TRANSPARENCY_TYPE_PIXEL = 0;
+ static final int TRANSPARENCY_TYPE_ALPHAS = 1;
+
+PngTrnsChunk(byte[] reference){
+ super(reference);
+}
+
+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;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java
new file mode 100755
index 0000000000..fc94da00d2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinBMPFileFormat.java
@@ -0,0 +1,667 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+/* Class Definition */
+final class WinBMPFileFormat extends FileFormat {
+ int compression;
+ int importantColors;
+ Point pelsPerMeter = new Point(0, 0);
+ public static final int BMPHeaderFixedSize = 40;
+
+/**
+ * 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;
+}
+public static boolean isBMPFile(LEDataInputStream stream) {
+ try {
+ byte[] header = new byte[2];
+ stream.read(header);
+ stream.unread(header);
+ return header[0] == 0x42 && header[1] == 0x4D;
+ } 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);
+ 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) { // 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);
+ }
+ 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.compression = (infoHeader[16] & 0xFF) | ((infoHeader[17] & 0xFF) << 8) | ((infoHeader[18] & 0xFF) << 16) | ((infoHeader[19] & 0xFF) << 24);
+ 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 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 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 << ((infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8));
+ } 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)
+ return new PaletteData(0x7C00, 0x3E0, 0x1F);
+ return new PaletteData(0xFF, 0xFF00, 0xFF0000);
+}
+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.
+ */
+byte[] paletteToBytes(PaletteData pal) {
+ int n = (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(ImageData image) {
+ byte[] rgbs;
+ int numCols;
+ if (!((image.depth == 1) || (image.depth == 4) || (image.depth == 8) ||
+ (image.depth == 16) || (image.depth == 24)))
+ 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)) {
+ 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 = 54;
+ 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[] compressedData = out.toByteArray();
+
+ // Calculate file size
+ fileHeader[1] = fileHeader[4] + compressedData.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(WinBMPFileFormat.BMPHeaderFixedSize);
+ outputStream.writeInt(image.width);
+ outputStream.writeInt(image.height);
+ outputStream.writeShort(1);
+ outputStream.writeShort((short)image.depth);
+ outputStream.writeInt(comp);
+ outputStream.writeInt(compressedData.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(compressedData);
+ } 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;
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java
new file mode 100755
index 0000000000..4ff4b0d3f9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/WinICOFileFormat.java
@@ -0,0 +1,284 @@
+package org.eclipse.swt.internal.image;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+
+/* Class Definition */
+final class WinICOFileFormat extends FileFormat {
+/**
+ * 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;
+ return WinBMPFileFormat.BMPHeaderFixedSize + (i.palette.colors.length * 4) + dataSize;
+}
+public static boolean isICOFile(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) {
+ if (!((i.depth == 1) || (i.depth == 4) || (i.depth == 8)))
+ return false;
+ int size = i.palette.colors.length;
+ return ((size == 2) || (size == 16) || (size == 32) || (size == 256));
+}
+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 depth = (infoHeader[14] & 0xFF) | ((infoHeader[15] & 0xFF) << 8);
+ infoHeader[14] = 1;
+ infoHeader[15] = 0;
+ byte[] maskData = bmpFormat.loadData(infoHeader);
+ bitInvertData(maskData, 0, maskData.length);
+ 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);
+ return ImageData.internal_new(
+ infoWidth,
+ infoHeight,
+ depth,
+ palette,
+ 4,
+ shapeData,
+// 4,
+ 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];
+ 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))))
+ 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.length);
+ outputStream.writeInt(0);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+
+ byte[] rgbs = new 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.writeByte((byte)i.width);
+ outputStream.writeByte((byte)i.height);
+ outputStream.writeShort(i.palette.colors.length);
+ outputStream.writeShort(0);
+ outputStream.writeShort(0);
+ outputStream.writeInt(iconSize);
+ outputStream.writeInt(offset);
+ } catch (IOException e) {
+ SWT.error(SWT.ERROR_IO, e);
+ }
+}
+void unloadIntoByteStream(ImageData image) {
+ 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) {
+ int bpl = (icon.width + 7) / 8;
+ int pad = 4;
+ 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.getTransparencyMask().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 = 4;
+ 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);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html
new file mode 100755
index 0000000000..62fccda519
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/image/package.html
@@ -0,0 +1,18 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT internal image loading/saving support classes.
+<h2>
+Package Specification</h2>
+This package contains the classes used by SWT to load and save images
+in the various formats we support, including GIF, JPEG, PNG, BMP, and ICO.
+<p>
+Applications should not need to reference the classes in this package
+directly.
+</p>
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html
new file mode 100755
index 0000000000..da0cec585e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/internal/package.html
@@ -0,0 +1,20 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT internal classes
+<h2>
+Package Specification</h2>
+This package provides the <code>Callback</code> class which is used to
+map the operating system's callback mechanism to Java message sends, and
+the <code>Converter</code> class which provides translation between Unicode
+and platform specific character sets.
+<p>
+Applications should not need to reference the classes in this package
+directly.
+</p>
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java
new file mode 100755
index 0000000000..64d1bf4dc0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/FillLayout.java
@@ -0,0 +1,67 @@
+package org.eclipse.swt.layout;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public final class FillLayout extends Layout {
+ /**
+ * type specifies how controls will be positioned
+ * within the layout.
+ *
+ * The default value is HORIZONTAL.
+ *
+ * Possible values are:
+ *
+ * HORIZONTAL: Position the controls horizontally from left to right
+ * VERTICAL: Position the controls vertically from top to bottom
+ */
+ public int type = SWT.HORIZONTAL;
+public FillLayout () {
+}
+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];
+ Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ maxWidth = Math.max (maxWidth, pt.x);
+ maxHeight = Math.max (maxHeight, pt.y);
+ }
+ if (type == SWT.HORIZONTAL) {
+ return new Point (count * maxWidth, maxHeight);
+ }
+ return new Point (maxWidth, count * maxHeight);
+}
+protected void layout (Composite composite, boolean flushCache) {
+ Rectangle rect = composite.getClientArea ();
+ Control [] children = composite.getChildren ();
+ int count = children.length;
+ if (count == 0) return;
+ if (type == SWT.HORIZONTAL) {
+ int x = rect.x + ((rect.width % count) / 2);
+ int width = rect.width / count;
+ int y = rect.y, height = rect.height;
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ child.setBounds (x, y, width, height);
+ x += width;
+ }
+ return;
+ }
+ int x = rect.x, width = rect.width;
+ int y = rect.y + ((rect.height % count) / 2);
+ int height = rect.height / count;
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ child.setBounds (x, y, width, height);
+ y += height;
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java
new file mode 100755
index 0000000000..b58e62fb39
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridData.java
@@ -0,0 +1,157 @@
+package org.eclipse.swt.layout;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public final class GridData {
+ /**
+ * verticalAlignment specifies how controls will be positioned
+ * vertically within a cell.
+ *
+ * The default value is CENTER.
+ *
+ * Possible values are:
+ *
+ * BEGINNING: Position the control at the top of the cell
+ * CENTER: Position the control in the vertical center of the cell
+ * END: Position the control at the bottom of the cell
+ * FILL: Resize the control to fill the cell vertically
+ */
+ public int verticalAlignment = CENTER;
+ /**
+ * horizontalAlignment specifies how controls will be positioned
+ * horizontally within a cell.
+ *
+ * The default value is BEGINNING.
+ *
+ * Possible values are:
+ *
+ * BEGINNING: Position the control at the left of the cell
+ * CENTER: Position the control in the horizontal center of the cell
+ * END: Position the control at the right of the cell
+ * FILL: Resize the control to fill the cell horizontally
+ */
+ public int horizontalAlignment = BEGINNING;
+ /**
+ * widthHint specifies a minimum width for the column. A value of
+ * SWT.DEFAULT indicates that no minimum width is specified.
+ *
+ * The default value is SWT.DEFAULT.
+ */
+ public int widthHint = SWT.DEFAULT;
+ /**
+ * heightHint specifies a minimum height for the row. A value of
+ * SWT.DEFAULT indicates that no minimum height is specified.
+ *
+ * The default value is SWT.DEFAULT.
+ */
+ 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;
+ /**
+ * 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;
+ /**
+ * grabExcessHorizontalSpace specifies whether the cell will be made
+ * wide enough to fit the remaining horizontal space.
+ *
+ * The default value is false.
+ */
+ public boolean grabExcessHorizontalSpace = false;
+ /**
+ * grabExcessVerticalSpace specifies whether the cell will be made
+ * tall enough to fit the remaining vertical space.
+ *
+ * The default value is false.
+ */
+ public boolean grabExcessVerticalSpace = false;
+
+ // Alignment constants.
+ public static final int BEGINNING = 1;
+ public static final int CENTER = 2;
+ public static final int END = 3;
+ public static final int FILL = 4;
+
+ // Style constants
+ public static final int VERTICAL_ALIGN_BEGINNING = 1 << 1;
+ public static final int VERTICAL_ALIGN_CENTER = 1 << 2;
+ public static final int VERTICAL_ALIGN_END = 1 << 3;
+ public static final int VERTICAL_ALIGN_FILL = 1 << 4;
+ public static final int HORIZONTAL_ALIGN_BEGINNING = 1 << 5;
+ public static final int HORIZONTAL_ALIGN_CENTER = 1 << 6;
+ public static final int HORIZONTAL_ALIGN_END = 1 << 7;
+ public static final int HORIZONTAL_ALIGN_FILL = 1 << 8;
+ public static final int GRAB_HORIZONTAL = 1 << 9;
+ public static final int GRAB_VERTICAL = 1 << 10;
+
+ // Style convenience constants
+ public static final int FILL_VERTICAL = VERTICAL_ALIGN_FILL | GRAB_VERTICAL;
+ public static final int FILL_HORIZONTAL = HORIZONTAL_ALIGN_FILL | GRAB_HORIZONTAL;
+ public static final int FILL_BOTH = FILL_VERTICAL | FILL_HORIZONTAL;
+
+ // Private
+ int childIndex;
+ boolean isItemData = true;
+public GridData() {
+ super();
+}
+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;
+
+ if ((style & GRAB_HORIZONTAL) != 0)
+ grabExcessHorizontalSpace = true;
+ else
+ grabExcessHorizontalSpace = false;
+ if ((style & GRAB_VERTICAL) != 0)
+ grabExcessVerticalSpace = true;
+ else
+ grabExcessVerticalSpace = false;
+
+}
+boolean isItemData() {
+ return isItemData;
+}
+boolean isSpacerData() {
+ return !isItemData;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java
new file mode 100755
index 0000000000..76d3220c92
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/GridLayout.java
@@ -0,0 +1,638 @@
+package org.eclipse.swt.layout;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+public final class GridLayout 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 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;
+ /**
+ * numColumns specifies the number of cell columns in the layout.
+ *
+ * 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;
+ /**
+ * 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;
+
+ // Private variables. Cached values used to cut down on grid calculations.
+ boolean initialLayout = true;
+ Vector grid = new Vector();
+ int [] pixelColumnWidths;
+ int [] pixelRowHeights;
+ int [] expandableColumns;
+ int [] expandableRows;
+public GridLayout() {
+ super();
+}
+void adjustGridDimensions(Composite composite, boolean flushCache) {
+ // Ensure that widgets that span more than one row or column have enough space.
+ for (int row = 0; row < grid.size(); row++) {
+ for (int column = 0; column < numColumns; column++) {
+ GridData spec = ((GridData[]) grid.elementAt(row))[column];
+ if (spec.isItemData()) {
+ // Widgets spanning columns.
+ if (spec.horizontalSpan > 1) {
+ Control child = composite.getChildren()[spec.childIndex];
+ Point extent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);
+
+ // Calculate the size of the widget's spanned columns.
+ int lastSpanIndex = column + spec.horizontalSpan;
+ int spannedSize = 0;
+ for (int c = column; c < lastSpanIndex; c++) {
+ spannedSize = spannedSize + pixelColumnWidths[c] + horizontalSpacing;
+ }
+ spannedSize = spannedSize - horizontalSpacing;
+
+ // If the spanned columns are not large enough to display the widget, adjust the column
+ // sizes to account for the extra space that is needed.
+ if (extent.x + spec.horizontalIndent > spannedSize) {
+ int extraSpaceNeeded = extent.x + spec.horizontalIndent - spannedSize;
+ int lastColumn = column + spec.horizontalSpan - 1;
+ int colWidth;
+ if (makeColumnsEqualWidth) {
+ // Evenly distribute the extra space amongst all of the columns.
+ int columnExtra = extraSpaceNeeded / numColumns;
+ int columnRemainder = extraSpaceNeeded % numColumns;
+ for (int i = 0; i < pixelColumnWidths.length; i++) {
+ colWidth = pixelColumnWidths[i] + columnExtra;
+ pixelColumnWidths[i] = colWidth;
+ }
+ colWidth = pixelColumnWidths[lastColumn] + columnRemainder;
+ pixelColumnWidths[lastColumn] = colWidth;
+ } else {
+ Vector localExpandableColumns = new Vector();
+ for (int i = column; i < lastColumn; i++) {
+ for (int j = 0; j < expandableColumns.length; j++) {
+ if (expandableColumns[j] == i) {
+ localExpandableColumns.addElement(new Integer(i));
+ }
+ }
+ }
+ if (localExpandableColumns.size() > 0) {
+ // If any of the widget's columns grab excess space, allocate the space amongst those columns.
+ int columnExtra = extraSpaceNeeded / localExpandableColumns.size();
+ int columnRemainder = extraSpaceNeeded % localExpandableColumns.size();
+ for (int i = 0; i < localExpandableColumns.size(); i++) {
+ int expandableCol = ((Integer) localExpandableColumns.elementAt(i)).intValue();
+ colWidth = pixelColumnWidths[expandableCol] + columnExtra;
+ pixelColumnWidths[expandableCol] = colWidth;
+ }
+ colWidth = pixelColumnWidths[lastColumn] + columnRemainder;
+ pixelColumnWidths[lastColumn] = colWidth;
+ } else {
+ // Add the extra space to the widget's last column if none of its columns grab excess space.
+ colWidth = pixelColumnWidths[lastColumn] + extraSpaceNeeded;
+ pixelColumnWidths[lastColumn] = colWidth;
+ }
+ }
+ }
+ }
+
+ // Widgets spanning rows.
+ if (spec.verticalSpan > 1) {
+ Control child = composite.getChildren()[spec.childIndex];
+ Point extent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);
+
+ // Calculate the size of the widget's spanned rows.
+ int lastSpanIndex = row + spec.verticalSpan;
+ int spannedSize = 0;
+ for (int r = row; r < lastSpanIndex; r++) {
+ spannedSize = spannedSize + pixelRowHeights[r] + verticalSpacing;
+ }
+ spannedSize = spannedSize - verticalSpacing;
+ // If the spanned rows are not large enough to display the widget, adjust the row
+ // sizes to account for the extra space that is needed.
+ if (extent.y > spannedSize) {
+ int extraSpaceNeeded = extent.y - spannedSize;
+ int lastRow = row + spec.verticalSpan - 1;
+ int rowHeight;
+ Vector localExpandableRows = new Vector();
+ for (int i = row; i < lastRow; i++) {
+ for (int j = 0; j < expandableRows.length; j++) {
+ if (expandableRows[j] == i) {
+ localExpandableRows.addElement(new Integer(i));
+ }
+ }
+ }
+ if (localExpandableRows.size() > 0) {
+ // If any of the widget's rows grab excess space, allocate the space amongst those rows.
+ int rowExtra = extraSpaceNeeded / localExpandableRows.size();
+ int rowRemainder = extraSpaceNeeded % localExpandableRows.size();
+ for (int i = 0; i < localExpandableRows.size(); i++) {
+ int expandableRow = ((Integer) localExpandableRows.elementAt(i)).intValue();
+ rowHeight = pixelRowHeights[expandableRow] + rowExtra;
+ pixelRowHeights[expandableRow] = rowHeight;
+ }
+ rowHeight = pixelRowHeights[lastRow] + rowRemainder;
+ pixelRowHeights[lastRow] = rowHeight;
+ } else {
+ // Add the extra space to the widget's last row if no rows grab excess space.
+ rowHeight = pixelRowHeights[lastRow] + extraSpaceNeeded;
+ pixelRowHeights[lastRow] = rowHeight;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+void calculateGridDimensions(Composite composite, boolean flushCache) {
+ int maxWidth, childWidth, maxHeight, childHeight;
+
+ //
+ Control[] children = composite.getChildren();
+ Point[] childSizes = new Point[children.length];
+ pixelColumnWidths = new int[numColumns];
+ pixelRowHeights = new int[grid.size()];
+
+ // Loop through the grid by column to get the width that each column needs to be.
+ // Each column will be as wide as its widest widget.
+ for (int column = 0; column < numColumns; column++) {
+ maxWidth = 0;
+ for (int row = 0; row < grid.size(); row++) {
+ GridData spec = ((GridData[]) grid.elementAt(row))[column];
+ if (spec.isItemData()) {
+ Control child = children[spec.childIndex];
+ childSizes[spec.childIndex] = child.computeSize(spec.widthHint, spec.heightHint, flushCache);
+ childWidth = childSizes[spec.childIndex].x + spec.horizontalIndent;
+ if (spec.horizontalSpan == 1) {
+ maxWidth = Math.max(maxWidth, childWidth);
+ }
+ }
+ }
+ // Cache the values for later use.
+ pixelColumnWidths[column] = maxWidth;
+ }
+
+ //
+ if (makeColumnsEqualWidth) {
+ maxWidth = 0;
+ // Find the largest column size that is necessary and make each column that size.
+ for (int i = 0; i < numColumns; i++) {
+ maxWidth = Math.max(maxWidth, pixelColumnWidths[i]);
+ }
+ for (int i = 0; i < numColumns; i++) {
+ pixelColumnWidths[i] = maxWidth;
+ }
+ }
+
+ // Loop through the grid by row to get the height that each row needs to be.
+ // Each row will be as high as its tallest widget.
+ for (int row = 0; row < grid.size(); row++) {
+ maxHeight = 0;
+ for (int column = 0; column < numColumns; column++) {
+ GridData spec = ((GridData[]) grid.elementAt(row))[column];
+ if (spec.isItemData()) {
+ Control child = children[spec.childIndex];
+ childHeight = childSizes[spec.childIndex].y;
+ if (spec.verticalSpan == 1) {
+ maxHeight = Math.max(maxHeight, childHeight);
+ }
+ }
+ }
+ // Cache the values for later use.
+ pixelRowHeights[row] = maxHeight;
+ }
+}
+void computeExpandableCells() {
+ // If a widget grabs excess horizontal space, the last column that the widget spans
+ // will be expandable. Similarly, if a widget grabs excess vertical space, the
+ // last row that the widget spans will be expandable.
+ Hashtable growColumns = new Hashtable();
+ Hashtable growRows = new Hashtable();
+ for (int col = 0; col < numColumns; col++) {
+ for (int row = 0; row < grid.size(); row++) {
+ GridData spec = ((GridData[]) grid.elementAt(row))[col];
+ if (spec.grabExcessHorizontalSpace) {
+ growColumns.put(new Integer(col + spec.horizontalSpan - 1), new Object());
+ }
+ if (spec.grabExcessVerticalSpace) {
+ growRows.put(new Integer(row + spec.verticalSpan - 1), new Object());
+ }
+ }
+ }
+
+ // Cache the values. These values are used later during children layout.
+ int i = 0;
+ Enumeration enum = growColumns.keys();
+ expandableColumns = new int[growColumns.size()];
+ while (enum.hasMoreElements()) {
+ expandableColumns[i] = ((Integer)enum.nextElement()).intValue();
+ i = i + 1;
+ }
+ i = 0;
+ enum = growRows.keys();
+ expandableRows = new int[growRows.size()];
+ while (enum.hasMoreElements()) {
+ expandableRows[i] = ((Integer)enum.nextElement()).intValue();
+ i = i + 1;
+ }
+}
+Point computeLayoutSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ int totalMarginHeight, totalMarginWidth;
+ int totalWidth, totalHeight;
+ int cols, rows;
+
+ // Initialize the grid and other cached information that help with the grid layout.
+ if (grid.size() == 0) {
+ createGrid(composite);
+ calculateGridDimensions(composite, flushCache);
+ computeExpandableCells();
+ adjustGridDimensions(composite, flushCache);
+ }
+
+ //
+ cols = numColumns;
+ rows = grid.size();
+ totalMarginHeight = marginHeight;
+ totalMarginWidth = marginWidth;
+
+ // The total width is the margin plus border width plus space between each column,
+ // plus the width of each column.
+ totalWidth = (totalMarginWidth * 2) + ((cols - 1) * horizontalSpacing);
+
+ //Add up the width of each column.
+ for (int i = 0; i < pixelColumnWidths.length; i++) {
+ totalWidth = totalWidth + pixelColumnWidths[i];
+ }
+
+ // The total height is the margin plus border height, plus space between each row,
+ // plus the height of the tallest child in each row.
+ totalHeight = (totalMarginHeight * 2) + ((rows - 1) * verticalSpacing);
+
+ //Add up the height of each row.
+ for (int i = 0; i < pixelRowHeights.length; i++) {
+ totalHeight = totalHeight + pixelRowHeights[i];
+ }
+
+ if (wHint != SWT.DEFAULT) {
+ totalWidth = wHint;};
+ if (hHint != SWT.DEFAULT) {
+ totalHeight = hHint;};
+ // The preferred extent is the width and height that will accomodate the grid's widgets.
+ return new Point(totalWidth, totalHeight);
+}
+protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
+ Control[] children = composite.getChildren();
+ int numChildren = children.length;
+
+ if (numChildren == 0) return new Point(0,0);
+
+ // Make sure that all of the composite children have a layout spec. Do this by
+ // using the initialLayout flag.
+ if (flushCache)
+ initialLayout = true;
+ if (initialLayout) {
+ initializeLayoutData(composite);
+ initialLayout = false;
+ }
+
+ if (flushCache) {
+ // Cause the grid and its related information to be calculated
+ // again.
+ grid.removeAllElements();
+ }
+ return computeLayoutSize(composite, wHint, hHint, flushCache);
+}
+void createGrid(Composite composite) {
+ int row, column, rowFill, columnFill;
+ Vector rows;
+ Control[] children;
+ GridData spacerSpec;
+
+ //
+ children = composite.getChildren();
+
+ //
+ grid.addElement(emptyRow());
+ row = 0;
+ column = 0;
+
+ // Loop through the children and place their associated layout specs in the
+ // grid. Placement occurs left to right, top to bottom (i.e., by row).
+ for (int i = 0; i < children.length; i++) {
+ // Find the first available spot in the grid.
+ Control child = children[i];
+ GridData spec = (GridData) child.getLayoutData();
+ while (((GridData[]) grid.elementAt(row))[column] != null) {
+ column = column + 1;
+ if (column >= numColumns) {
+ row = row + 1;
+ column = 0;
+ if (row >= grid.size()) {
+ grid.addElement(emptyRow());
+ }
+ }
+ }
+ // See if the place will support the widget's horizontal span. If not, go to the
+ // next row.
+ if (column + spec.horizontalSpan - 1 >= numColumns) {
+ grid.addElement(emptyRow());
+ row = row + 1;
+ column = 0;
+ }
+
+ // The vertical span for the item will be at least 1. If it is > 1,
+ // add other rows to the grid.
+ for (int j = 2; j <= spec.verticalSpan; j++) {
+ if (row + j > grid.size()) {
+ grid.addElement(emptyRow());
+ }
+ }
+
+ // Store the layout spec. Also cache the childIndex. NOTE: That we assume the children of a
+ // composite are maintained in the order in which they are created and added to the composite.
+ ((GridData[]) grid.elementAt(row))[column] = spec;
+ spec.childIndex = i;
+
+ // Put spacers in the grid to account for the item's vertical and horizontal
+ // span.
+ rowFill = spec.verticalSpan - 1;
+ columnFill = spec.horizontalSpan - 1;
+ for (int r = 1; r <= rowFill; r++) {
+ for (int c = 0; c < spec.horizontalSpan; c++) {
+ spacerSpec = new GridData();
+ spacerSpec.isItemData = false;
+ ((GridData[]) grid.elementAt(row + r))[column + c] = spacerSpec;
+ }
+ }
+ for (int c = 1; c <= columnFill; c++) {
+ for (int r = 0; r < spec.verticalSpan; r++) {
+ spacerSpec = new GridData();
+ spacerSpec.isItemData = false;
+ ((GridData[]) grid.elementAt(row + r))[column + c] = spacerSpec;
+ }
+ }
+ column = column + spec.horizontalSpan - 1;
+ }
+
+ // Fill out empty grid cells with spacers.
+ for (int k = column + 1; k < numColumns; k++) {
+ spacerSpec = new GridData();
+ spacerSpec.isItemData = false;
+ ((GridData[]) grid.elementAt(row))[k] = spacerSpec;
+ }
+ for (int k = row + 1; k < grid.size(); k++) {
+ spacerSpec = new GridData();
+ spacerSpec.isItemData = false;
+ ((GridData[]) grid.elementAt(k))[column] = spacerSpec;
+ }
+}
+GridData[] emptyRow() {
+ GridData[] row = new GridData[numColumns];
+ for (int i = 0; i < numColumns; i++) {
+ row[i] = null;}
+ return row;
+}
+void initializeLayoutData(Composite composite) {
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (child.getLayoutData() == null) {
+ child.setLayoutData(new GridData());
+ }
+ }
+}
+protected void layout(Composite composite, boolean flushCache) {
+ int[] columnWidths;
+ int[] rowHeights;
+ int columnSize, rowSize, rowY, columnX;
+ int compositeWidth, compositeHeight;
+ int excessHorizontal, excessVertical;
+ Control[] children;
+ if (flushCache) {
+ // Cause the grid and its related information to be calculated
+ // again.
+ grid.removeAllElements();
+ }
+ children = composite.getChildren();
+ if (children.length == 0)
+ return;
+
+ //
+ Point extent = computeSize(composite, SWT.DEFAULT, SWT.DEFAULT, flushCache);
+ columnWidths = new int[numColumns];
+ for (int i = 0; i < pixelColumnWidths.length; i++) {
+ columnWidths[i] = pixelColumnWidths[i];
+ }
+ rowHeights = new int[grid.size()];
+ for (int i = 0; i < pixelRowHeights.length; i++) {
+ rowHeights[i] = pixelRowHeights[i];
+ }
+ int columnWidth = 0;
+ columnSize = Math.max(1, numColumns);
+ rowSize = Math.max(1, grid.size());
+
+ //
+ compositeWidth = extent.x;
+ compositeHeight = extent.y;
+
+ // Calculate whether or not there is any extra space or not enough space due to a resize
+ // operation. Then allocate/deallocate the space to columns and rows that are expandable.
+ // If a widget grabs excess space, its last column or row will be expandable.
+ excessHorizontal = composite.getClientArea().width - compositeWidth;
+ excessVertical = composite.getClientArea().height - compositeHeight;
+
+ // Allocate/deallocate horizontal space.
+ if (expandableColumns.length != 0) {
+ int excess, remainder, last;
+ int colWidth;
+ excess = excessHorizontal / expandableColumns.length;
+ remainder = excessHorizontal % expandableColumns.length;
+ last = 0;
+ for (int i = 0; i < expandableColumns.length; i++) {
+ int expandableCol = expandableColumns[i];
+ colWidth = columnWidths[expandableCol];
+ colWidth = colWidth + excess;
+ columnWidths[expandableCol] = colWidth;
+ last = Math.max(last, expandableCol);
+ }
+ colWidth = columnWidths[last];
+ colWidth = colWidth + remainder;
+ columnWidths[last] = colWidth;
+ }
+
+ // Go through all specs in each expandable column and get the maximum specified
+ // widthHint. Use this as the minimumWidth for the column.
+ for (int i = 0; i < expandableColumns.length; i++) {
+ int expandableCol = expandableColumns[i];
+ int colWidth = columnWidths[expandableCol];
+ int minWidth = 0;
+ for (int j = 0; j < grid.size(); j++) {
+ GridData[] row = (GridData[]) grid.elementAt(j);
+ GridData spec = row[expandableCol];
+ minWidth = Math.max(minWidth, spec.widthHint);
+ }
+ columnWidths[expandableCol] = Math.max(colWidth, minWidth);
+ }
+ // Allocate/deallocate vertical space.
+ if (expandableRows.length != 0) {
+ int excess, remainder, last;
+ int rowHeight;
+ excess = excessVertical / expandableRows.length;
+ remainder = excessVertical % expandableRows.length;
+ last = 0;
+ for (int i = 0; i < expandableRows.length; i++) {
+ int expandableRow = expandableRows[i];
+ rowHeight = rowHeights[expandableRow];
+ rowHeight = rowHeight + excess;
+ rowHeights[expandableRow] = rowHeight;
+ last = Math.max(last, expandableRow);
+ }
+ rowHeight = rowHeights[last];
+ rowHeight = rowHeight + remainder;
+ rowHeights[last] = rowHeight;
+ }
+ // Go through all specs in each expandable row and get the maximum specified
+ // heightHint. Use this as the minimumHeight for the row.
+ for (int i = 0; i < expandableRows.length; i++) {
+ int expandableRow = expandableRows[i];
+ int rowHeight = rowHeights[expandableRow];
+ int minHeight = 0;
+ GridData[] row = (GridData[]) grid.elementAt(expandableRow);
+ for (int j = 0; j < numColumns; j++) {
+ GridData spec = row[j];
+ minHeight = Math.max(minHeight, spec.heightHint);
+ }
+ rowHeights[expandableRow] = Math.max(rowHeight, minHeight);
+ }
+
+ // Get the starting x and y.
+ columnX = marginWidth + composite.getClientArea().x;
+ rowY = marginHeight + composite.getClientArea().y;
+
+ // Layout the widget left to right, top to bottom.
+ for (int r = 0; r < rowSize; r++) {
+ int rowHeight = rowHeights[r];
+ GridData[] row = (GridData[]) grid.elementAt(r);
+
+ //
+ for (int c = 0; c < row.length; c++) {
+ int spannedWidth = 0, spannedHeight = 0;
+ int hAlign = 0, vAlign = 0;
+ int widgetX = 0, widgetY = 0;
+ int widgetW = 0, widgetH = 0;
+
+ //
+ GridData spec = (GridData) row[c];
+ if (makeColumnsEqualWidth) {
+ columnWidth = composite.getClientArea().width - 2 * (marginWidth) - ((numColumns - 1) * horizontalSpacing);
+ columnWidth = columnWidth / numColumns;
+ for (int i = 0; i < columnWidths.length; i++) {
+ columnWidths[i] = columnWidth;
+ }
+ } else {
+ columnWidth = columnWidths[c];
+ }
+
+ //
+ spannedWidth = columnWidth;
+ for (int k = 1; k < spec.horizontalSpan; k++) {
+ if ((c + k) <= numColumns) {
+ if (!makeColumnsEqualWidth) {
+ columnWidth = columnWidths[c + k];
+ }
+ spannedWidth = spannedWidth + columnWidth + horizontalSpacing;
+ }
+ }
+
+ //
+ spannedHeight = rowHeight;
+ for (int k = 1; k < spec.verticalSpan; k++) {
+ if ((r + k) <= grid.size()) {
+ spannedHeight = spannedHeight + rowHeights[r + k] + verticalSpacing;
+ }
+ }
+
+ //
+ if (spec.isItemData()) {
+ Control child = children[spec.childIndex];
+ Point childExtent = child.computeSize(spec.widthHint, spec.heightHint, flushCache);
+ hAlign = spec.horizontalAlignment;
+ widgetX = columnX;
+
+ // Calculate the x and width values for the widget.
+ if (hAlign == spec.CENTER) {
+ widgetX = widgetX + (spannedWidth / 2) - (childExtent.x / 2);
+ } else
+ if (hAlign == spec.END) {
+ widgetX = widgetX + spannedWidth - childExtent.x - spec.horizontalIndent;
+ } else {
+ widgetX = widgetX + spec.horizontalIndent;
+ }
+ if (hAlign == spec.FILL) {
+ widgetW = spannedWidth - spec.horizontalIndent;
+ widgetX = columnX + spec.horizontalIndent;
+ } else {
+ widgetW = childExtent.x;
+ }
+
+ // Calculate the y and height values for the widget.
+ vAlign = spec.verticalAlignment;
+ widgetY = rowY;
+ if (vAlign == spec.CENTER) {
+ widgetY = widgetY + (spannedHeight / 2) - (childExtent.y / 2);
+ } else
+ if (vAlign == spec.END) {
+ widgetY = widgetY + spannedHeight - childExtent.y;
+ } else {
+ widgetY = widgetY;
+ }
+ if (vAlign == spec.FILL) {
+ widgetH = spannedHeight;
+ widgetY = rowY;
+ } else {
+ widgetH = childExtent.y;
+ }
+ // Place the widget.
+ child.setBounds(widgetX, widgetY, widgetW, widgetH);
+ }
+ // Update the starting x value.
+ columnX = columnX + columnWidths[c] + horizontalSpacing;
+ }
+ // Update the starting y value and since we're starting a new row, reset the starting x value.
+ rowY = rowY + rowHeights[r] + verticalSpacing;
+ columnX = marginWidth + composite.getClientArea().x;
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java
new file mode 100755
index 0000000000..a3a0f8f282
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowData.java
@@ -0,0 +1,29 @@
+package org.eclipse.swt.layout;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public final class RowData {
+ /**
+ * width specifies the width of the cell in pixels.
+ */
+ public int width;
+ /**
+ * height specifies the height of the cell in pixels.
+ */
+ public int height;
+public RowData () {
+ this (SWT.DEFAULT, SWT.DEFAULT);
+}
+public RowData (int width, int height) {
+ this.width = width; this.height = height;
+}
+public RowData (Point point) {
+ this (point.x, point.y);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java
new file mode 100755
index 0000000000..1e43a2287c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/RowLayout.java
@@ -0,0 +1,151 @@
+package org.eclipse.swt.layout;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public final class RowLayout extends Layout {
+ /**
+ * 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 are forced
+ * to be the same size.
+ *
+ * The default value is true.
+ */
+ public boolean pack = true;
+ /**
+ * 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;
+ /**
+ * 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;
+ /**
+ * 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;
+public RowLayout () {
+}
+protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
+ Point extent = layout (composite, false, (wHint != SWT.DEFAULT) && wrap, wHint, flushCache);
+ if (wHint != SWT.DEFAULT) extent.x = wHint;
+ if (hHint != SWT.DEFAULT) extent.y = hHint;
+ return extent;
+}
+Point getSize (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 void layout (Composite composite, boolean flushCache) {
+ Rectangle clientArea = composite.getClientArea ();
+ layout (composite, true, wrap, clientArea.width, flushCache);
+}
+Point layout (Composite composite, boolean move, boolean wrap, int width, boolean flushCache) {
+ Control [] children = composite.getChildren ();
+ int count = children.length;
+ int childWidth = 0, childHeight = 0, maxHeight = 0;
+ if (!pack) {
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ Point pt = getSize (child, flushCache);
+ childWidth = Math.max (childWidth, pt.x);
+ childHeight = Math.max (childHeight, pt.y);
+ }
+ maxHeight = childHeight;
+ }
+ int clientX = 0, clientY = 0;
+ if (move) {
+ Rectangle rect = composite.getClientArea ();
+ clientX = rect.x; clientY = rect.y;
+ }
+ boolean wrapped = false;
+ Rectangle [] bounds = null;
+ if (move && justify) bounds = new Rectangle [count];
+ int maxX = 0, x = marginLeft, y = marginTop;
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ if (pack) {
+ Point pt = getSize (child, flushCache);
+ childWidth = pt.x; childHeight = pt.y;
+ }
+ if (wrap && (i != 0) && (x + childWidth > width)) {
+ wrapped = true;
+ x = marginLeft; y += spacing + maxHeight;
+ }
+ if (pack) {
+ maxHeight = Math.max (maxHeight, childHeight);
+ }
+ if (move) {
+ int childX = x + clientX, childY = y + clientY;
+ if (justify) {
+ bounds [i] = new Rectangle (childX, childY, childWidth, childHeight);
+ } else {
+ child.setBounds (childX, childY, childWidth, childHeight);
+ }
+ }
+ x += spacing + childWidth;
+ maxX = Math.max (maxX, x);
+ }
+ if (!wrap) maxX = x + marginRight;
+ if (move && justify) {
+ int space = 0, margin = 0;
+ if (!wrapped) {
+ space = Math.max (0, (width - maxX) / (count + 1));
+ margin = Math.max (0, ((width - maxX) % (count + 1)) / 2);
+ }
+ for (int i=0; i<count; i++) {
+ Control child = children [i];
+ bounds [i].x += (space * (i + 1)) + margin;
+ child.setBounds (bounds [i]);
+ }
+ }
+ return new Point (maxX, y + maxHeight + marginBottom);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html
new file mode 100755
index 0000000000..2f36647b51
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/layout/package.html
@@ -0,0 +1,13 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+Brief overview will be provided here.
+<h2>
+Package Specification</h2>
+Detailed overview will be provided here.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html
new file mode 100755
index 0000000000..ec94fab277
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/package.html
@@ -0,0 +1,15 @@
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT constants and error handling support.
+<h2>
+Package Specification</h2>
+This package provides the class <code>SWT</code> which contains all of the
+constants used by SWT as well as a small selection of error handling routines
+and queries such as <code>getPlatform</code> and <code>getVersion</code>.
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
new file mode 100755
index 0000000000..c20fba446c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Dialog.java
@@ -0,0 +1,207 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * 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>
+ * Note: The <em>modality</em> styles supported by this class
+ * must be treated as <em>HINT</em>s, because not all are
+ * supported by every subclass. 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, MODELESS, PRIMARY_MODAL, SYSTEM_MODAL</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ *
+ * @see Shell
+ */
+
+public abstract class Dialog {
+
+ int style;
+ Shell parent;
+ String title;
+
+/**
+ * Constructs a new instance of this class given only its
+ * parent.
+ * <p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the dialog on the currently active
+ * display if there is one. If there is no current display, the
+ * dialog 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_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 Dialog (Shell parent) {
+ this (parent, 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
+ * for all SWT dialog classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the dialog on the currently active
+ * display if there is one. If there is no current display, the
+ * dialog 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_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 Dialog (Shell parent, int style) {
+ checkSubclass ();
+ 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);
+ }
+}
+
+/**
+ * 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 SWTError#error
+ */
+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 may not be null.
+ *
+ * @param text the new text
+ *
+ * @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>
+ */
+public void setText (String string) {
+ title = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java
new file mode 100755
index 0000000000..34c4c2ebea
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Event.java
@@ -0,0 +1,84 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+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 TypedEvent
+ */
+
+public class Event {
+
+ /**
+ * the type of event, as defined by the event type constants
+ * in class <code>SWT</code>
+ *
+ * @see SWT
+ */
+ public int type;
+
+ /**
+ * the widget that the event occurred in
+ */
+ public Widget widget;
+ public Widget item;
+ public GC gc;
+ public int detail;
+ public int x, y, width, height;
+ public int time;
+ public int count;
+ public int button;
+ public int keyCode;
+ public int stateMask;
+ public char character;
+ public int start, end;
+ public String text;
+ public boolean doit = true;
+ public Object data;
+
+/**
+* Gets the bounds.
+* <p>
+* @return a rectangle that is the bounds.
+*/
+public Rectangle getBounds () {
+ return new Rectangle (x, y, width, height);
+}
+/**
+* Sets the bounds.
+* <p>
+* @param x the new x position
+* @param y the new y position
+* @param width the new width
+* @param height the new height
+*/
+public void setBounds (Rectangle rect) {
+ this.x = rect.x;
+ this.y = rect.y;
+ this.width = rect.width;
+ this.height = rect.height;
+}
+/**
+* Returns a string representation of the object.
+*
+* @return a string representation of the object
+*/
+public String toString () {
+ return "Event {type=" + type + ",widget=" + widget + ",x=" + x + ",y=" + y + ",width=" + width + ",height=" + height + "}";
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/EventTable.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/EventTable.java
new file mode 100755
index 0000000000..197c06245f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/EventTable.java
@@ -0,0 +1,85 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+
+/**
+ * Instances of this class implement a simple
+ * look up mechanism that maps an event type
+ * to a listener. Muliple listeners for the
+ * same event type are supported.
+ */
+
+class EventTable {
+ int [] types;
+ Listener [] handlers;
+
+public void hook (int eventType, Listener handler) {
+ if (types == null) types = new int [4];
+ if (handlers == null) handlers = new Listener [4];
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == 0) {
+ types [i] = eventType;
+ handlers [i] = handler;
+ return;
+ }
+ }
+ int size = types.length;
+ int [] newTypes = new int [size + 4];
+ Listener [] newHandlers = new Listener [size + 4];
+ System.arraycopy (types, 0, newTypes, 0, size);
+ System.arraycopy (handlers, 0, newHandlers, 0, size);
+ types = newTypes; handlers = newHandlers;
+ types [size] = eventType; handlers [size] = handler;
+}
+
+public boolean hooks (int eventType) {
+ if (handlers == 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 (handlers == null) return;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == event.type) {
+ Listener listener = handlers [i];
+ if (listener != null) listener.handleEvent (event);
+ }
+ }
+}
+
+public void unhook (int eventType, Listener handler) {
+ if (handlers == null) return;
+ for (int i=0; i<types.length; i++) {
+ if ((types [i] == eventType) && (handlers [i] == handler)) {
+ types [i] = 0;
+ handlers [i] = null;
+ return;
+ }
+ }
+}
+
+public void unhook (int eventType, EventListener handler) {
+ if (handlers == null) return;
+ for (int i=0; i<types.length; i++) {
+ if (types [i] == eventType) {
+ if (handlers [i] instanceof TypedListener) {
+ TypedListener listener = (TypedListener) handlers [i];
+ if (listener.getEventListener () == handler) {
+ types [i] = 0;
+ handlers [i] = null;
+ return;
+ }
+ }
+ }
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
new file mode 100755
index 0000000000..a7c8744959
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Item.java
@@ -0,0 +1,110 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+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.
+ */
+
+public abstract class Item extends Widget {
+ String text;
+ Image image;
+
+public Item (Widget parent, int style) {
+ super (parent, style);
+ text = "";
+}
+
+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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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;
+}
+
+/**
+ * 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 ();
+ text = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Layout.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Layout.java
new file mode 100755
index 0000000000..120a78d145
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Layout.java
@@ -0,0 +1,76 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+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.
+ */
+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 minimum size that the
+ * client area of the composite must be in order to
+ * position all children at their minimum 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 minimum
+ * 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 minimum)
+ * @param hHint height (<code>SWT.DEFAULT</code> for minimum)
+ * @param flushCache <code>true</code> means flush cached layout values
+ * @return a point containing the computed size (width, height)
+ * @see #layout
+ */
+protected abstract Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache);
+
+/**
+ * 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 layed 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Listener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Listener.java
new file mode 100755
index 0000000000..0541c8a24f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Listener.java
@@ -0,0 +1,45 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * <code>Listener</code>s implement 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
+ * 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);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/RunnableLock.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/RunnableLock.java
new file mode 100755
index 0000000000..a50c77e828
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/RunnableLock.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * Instances of this class are used to ensure that an
+ * application cannot interfere with the locking mechanism
+ * used to implement asynchonous and synchronous communication
+ * between widgets and background threads.
+ */
+
+class RunnableLock {
+ Runnable runnable;
+ Thread thread;
+
+RunnableLock (Runnable runnable) {
+ this.runnable = runnable;
+}
+
+boolean done () {
+ return runnable == null;
+}
+
+void run () {
+ if (runnable != null) runnable.run ();
+ runnable = null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java
new file mode 100755
index 0000000000..6338a4c0bb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/Synchronizer.java
@@ -0,0 +1,140 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/**
+ * 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
+ */
+public class Synchronizer {
+ Display display;
+ int messagesSize;
+ RunnableLock [] messages;
+ Object messageLock = new Object ();
+ Thread syncThread;
+
+public Synchronizer (Display display) {
+ this.display = display;
+}
+
+void addLast (RunnableLock entry) {
+ synchronized (messageLock) {
+ if (messages == null) messages = new RunnableLock [4];
+ if (messagesSize == messages.length) {
+ RunnableLock[] newMessages = new RunnableLock [messagesSize + 4];
+ System.arraycopy (messages, 0, newMessages, 0, messagesSize);
+ messages = newMessages;
+ }
+ messages [messagesSize++] = entry;
+ }
+}
+
+/**
+ * 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) addLast (new RunnableLock (runnable));
+ display.wake ();
+}
+
+void releaseSynchronizer () {
+ display = null;
+ messages = null;
+ messageLock = null;
+ syncThread = null;
+}
+
+RunnableLock removeFirst () {
+ synchronized (messageLock) {
+ if (messagesSize == 0) return null;
+ RunnableLock lock = messages [0];
+ System.arraycopy (messages, 1, messages, 0, --messagesSize);
+ messages [messagesSize] = null;
+ if (messagesSize == 0) messages = null;
+ return lock;
+ }
+}
+
+boolean runAsyncMessages () {
+ if (messagesSize == 0) return false;
+ do {
+ RunnableLock lock = removeFirst ();
+ if (lock == null) return true;
+ synchronized (lock) {
+ syncThread = lock.thread;
+ try {
+ lock.run ();
+ } finally {
+ syncThread = null;
+ }
+ lock.notifyAll ();
+ };
+ } while (true);
+}
+
+/**
+ * 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.
+ *
+ * @see #asyncExec
+ */
+protected void syncExec (Runnable runnable) {
+ if (display.isValidThread ()) {
+ if (runnable != null) runnable.run ();
+ return;
+ }
+ if (runnable == null) {
+ display.wake ();
+ return;
+ }
+ RunnableLock lock = new RunnableLock (runnable);
+ /*
+ * Only remember the syncThread for syncExec.
+ */
+ lock.thread = Thread.currentThread();
+ synchronized (lock) {
+ addLast (lock);
+ display.wake ();
+ boolean interrupted = false;
+ while (!lock.done ()) {
+ try {
+ lock.wait ();
+ } catch (InterruptedException e) {
+ interrupted = true;
+ }
+ }
+ if (interrupted) {
+ Thread.currentThread ().interrupt ();
+ }
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java
new file mode 100755
index 0000000000..f4489cacab
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/TypedListener.java
@@ -0,0 +1,222 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import java.util.EventListener;
+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
+ *
+ * @private
+ */
+public class TypedListener implements Listener {
+
+ /**
+ * The receiver's event listener
+ */
+ protected EventListener 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 (EventListener 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 EventListener 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>
+ */
+public void handleEvent (Event e) {
+ switch (e.type) {
+ case SWT.Paint: {
+ /* Field set by Control */
+ PaintEvent event = new PaintEvent (e);
+ ((PaintListener) eventListener).paintControl (event);
+ e.gc = event.gc;
+ 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.DefaultSelection: {
+ ((SelectionListener)eventListener).widgetDefaultSelected(new SelectionEvent(e));
+ break;
+ }
+ case SWT.Dispose: {
+ ((DisposeListener) eventListener).widgetDisposed(new DisposeEvent(e));
+ break;
+ }
+ case SWT.FocusIn: {
+ ((FocusListener) eventListener).focusGained(new FocusEvent(e));
+ break;
+ }
+ case SWT.FocusOut: {
+ ((FocusListener) eventListener).focusLost(new FocusEvent(e));
+ break;
+ }
+ case SWT.Hide: {
+ ((MenuListener) eventListener).menuHidden(new MenuEvent(e));
+ break;
+ }
+ case SWT.Show: {
+ ((MenuListener) eventListener).menuShown(new MenuEvent(e));
+ break;
+ }
+ case SWT.KeyDown: {
+ ((KeyListener) eventListener).keyPressed(new KeyEvent(e));
+ break;
+ }
+ case SWT.KeyUp: {
+ ((KeyListener) eventListener).keyReleased(new KeyEvent(e));
+ break;
+ }
+ case SWT.MouseDown: {
+ ((MouseListener) eventListener).mouseDown(new MouseEvent(e));
+ break;
+ }
+ case SWT.MouseUp: {
+ ((MouseListener) eventListener).mouseUp(new MouseEvent(e));
+ break;
+ }
+ case SWT.MouseDoubleClick: {
+ ((MouseListener) eventListener).mouseDoubleClick(new MouseEvent(e));
+ break;
+ }
+ case SWT.MouseMove: {
+ ((MouseMoveListener) eventListener).mouseMove(new MouseEvent(e));
+ return;
+ }
+ case SWT.Resize: {
+ ((ControlListener) eventListener).controlResized(new ControlEvent(e));
+ break;
+ }
+ case SWT.Move: {
+ ((ControlListener) eventListener).controlMoved(new ControlEvent(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.Activate: {
+ ((ShellListener) eventListener).shellActivated(new ShellEvent(e));
+ break;
+ }
+ case SWT.Deactivate: {
+ ((ShellListener) eventListener).shellDeactivated(new ShellEvent(e));
+ break;
+ }
+ case SWT.Iconify: {
+ ((ShellListener) eventListener).shellIconified(new ShellEvent(e));
+ break;
+ }
+ case SWT.Deiconify: {
+ ((ShellListener) eventListener).shellDeiconified(new ShellEvent(e));
+ break;
+ }
+ case SWT.Expand: {
+ ((TreeListener) eventListener).treeExpanded(new TreeEvent(e));
+ break;
+ }
+ case SWT.Collapse: {
+ ((TreeListener) eventListener).treeCollapsed(new TreeEvent(e));
+ break;
+ }
+ case SWT.Modify: {
+ ((ModifyListener) eventListener).modifyText(new ModifyEvent(e));
+ 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;
+ }
+ case SWT.Help: {
+ ((HelpListener) eventListener).helpRequested (new HelpEvent (e));
+ break;
+ }
+ case SWT.Arm: {
+ ((ArmListener) eventListener).widgetArmed (new ArmEvent (e));
+ break;
+ }
+ case SWT.MouseExit: {
+ ((MouseTrackListener) eventListener).mouseExit (new MouseEvent (e));
+ break;
+ }
+ case SWT.MouseEnter: {
+ ((MouseTrackListener) eventListener).mouseEnter (new MouseEvent (e));
+ break;
+ }
+ case SWT.MouseHover: {
+ ((MouseTrackListener) eventListener).mouseHover (new MouseEvent (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;
+ }
+
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html
new file mode 100755
index 0000000000..b23d27be20
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/widgets/package.html
@@ -0,0 +1,15 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT widget public API classes.
+<h2>
+Package Specification</h2>
+This package contains the classes which make up the public SWT widget
+API as well as the related public support classes (for example, class
+<code>Event</code>).
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/readme_swt.html b/bundles/org.eclipse.swt/Eclipse SWT/common/readme_swt.html
new file mode 100755
index 0000000000..92796ff893
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/readme_swt.html
@@ -0,0 +1,550 @@
+<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="GENERATOR" content="Mozilla/4.5 [en] (Win98; I) [Netscape]">
+ <meta name="Author" content="IBM">
+ <title>Eclipse Platform Release Notes - SWT</title>
+</head>
+<body>
+
+<h1>
+Eclipse Platform Release Notes<br>
+SWT</h1>
+SWT Build 105 - Thursday May 10, 2001
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GDH5XA: SWT:Linux - Shell deactivate Event not fired
+<br>1GDGWW9: SWT:WIN2000 - Converter @param tags missing var name for terminate
+<br>1GDGN75: SWT:WIN2000 - Table should reset image list if no items
+<br>1GDCYE3: ITPJUI:WINNT - all perspectives corrupted
+<br>1GDCSRP: SWT:WINNT - Reading PNG streams having 2-bit image depth
+<br>1GD7UBX: SWT:WINNT - Trivial error in TableEditor class comment
+<br>1GD46XF: SWT:WIN2000 - Since build 048, Label widget has no left margin for text
+<br>1GBQ19X: SWT:WIN2000 - Problems with context menu lifecycle
+</blockquote>
+<h1>
+Eclipse Platform Release Notes<br>
+SWT</h1>
+SWT Build 104 - Monday May 7, 2001
+
+<h2><a NAME="What's new"></a>What's new in this drop</h2>
+
+<h3><a NAME="Behaviour Changes"></a>Behaviour Changes</h3>
+<ul>
+<li>StyledText was incorrectly changing the cursor to a busy cursor when performing a copy or paste. Setting the cursor is the responsibility of the application.
+</ul>
+
+<h3><a NAME="API Changes"></a>API Changes</h3>
+<ul>
+<li>StyledText.print() has been added.
+<li>Printer support has been added.
+</ul>
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GD7MK9: SWT:WINNT - Cheese in label when setting a different size image and changing the bounds in the layout
+<br>1GD63XZ: SWT:WIN2000 - exit eclipse workbench throws exception
+<br>1GD5ZND: SWT:WINNT - Label ignoring setAlignment method call
+<br>1GD0LO7: ITPUI:Linux - External files given wrong path
+<br>1GD0BZR: SWT:Linux - StyledText: I-beam cursor cheese when scrolling
+<br>1GBPPQW: ITPJUI:WIN2000 - Tab width is 2 instead of 4
+<br>1GBOBBO: SWT:ALL - Should check in Display methods if display is disposed
+<br>1GBCXQA: SWT:Linux - Cannot paste to single-line Text widget
+<br>1GAP5O4: SWT:ALL - DCR: Printing API and implementation
+</blockquote>
+
+<h1>
+Eclipse Platform Release Notes<br>
+SWT</h1>
+SWT Build 103 - Thursday May 3, 2001
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GD4KNI: SWT:WIN2000 - TableEditor.setColumn(int) has off-by-one error
+<br>1GD45AU: SWT:Linux - UnsatisfiedLinkError gnome_mime_type
+<br>1GD3XC2: SWT:WIN - GC.dispose() doesn't fully clean up - leaves itself in image
+<br>1GD3M6G: ITPUI:WIN2000 - SWT Error when closing Workbench
+<br>1GD3LD6: ITPUI:WINNT - Exception closing a second workbench window
+<br>1GD3FWL: ITPJUI:WINNT - walkback on closing the workbench
+<br>1GCV0HC: SWT:WIN2000 - TreeItem::setExpanded does not trigger selection change?
+<br>1GBOADO: SWT:WIN - WIN - Clean up after RichText removal
+<br>1GCN531: SWT:WIN2000 - CTabFolder child's visibility is false on notification
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 102 - Tuesday May 1, 2001
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GD0J8V: SWT:Linux - NPE setting background pixel on label
+<br>1GD0BTL: SWT:Linux - Cursor doesn't blink unless you move the mouse
+<br>1GCUT5I: SWT:ALL - ViewForm::setBorderVisible() does not draw properly
+<br>1GCUIH2: SWT:Linux - NPE on image dispose setting label background color
+<br>1GCPHMP: SWT:Linux - GC.copyArea results in X_ClearArea error when regions are disjoint
+<br>1GAZZ7F: SWT:ALL - package com.ibm.itp.os.* should be renamed
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 100 - Thursday April 26, 2001
+
+<p><b>Renaming of packages and projects to org.eclipse version</b></p>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 075 - Thursday April 26, 2001
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GCQU7S: SWT:WINNT - Exception getting image pixel
+<br>1GCQPTX: SWT:WINNT - Gradient colour is black on WINNT
+<br>1GCQKWP: SWT:WINNT - ImageData corrupt for certain images
+<br>1GCP2JE: SWT:WINNT - Exception collapsing the parent of an item with a TreeEditor open
+<br>1GCP11O: SWT:WINNT - TreeEditor created too far left
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 074 - Tuesday April 24, 2001
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GCGDPB: SWT:Linux - Table column resize
+<br>1GCGA89: SWT:ALL - CLabel tool tip does not always update properly
+<br>1GCG3O2: SWT:WIN - NullPointerException when closing window
+<br>1GCG1TY: SWT:WIN2000 - Label.setImage(null) doesn't work and background does not show through
+<br>1GCFUMC: SWT:ALL - CTabFolder X button not centered
+<br>1GBZEZ2: SWT:ALL - CTabItem is not showing tool tip.
+<br>1FVEUN9: SWT:Linux - Expand all problems operation in LF is slow
+<br>1FMRW6Q: SWT:UNIX - Tree/Table don't repaint on setForeground()
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 073 - Thursday April 19, 2001
+
+<h2><a NAME="What's new"></a>What's new in this drop</h2>
+
+<h3><a NAME="Behaviour Changes"></a>Behaviour Changes</h3>
+<ul>
+<li>FocusIn and FocusOut events sent for OleControlSite and OleClientSite
+</ul>
+
+<h3><a NAME="API Changes"></a>API Changes</h3>
+
+<ul>
+<li>Support for the following system colors has been added:
+ <ul>
+ <li>SWT.COLOR_TITLE_FOREGROUND
+ <li>SWT.COLOR_TITLE_BACKGROUND
+ <li>SWT.COLOR_TITLE_BACKGROUND_GRADIENT
+ <li>SWT.COLOR_TITLE_INACTIVE_FOREGROUND
+ <li>SWT.COLOR_TITLE_INACTIVE_BACKGROUND
+ <li>SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT
+ </ul>
+<li>CTabFolder.setInsertMark(int index, boolean after) added
+<li>CTabFolder.setInsertMark(CTabItem item, boolean after) added
+<li>CTabFolder.setSelectionForeground(Color color) added
+<li>CTabFolder.setBackground(Image image) deprecated - use CTabFolder.setSelectionBackground(Image image)
+<li>CTabFolder.setBackground(Color[] colors, int[] percents) deprecated - use CTabFolder.setSelectionBackground(Color[] colors, int[] percents)
+</ul>
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GCC93K: SWT:ALL - Should SWT be issuing selection event when tab item added?
+<br>1GCC7G8: SWT:Linux - scrolled to far left when opening CTabFolder
+<br>1GCALVS: SWT:WIN - Button.computeSize() not correct for radio buttons w/ 48 point font
+<br>1GC3YIG: SWT:WIN - FileDialog chooses a bogus initial filterExtension
+<br>1GBPOYG: ITPJUI:WIN2000 - Editor tabs are changing size when switching between different tabs
+<br>1GB2373: SWT:WINNT - Menu help callback: widget is destroyed
+<br>1GAW5MX: SWT:WINNT - Shell calls saveFocus after firing deactivate event
+<br>1G9X2Z4: SWT:WINNT - GIF transparent color not transparent
+<br>1G3ESH6: SWT:ALL - GIFs with transparency problems
+<br>1G0V4WM: J9JCL:WINNT - Transparency index vs Transparency color...
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 072 - Tuesday April 17, 2001
+
+<h2><a NAME="What's new"></a>What's new in this drop</h2>
+<h3><a NAME="API Changes"></a>API Changes</h3>
+
+<ul>
+<li>CLabel.setBackground(Image image) added
+<li>CTabFolder.setBackground(Image image) added
+</ul>
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+<blockquote>
+1GCA2T3: SWT:WINNT - Program.getImageData() has NumberFormatException
+<br>1GAJCZU: ITPJUI:WINNT - segmented viewer toolbar icon shows up in random places
+<br>1GBPGMO: ITPJUI:WINNT - Create package toolbar icon is wrong
+<br>1GBXHID: SWT:Linux - NullPointerException disposing Color
+<br>1GC1AEN: SWT:Linux - Walkback during shutdown on linux
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 071 - Thursday April 12, 2001
+
+<h2><a NAME="What's new"></a>What's new in this drop</h2>
+<h3><a NAME="API Changes"></a>API Changes</h3>
+
+<ul>
+<li> Tracker.open() now returns a boolean - false when tracking cancelled.
+<li> added Display.getSyncThread() for core
+</ul>
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GC182H: SWT:Neutrino - Bug in error checking in GC.drawImage()
+<br>1GBXGV0: SWT:ALL - DCR: No api on Tracker to know escape key pressed
+<br>1GBRRGA: SWT:WIN2000 - TableTree: Mouse selection on text toggles checkbox
+<br>1GBPLGT: ITPJUI:WINNT - Can't enter umlauts in JavaEditor
+<br>1GBPI4O: SWT:WIN2000 - Losing close box of Editor
+<br>1GBOC3W: SWT:Linux - Problem with Mask when drawing on image
+<br>1GBADIS: SWT:ALL - minimumSize gives wrong size in Composite which result in wrong behavior of calculateSize() and pack()
+<br>1GALCDN: SWT:WIN98 - GC keeps line width set at 0
+<br>1G97CWG: SWT:Linux - Wiggly mouse
+<br>1G82MBI: IVJIDT:WIN98 - GPF (repeatable) - 3.5.3 - when terminating running java code - editing running code
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 070 - Tuesday April 10, 2001
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GBR8U9: SWT:WIN2000 - SashForm.setMaximizedControl problem
+<br>1GBQ145: SWT:WIN2000 - broken implementation of ViewForm.layout
+<br>1GBM11E: SWT:WIN2000 - ViewForm border problems
+<br>1GBR6XI: SWT:WIN2000 - SashForm overrides wrong layout method
+<br>1GBRCNC: SWT:WIN2000 - Layout problems with SashForm & ViewForm
+<br>1G98NJQ: ITPJUI:WIN2000 - Outliner context menu disappears after empty selection
+<br>1GBM8SZ: SWT:WIN2000 - SashForm doesn't work in wizard pages
+<br>1GBKSNP: SWT:Linux - Control.setForeground does not redraw control
+<br>1GBLZDR: SWT:WIN2000 - Label text moves up when pane titlebar splits
+<br>1GBPPLT: ITPJUI:WIN2000 - Strange line spacing in Java Editor
+<br>1GBQ54Q: SWT:Linux - MenuItems are not added in the right position.
+<br>1GBRBTY: SWT:WIN2000 - SashForm clips bottom most control by one pixel
+<br>1GBRC0V: SWT:WIN2000 - ViewForm renders a "title bar" also none of the top controls are set
+<br>1GBRCGL: SWT:WIN2000 - Animated Progress shows up with slider in ProgressDialog
+<br>1GBX8G1: SWT:Neutrino - Default font support doesn't capture style, height
+<br>1GBX8LN: SWT:WIN2000 - Tree.getSelection() iterates over all items twice if selection is empty
+</blockquote>
+
+<h1>IBM Eclipse Platform Release Notes<br>SWT</h1>
+SWT Build 069 - Thursday April 5, 2001
+
+<h2><a NAME="What's new"></a>What's new in this drop</h2>
+<h3><a NAME="API Changes"></a>API Changes</h3>
+<ul>
+<li>The class RichText has been removed.
+Use com.ibm.swt.custom.StyledText instead.
+
+<li>
+The class com.ibm.itp.os.ProgramSupport has been deprecated because
+it was a random assortment of helper methods some of which Windows
+specific and could not be implemented on other platforms.
+The functionality has been redistributed as follows:
+<ul>
+<li>ProgramSupport.getWindowSystem - use SWT.getPlatform
+<li>ProgramSupport.isReparentable - use Control.isReparentable
+<li>ProgramSupport.print - RichText no longer exists
+<li>ProgramSupport.getFriendlyName - not used
+<li>ProgramSupport.loadLargeIcon - not used
+<li>ProgramSupport.loadSmallIcon - use Program.getImageData
+<li>ProgramSupport.queryExtension - use Program.findProgram
+<li>ProgramSupport.queryExtensionIcon - use Program.getImageData
+<li>ProgramSupport.queryExtensionProgramID - use OLE.findProgramID
+<li>ProgramSupport.queryInsertables - not used
+<li>ProgramSupport.queryRegisteredPrograms - use Program.getPrograms
+<li>ProgramSupport.shellExecute - use Program.launch
+</ul>
+
+<li>OleClientSite.containsOleInfo has been deprecated - use OLE.isOleFile
+
+<li>The methods Control.isValidWidget, Widget.isValidWidget and Menu.isValidWidget have been removed.
+
+</ul>
+
+<h2>
+<a NAME="Known deficiencies"></a>Known deficiencies</h2>
+
+<ul>
+<li>
+The support for running Swing and AWT widgets within SWT layouts only works
+on Windows. There are currently significant incompatibilities between the
+way AWT and SWT deal with Motif. There is no workaround at this time.</li>
+
+<li>
+TableEditors are not notified when the cell they are editing changes its
+dimensions. This can cause them to look odd when the underlying table (or
+one of its columns) is resized while they are open. This occurs on both
+Windows and Linux. In addition, because of the way XWindows handles child
+widgets, it is possible for TableEditors to lose focus on Linux in situations
+where they do not on Windows. Simply clicking on the TableEditor again,
+will return focus to it.</li>
+</ul>
+
+<h2><a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+1GBLZLL: SWT:WINNT - NegativeArraySizeException in SashForm
+<br>1GBKN67: SWT:WINNT - StyledText - paste replacing text does not show new text
+<br>1GBKERA: SWT:ALL - Typo in BusyIndicator.showWhile - 'Dusplay'
+<br>1GBKCLF: SWT:WINNT - StyledText - IllegalArgumentException in DefaultContent.getLine
+<br>1GBF77D: SWT:WINNT - getFontData().getHeight() discrepancy
+<br>1GBF74Z: SWT:ALL - CLabel::onPaint exception
+<br>1GBEI94: ITPUI:WIN2000 - Walkback in AnimatedProgress
+<br>1GBD9LZ: SWT:ALL - CTabFolder exception using scroll arrows
+<br>1GBD356: SWT:ALL - TabItem.setControl(null) throws NullPointerException
+<br>1GB9GZD: SWT:Linux - Motif - Color depth scaling
+<br>1FT97NJ: SWT:Linux - Tree/Table turns item grey when focus lost
+</blockquote>
+
+<h1>
+IBM Eclipse Platform Release Notes<br>
+SWT</h1>
+SWT Build 063 through SWT Build 068 - Thursday March 29, 2001
+
+<h2>
+<a NAME="What's new"></a>What's new in this drop</h2>
+
+<h3><a NAME="New Classes"></a>New Classes</h3>
+<ul>
+<li><b>SashForm</b> The SashForm lays out its children in a Row or Column arrangement (as specified
+by the orientation) and places a Sash between the children.
+One child may be maximized to occupy the entire size of the SashForm.
+The relative sizes of the children may be specfied using weights.
+
+<li><b>StackLayout</b> 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 the call
+layout() on the composite which has the StackLayout.
+</ul>
+
+<h3>
+<a NAME="API Changes"></a>API Changes</h3>
+<li>Widget.notifyListener deleted - Use Widget.notifyListeners
+<li>SelectionAdapter.widgetDoubleSelected deleted - Use SelectionAdapter.widgetDefaultSelected instead
+<li>SelectionListener.widgetDoubleSelected deleted - Use SelectionListener.widgetDefaultSelected instead
+<li>SWT.DoubleSelection deleted - Use SWT.DefaultSelection instead.
+<li>WidgetListener deleted - Use DisposeListener instead.
+<li>Widget.addWidgetListener deleted - Use Widget.addDisposeListener instead.
+<li>Widget.removeWidgetListener deleted - Use Widget.removeDisposeListener instead
+<li>SWT.ERROR_NO_COMMON_PARENT deleted
+<li>Clipboard.Clipboard() deleted - Use Clipboard.Clipboard(Display) instead
+<li>DragSource.startDrag() deleted - Use DragSourceListener.dragStart instead
+<li>GridLayout.id deleted
+<li>ImageData.DM_UNSPECIFIED deleted
+<li>ImageData.DM_FILL_NONE deleted
+<li>ImageData.DM_FILL_BACKGROUND deleted
+<li>ImageData.DM_FILL_PREVIOUS deleted
+<li>ImageData.isIcon() deleted
+<li>com.ibm.swt.custom.CustomLabel deleted - Use CLabel instead
+<li>com.ibm.swt.custom.CustomPane deleted - Use ViewForm instead
+<li>com.ibm.swt.custom.ScrollingComposite deleted - Use ScrolledComposite instead
+</ul>
+
+<p><b>***NOTE***</b> There has been some renaming of Interface methods, which will unavoidably
+break code while the rename is being done. In order to make it easier for
+yourself before we rename next week, you might want to do the rename in
+your copy of SWT after you get tomorrow's drop, and fix all breakage immediately.
+<br><b>***NOTE2***</b> in general, you always want to try to use an Adapter
+(when one exists) instead of implementing the corresponding Listener.
+This will insulate you from changes to the interface. Also, we have
+seen cases where an SWT event Listener interface is being implemented
+by a public class. This not only exposes your public class to interface
+changes, but it also forces your public class to bogusly provide the
+SWT Listener interface's methods as your public API. <em>Don't do that.</em>
+
+<h3>
+<a NAME="Styled Text changes"></a>Styled Text changes</h3>
+
+<ul>
+<li>StyledText
+<br>
+For those who are implementing StyledTextContent,
+the constructor for the TextChangedEvent class has changed.
+The TextChangedEvent() constructor no longer exists.
+Use the TextChangedEvent(StyledTextContent source) constructor instead.
+<b>NOTE:</b> The parameter to this constructor cannot be null.
+</ul>
+
+<p><b>These StyledText methods have been renamed:</b>
+<ul>
+<li>StyledText.getSelection() ==> use getSelectionRange() instead
+<li>StyledText.getText(int start, int length) ==> use getTextRange(int,int) instead
+<li>StyledTextContent.getText(int start, int length) ==> use getTextRange(int,int) instead
+<li>StyledText.redraw(int,int,boolean) ==> use redrawRange(int,int,boolean) instead
+<li>StyledText.replace(int start, int length) ==> use replaceTextRange(int,int) instead
+<li>StyledTextContent.replaceText(int start, int length) ==> use replaceTextRange(int,int) instead
+<li>StyledText.setSelection(int start, int length) ==> use setSelectionRange(int,int) instead
+</ul>
+
+<p><b>These methods have been introduced to maintain SWT API consistency.</b>
+<p>StyledText selection methods used to take (int start, int length) and now the parameters are (int start, int end).
+<p><b> WARNING</b>These names are the same as the old names, BUT the semantics have changed.
+Also note that in the case of setSelection(start,end) the behavior has also changed to be consistent with
+SWT (the selection is made visible):
+<ul>
+<li>StyledText.getSelection() ==> returns Point(start,end)
+<li>StyledText.getText(int start, int end)
+<li>StyledText.setSelection(int start, int end)
+</ul>
+
+<p>The compiler is not going to point these changes out automatically.
+You can decide whether to use the new "selection range" API with (start, length) semantics,
+or stick with the old method names and change your calling semantics to (start, end).
+We suggest you use the following trick to get the compiler to help you make the changes:
+<ol>
+<li>Make sure you have SWT 0.067 loaded.
+<li>Rename the 3 StyledText methods, getSelection, getText, and setSelection, to getSelection2,
+ getText2, and setSelection2.
+<li>You will now have red x's everywhere you called those methods.
+<li>Make the changes (either change to call getSelectionRange/getTextRange/setSelectionRange,
+ or change to use "start, end").
+<li>Replace the 3 StyledText methods with the released version.
+</ol>
+
+<p><b>These deprecated methods have been removed from StyledText:</b>
+<ul>
+<li>StyledText.getCaretLineNumber()
+<li>StyledText.getCaretLocation()
+<li>StyledText.getCaretPosition()
+<li>StyledText.getDelimiter()
+<li>StyledText.getDoubleClick()
+<li>StyledText.setDoubleClick(boolean)
+<li>StyledText.setSelectionForeground (Color color)
+<li>StyledText.setSelectionVisible(boolean visible)
+<li>StyledText.setText(String string, Color colors [], int [] ranges)
+</ul>
+
+<p><b>These deprecated methods have been undeprecated:</b>
+<ul>
+<li>StyledText.append (String string)
+<li>StyledText.insert (String string)
+<li>StyledText.getLineCount ()
+<li>StyledText.selectAll()
+<li>StyledText.getSelectionCount()
+<li>StyledText.setSelection (int start)
+<li>StyledText.setSelection(Point point)
+</ul>
+
+<p>The method invokeAction(int) is now public. You may use this method to support special key
+binding needs like multi-keystroke bindings or macro recording/playback.
+
+<h3>
+<a NAME="Other highlights"></a>Other highlights</h3>
+
+<ul>
+<li> The ability to set a Disabled image for use in the Toolbar has been added.
+<li> The ability to create a new gray scale image from a color image has been added.
+<pre>
+ Image grayImage = new Image(getDisplay(), colorImage, SWT.IMAGE_GRAY)
+</pre>
+</ul>
+
+<h2>
+<a NAME="Known deficiencies"></a>Known deficiencies</h2>
+
+<ul>
+<li>
+The support for running Swing and AWT widgets within SWT layouts only works
+on Windows. There are currently significant incompatibilities between the
+way AWT and SWT deal with Motif. There is no workaround at this time.</li>
+
+<li>
+TableEditors are not notified when the cell they are editing changes its
+dimensions. This can cause them to look odd when the underlying table (or
+one of its columns) is resized while they are open. This occurs on both
+Windows and Linux. In addition, because of the way XWindows handles child
+widgets, it is possible for TableEditors to lose focus on Linux in situations
+where they do not on Windows. Simply clicking on the TableEditor again,
+will return focus to it.</li>
+</ul>
+
+<h2>
+<a NAME="Problem reports fixed"></a>Problem reports fixed</h2>
+
+<blockquote>
+<br><b>In 68:</b>
+<br>1GBCTBY: SWT:ALL - DCR: Make 3 border rgb color public
+<br>1GBCSHG: SWT:WIN2000 - TableTree should have getItem(Point point)
+<br>1GBB8NJ: SWT:ALL - StyledText - caret not updated when Modify is sent
+<br>1GB9FJB: SWT:ALL - DCR: CTabFolder close icon not "transparent"
+<br>1GB9F5O: SWT:ALL - DCR: Empty CTabFolder border drawing
+<br>1GB93QT: SWT:WIN - StyledText - blt problem when cutting text
+<br>1GAWIAP: SWT:WINNT - StyledText - key bindings - make doAction() public
+<br>1GAVQGI: SWT:ALL - Migrate remaining JFace widgets
+<br>1GAVQA6: SWT:ALL - Notebook custom widget
+<br>1GAJ9KP: SWT:ALL - TableTree class has no selection support for the SWT.CHECK style
+<br>1G5T37N: SWT:Linux - Table repaints excessively
+
+<br>
+<br>
+<br><b>In 67:</b>
+<br>1GB1VFN: SWT:Neutrino - Cannot "swipe select" text in Text (SINGLE style)
+<br>1GB0DAQ: SWT:Neutrino - Calling getText() on a Button of style CHECK causes an exception
+<br>1GAZU5I: SWT:ALL - TableTree - order of items is wrong when first opened
+<br>1GAXJIG: SWT:WIN2000 - Why does the new BusyIndiocator need a display passed in
+<br>1GAUU7N: SWT:ALL - StyledText - SWT API Compliance
+<br>1GAU7AO: SWT:ALL - Increase max VTable size
+<br>1GAQREA: SWT:ALL - DOC: Using SWT Layouts
+<br>1GAPCPB: SWT:ALL - StyledText: last line slurs when scrolling
+<br>1GAP7II: SWT:ALL - DCR - CTabItem visual enhancements
+<br>1G6ZJXO: SWT:WINNT - Changing the visibility of a Splitter's child doesn't work
+<br>1G54RZE: SWT:WINNT - GC.drawImage(Image, int, int) too slow
+<br>1G0I960: SWT:WINNT - GC.drawImage newing Objects, could be much faster
+
+<br>
+<br>
+<br><b>In 66:</b>
+<br>1GAX9NB: SWT:Neutrino - Combo dropdown erased when MouseEnter/Exit hooked on Container
+<br>1GAWHN7: SWT:WIN2000 - computeSize on toolbar makes it Visible
+<br>1GAW64X: SWT:WIN2000 - Most setters of ViewForm are broken
+<br>1GAUR6V: SWT:WIN - "Hot Images in ToolBar" does not work if items are disabled
+<br>1GAPCG7: SWT:ALL - StyledText: inefficiencies when redrawing multiple lines
+<br>1GAP46W: SWT:ALL - ViewForm activeBorder not always visible
+<br>1GAP36M: SWT:ALL - CLabel::setBackgroundGradient does not redraw
+<br>1G8VVLS: SWT:ALL - DCR: Need an API to get the color of a pixel at a point on the Desktop
+<br>1G2O4LD: SWT:ALL - Need API to take a screen snapshot
+
+<br>
+<br>
+<br><b>In 65:</b>
+<br>1GAUEK1: SWT:WIN2000 - Context menus get never removed from the shell
+<br>1GAP7DE: SWT:ALL - OLE editor go gray when deactivated
+<br>1GAP2VP: SWT:ALL - Background gradient api diff for CTabFolder & CLabel
+<br>1GAL0ES: SWT:WINNT - Menu item help callback does not occur until after menu is down
+<br>1GAJBTA: ITPJUI:WINNT - walkback when editing java file
+<br>1GAJ9GX: SWT:ALL - combo box never receives an event for an "enter" key
+<br>1G8IU7A: SWT:ALL - new alpha APIs on ImageData
+<br>1G8HBF8: SWT:Neutrino - Alpha problems with off-screen graphics
+<br>1G7YWTN: SWT:Neutrino - No KeyDown or KeyUp for multi-line text
+<br>1G7MIEJ: SWT:WINNT - notification of enter & double click
+<br>1G7GHRM: SWT:WIN98 - prop sheet - second column does not fit
+<br>1G7EQ69: SWT:Neutrino - No KeyUp messages sent
+<br>1G55SCR: SWT:Neutrino - List.getItemHeight() completely bogus
+<br>1G54XZT: SWT:WINNT - Combo box - can't tell if someone hits <Enter>
+<br>1FT06EX: SWT:ALL - FileDialog.setFilterExtensions() does not properly degrade on non Windows platforms
+<br>1FSY6QR: SWT:WINNT - DCR - FileDialog API should better balance platform function vs. portability
+<br>1FMGL58: SWT:WIN - Single-line TextEditor does not send event when <Enter> is pressed
+<br>1FBPLB5: SWT:ALL - List(SINGLE) - setSelection and selectAll inconsistent
+<br>1FBPKD9: SWT:WIN - List - selectAll() setSelection() inconsistancy when items repeat
+<br>1FBPKCY: SWT:WIN - List - inconsistent setSelection() behaviour
+
+<br>
+<br>
+<br><b>In 63:</b>
+<br>1GABZR5: SWT:Linux - Table cheese when removing last column
+<br>1G9XBWB: SWT:ALL - DOC: Layout class still has Smalltalk-style comments
+<br>1G7PMZX: SWT:ALL - notifyListener should be called notifyListeners
+<br>1G7AQDI: SWT:Neutrino - Font() constructor should use PfGenerateFontName()
+<br>1G4DGHG: SWT:Linux - Thumb drag scrolling causes cheese
+<br>1FZU2X2: SWT:ALL - Why is DisposeListener called "WidgetListener"?
+<br>1FVX5JS: SWT:WINNT - PaletteData.getPixel(RGB) needs to be fixed
+<br>1FT05NQ: SWT:ALL - DCR FileDialog.setFilterExtensions() doesn't support common Windows usage
+<br>1FCDRW0: SWT:AIX - TrackBar - setPageIncrement()
+</blockquote>
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
new file mode 100755
index 0000000000..f0cbe6f358
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/build.csh
@@ -0,0 +1,59 @@
+#!/bin/csh
+# (c) Copyright IBM Corp 1999, 2000
+# This command script can be invoked with the "clean" argument.
+
+# The major and minor version numbers and the build numbers are returned by the
+# getSharedLibraryMajorVersionNumber and getSharedLibraryMinorVersionNumber
+# calls so java can query the swt shared library version number
+
+setenv MAJOR_VER 0
+setenv MINOR_VER 105
+setenv BUILD_NUM 0
+
+# Some UNIX/Linux compilers don't like <CR>'s in files (DOS format).
+set fixup_files = `grep -l "\ " *.[ch]`
+if ( "$fixup_files" != "" ) then
+ echo "Converting files from DOS to UNIX format:"
+ foreach file ($fixup_files)
+ echo " $file"
+ ex $file << EOF >& /dev/null
+g/ \$/s///
+w
+EOF
+ end
+endif
+
+# Determine the operating system being built
+set OS=`uname -s`
+switch ($OS )
+
+ case Linux:
+ if ( "$1" == "clean" ) then
+ make -f make_linux.mak clean
+ else
+ echo "Building Linux version of SWT and GNOME DLLs."
+ make -f make_linux.mak make_swt make_gnome
+
+ set build_kde = `rpm -q kdebase | grep "not installed"`
+ set build_kde = "not ported" # KDE porting not complete yet (KJC)
+ if ( "$build_kde" == "" ) then
+ echo "Building Linux version of KDE DLL."
+ make -f make_linux.mak make_kde
+ endif
+ endif
+ breaksw
+
+ case SunOS:
+ if ( "$1" == "clean" ) then
+ make -f make_solaris.mak clean
+ else
+ echo "Building Solaris version of SWT and CDE DLLs."
+ make -f make_solaris.mak make_swt
+ # KJC make -f make_solaris.mak make_cde
+ endif
+ breaksw
+
+ default:
+ echo "Unknown"
+ breaksw
+endsw
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/gnome.c b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/gnome.c
new file mode 100755
index 0000000000..89ce255fad
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/gnome.c
@@ -0,0 +1,153 @@
+/**
+ * SWT GNOME natives implementation.
+ */
+
+/* #define PRINT_FAILED_RCODES */
+#define NDEBUG
+
+#include "globals.h"
+#include "structs.h"
+
+#include <stdio.h>
+#include <assert.h>
+#include <gnome.h>
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: g_1get_1home_1dir
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_GNOME_g_1get_1home_1dir
+ (JNIEnv *env, jclass that)
+{
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "g_1get_1home_1dir\n");
+#endif
+ rc = (jint) g_get_home_dir();
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: gnome_1datadir_1file
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_GNOME_gnome_1datadir_1file
+ (JNIEnv * env, jclass that, jbyteArray fileName)
+{
+ jbyte *fileName1 = NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gnome_1datadir_1file\n");
+#endif
+
+ if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+ rc = (jint) gnome_datadir_file(fileName1);
+ if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: gnome_1desktop_1entry_1load
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_GNOME_gnome_1desktop_1entry_1load
+ (JNIEnv * env, jclass that, jbyteArray fileName)
+{
+ jbyte *fileName1 = NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gnome_1desktop_1entry_1load\n");
+#endif
+
+ if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+ rc = (jint) gnome_desktop_entry_load(fileName1);
+ if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: gnome_1desktop_1entry_1free
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_GNOME_gnome_1desktop_1entry_1free
+ (JNIEnv * env, jclass that, jint entry)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gnome_1desktop_1entry_1free\n");
+#endif
+
+ gnome_desktop_entry_free((GnomeDesktopEntry*)entry);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: gnome_1mime_1get_1value
+ * Signature: ([B[B)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_GNOME_gnome_1mime_1get_1value
+ (JNIEnv *env, jclass that, jbyteArray mimeType, jbyteArray key)
+{
+ jbyte *mimeType1 = NULL;
+ jbyte *key1 = NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gnome_1mime_1get_1value\n");
+#endif
+
+ if (mimeType) mimeType1 = (*env)->GetByteArrayElements(env, mimeType, NULL);
+ if (key) key1 = (*env)->GetByteArrayElements(env, key, NULL);
+ rc = (jint) gnome_mime_get_value(mimeType1, key1);
+ if (mimeType) (*env)->ReleaseByteArrayElements(env, mimeType, mimeType1, 0);
+ if (key) (*env)->ReleaseByteArrayElements(env, key, key1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: gnome_1mime_1type
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_GNOME_gnome_1mime_1type
+ (JNIEnv *env, jclass that, jbyteArray fileName)
+{
+ jbyte *fileName1 = NULL;
+ const char* rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gnome_1mime_1type\n");
+#endif
+
+ if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+ rc = gnome_mime_type(fileName1);
+ if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+ return (jint) rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_GNOME
+ * Method: gnome_1pixmap_1file
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_GNOME_gnome_1pixmap_1file
+ (JNIEnv * env, jclass that, jbyteArray fileName)
+{
+ jbyte *fileName1 = NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "gnome_1pixmap_1file\n");
+#endif
+
+ if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+ rc = (jint) gnome_pixmap_file(fileName1);
+ if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+ return rc;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
new file mode 100755
index 0000000000..374593b370
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/kde.cc
@@ -0,0 +1,509 @@
+/**
+ * SWT KDE natives implementation.
+ */
+
+/* #define PRINT_FAILED_RCODES */
+#define NDEBUG
+
+#include <stdio.h>
+#include "jni.h"
+
+#include <kapp.h>
+#include <kservice.h>
+#include <kmimetype.h>
+#include <kuserprofile.h>
+#include <kurl.h>
+#include <qstring.h>
+
+extern "C" {
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KApplication_1new
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KApplication_1new
+ (JNIEnv *env, jclass that, int appName)
+{
+ int myArgc = 0;
+ char* myArgv[1];
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KApplication_1new\n");
+#endif
+ QCString qcString = *((QCString*) appName);
+ KApplication* app = new KApplication(myArgc, myArgv, qcString);
+ return (jint) app;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KGlobal_1iconLoader
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KGlobal_1iconLoader
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KGlobal_1iconLoader\n");
+#endif
+ return (jint) KGlobal::iconLoader();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KIconLoader_1iconPath
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KIconLoader_1iconPath
+ (JNIEnv *env, jclass that, jint receiver, jint iconQString, jint iconType, jint canReturnNull)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KIconLoader_1iconPath\n");
+#endif
+ KIconLoader* loader = (KIconLoader*) receiver;
+ QString iconName = *((QString*) iconQString);
+ QString iconPath = loader->iconPath(iconName, iconType, canReturnNull);
+ if (iconPath == 0) return 0;
+ QString* answer = new QString();
+ *answer = iconPath;
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KMimeType_1findByURL
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1findByURL
+ (JNIEnv *env, jclass that, jint kurl)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KMimeType_1findByURL\n");
+#endif
+ KURL url = *((KURL*) kurl);
+ KSharedPtr<KMimeType>* mimeType = new KSharedPtr<KMimeType>();
+ *mimeType = KMimeType::findByURL(url);
+ return (jint) mimeType;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KMimeType_1icon
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1icon
+ (JNIEnv *env, jclass that, jint receiver, jint unused1, jint unused2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KMimeType_1icon\n");
+#endif
+ KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) receiver);
+ QString* answer = new QString();
+ *answer = mimeType->icon((const QString&) NULL, 0);
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KMimeType_1name
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KMimeType_1name
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KMimeType_1name\n");
+#endif
+ KSharedPtr<KMimeType> mimeType = *((KSharedPtr<KMimeType>*) receiver);
+ QString* answer = new QString();
+ *answer = mimeType->name();
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KService_1allServices
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1allServices
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KService_1allServices\n");
+#endif
+ KService::List* pointer = new KService::List();
+ *pointer = KService::allServices();
+ return (jint) pointer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KService_1exec
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1exec
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KService_1exec\n");
+#endif
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->exec();
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KService_1icon
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1icon
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KService_1icon\n");
+#endif
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->icon();
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KService_1name
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1name
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KService_1name\n");
+#endif
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->name();
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KService_1serviceByName
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1serviceByName
+ (JNIEnv *env, jclass that, jint serviceName)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KService_1serviceByName\n");
+#endif
+ QString* name = (QString*) serviceName;
+ KSharedPtr<KService> service = KService::serviceByName(*name);
+ if (service == 0) return 0;
+ KSharedPtr<KService>* pointer = new KSharedPtr<KService>();
+ *pointer = service;
+ return (jint) pointer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KService_1type
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KService_1type
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KService_1type\n");
+#endif
+ KSharedPtr<KService> service = *((KSharedPtr<KService>*) receiver);
+ QString* answer = new QString();
+ *answer = service->type();
+ return (jint) answer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceTypeProfile_1preferredService
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceTypeProfile_1preferredService
+ (JNIEnv *env, jclass that, jint mimeTypeQString, jint needApp)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceTypeProfile_1preferredService\n");
+#endif
+ QString mimeTypeName = *((QString*) mimeTypeQString);
+ KSharedPtr<KService> service = KServiceTypeProfile::preferredService(mimeTypeName, needApp);
+ if (service == 0) return 0;
+ KSharedPtr<KService>* pointer = new KSharedPtr<KService>();
+ *pointer = service;
+ return (jint) pointer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KURL_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1delete
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KURL_1delete\n");
+#endif
+ delete (KURL*) receiver;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KURL_1new
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KURL_1new
+ (JNIEnv *env, jclass that, jint qString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KURL_1new\n");
+#endif
+ QString urlString = *((QString*) qString);
+ return (jint) new KURL(urlString);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceList_1begin
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1begin
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceList_1begin\n");
+#endif
+ KService::List *list= (KService::List*) receiver;
+ QValueListConstIterator<KService::Ptr>* beginning = new QValueListConstIterator<KService::Ptr>();
+ *beginning = list->begin();
+ return (jint) beginning;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceList_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1delete
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceList_1delete\n");
+#endif
+ delete (KService::List*) receiver;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceList_1end
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceList_1end
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceList_1end\n");
+#endif
+ KService::List *list = (KService::List*) receiver;
+ QValueListConstIterator<KService::Ptr>* end = new QValueListConstIterator<KService::Ptr>();
+ *end = list->end();
+ return (jint) end;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QCString_1data
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1data
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QCString_1data\n");
+#endif
+ return (jint) ((QCString*) receiver)->data();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QCString_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1delete
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QCString_1delete\n");
+#endif
+ delete (QCString*) receiver;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QCString_1new
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QCString_1new
+ (JNIEnv *env, jclass that, jbyteArray text)
+{
+ jbyte *text1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QCString_1new\n");
+#endif
+ if (text) text1 = env->GetByteArrayElements(text, NULL);
+ QCString* qcString = new QCString((char*) text1);
+ if (text) env->ReleaseByteArrayElements(text, text1, 0);
+ return (jint) qcString;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QString_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1delete
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QString_1delete\n");
+#endif
+ delete (QString*) receiver;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QString_1equals
+ * Signature: (I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1equals
+ (JNIEnv *env, jclass that, jint receiver, jint object)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QString_1equals\n");
+#endif
+ return *((QString*) receiver) == *((QString*) object);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QString_1new
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1new
+ (JNIEnv *env, jclass that, jbyteArray text)
+{
+ jbyte *text1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QString_1new\n");
+#endif
+ if (text) text1 = env->GetByteArrayElements(text, NULL);
+ QString* qString = new QString((char*) text1);
+ if (text) env->ReleaseByteArrayElements(text, text1, 0);
+ return (jint) qString;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: QString_1utf8
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_QString_1utf8
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "QString_1utf8\n");
+#endif
+ QString string = *((QString*) receiver);
+ QCString* qcString = new QCString();
+ *qcString = string.utf8();
+ return (jint) qcString;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1delete
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1delete
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1delete\n");
+#endif
+ delete (QValueListIterator<KService::Ptr>*) receiver;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1dereference
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1dereference
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1dereference\n");
+#endif
+ KSharedPtr<KService>* service = new KSharedPtr<KService>();
+ *service = *(*((QValueListIterator<KService::Ptr>*) receiver));
+ return (jint) service;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1increment
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1increment
+ (JNIEnv *env, jclass that, jint receiver)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1increment\n");
+#endif
+ ++(*((QValueListIterator<KService::Ptr>*) receiver));
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1new
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1new
+ (JNIEnv *env, jclass that, jint listBeginning)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1new\n");
+#endif
+ const QValueListIterator<KService::Ptr> *iterator =
+ (const QValueListIterator<KService::Ptr> *) listBeginning;
+
+ return (jint) new QValueListIterator<KService::Ptr>(*iterator);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_KDE
+ * Method: KServiceListIterator_1equals
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_KDE_KServiceListIterator_1equals
+ (JNIEnv *env, jclass that, jint receiver, jint object)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KServiceListIterator_1equals\n");
+#endif
+ return *((QValueListIterator<KService::Ptr>*) receiver) ==
+ *((QValueListIterator<KService::Ptr>*) object);
+}
+
+
+} /* extern "C" */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/library.c b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/library.c
new file mode 100755
index 0000000000..9a2a6e8b8e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/library.c
@@ -0,0 +1,32 @@
+/**
+ * library.c
+ *
+ * This file contains the implementation of the
+ * shared libraries functions.
+ *
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+unsigned int OpenLibrary(char *name)
+{
+ void * handle = dlopen (name, RTLD_LAZY | RTLD_GLOBAL);
+ if (handle == NULL) {
+ char buf[512];
+ sprintf(buf, "lib%s.so", name);
+ handle = dlopen (buf, 1);
+ }
+ return (unsigned int)handle;
+}
+
+unsigned int LibraryLookupName(unsigned int handle, char *name)
+{
+ if (handle == 0) return 0;
+ return (unsigned int)dlsym ((void *)handle, name);
+}
+
+void CloseLibrary(unsigned int handle)
+{
+ if (handle != 0) dlclose ((void *)handle);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
new file mode 100755
index 0000000000..8a0c7a8c99
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_linux.mak
@@ -0,0 +1,86 @@
+# Makefile for creating SWT libraries on Linux
+#
+# The following environment variables are assumed to be defined:
+#
+# MAJOR_VER - the major version number
+# MINOR_VER - the minor version number
+# BUILD_NUM - the build number
+
+DLL_VERSION=$(MAJOR_VER)$(MINOR_VER)
+
+
+# Define the installation directories for various products.
+# IVE_HOME - IBM's version of Java (J9)
+# MOTIF_HOME - Motif includes and libraries
+# QT_HOME - identifier namespace package (used by KDE)
+IVE_HOME = /bluebird/teamswt/swt-builddir/ive/bin
+MOTIF_HOME = /bluebird/teamswt/swt-builddir/motif21
+QT_HOME = /usr/lib/qt-2.2.0
+
+
+# Define the various DLL (shared) libraries to be made.
+
+SWT_PREFIX = swt
+SWT_DLL = lib$(SWT_PREFIX)$(DLL_VERSION).so
+SWT_OBJ = callback.o globals.o library.o structs.o swt.o
+SWT_LIB = $(MOTIF_HOME)/lib/libXm.a -L/usr/lib -L/usr/X11R6/lib \
+ -x -shared -lX11 -lm -lXext -lXt -lXp -lXpm -ldl
+
+GNOME_PREFIX = swt-gnome
+GNOME_DLL = lib$(GNOME_PREFIX)$(DLL_VERSION).so
+GNOME_OBJ = gnome.o
+GNOME_LIB = -x -shared \
+ `gnome-config --libs gnome`
+
+KDE_PREFIX = swt-kde
+KDE_DLL = lib$(KDE_PREFIX)$(DLL_VERSION).so
+KDE_OBJ = kde.o
+KDE_LIB = -L/usr/lib -L$(QT_HOME)/lib \
+ -shared -lksycoca -lkdecore -lq
+
+#
+# The following CFLAGS are for compiling both the SWT library and the GNOME
+# library. The KDE library uses its own (C++) flags.
+#
+CFLAGS = -O -s \
+ -DSWT_LIBRARY_MAJOR_VERSION=$(MAJOR_VER) \
+ -DSWT_LIBRARY_MINOR_VERSION=$(MINOR_VER) \
+ -DLINUX -DMOTIF -DGNOME -DXPM \
+ -fpic \
+ -I./ \
+ -I$(IVE_HOME)/include \
+ -I$(MOTIF_HOME)/include \
+ -I/usr/X11R6/include \
+ `gnome-config --cflags gnome gnomeui`
+
+
+all: make_swt make_gnome
+
+kde: make_kde
+
+
+make_swt: $(SWT_DLL)
+
+$(SWT_DLL): $(SWT_OBJ)
+ ld -o $@ $(SWT_OBJ) $(SWT_LIB)
+
+
+make_gnome: $(GNOME_DLL)
+
+$(GNOME_DLL): $(GNOME_OBJ)
+ ld -o $@ $(GNOME_OBJ) $(GNOME_LIB)
+
+
+make_kde: $(KDE_DLL)
+
+$(KDE_DLL): $(KDE_OBJ)
+ ld -o $@ $(KDE_OBJ) $(KDE_LIB)
+
+$(KDE_OBJ): kde.cc
+ g++ -c -O -I/usr/include/kde -I$(QT_HOME)/include -I./ \
+ -I../ -I$(IVE_HOME)/include -fno-rtti -o kde.o kde.cc
+
+clean:
+ rm -f $(SWT_OBJ) $(SWT_DLL) $(GNOME_OBJ) $(GNOME_DLL)
+ rm -f $(KDE_OBJ) $(KDE_DLL)
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_solaris.mak b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_solaris.mak
new file mode 100755
index 0000000000..89b698fa7b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/make_solaris.mak
@@ -0,0 +1,69 @@
+# Makefile for creating SWT libraries on Solaris
+#
+# The following environment variables are assumed to be defined:
+#
+# MAJOR_VER - the major version number
+# MINOR_VER - the minor version number
+# BUILD_NUM - the build number
+
+DLL_VERSION=$(MAJOR_VER)$(MINOR_VER)
+
+
+# Define the installation directories for various products.
+# JAVA_HOME - Sun's version of Java (JDK2)
+# MOTIF_HOME - Motif includes and libraries
+JAVA_HOME = /tools/java1.3
+MOTIF_HOME = /usr/dt
+CDE_HOME = /usr/dt
+
+
+# Define the various DLL (shared) libraries to be made.
+
+SWT_PREFIX = swt
+SWT_DLL = lib$(SWT_PREFIX)$(DLL_VERSION).so
+SWT_OBJ = callback.o globals.o library.o structs.o swt.o
+SWT_LIB = -L$(MOTIF_HOME)/lib -L/usr/lib \
+ -G -lXm -lXt -lX11 -lm
+
+CDE_PREFIX = swt-cde
+CDE_DLL = lib$(CDE_PREFIX)$(DLL_VERSION).so
+CDE_OBJ =
+CDE_LIB = -G -L$(CDE_HOME) -L. -l$(SWT_PREFIX)$(DLL_VERSION)
+
+
+#
+# The following CFLAGS are for compiling both the SWT library and the CDE
+# library.
+#
+# Note:
+# The flag -xarch=generic ensure the compiled modules will be targeted
+# for 32-bit architectures. If this flag is not
+#
+CFLAGS = -O -s \
+ -xarch=generic \
+ -DSWT_LIBRARY_MAJOR_VERSION=$(MAJOR_VER) \
+ -DSWT_LIBRARY_MINOR_VERSION=$(MINOR_VER) \
+ -DSOLARIS -DMOTIF -DCDE \
+ -KPIC \
+ -I./ \
+ -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/solaris \
+ -I$(MOTIF_HOME)/include \
+ -I$(CDE_HOME)/include
+
+
+all: make_swt make_cde
+
+make_swt: $(SWT_DLL)
+
+$(SWT_DLL): $(SWT_OBJ)
+ ld -o $@ $(SWT_OBJ) $(SWT_LIB)
+
+
+make_cde: $(CDE_DLL)
+
+$(CDE_DLL): $(CDE_OBJ)
+ ld -o $@ $(CDE_OBJ) $(CDE_LIB)
+
+
+clean:
+ rm -f $(SWT_OBJ) $(SWT_DLL) $(CDE_OBJ) $(CDE_DLL)
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.c
new file mode 100755
index 0000000000..02445f103d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.c
@@ -0,0 +1,1364 @@
+/**
+ * JNI SWT object field getters and setters declarations for Motif structs.
+ */
+
+#include <jni.h>
+#include "structs.h"
+
+/* ----------- fid and class caches ----------- */
+/*
+ * Used for Java objects passed into JNI that are
+ * declared like:
+ *
+ * nativeFunction (Rectangle p1, Rectangle p2, Rectangle p3)
+ *
+ * and not like this
+ *
+ * nativeFunction (Object p1, Object p2, Object p3)
+ *
+ *
+ */
+
+void cacheXimageFids(JNIEnv *env, jobject lpXimage, PXIMAGE_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->ximageClass = (*env)->GetObjectClass(env,lpXimage);
+
+ lpCache->width = (*env)->GetFieldID(env,lpCache->ximageClass,"width","I");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->ximageClass,"height","I");
+ lpCache->xoffset = (*env)->GetFieldID(env,lpCache->ximageClass,"xoffset","I");
+ lpCache->format = (*env)->GetFieldID(env,lpCache->ximageClass,"format","I");
+ lpCache->data = (*env)->GetFieldID(env,lpCache->ximageClass,"data","I");
+ lpCache->byte_order = (*env)->GetFieldID(env,lpCache->ximageClass,"byte_order","I");
+ lpCache->bitmap_unit = (*env)->GetFieldID(env,lpCache->ximageClass,"bitmap_unit","I");
+ lpCache->bitmap_bit_order = (*env)->GetFieldID(env,lpCache->ximageClass,"bitmap_bit_order","I");
+ lpCache->bitmap_pad = (*env)->GetFieldID(env,lpCache->ximageClass,"bitmap_pad","I");
+ lpCache->depth = (*env)->GetFieldID(env,lpCache->ximageClass,"depth","I");
+ lpCache->bytes_per_line = (*env)->GetFieldID(env,lpCache->ximageClass,"bytes_per_line","I");
+ lpCache->bits_per_pixel = (*env)->GetFieldID(env,lpCache->ximageClass,"bits_per_pixel","I");
+ lpCache->red_mask = (*env)->GetFieldID(env,lpCache->ximageClass,"red_mask","I");
+ lpCache->green_mask = (*env)->GetFieldID(env,lpCache->ximageClass,"green_mask","I");
+ lpCache->blue_mask = (*env)->GetFieldID(env,lpCache->ximageClass,"blue_mask","I");
+ lpCache->obdata = (*env)->GetFieldID(env,lpCache->ximageClass,"obdata","I");
+ lpCache->create_image = (*env)->GetFieldID(env,lpCache->ximageClass,"create_image","I");
+ lpCache->destroy_image = (*env)->GetFieldID(env,lpCache->ximageClass,"destroy_image","I");
+ lpCache->get_pixel = (*env)->GetFieldID(env,lpCache->ximageClass,"get_pixel","I");
+ lpCache->put_pixel = (*env)->GetFieldID(env,lpCache->ximageClass,"put_pixel","I");
+ lpCache->sub_image = (*env)->GetFieldID(env,lpCache->ximageClass,"sub_image","I");
+ lpCache->add_pixel = (*env)->GetFieldID(env,lpCache->ximageClass,"add_pixel","I");
+ lpCache->cached = 1;
+}
+
+void cacheVisualFids(JNIEnv *env, jobject lpVisual, PVISUAL_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->visualClass = (*env)->GetObjectClass(env,lpVisual);
+
+ lpCache->ext_data = (*env)->GetFieldID(env,lpCache->visualClass,"ext_data","I");
+ lpCache->visualid = (*env)->GetFieldID(env,lpCache->visualClass,"visualid","I");
+ lpCache->c_class = (*env)->GetFieldID(env,lpCache->visualClass,"c_class","I");
+ lpCache->red_mask = (*env)->GetFieldID(env,lpCache->visualClass,"red_mask","I");
+ lpCache->green_mask = (*env)->GetFieldID(env,lpCache->visualClass,"green_mask","I");
+ lpCache->blue_mask = (*env)->GetFieldID(env,lpCache->visualClass,"blue_mask","I");
+ lpCache->bits_per_rgb = (*env)->GetFieldID(env,lpCache->visualClass,"bits_per_rgb","I");
+ lpCache->map_entries = (*env)->GetFieldID(env,lpCache->visualClass,"map_entries","I");
+ lpCache->cached = 1;
+}
+
+void cacheXanyeventFids(JNIEnv *env, jobject lpXevent, PXANYEVENT_FID_CACHE lpCache)
+{
+ int i;
+
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ for (i=0; i<19; i++) {
+ char buffer [8];
+ sprintf(buffer, "pad%d", i);
+ lpCache->pad[i] = (*env)->GetFieldID(env,lpCache->xeventClass,buffer,"I");
+ }
+ lpCache->cached = 1;
+}
+
+void cacheXbuttoneventFids(JNIEnv *env, jobject lpXevent, PXBUTTONEVENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ lpCache->root = (*env)->GetFieldID(env,lpCache->xeventClass,"root","I");
+ lpCache->subwindow = (*env)->GetFieldID(env,lpCache->xeventClass,"subwindow","I");
+ lpCache->time = (*env)->GetFieldID(env,lpCache->xeventClass,"time","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xeventClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xeventClass,"y","I");
+ lpCache->x_root = (*env)->GetFieldID(env,lpCache->xeventClass,"x_root","I");
+ lpCache->y_root = (*env)->GetFieldID(env,lpCache->xeventClass,"y_root","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->xeventClass,"state","I");
+ lpCache->button = (*env)->GetFieldID(env,lpCache->xeventClass,"button","I");
+ lpCache->same_screen = (*env)->GetFieldID(env,lpCache->xeventClass,"same_screen","I");
+ lpCache->cached = 1;
+}
+
+void cacheXcharstructFids(JNIEnv *env, jobject lpXcharstruct, PXCHARSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xcharstructClass = (*env)->GetObjectClass(env,lpXcharstruct);
+
+ lpCache->lbearing = (*env)->GetFieldID(env,lpCache->xcharstructClass,"lbearing","S");
+ lpCache->rbearing = (*env)->GetFieldID(env,lpCache->xcharstructClass,"rbearing","S");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xcharstructClass,"width","S");
+ lpCache->ascent = (*env)->GetFieldID(env,lpCache->xcharstructClass,"ascent","S");
+ lpCache->descent = (*env)->GetFieldID(env,lpCache->xcharstructClass,"descent","S");
+ lpCache->attributes = (*env)->GetFieldID(env,lpCache->xcharstructClass,"attributes","S");
+ lpCache->cached = 1;
+}
+
+void cacheXconfigureeventFids(JNIEnv *env, jobject lpXevent, PXCONFIGUREEVENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xeventClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xeventClass,"y","I");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xeventClass,"width","I");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->xeventClass,"height","I");
+ lpCache->border_width = (*env)->GetFieldID(env,lpCache->xeventClass,"border_width","I");
+ lpCache->above = (*env)->GetFieldID(env,lpCache->xeventClass,"above","I");
+ lpCache->override_redirect = (*env)->GetFieldID(env,lpCache->xeventClass,"override_redirect","I");
+ lpCache->cached = 1;
+}
+
+void cacheXcrossingeventFids(JNIEnv *env, jobject lpXcrossingevent, PXCROSSINGEVENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xcrossingeventClass = (*env)->GetObjectClass(env,lpXcrossingevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"window","I");
+ lpCache->root = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"root","I");
+ lpCache->subwindow = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"subwindow","I");
+ lpCache->time = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"time","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"y","I");
+ lpCache->x_root = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"x_root","I");
+ lpCache->y_root = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"y_root","I");
+ lpCache->mode = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"mode","I");
+ lpCache->detail = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"detail","I");
+ lpCache->same_screen = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"same_screen","I");
+ lpCache->focus = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"focus","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->xcrossingeventClass,"state","I");
+ lpCache->cached = 1;
+}
+
+void cacheXexposeeventFids(JNIEnv *env, jobject lpXevent, PXEXPOSEEVENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xeventClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xeventClass,"y","I");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xeventClass,"width","I");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->xeventClass,"height","I");
+ lpCache->count = (*env)->GetFieldID(env,lpCache->xeventClass,"count","I");
+ lpCache->cached = 1;
+}
+
+void cacheXfocuschangeeventFids(JNIEnv *env, jobject lpXevent, PXFOCUSCHANGEEVENT_FID_CACHE lpCache)
+{
+ int i;
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ lpCache->mode = (*env)->GetFieldID(env,lpCache->xeventClass,"mode","I");
+ lpCache->detail = (*env)->GetFieldID(env,lpCache->xeventClass,"detail","I");
+ for (i=0; i<17; i++) {
+ char buffer [8];
+ sprintf(buffer, "pad%d", i);
+ lpCache->pad[i] = (*env)->GetFieldID(env,lpCache->xeventClass,buffer,"I");
+ }
+ lpCache->cached = 1;
+}
+
+void cacheXfontstructFids(JNIEnv *env, jobject lpXfontstruct, PXFONTSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xfontstructClass = (*env)->GetObjectClass(env,lpXfontstruct);
+
+ lpCache->ext_data = (*env)->GetFieldID(env,lpCache->xfontstructClass,"ext_data","I");
+ lpCache->fid = (*env)->GetFieldID(env,lpCache->xfontstructClass,"fid","I");
+ lpCache->direction = (*env)->GetFieldID(env,lpCache->xfontstructClass,"direction","I");
+ lpCache->min_char_or_byte2 = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_char_or_byte2","I");
+ lpCache->max_char_or_byte2 = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_char_or_byte2","I");
+ lpCache->min_byte1 = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_byte1","I");
+ lpCache->max_byte1 = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_byte1","I");
+ lpCache->all_chars_exist = (*env)->GetFieldID(env,lpCache->xfontstructClass,"all_chars_exist","I");
+ lpCache->default_char = (*env)->GetFieldID(env,lpCache->xfontstructClass,"default_char","I");
+ lpCache->n_properties = (*env)->GetFieldID(env,lpCache->xfontstructClass,"n_properties","I");
+ lpCache->properties = (*env)->GetFieldID(env,lpCache->xfontstructClass,"properties","I");
+ lpCache->min_bounds_lbearing = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_bounds_lbearing","S");
+ lpCache->min_bounds_rbearing = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_bounds_rbearing","S");
+ lpCache->min_bounds_width = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_bounds_width","S");
+ lpCache->min_bounds_ascent = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_bounds_ascent","S");
+ lpCache->min_bounds_descent = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_bounds_descent","S");
+ lpCache->min_bounds_attributes = (*env)->GetFieldID(env,lpCache->xfontstructClass,"min_bounds_attributes","S");
+ lpCache->max_bounds_lbearing = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_bounds_lbearing","S");
+ lpCache->max_bounds_rbearing = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_bounds_rbearing","S");
+ lpCache->max_bounds_width = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_bounds_width","S");
+ lpCache->max_bounds_ascent = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_bounds_ascent","S");
+ lpCache->max_bounds_descent = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_bounds_descent","S");
+ lpCache->max_bounds_attributes = (*env)->GetFieldID(env,lpCache->xfontstructClass,"max_bounds_attributes","S");
+ lpCache->per_char = (*env)->GetFieldID(env,lpCache->xfontstructClass,"per_char","I");
+ lpCache->ascent = (*env)->GetFieldID(env,lpCache->xfontstructClass,"ascent","I");
+ lpCache->descent = (*env)->GetFieldID(env,lpCache->xfontstructClass,"descent","I");
+ lpCache->cached = 1;
+}
+
+void cacheXkeyeventFids(JNIEnv *env, jobject lpXevent, PXKEYEVENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ lpCache->root = (*env)->GetFieldID(env,lpCache->xeventClass,"root","I");
+ lpCache->subwindow = (*env)->GetFieldID(env,lpCache->xeventClass,"subwindow","I");
+ lpCache->time = (*env)->GetFieldID(env,lpCache->xeventClass,"time","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xeventClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xeventClass,"y","I");
+ lpCache->x_root = (*env)->GetFieldID(env,lpCache->xeventClass,"x_root","I");
+ lpCache->y_root = (*env)->GetFieldID(env,lpCache->xeventClass,"y_root","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->xeventClass,"state","I");
+ lpCache->keycode = (*env)->GetFieldID(env,lpCache->xeventClass,"keycode","I");
+ lpCache->same_screen = (*env)->GetFieldID(env,lpCache->xeventClass,"same_screen","I");
+ lpCache->cached = 1;
+}
+
+void cacheXmotioneventFids(JNIEnv *env, jobject lpXevent, PXMOTIONEVENT_FID_CACHE lpCache)
+{
+ int i;
+ if (lpCache->cached) return;
+
+ lpCache->xeventClass = (*env)->GetObjectClass(env,lpXevent);
+
+ lpCache->type = (*env)->GetFieldID(env,lpCache->xeventClass,"type","I");
+ lpCache->serial = (*env)->GetFieldID(env,lpCache->xeventClass,"serial","I");
+ lpCache->send_event = (*env)->GetFieldID(env,lpCache->xeventClass,"send_event","I");
+ lpCache->display = (*env)->GetFieldID(env,lpCache->xeventClass,"display","I");
+ lpCache->window = (*env)->GetFieldID(env,lpCache->xeventClass,"window","I");
+ lpCache->root = (*env)->GetFieldID(env,lpCache->xeventClass,"root","I");
+ lpCache->subwindow = (*env)->GetFieldID(env,lpCache->xeventClass,"subwindow","I");
+ lpCache->time = (*env)->GetFieldID(env,lpCache->xeventClass,"time","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xeventClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xeventClass,"y","I");
+ lpCache->x_root = (*env)->GetFieldID(env,lpCache->xeventClass,"x_root","I");
+ lpCache->y_root = (*env)->GetFieldID(env,lpCache->xeventClass,"y_root","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->xeventClass,"state","I");
+ lpCache->is_hint = (*env)->GetFieldID(env,lpCache->xeventClass,"is_hint","I");
+ lpCache->same_screen = (*env)->GetFieldID(env,lpCache->xeventClass,"same_screen","I");
+ for (i=0; i<10; i++) {
+ char buffer [8];
+ sprintf(buffer, "pad%d", i);
+ lpCache->pad[i] = (*env)->GetFieldID(env,lpCache->xeventClass,buffer,"I");
+ }
+ lpCache->cached = 1;
+}
+
+void cacheXcolorFids(JNIEnv *env, jobject lpXcolor, PXCOLOR_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xcolorClass = (*env)->GetObjectClass(env,lpXcolor);
+
+ lpCache->pixel = (*env)->GetFieldID(env,lpCache->xcolorClass,"pixel","I");
+ lpCache->red = (*env)->GetFieldID(env,lpCache->xcolorClass,"red","S");
+ lpCache->green = (*env)->GetFieldID(env,lpCache->xcolorClass,"green","S");
+ lpCache->blue = (*env)->GetFieldID(env,lpCache->xcolorClass,"blue","S");
+ lpCache->flags = (*env)->GetFieldID(env,lpCache->xcolorClass,"flags","B");
+ lpCache->pad = (*env)->GetFieldID(env,lpCache->xcolorClass,"pad","B");
+ lpCache->cached = 1;
+}
+
+void cacheXgcvaluesFids(JNIEnv *env, jobject lpXgcvalues, PXGCVALUES_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xgcvaluesClass = (*env)->GetObjectClass(env,lpXgcvalues);
+
+ lpCache->function = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"function","I");
+ lpCache->plane_mask = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"plane_mask","I");
+ lpCache->foreground = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"foreground","I");
+ lpCache->background = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"background","I");
+ lpCache->line_width = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"line_width","I");
+ lpCache->line_style = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"line_style","I");
+ lpCache->cap_style = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"cap_style","I");
+ lpCache->join_style = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"join_style","I");
+ lpCache->fill_style = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"fill_style","I");
+ lpCache->fill_rule = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"fill_rule","I");
+ lpCache->arc_mode = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"arc_mode","I");
+ lpCache->tile = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"tile","I");
+ lpCache->stipple = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"stipple","I");
+ lpCache->ts_x_origin = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"ts_x_origin","I");
+ lpCache->ts_y_origin = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"ts_y_origin","I");
+ lpCache->font = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"font","I");
+ lpCache->subwindow_mode = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"subwindow_mode","I");
+ lpCache->graphics_exposures = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"graphics_exposures","I");
+ lpCache->clip_x_origin = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"clip_x_origin","I");
+ lpCache->clip_y_origin = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"clip_y_origin","I");
+ lpCache->clip_mask = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"clip_mask","I");
+ lpCache->dash_offset = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"dash_offset","I");
+
+ lpCache->dashes = (*env)->GetFieldID(env,lpCache->xgcvaluesClass,"dashes","B");
+ lpCache->cached = 1;
+}
+
+void cacheXmanycallbackstructFids(JNIEnv *env, jobject lpXmanycallback, PXMANYCALLBACKSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xmanycallbackstructClass = (*env)->GetObjectClass(env,lpXmanycallback);
+
+ lpCache->reason = (*env)->GetFieldID(env,lpCache->xmanycallbackstructClass,"reason","I");
+ lpCache->event = (*env)->GetFieldID(env,lpCache->xmanycallbackstructClass,"event","I");
+ lpCache->cached = 1;
+}
+
+void cacheXmdragproccallbackFids(JNIEnv *env, jobject lpXmdragproccallback, PXMDRAGPROCCALLBACK_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xmdragproccallbackClass = (*env)->GetObjectClass(env,lpXmdragproccallback);
+
+ lpCache->reason = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"reason","I");
+ lpCache->event = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"event","I");
+ lpCache->timeStamp = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"timeStamp","I");
+ lpCache->dragContext = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"dragContext","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"x","S");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"y","S");
+ lpCache->dropSiteStatus = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"dropSiteStatus","B");
+ lpCache->operation = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"operation","B");
+ lpCache->operations = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"operations","B");
+ lpCache->animate = (*env)->GetFieldID(env,lpCache->xmdragproccallbackClass,"animate","B");
+ lpCache->cached = 1;
+}
+
+void cacheXmdropproccallbackFids(JNIEnv *env, jobject lpXmdropproccallback, PXMDROPPROCCALLBACK_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xmdropproccallbackClass = (*env)->GetObjectClass(env,lpXmdropproccallback);
+
+ lpCache->reason = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"reason","I");
+ lpCache->event = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"event","I");
+ lpCache->timeStamp = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"timeStamp","I");
+ lpCache->dragContext = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"dragContext","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"x","S");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"y","S");
+ lpCache->dropSiteStatus = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"dropSiteStatus","B");
+ lpCache->operation = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"operation","B");
+ lpCache->operations = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"operations","B");
+ lpCache->dropAction = (*env)->GetFieldID(env,lpCache->xmdropproccallbackClass,"dropAction","B");
+ lpCache->cached = 1;
+}
+
+void cacheXmdropfinishcallbackFids(JNIEnv *env, jobject lpXmdropfinishcallback, PXMDROPFINISHCALLBACK_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xmdropfinishcallbackClass = (*env)->GetObjectClass(env,lpXmdropfinishcallback);
+
+ lpCache->reason = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"reason","I");
+ lpCache->event = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"event","I");
+ lpCache->timeStamp = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"timeStamp","I");
+ lpCache->operation = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"operation","B");
+ lpCache->operations = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"operations","B");
+ lpCache->dropSiteStatus = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"dropSiteStatus","B");
+ lpCache->dropAction = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"dropAction","B");
+ lpCache->completionStatus = (*env)->GetFieldID(env,lpCache->xmdropfinishcallbackClass,"completionStatus","B");
+ lpCache->cached = 1;
+}
+
+void cacheXmtextblockrecFids(JNIEnv *env, jobject lpXmtextblockrec, PXMTEXTBLOCKREC_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xmtextblockrecClass = (*env)->GetObjectClass(env,lpXmtextblockrec);
+
+ lpCache->ptr = (*env)->GetFieldID(env,lpCache->xmtextblockrecClass,"ptr","I");
+ lpCache->length = (*env)->GetFieldID(env,lpCache->xmtextblockrecClass,"length","I");
+ lpCache->format = (*env)->GetFieldID(env,lpCache->xmtextblockrecClass,"format","I");
+ lpCache->cached = 1;
+}
+
+void cacheXmtextverifycallbackstructFids(JNIEnv *env, jobject lpXmtextverifycallback, PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xmtextverifycallbackstructClass = (*env)->GetObjectClass(env,lpXmtextverifycallback);
+
+ lpCache->reason = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"reason","I");
+ lpCache->event = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"event","I");
+ lpCache->doit = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"doit","B");
+ lpCache->currInsert = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"currInsert","I");
+ lpCache->newInsert = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"newInsert","I");
+ lpCache->startPos = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"startPos","I");
+ lpCache->endPos = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"endPos","I");
+ lpCache->text = (*env)->GetFieldID(env,lpCache->xmtextverifycallbackstructClass,"text","I");
+ lpCache->cached = 1;
+}
+
+void cacheXrectangleFids(JNIEnv *env, jobject lpXrect, PXRECTANGLE_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xrectClass = (*env)->GetObjectClass(env,lpXrect);
+
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xrectClass,"x","S");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xrectClass,"y","S");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xrectClass,"width","S");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->xrectClass,"height","S");
+ lpCache->cached = 1;
+}
+
+void cacheXsetwindowattributesFids(JNIEnv *env, jobject lpXsetwindowattributes, PXSETWINDOWATTRIBUTES_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xsetwindowattributesClass = (*env)->GetObjectClass(env,lpXsetwindowattributes);
+
+ lpCache->background_pixmap = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"background_pixmap","I");
+ lpCache->background_pixel = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"background_pixel","I");
+ lpCache->border_pixmap = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"border_pixmap","I");
+ lpCache->border_pixel = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"border_pixel","I");
+ lpCache->bit_gravity = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"bit_gravity","I");
+ lpCache->win_gravity = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"win_gravity","I");
+ lpCache->backing_store = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"backing_store","I");
+ lpCache->backing_planes = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"backing_planes","I");
+ lpCache->backing_pixel = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"backing_pixel","I");
+ lpCache->save_under = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"save_under","I");
+ lpCache->event_mask = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"event_mask","I");
+ lpCache->do_not_propagate_mask = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"do_not_propagate_mask","I");
+ lpCache->override_redirect = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"override_redirect","I");
+ lpCache->colormap = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"colormap","I");
+ lpCache->cursor = (*env)->GetFieldID(env,lpCache->xsetwindowattributesClass,"cursor","I");
+ lpCache->cached = 1;
+}
+
+void cacheXwindowattributesFids(JNIEnv *env, jobject lpXwindowattributes, PXWINDOWATTRIBUTES_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xwindowattributesClass = (*env)->GetObjectClass(env,lpXwindowattributes);
+
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"y","I");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"width","I");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"height","I");
+ lpCache->border_width = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"border_width","I");
+ lpCache->depth = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"depth","I");
+ lpCache->visual = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"visual","I");
+ lpCache->root = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"root","I");
+ lpCache->class = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"c_class","I");
+ lpCache->bit_gravity = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"bit_gravity","I");
+ lpCache->win_gravity = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"win_gravity","I");
+ lpCache->backing_store = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"backing_store","I");
+ lpCache->backing_planes = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"backing_planes","I");
+ lpCache->backing_pixel = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"backing_pixel","I");
+ lpCache->save_under = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"save_under","I");
+ lpCache->colormap = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"colormap","I");
+ lpCache->map_installed = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"map_installed","I");
+ lpCache->map_state = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"map_state","I");
+ lpCache->all_event_masks = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"all_event_masks","I");
+ lpCache->your_event_mask = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"your_event_mask","I");
+ lpCache->do_not_propagate_mask = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"do_not_propagate_mask","I");
+ lpCache->override_redirect = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"override_redirect","I");
+ lpCache->screen = (*env)->GetFieldID(env,lpCache->xwindowattributesClass,"screen","I");
+ lpCache->cached = 1;
+}
+
+void cacheXwindowchangesFids(JNIEnv *env, jobject lpXwindowchanges, PXWINDOWCHANGES_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xwindowchangesClass = (*env)->GetObjectClass(env,lpXwindowchanges);
+
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"y","I");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"width","I");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"height","I");
+ lpCache->border_width = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"border_width","I");
+ lpCache->sibling = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"sibling","I");
+ lpCache->stack_mode = (*env)->GetFieldID(env,lpCache->xwindowchangesClass,"stack_mode","I");
+ lpCache->cached = 1;
+}
+
+void cacheXtwidgetgeometryFids(JNIEnv *env, jobject lpXtwidgetgeometry, PXTWIDGETGEOMETRY_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+
+ lpCache->xtwidgetgeometryClass = (*env)->GetObjectClass(env,lpXtwidgetgeometry);
+
+ lpCache->request_mode = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"request_mode","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"y","I");
+ lpCache->width = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"width","I");
+ lpCache->height = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"height","I");
+ lpCache->border_width = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"border_width","I");
+ lpCache->sibling = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"sibling","I");
+ lpCache->stack_mode = (*env)->GetFieldID(env,lpCache->xtwidgetgeometryClass,"stack_mode","I");
+ lpCache->cached = 1;
+}
+
+/* ----------- getters and setters ----------- */
+/**
+ * These functions get or set object field ids assuming that the
+ * fids for these objects have already been cached.
+ *
+ */
+
+void getVisualFields(JNIEnv *env, jobject lpObject, Visual *lpVisual, VISUAL_FID_CACHE *lpVisualFc)
+{
+ lpVisual->ext_data = (XExtData *)(*env)->GetIntField(env,lpObject,lpVisualFc->ext_data);
+ lpVisual->visualid = (*env)->GetIntField(env,lpObject,lpVisualFc->visualid);
+ lpVisual->class = (*env)->GetIntField(env,lpObject,lpVisualFc->c_class);
+ lpVisual->red_mask = (*env)->GetIntField(env,lpObject,lpVisualFc->red_mask);
+ lpVisual->green_mask = (*env)->GetIntField(env,lpObject,lpVisualFc->green_mask);
+ lpVisual->blue_mask = (*env)->GetIntField(env,lpObject,lpVisualFc->blue_mask);
+ lpVisual->bits_per_rgb = (*env)->GetIntField(env,lpObject,lpVisualFc->bits_per_rgb);
+ lpVisual->map_entries = (*env)->GetIntField(env,lpObject,lpVisualFc->map_entries);
+}
+
+void setVisualFields(JNIEnv *env, jobject lpObject, Visual *lpVisual, VISUAL_FID_CACHE *lpVisualFc)
+{
+ (*env)->SetIntField(env,lpObject,lpVisualFc->ext_data, (jint)lpVisual->ext_data);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->visualid, lpVisual->visualid);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->c_class, lpVisual->class);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->red_mask, (int)lpVisual->red_mask);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->green_mask, lpVisual->green_mask);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->blue_mask, lpVisual->blue_mask);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->bits_per_rgb, (int)lpVisual->bits_per_rgb);
+ (*env)->SetIntField(env,lpObject,lpVisualFc->map_entries, lpVisual->map_entries);
+}
+
+void getXanyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XANYEVENT_FID_CACHE *lpXanyeventFc)
+{
+ int i;
+
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXanyeventFc->type);
+ lpXevent->xany.serial = (*env)->GetIntField(env,lpObject,lpXanyeventFc->serial);
+ lpXevent->xany.send_event = (*env)->GetIntField(env,lpObject,lpXanyeventFc->send_event);
+ lpXevent->xany.display = (Display *)(*env)->GetIntField(env,lpObject,lpXanyeventFc->display);
+ lpXevent->xany.window = (*env)->GetIntField(env,lpObject,lpXanyeventFc->window);
+ for (i=0; i<19; i++) {
+ lpXevent->pad[i+5] = (*env)->GetIntField(env,lpObject,lpXanyeventFc->pad[i]);
+ }
+}
+
+void setXanyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XANYEVENT_FID_CACHE *lpXanyeventFc)
+{
+ int i;
+
+ (*env)->SetIntField(env,lpObject,lpXanyeventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXanyeventFc->serial, lpXevent->xany.serial);
+ (*env)->SetIntField(env,lpObject,lpXanyeventFc->send_event, lpXevent->xany.send_event);
+ (*env)->SetIntField(env,lpObject,lpXanyeventFc->display, (int)lpXevent->xany.display);
+ (*env)->SetIntField(env,lpObject,lpXanyeventFc->window, lpXevent->xany.window);
+ for (i=0; i<19; i++) {
+ (*env)->SetIntField(env,lpObject,lpXanyeventFc->pad[i],lpXevent->pad[i+5]);
+ }
+}
+
+void getXbuttoneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XBUTTONEVENT_FID_CACHE *lpXbuttoneventFc)
+{
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->type);
+ lpXevent->xbutton.serial = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->serial);
+ lpXevent->xbutton.send_event = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->send_event);
+ lpXevent->xbutton.display = (Display *)(*env)->GetIntField(env,lpObject,lpXbuttoneventFc->display);
+ lpXevent->xbutton.window = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->window);
+ lpXevent->xbutton.root = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->root);
+ lpXevent->xbutton.subwindow = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->subwindow);
+ lpXevent->xbutton.time = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->time);
+ lpXevent->xbutton.x = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->x);
+ lpXevent->xbutton.y = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->y);
+ lpXevent->xbutton.x_root = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->x_root);
+ lpXevent->xbutton.y_root = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->y_root);
+ lpXevent->xbutton.state = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->state);
+ lpXevent->xbutton.button = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->button);
+ lpXevent->xbutton.same_screen = (*env)->GetIntField(env,lpObject,lpXbuttoneventFc->same_screen);
+}
+
+void setXbuttoneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XBUTTONEVENT_FID_CACHE *lpXbuttoneventFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->serial, lpXevent->xbutton.serial);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->send_event, lpXevent->xbutton.send_event);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->display, (int)lpXevent->xbutton.display);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->window, lpXevent->xbutton.window);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->root, lpXevent->xbutton.root);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->subwindow, lpXevent->xbutton.subwindow);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->time, lpXevent->xbutton.time);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->x, lpXevent->xbutton.x);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->y, lpXevent->xbutton.y);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->x_root, lpXevent->xbutton.x_root);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->y_root, lpXevent->xbutton.y_root);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->state, lpXevent->xbutton.state);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->button, lpXevent->xbutton.button);
+ (*env)->SetIntField(env,lpObject,lpXbuttoneventFc->same_screen, lpXevent->xbutton.same_screen);
+}
+
+void getXconfigureeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XCONFIGUREEVENT_FID_CACHE *lpXconfigureeventFc)
+{
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->type);
+ lpXevent->xconfigure.serial = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->serial);
+ lpXevent->xconfigure.send_event = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->send_event);
+ lpXevent->xconfigure.display = (Display *)(*env)->GetIntField(env,lpObject,lpXconfigureeventFc->display);
+ lpXevent->xconfigure.window = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->window);
+ lpXevent->xconfigure.x = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->x);
+ lpXevent->xconfigure.y = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->y);
+ lpXevent->xconfigure.width = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->width);
+ lpXevent->xconfigure.height = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->height);
+ lpXevent->xconfigure.border_width = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->border_width);
+ lpXevent->xconfigure.above = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->above);
+ lpXevent->xconfigure.override_redirect = (*env)->GetIntField(env,lpObject,lpXconfigureeventFc->override_redirect);
+}
+
+void setXconfigureeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XCONFIGUREEVENT_FID_CACHE *lpXconfigureeventFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->serial, lpXevent->xconfigure.serial);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->send_event, lpXevent->xconfigure.send_event);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->display, (int)lpXevent->xconfigure.display);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->window, lpXevent->xconfigure.window);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->x, lpXevent->xconfigure.x);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->y, lpXevent->xconfigure.y);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->width, lpXevent->xconfigure.width);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->height, lpXevent->xconfigure.height);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->border_width, lpXevent->xconfigure.border_width);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->above, lpXevent->xconfigure.above);
+ (*env)->SetIntField(env,lpObject,lpXconfigureeventFc->override_redirect, lpXevent->xconfigure.override_redirect);
+}
+
+void getXcharstructFields(JNIEnv *env, jobject lpObject, XCharStruct *lpXcharstruct, XCHARSTRUCT_FID_CACHE *lpXcharstructFc)
+{
+ lpXcharstruct->lbearing = (*env)->GetShortField(env,lpObject,lpXcharstructFc->lbearing);
+ lpXcharstruct->rbearing = (*env)->GetShortField(env,lpObject,lpXcharstructFc->rbearing);
+ lpXcharstruct->width = (*env)->GetShortField(env,lpObject,lpXcharstructFc->width);
+ lpXcharstruct->ascent = (*env)->GetShortField(env,lpObject,lpXcharstructFc->ascent);
+ lpXcharstruct->descent = (*env)->GetShortField(env,lpObject,lpXcharstructFc->descent);
+ lpXcharstruct->attributes = (*env)->GetShortField(env,lpObject,lpXcharstructFc->attributes);
+}
+
+void setXcharstructFields(JNIEnv *env, jobject lpObject, XCharStruct *lpXcharstruct, XCHARSTRUCT_FID_CACHE *lpXcharstructFc)
+{
+ (*env)->SetShortField(env,lpObject,lpXcharstructFc->lbearing, lpXcharstruct->lbearing);
+ (*env)->SetShortField(env,lpObject,lpXcharstructFc->rbearing, lpXcharstruct->rbearing);
+ (*env)->SetShortField(env,lpObject,lpXcharstructFc->width, lpXcharstruct->width);
+ (*env)->SetShortField(env,lpObject,lpXcharstructFc->ascent, lpXcharstruct->ascent);
+ (*env)->SetShortField(env,lpObject,lpXcharstructFc->descent, lpXcharstruct->descent);
+ (*env)->SetShortField(env,lpObject,lpXcharstructFc->attributes, lpXcharstruct->attributes);
+
+}
+
+void getXcrossingeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXcrossingevent, XCROSSINGEVENT_FID_CACHE *lpXcrossingeventFc)
+{
+ int i;
+
+ lpXcrossingevent->type = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->type);
+ lpXcrossingevent->xcrossing.serial = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->serial);
+ lpXcrossingevent->xcrossing.send_event = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->send_event);
+ lpXcrossingevent->xcrossing.display = (Display *)(*env)->GetIntField(env,lpObject,lpXcrossingeventFc->display);
+ lpXcrossingevent->xcrossing.window = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->window);
+ lpXcrossingevent->xcrossing.root = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->root);
+ lpXcrossingevent->xcrossing.subwindow = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->subwindow);
+ lpXcrossingevent->xcrossing.time = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->time);
+ lpXcrossingevent->xcrossing.x = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->x);
+ lpXcrossingevent->xcrossing.y = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->y);
+ lpXcrossingevent->xcrossing.x_root = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->x_root);
+ lpXcrossingevent->xcrossing.y_root = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->y_root);
+ lpXcrossingevent->xcrossing.mode = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->mode);
+ lpXcrossingevent->xcrossing.detail = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->detail);
+ lpXcrossingevent->xcrossing.same_screen = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->same_screen);
+ lpXcrossingevent->xcrossing.focus = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->focus);
+ lpXcrossingevent->xcrossing.state = (*env)->GetIntField(env,lpObject,lpXcrossingeventFc->state);
+}
+
+void setXcrossingeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXcrossingevent, XCROSSINGEVENT_FID_CACHE *lpXcrossingeventFc)
+{
+ int i;
+
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->type, lpXcrossingevent->type);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->serial, lpXcrossingevent->xcrossing.serial);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->send_event, lpXcrossingevent->xcrossing.send_event);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->display, (int)lpXcrossingevent->xcrossing.display);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->window, lpXcrossingevent->xcrossing.window);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->root, lpXcrossingevent->xcrossing.root);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->subwindow, lpXcrossingevent->xcrossing.subwindow);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->time, lpXcrossingevent->xcrossing.time);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->x, lpXcrossingevent->xcrossing.x);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->y, lpXcrossingevent->xcrossing.y);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->x_root, lpXcrossingevent->xcrossing.x_root);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->y_root, lpXcrossingevent->xcrossing.y_root);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->mode, lpXcrossingevent->xcrossing.mode);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->detail, lpXcrossingevent->xcrossing.detail);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->same_screen, lpXcrossingevent->xcrossing.same_screen);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->focus, lpXcrossingevent->xcrossing.focus);
+ (*env)->SetIntField(env,lpObject,lpXcrossingeventFc->state, lpXcrossingevent->xcrossing.state);
+}
+
+void getXexposeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XEXPOSEEVENT_FID_CACHE *lpXexposeeventFc)
+{
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->type);
+ lpXevent->xexpose.serial = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->serial);
+ lpXevent->xexpose.send_event = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->send_event);
+ lpXevent->xexpose.display = (Display *)(*env)->GetIntField(env,lpObject,lpXexposeeventFc->display);
+ lpXevent->xexpose.window = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->window);
+ lpXevent->xexpose.x = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->x);
+ lpXevent->xexpose.y = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->y);
+ lpXevent->xexpose.width = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->width);
+ lpXevent->xexpose.height = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->height);
+ lpXevent->xexpose.count = (*env)->GetIntField(env,lpObject,lpXexposeeventFc->count);
+}
+
+void setXexposeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XEXPOSEEVENT_FID_CACHE *lpXexposeeventFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->serial, lpXevent->xexpose.serial);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->send_event, lpXevent->xexpose.send_event);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->display, (int)lpXevent->xexpose.display);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->window, lpXevent->xexpose.window);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->x, lpXevent->xexpose.x);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->y, lpXevent->xexpose.y);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->width, lpXevent->xexpose.width);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->height, lpXevent->xexpose.height);
+ (*env)->SetIntField(env,lpObject,lpXexposeeventFc->count, lpXevent->xexpose.count);
+}
+
+void getXfontstructFields(JNIEnv *env, jobject lpObject, XFontStruct *lpXfontstruct, XFONTSTRUCT_FID_CACHE *lpXfontstructFc)
+{
+ lpXfontstruct->ext_data = (XExtData *)(*env)->GetIntField(env,lpObject,lpXfontstructFc->ext_data);
+ lpXfontstruct->fid = (Font)(*env)->GetIntField(env,lpObject,lpXfontstructFc->fid);
+ lpXfontstruct->direction = (unsigned)(*env)->GetIntField(env,lpObject,lpXfontstructFc->direction);
+ lpXfontstruct->min_char_or_byte2 = (unsigned)(*env)->GetIntField(env,lpObject,lpXfontstructFc->min_char_or_byte2);
+ lpXfontstruct->max_char_or_byte2 = (unsigned)(*env)->GetIntField(env,lpObject,lpXfontstructFc->max_char_or_byte2);
+ lpXfontstruct->min_byte1 = (unsigned)(*env)->GetIntField(env,lpObject,lpXfontstructFc->min_byte1);
+ lpXfontstruct->max_byte1 = (unsigned)(*env)->GetIntField(env,lpObject,lpXfontstructFc->max_byte1);
+ lpXfontstruct->all_chars_exist = (Bool)(*env)->GetIntField(env,lpObject,lpXfontstructFc->all_chars_exist);
+ lpXfontstruct->default_char = (unsigned)(*env)->GetIntField(env,lpObject,lpXfontstructFc->default_char);
+ lpXfontstruct->n_properties = (*env)->GetIntField(env,lpObject,lpXfontstructFc->n_properties);
+ lpXfontstruct->properties = (XFontProp *)(*env)->GetIntField(env,lpObject,lpXfontstructFc->properties);
+ lpXfontstruct->min_bounds.lbearing = (*env)->GetShortField(env,lpObject,lpXfontstructFc->min_bounds_lbearing);
+ lpXfontstruct->min_bounds.rbearing = (*env)->GetShortField(env,lpObject,lpXfontstructFc->min_bounds_rbearing);
+ lpXfontstruct->min_bounds.width = (*env)->GetShortField(env,lpObject,lpXfontstructFc->min_bounds_lbearing);
+ lpXfontstruct->min_bounds.ascent = (*env)->GetShortField(env,lpObject,lpXfontstructFc->min_bounds_lbearing);
+ lpXfontstruct->min_bounds.descent = (*env)->GetShortField(env,lpObject,lpXfontstructFc->min_bounds_lbearing);
+ lpXfontstruct->min_bounds.attributes = (*env)->GetShortField(env,lpObject,lpXfontstructFc->min_bounds_lbearing);
+ lpXfontstruct->max_bounds.lbearing = (*env)->GetShortField(env,lpObject,lpXfontstructFc->max_bounds_lbearing);
+ lpXfontstruct->max_bounds.rbearing = (*env)->GetShortField(env,lpObject,lpXfontstructFc->max_bounds_rbearing);
+ lpXfontstruct->max_bounds.width = (*env)->GetShortField(env,lpObject,lpXfontstructFc->max_bounds_width);
+ lpXfontstruct->max_bounds.ascent = (*env)->GetShortField(env,lpObject,lpXfontstructFc->max_bounds_ascent);
+ lpXfontstruct->max_bounds.descent = (*env)->GetShortField(env,lpObject,lpXfontstructFc->max_bounds_descent);
+ lpXfontstruct->max_bounds.attributes = (*env)->GetShortField(env,lpObject,lpXfontstructFc->max_bounds_attributes);
+ lpXfontstruct->per_char = (XCharStruct *)(*env)->GetIntField(env,lpObject,lpXfontstructFc->per_char);
+ lpXfontstruct->ascent = (*env)->GetIntField(env,lpObject,lpXfontstructFc->ascent);
+ lpXfontstruct->descent = (*env)->GetIntField(env,lpObject,lpXfontstructFc->descent);
+}
+
+void setXfontstructFields(JNIEnv *env, jobject lpObject, XFontStruct *lpXfontstruct, XFONTSTRUCT_FID_CACHE *lpXfontstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->ext_data, (jint)lpXfontstruct->ext_data);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->fid, (jint)lpXfontstruct->fid);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->direction, (jint)lpXfontstruct->direction);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->min_char_or_byte2, (jint)lpXfontstruct->min_char_or_byte2);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->max_char_or_byte2, (jint)lpXfontstruct->max_char_or_byte2);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->min_byte1, (jint)lpXfontstruct->min_byte1);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->max_byte1, (jint)lpXfontstruct->max_byte1);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->all_chars_exist, (jint)lpXfontstruct->all_chars_exist);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->default_char, (jint)lpXfontstruct->default_char);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->n_properties, (jint)lpXfontstruct->n_properties);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->properties, (jint)lpXfontstruct->properties);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->min_bounds_lbearing, (jint)lpXfontstruct->min_bounds.lbearing);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->min_bounds_rbearing, (jint)lpXfontstruct->min_bounds.rbearing);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->min_bounds_width, (jint)lpXfontstruct->min_bounds.width);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->min_bounds_ascent, (jint)lpXfontstruct->min_bounds.ascent);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->min_bounds_descent, (jint)lpXfontstruct->min_bounds.descent);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->min_bounds_attributes, (jint)lpXfontstruct->min_bounds.attributes);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->max_bounds_lbearing, (jint)lpXfontstruct->max_bounds.lbearing);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->max_bounds_rbearing, (jint)lpXfontstruct->max_bounds.rbearing);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->max_bounds_width, (jint)lpXfontstruct->max_bounds.width);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->max_bounds_ascent, (jint)lpXfontstruct->max_bounds.ascent);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->max_bounds_descent, (jint)lpXfontstruct->max_bounds.descent);
+ (*env)->SetShortField(env,lpObject,lpXfontstructFc->max_bounds_attributes, (jint)lpXfontstruct->max_bounds.attributes);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->per_char, (jint)lpXfontstruct->per_char);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->ascent, (jint)lpXfontstruct->ascent);
+ (*env)->SetIntField(env,lpObject,lpXfontstructFc->descent, (jint)lpXfontstruct->descent);
+}
+
+
+void getXfocuschangeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XFOCUSCHANGEEVENT_FID_CACHE *lpXfocuschangeeventFc)
+{
+ int i;
+
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->type);
+ lpXevent->xfocus.serial = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->serial);
+ lpXevent->xfocus.send_event = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->send_event);
+ lpXevent->xfocus.display = (Display *)(*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->display);
+ lpXevent->xfocus.window = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->window);
+ lpXevent->xfocus.mode = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->mode);
+ lpXevent->xfocus.detail = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->detail);
+ for (i=0; i<17; i++) {
+ lpXevent->pad[i+7] = (*env)->GetIntField(env,lpObject,lpXfocuschangeeventFc->pad[i]);
+ }
+}
+
+void setXfocuschangeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XFOCUSCHANGEEVENT_FID_CACHE *lpXfocuschangeeventFc)
+{
+ int i;
+
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->serial, lpXevent->xfocus.serial);
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->send_event, lpXevent->xfocus.send_event);
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->display, (int)lpXevent->xfocus.display);
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->window, lpXevent->xfocus.window);
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->mode, lpXevent->xfocus.mode);
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->detail, lpXevent->xfocus.detail);
+ for (i=0; i<17; i++) {
+ (*env)->SetIntField(env,lpObject,lpXfocuschangeeventFc->pad[i],lpXevent->pad[i+7]);
+ }
+}
+
+void getXimageFields(JNIEnv *env, jobject lpObject, XImage *lpXimage, XIMAGE_FID_CACHE *lpXimageFc)
+{
+ lpXimage->width = (*env)->GetIntField(env,lpObject,lpXimageFc->width);
+ lpXimage->height = (*env)->GetIntField(env,lpObject,lpXimageFc->height);
+ lpXimage->xoffset = (*env)->GetIntField(env,lpObject,lpXimageFc->xoffset);
+ lpXimage->format = (*env)->GetIntField(env,lpObject,lpXimageFc->format);
+ lpXimage->data = (char *)(*env)->GetIntField(env,lpObject,lpXimageFc->data);
+ lpXimage->byte_order = (*env)->GetIntField(env,lpObject,lpXimageFc->byte_order);
+ lpXimage->bitmap_unit = (*env)->GetIntField(env,lpObject,lpXimageFc->bitmap_unit);
+ lpXimage->bitmap_bit_order = (*env)->GetIntField(env,lpObject,lpXimageFc->bitmap_bit_order);
+ lpXimage-> bitmap_pad= (*env)->GetIntField(env,lpObject,lpXimageFc->bitmap_pad);
+ lpXimage->depth = (*env)->GetIntField(env,lpObject,lpXimageFc->depth);
+ lpXimage->bytes_per_line = (*env)->GetIntField(env,lpObject,lpXimageFc->bytes_per_line);
+ lpXimage->bits_per_pixel = (*env)->GetIntField(env,lpObject,lpXimageFc->bits_per_pixel);
+ lpXimage->red_mask = (*env)->GetIntField(env,lpObject,lpXimageFc->red_mask);
+ lpXimage->green_mask = (*env)->GetIntField(env,lpObject,lpXimageFc->green_mask);
+ lpXimage->blue_mask = (*env)->GetIntField(env,lpObject,lpXimageFc->blue_mask);
+ lpXimage->obdata = (char *)(*env)->GetIntField(env,lpObject,lpXimageFc->obdata);
+ lpXimage->f.create_image = (struct _XImage *(*)())(*env)->GetIntField(env,lpObject,lpXimageFc->create_image);
+ lpXimage->f.destroy_image = (int (*)(struct _XImage *))(*env)->GetIntField(env,lpObject,lpXimageFc->destroy_image);
+ lpXimage->f.get_pixel = (unsigned long (*)(struct _XImage *, int, int))(*env)->GetIntField(env,lpObject,lpXimageFc->get_pixel);
+ lpXimage->f.put_pixel = (int (*)(struct _XImage *, int, int, unsigned long))(*env)->GetIntField(env,lpObject,lpXimageFc->put_pixel);
+ lpXimage->f.sub_image = (struct _XImage *(*)(struct _XImage *, int, int, unsigned int, unsigned int))(*env)->GetIntField(env,lpObject,lpXimageFc->sub_image);
+ lpXimage->f.add_pixel = (int (*)(struct _XImage *, long))(*env)->GetIntField(env,lpObject,lpXimageFc->add_pixel);
+}
+
+void setXimageFields(JNIEnv *env, jobject lpObject, XImage *lpXimage, XIMAGE_FID_CACHE *lpXimageFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXimageFc->width, lpXimage->width);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->height, lpXimage->height);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->xoffset, lpXimage->xoffset);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->format, lpXimage->format);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->data, (jint)lpXimage->data);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->byte_order, lpXimage->byte_order);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->bitmap_unit, lpXimage->bitmap_unit);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->bitmap_bit_order, lpXimage->bitmap_bit_order);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->bitmap_pad, lpXimage->bitmap_pad);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->depth, lpXimage->depth);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->bytes_per_line, lpXimage->bytes_per_line);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->bits_per_pixel, lpXimage->bits_per_pixel);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->red_mask, lpXimage->red_mask);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->green_mask, lpXimage->green_mask);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->blue_mask, lpXimage->blue_mask);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->obdata, (jint)lpXimage->obdata);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->create_image, (jint)lpXimage->f.create_image);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->destroy_image, (jint)lpXimage->f.destroy_image);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->get_pixel, (jint)lpXimage->f.get_pixel);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->put_pixel, (jint)lpXimage->f.put_pixel);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->sub_image, (jint)lpXimage->f.sub_image);
+ (*env)->SetIntField(env,lpObject,lpXimageFc->add_pixel, (jint)lpXimage->f.add_pixel);
+}
+
+void getXkeyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XKEYEVENT_FID_CACHE *lpXkeyeventFc)
+{
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->type);
+ lpXevent->xkey.serial = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->serial);
+ lpXevent->xkey.send_event = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->send_event);
+ lpXevent->xkey.display = (Display *)(*env)->GetIntField(env,lpObject,lpXkeyeventFc->display);
+ lpXevent->xkey.window = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->window);
+ lpXevent->xkey.root = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->root);
+ lpXevent->xkey.subwindow = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->subwindow);
+ lpXevent->xkey.time = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->time);
+ lpXevent->xkey.x = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->x);
+ lpXevent->xkey.y = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->y);
+ lpXevent->xkey.x_root = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->x_root);
+ lpXevent->xkey.y_root = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->y_root);
+ lpXevent->xkey.state = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->state);
+ lpXevent->xkey.keycode = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->keycode);
+ lpXevent->xkey.same_screen = (*env)->GetIntField(env,lpObject,lpXkeyeventFc->same_screen);
+}
+
+void setXkeyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XKEYEVENT_FID_CACHE *lpXkeyeventFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->serial, lpXevent->xkey.serial);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->send_event, lpXevent->xkey.send_event);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->display, (int)lpXevent->xkey.display);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->window, lpXevent->xkey.window);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->root, lpXevent->xkey.root);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->subwindow, lpXevent->xkey.subwindow);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->time, lpXevent->xkey.time);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->x, lpXevent->xkey.x);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->y, lpXevent->xkey.y);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->x_root, lpXevent->xkey.x_root);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->y_root, lpXevent->xkey.y_root);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->state, lpXevent->xkey.state);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->keycode, lpXevent->xkey.keycode);
+ (*env)->SetIntField(env,lpObject,lpXkeyeventFc->same_screen, lpXevent->xkey.same_screen);
+}
+
+void getXmotioneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XMOTIONEVENT_FID_CACHE *lpXmotioneventFc)
+{
+ int i;
+
+ lpXevent->type = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->type);
+ lpXevent->xmotion.serial = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->serial);
+ lpXevent->xmotion.send_event = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->send_event);
+ lpXevent->xmotion.display = (Display *)(*env)->GetIntField(env,lpObject,lpXmotioneventFc->display);
+ lpXevent->xmotion.window = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->window);
+ lpXevent->xmotion.root = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->root);
+ lpXevent->xmotion.subwindow = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->subwindow);
+ lpXevent->xmotion.time = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->time);
+ lpXevent->xmotion.x = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->x);
+ lpXevent->xmotion.y = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->y);
+ lpXevent->xmotion.x_root = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->x_root);
+ lpXevent->xmotion.y_root = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->y_root);
+ lpXevent->xmotion.state = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->state);
+ lpXevent->xmotion.is_hint = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->is_hint);
+ lpXevent->xmotion.same_screen = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->same_screen);
+ for (i=0; i<10; i++) {
+ lpXevent->pad[i+15] = (*env)->GetIntField(env,lpObject,lpXmotioneventFc->pad[i]);
+ }
+}
+
+void setXmotioneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XMOTIONEVENT_FID_CACHE *lpXmotioneventFc)
+{
+ int i;
+
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->type, lpXevent->type);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->serial, lpXevent->xmotion.serial);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->send_event, lpXevent->xmotion.send_event);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->display, (int)lpXevent->xmotion.display);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->window, lpXevent->xmotion.window);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->root, lpXevent->xmotion.root);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->subwindow, lpXevent->xmotion.subwindow);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->time, lpXevent->xmotion.time);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->x, lpXevent->xmotion.x);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->y, lpXevent->xmotion.y);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->x_root, lpXevent->xmotion.x_root);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->y_root, lpXevent->xmotion.y_root);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->state, lpXevent->xmotion.state);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->is_hint, lpXevent->xmotion.is_hint);
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->same_screen, lpXevent->xmotion.same_screen);
+ for (i=0; i<10; i++) {
+ (*env)->SetIntField(env,lpObject,lpXmotioneventFc->pad[i],lpXevent->pad[i+15]);
+ }
+}
+
+void getXcolorFields(JNIEnv *env, jobject lpObject, XColor *lpXcolor, PXCOLOR_FID_CACHE lpXcolorFc)
+{
+ lpXcolor->pixel = (*env)->GetIntField(env,lpObject,lpXcolorFc->pixel);
+ lpXcolor->red = (*env)->GetShortField(env,lpObject,lpXcolorFc->red);
+ lpXcolor->green = (*env)->GetShortField(env,lpObject,lpXcolorFc->green);
+ lpXcolor->blue = (*env)->GetShortField(env,lpObject,lpXcolorFc->blue);
+ lpXcolor->flags = (*env)->GetByteField(env,lpObject,lpXcolorFc->flags);
+ lpXcolor->pad = (*env)->GetByteField(env,lpObject,lpXcolorFc->pad);
+}
+
+void setXcolorFields(JNIEnv *env, jobject lpObject, XColor *lpXcolor, PXCOLOR_FID_CACHE lpXcolorFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXcolorFc->pixel, lpXcolor->pixel);
+ (*env)->SetShortField(env,lpObject,lpXcolorFc->red, lpXcolor->red);
+ (*env)->SetShortField(env,lpObject,lpXcolorFc->green, lpXcolor->green);
+ (*env)->SetShortField(env,lpObject,lpXcolorFc->blue, lpXcolor->blue);
+ (*env)->SetByteField(env,lpObject,lpXcolorFc->flags, lpXcolor->flags);
+ (*env)->SetByteField(env,lpObject,lpXcolorFc->pad, lpXcolor->pad);
+}
+
+void getXgcvaluesFields(JNIEnv *env, jobject lpObject, XGCValues *lpXgcvalues, PXGCVALUES_FID_CACHE lpXgcvaluesFc)
+{
+ lpXgcvalues->function = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->function);
+ lpXgcvalues->plane_mask = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->plane_mask);
+ lpXgcvalues->foreground = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->foreground);
+ lpXgcvalues->background = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->background);
+ lpXgcvalues->line_width = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->line_width);
+ lpXgcvalues->line_style = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->line_style);
+ lpXgcvalues->cap_style = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->cap_style);
+ lpXgcvalues->join_style = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->join_style);
+ lpXgcvalues->fill_style = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->fill_style);
+ lpXgcvalues->fill_rule = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->fill_rule);
+ lpXgcvalues->arc_mode = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->arc_mode);
+ lpXgcvalues->tile = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->tile);
+ lpXgcvalues->stipple = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->stipple);
+ lpXgcvalues->ts_x_origin = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->ts_x_origin);
+ lpXgcvalues->ts_y_origin = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->ts_y_origin);
+ lpXgcvalues->font = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->font);
+ lpXgcvalues->subwindow_mode = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->subwindow_mode);
+ lpXgcvalues->graphics_exposures = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->graphics_exposures);
+ lpXgcvalues->clip_x_origin = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->clip_x_origin);
+ lpXgcvalues->clip_y_origin = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->clip_y_origin);
+ lpXgcvalues->clip_mask = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->clip_mask);
+ lpXgcvalues->dash_offset = (*env)->GetIntField(env,lpObject,lpXgcvaluesFc->dash_offset);
+ lpXgcvalues->dashes = (*env)->GetByteField(env,lpObject,lpXgcvaluesFc->dashes);
+}
+
+void setXgcvaluesFields(JNIEnv *env, jobject lpObject, XGCValues *lpXgcvalues, PXGCVALUES_FID_CACHE lpXgcvaluesFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->function, lpXgcvalues->function);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->plane_mask, lpXgcvalues->plane_mask);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->foreground, lpXgcvalues->foreground);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->background, lpXgcvalues->background);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->line_width, lpXgcvalues->line_width);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->line_style, lpXgcvalues->line_style);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->cap_style, lpXgcvalues->cap_style);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->join_style, lpXgcvalues->join_style);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->fill_style, lpXgcvalues->fill_style);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->fill_rule, lpXgcvalues->fill_rule);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->arc_mode, lpXgcvalues->arc_mode);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->tile, lpXgcvalues->tile);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->stipple, lpXgcvalues->stipple);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->ts_x_origin, lpXgcvalues->ts_x_origin);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->ts_y_origin, lpXgcvalues->ts_y_origin);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->font, lpXgcvalues->font);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->subwindow_mode, lpXgcvalues->subwindow_mode);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->graphics_exposures, lpXgcvalues->graphics_exposures);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->clip_x_origin, lpXgcvalues->clip_x_origin);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->clip_y_origin, lpXgcvalues->clip_y_origin);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->clip_mask, lpXgcvalues->clip_mask);
+ (*env)->SetIntField(env,lpObject,lpXgcvaluesFc->dash_offset, lpXgcvalues->dash_offset);
+
+ (*env)->SetByteField(env,lpObject,lpXgcvaluesFc->dashes, lpXgcvalues->dashes);
+}
+
+void getXmanycallbackstructFields(JNIEnv *env, jobject lpObject, XmAnyCallbackStruct *lpXmanycallbackstruct, PXMANYCALLBACKSTRUCT_FID_CACHE lpXmanycallbackstructFc)
+{
+ lpXmanycallbackstruct->reason = (*env)->GetIntField(env,lpObject,lpXmanycallbackstructFc->reason);
+ lpXmanycallbackstruct->event = (XEvent *)(*env)->GetIntField(env,lpObject,lpXmanycallbackstructFc->event);
+}
+
+void setXmanycallbackstructFields(JNIEnv *env, jobject lpObject, XmAnyCallbackStruct *lpXmanycallbackstruct, PXMANYCALLBACKSTRUCT_FID_CACHE lpXmanycallbackstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXmanycallbackstructFc->reason, lpXmanycallbackstruct->reason);
+ (*env)->SetIntField(env,lpObject,lpXmanycallbackstructFc->event, (jint)lpXmanycallbackstruct->event);
+}
+
+void getXmdragproccallbackFields(JNIEnv *env, jobject lpObject, XmDragProcCallbackStruct *lpXmdragproccallback, PXMDRAGPROCCALLBACK_FID_CACHE lpXmdragproccallbackFc)
+{
+ lpXmdragproccallback->reason = (*env)->GetIntField(env,lpObject,lpXmdragproccallbackFc->reason);
+ lpXmdragproccallback->event = (XEvent *)(*env)->GetIntField(env,lpObject,lpXmdragproccallbackFc->event);
+ lpXmdragproccallback->timeStamp = (*env)->GetIntField(env,lpObject,lpXmdragproccallbackFc->timeStamp);
+ lpXmdragproccallback->dragContext = (Widget)(*env)->GetIntField(env,lpObject,lpXmdragproccallbackFc->dragContext);
+ lpXmdragproccallback->x = (*env)->GetShortField(env,lpObject,lpXmdragproccallbackFc->x);
+ lpXmdragproccallback->y = (*env)->GetShortField(env,lpObject,lpXmdragproccallbackFc->y);
+ lpXmdragproccallback->dropSiteStatus = (*env)->GetByteField(env,lpObject,lpXmdragproccallbackFc->dropSiteStatus);
+ lpXmdragproccallback->operation = (*env)->GetByteField(env,lpObject,lpXmdragproccallbackFc->operation);
+ lpXmdragproccallback->operations = (*env)->GetByteField(env,lpObject,lpXmdragproccallbackFc->operations);
+ lpXmdragproccallback->animate = (*env)->GetByteField(env,lpObject,lpXmdragproccallbackFc->animate);
+}
+
+void setXmdragproccallbackFields(JNIEnv *env, jobject lpObject, XmDragProcCallbackStruct *lpXmdragproccallback, PXMDRAGPROCCALLBACK_FID_CACHE lpXmdragproccallbackFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXmdragproccallbackFc->reason, lpXmdragproccallback->reason);
+ (*env)->SetIntField(env,lpObject,lpXmdragproccallbackFc->event, (jint)lpXmdragproccallback->event);
+ (*env)->SetIntField(env,lpObject,lpXmdragproccallbackFc->timeStamp, lpXmdragproccallback->timeStamp);
+ (*env)->SetIntField(env,lpObject,lpXmdragproccallbackFc->dragContext, (jint)lpXmdragproccallback->dragContext);
+ (*env)->SetShortField(env,lpObject,lpXmdragproccallbackFc->x, lpXmdragproccallback->x);
+ (*env)->SetShortField(env,lpObject,lpXmdragproccallbackFc->y, lpXmdragproccallback->y);
+ (*env)->SetByteField(env,lpObject,lpXmdragproccallbackFc->dropSiteStatus, lpXmdragproccallback->dropSiteStatus);
+ (*env)->SetByteField(env,lpObject,lpXmdragproccallbackFc->operation, lpXmdragproccallback->operation);
+ (*env)->SetByteField(env,lpObject,lpXmdragproccallbackFc->operations, lpXmdragproccallback->operations);
+ (*env)->SetByteField(env,lpObject,lpXmdragproccallbackFc->animate, lpXmdragproccallback->animate);
+}
+
+void getXmdropproccallbackFields(JNIEnv *env, jobject lpObject, XmDropProcCallbackStruct *lpXmdropproccallback, PXMDROPPROCCALLBACK_FID_CACHE lpXmdropproccallbackFc)
+{
+ lpXmdropproccallback->reason = (*env)->GetIntField(env,lpObject,lpXmdropproccallbackFc->reason);
+ lpXmdropproccallback->event = (XEvent *)(*env)->GetIntField(env,lpObject,lpXmdropproccallbackFc->event);
+ lpXmdropproccallback->timeStamp = (*env)->GetIntField(env,lpObject,lpXmdropproccallbackFc->timeStamp);
+ lpXmdropproccallback->dragContext = (Widget)(*env)->GetIntField(env,lpObject,lpXmdropproccallbackFc->dragContext);
+ lpXmdropproccallback->x = (*env)->GetShortField(env,lpObject,lpXmdropproccallbackFc->x);
+ lpXmdropproccallback->y = (*env)->GetShortField(env,lpObject,lpXmdropproccallbackFc->y);
+ lpXmdropproccallback->dropSiteStatus = (*env)->GetByteField(env,lpObject,lpXmdropproccallbackFc->dropSiteStatus);
+ lpXmdropproccallback->operation = (*env)->GetByteField(env,lpObject,lpXmdropproccallbackFc->operation);
+ lpXmdropproccallback->operations = (*env)->GetByteField(env,lpObject,lpXmdropproccallbackFc->operations);
+ lpXmdropproccallback->dropAction = (*env)->GetByteField(env,lpObject,lpXmdropproccallbackFc->dropAction);
+}
+
+void setXmdropproccallbackFields(JNIEnv *env, jobject lpObject, XmDropProcCallbackStruct *lpXmdropproccallback, PXMDROPPROCCALLBACK_FID_CACHE lpXmdropproccallbackFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXmdropproccallbackFc->reason, lpXmdropproccallback->reason);
+ (*env)->SetIntField(env,lpObject,lpXmdropproccallbackFc->event, (jint)lpXmdropproccallback->event);
+ (*env)->SetIntField(env,lpObject,lpXmdropproccallbackFc->timeStamp, lpXmdropproccallback->timeStamp);
+ (*env)->SetIntField(env,lpObject,lpXmdropproccallbackFc->dragContext, (jint)lpXmdropproccallback->dragContext);
+ (*env)->SetShortField(env,lpObject,lpXmdropproccallbackFc->x, lpXmdropproccallback->x);
+ (*env)->SetShortField(env,lpObject,lpXmdropproccallbackFc->y, lpXmdropproccallback->y);
+ (*env)->SetByteField(env,lpObject,lpXmdropproccallbackFc->dropSiteStatus, lpXmdropproccallback->dropSiteStatus);
+ (*env)->SetByteField(env,lpObject,lpXmdropproccallbackFc->operation, lpXmdropproccallback->operation);
+ (*env)->SetByteField(env,lpObject,lpXmdropproccallbackFc->operations, lpXmdropproccallback->operations);
+ (*env)->SetByteField(env,lpObject,lpXmdropproccallbackFc->dropAction, lpXmdropproccallback->dropAction);
+}
+
+void getXmdropfinishcallbackFields(JNIEnv *env, jobject lpObject, XmDropFinishCallbackStruct *lpXmdropfinishcallback, PXMDROPFINISHCALLBACK_FID_CACHE lpXmdropfinishcallbackFc)
+{
+ lpXmdropfinishcallback->reason = (*env)->GetIntField(env,lpObject,lpXmdropfinishcallbackFc->reason);
+ lpXmdropfinishcallback->event = (XEvent *)(*env)->GetIntField(env,lpObject,lpXmdropfinishcallbackFc->event);
+ lpXmdropfinishcallback->timeStamp = (*env)->GetIntField(env,lpObject,lpXmdropfinishcallbackFc->timeStamp);
+ lpXmdropfinishcallback->operation = (*env)->GetByteField(env,lpObject,lpXmdropfinishcallbackFc->operation);
+ lpXmdropfinishcallback->operations = (*env)->GetByteField(env,lpObject,lpXmdropfinishcallbackFc->operations);
+ lpXmdropfinishcallback->dropSiteStatus = (*env)->GetByteField(env,lpObject,lpXmdropfinishcallbackFc->dropSiteStatus);
+ lpXmdropfinishcallback->dropAction = (*env)->GetByteField(env,lpObject,lpXmdropfinishcallbackFc->dropAction);
+ lpXmdropfinishcallback->completionStatus = (*env)->GetByteField(env,lpObject,lpXmdropfinishcallbackFc->completionStatus);
+}
+
+void setXmdropfinishcallbackFields(JNIEnv *env, jobject lpObject, XmDropFinishCallbackStruct *lpXmdropfinishcallback, PXMDROPFINISHCALLBACK_FID_CACHE lpXmdropfinishcallbackFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXmdropfinishcallbackFc->reason, lpXmdropfinishcallback->reason);
+ (*env)->SetIntField(env,lpObject,lpXmdropfinishcallbackFc->event, (jint)lpXmdropfinishcallback->event);
+ (*env)->SetIntField(env,lpObject,lpXmdropfinishcallbackFc->timeStamp, lpXmdropfinishcallback->timeStamp);
+ (*env)->SetByteField(env,lpObject,lpXmdropfinishcallbackFc->operation, lpXmdropfinishcallback->operation);
+ (*env)->SetByteField(env,lpObject,lpXmdropfinishcallbackFc->operations, lpXmdropfinishcallback->operations);
+ (*env)->SetByteField(env,lpObject,lpXmdropfinishcallbackFc->dropSiteStatus, lpXmdropfinishcallback->dropSiteStatus);
+ (*env)->SetByteField(env,lpObject,lpXmdropfinishcallbackFc->dropAction, lpXmdropfinishcallback->dropAction);
+ (*env)->SetByteField(env,lpObject,lpXmdropfinishcallbackFc->completionStatus, lpXmdropfinishcallback->completionStatus);
+}
+
+void getXmtextblockrecFields(JNIEnv *env, jobject lpObject, XmTextBlockRec *lpXmtextblockrec, PXMTEXTBLOCKREC_FID_CACHE lpXmtextblockrecFc)
+{
+ lpXmtextblockrec->ptr = (char *)(*env)->GetIntField(env,lpObject,lpXmtextblockrecFc->ptr);
+ lpXmtextblockrec->length = (*env)->GetIntField(env,lpObject,lpXmtextblockrecFc->length);
+ lpXmtextblockrec->format = (XmTextFormat)(*env)->GetIntField(env,lpObject,lpXmtextblockrecFc->format);
+}
+
+void setXmtextblockrecFields(JNIEnv *env, jobject lpObject, XmTextBlockRec *lpXmtextblockrec, PXMTEXTBLOCKREC_FID_CACHE lpXmtextblockrecFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXmtextblockrecFc->ptr, (jint)lpXmtextblockrec->ptr);
+ (*env)->SetIntField(env,lpObject,lpXmtextblockrecFc->length, lpXmtextblockrec->length);
+ (*env)->SetIntField(env,lpObject,lpXmtextblockrecFc->format, (jint)lpXmtextblockrec->format);
+}
+
+void getXmtextverifycallbackstructFields(JNIEnv *env, jobject lpObject, XmTextVerifyCallbackStruct *lpXmtextverifycallbackstruct, PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE lpXmtextverifycallbackstructFc)
+{
+ lpXmtextverifycallbackstruct->reason = (*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->reason);
+ lpXmtextverifycallbackstruct->event = (XEvent *)(*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->event);
+ lpXmtextverifycallbackstruct->doit = (Boolean)(*env)->GetByteField(env,lpObject,lpXmtextverifycallbackstructFc->doit);
+ lpXmtextverifycallbackstruct->currInsert = (*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->currInsert);
+ lpXmtextverifycallbackstruct->newInsert = (*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->newInsert);
+ lpXmtextverifycallbackstruct->startPos = (*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->startPos);
+ lpXmtextverifycallbackstruct->endPos = (*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->endPos);
+ lpXmtextverifycallbackstruct->text = (XmTextBlock)(*env)->GetIntField(env,lpObject,lpXmtextverifycallbackstructFc->text);
+}
+
+void setXmtextverifycallbackstructFields(JNIEnv *env, jobject lpObject, XmTextVerifyCallbackStruct *lpXmtextverifycallbackstruct, PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE lpXmtextverifycallbackstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->reason, lpXmtextverifycallbackstruct->reason);
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->event, (jint)lpXmtextverifycallbackstruct->event);
+ (*env)->SetByteField(env,lpObject,lpXmtextverifycallbackstructFc->doit, (jint)lpXmtextverifycallbackstruct->doit);
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->currInsert, lpXmtextverifycallbackstruct->currInsert);
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->newInsert, lpXmtextverifycallbackstruct->newInsert);
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->startPos, lpXmtextverifycallbackstruct->startPos);
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->endPos, lpXmtextverifycallbackstruct->endPos);
+ (*env)->SetIntField(env,lpObject,lpXmtextverifycallbackstructFc->text, (jint)lpXmtextverifycallbackstruct->text);
+}
+
+void getXrectangleFields(JNIEnv *env, jobject lpObject, XRectangle *lpXrect, PXRECTANGLE_FID_CACHE lpXrectFc)
+{
+ lpXrect->x = (*env)->GetShortField(env,lpObject,lpXrectFc->x);
+ lpXrect->y = (*env)->GetShortField(env,lpObject,lpXrectFc->y);
+ lpXrect->width = (*env)->GetShortField(env,lpObject,lpXrectFc->width);
+ lpXrect->height = (*env)->GetShortField(env,lpObject,lpXrectFc->height);
+}
+
+void setXrectangleFields(JNIEnv *env, jobject lpObject, XRectangle *lpXrect, PXRECTANGLE_FID_CACHE lpXrectFc)
+{
+ (*env)->SetShortField(env,lpObject,lpXrectFc->x, lpXrect->x);
+ (*env)->SetShortField(env,lpObject,lpXrectFc->y, lpXrect->y);
+ (*env)->SetShortField(env,lpObject,lpXrectFc->width, lpXrect->width);
+ (*env)->SetShortField(env,lpObject,lpXrectFc->height, lpXrect->height);
+}
+
+void getXsetwindowattributesFields(JNIEnv *env, jobject lpObject, XSetWindowAttributes *lpXsetwindowattributes, PXSETWINDOWATTRIBUTES_FID_CACHE lpXsetwindowattributesFc)
+{
+ lpXsetwindowattributes->background_pixmap = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->background_pixmap);
+ lpXsetwindowattributes->background_pixel = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->background_pixel);
+ lpXsetwindowattributes->border_pixmap = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->border_pixmap);
+ lpXsetwindowattributes->border_pixel = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->border_pixel);
+ lpXsetwindowattributes->bit_gravity = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->bit_gravity);
+ lpXsetwindowattributes->win_gravity = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->win_gravity);
+ lpXsetwindowattributes->backing_store = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->backing_store);
+ lpXsetwindowattributes->backing_planes = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->backing_planes);
+ lpXsetwindowattributes->backing_pixel = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->backing_pixel);
+ lpXsetwindowattributes->save_under = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->save_under);
+ lpXsetwindowattributes->event_mask = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->event_mask);
+ lpXsetwindowattributes->do_not_propagate_mask = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->do_not_propagate_mask);
+ lpXsetwindowattributes->override_redirect = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->override_redirect);
+ lpXsetwindowattributes->colormap = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->colormap);
+ lpXsetwindowattributes->cursor = (*env)->GetIntField(env,lpObject,lpXsetwindowattributesFc->cursor);
+}
+
+void setXsetwindowattributesFields(JNIEnv *env, jobject lpObject, XSetWindowAttributes *lpXsetwindowattributes, PXSETWINDOWATTRIBUTES_FID_CACHE lpXsetwindowattributesFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->background_pixmap, lpXsetwindowattributes->background_pixmap);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->background_pixel, lpXsetwindowattributes->background_pixel);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->border_pixmap, lpXsetwindowattributes->border_pixmap);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->border_pixel, lpXsetwindowattributes->border_pixel);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->bit_gravity, lpXsetwindowattributes->bit_gravity);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->win_gravity, lpXsetwindowattributes->win_gravity);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->backing_store, lpXsetwindowattributes->backing_store);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->backing_planes, lpXsetwindowattributes->backing_planes);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->backing_pixel, lpXsetwindowattributes->backing_pixel);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->save_under, lpXsetwindowattributes->save_under);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->event_mask, lpXsetwindowattributes->event_mask);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->do_not_propagate_mask, lpXsetwindowattributes->do_not_propagate_mask);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->override_redirect, lpXsetwindowattributes->override_redirect);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->colormap, lpXsetwindowattributes->colormap);
+ (*env)->SetIntField(env,lpObject,lpXsetwindowattributesFc->cursor, lpXsetwindowattributes->cursor);
+}
+
+void getXwindowattributesFields(JNIEnv *env, jobject lpObject, XWindowAttributes *lpXwindowattributes, PXWINDOWATTRIBUTES_FID_CACHE lpXwindowattributesFc)
+{
+ lpXwindowattributes->x = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->x);
+ lpXwindowattributes->y = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->y);
+ lpXwindowattributes->width = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->width);
+ lpXwindowattributes->height = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->height);
+ lpXwindowattributes->border_width = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->border_width);
+ lpXwindowattributes->depth = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->depth);
+ lpXwindowattributes->visual = (Visual *)(*env)->GetIntField(env,lpObject,lpXwindowattributesFc->visual);
+ lpXwindowattributes->root = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->root);
+ lpXwindowattributes->class = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->class);
+ lpXwindowattributes->bit_gravity = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->bit_gravity);
+ lpXwindowattributes->win_gravity = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->win_gravity);
+ lpXwindowattributes->backing_store = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->backing_store);
+ lpXwindowattributes->backing_planes = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->backing_planes);
+ lpXwindowattributes->backing_pixel = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->backing_pixel);
+ lpXwindowattributes->save_under = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->save_under);
+ lpXwindowattributes->colormap = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->colormap);
+ lpXwindowattributes->map_installed = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->map_installed);
+ lpXwindowattributes->map_state = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->map_state);
+ lpXwindowattributes->all_event_masks = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->all_event_masks);
+ lpXwindowattributes->your_event_mask = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->your_event_mask);
+ lpXwindowattributes->do_not_propagate_mask = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->do_not_propagate_mask);
+ lpXwindowattributes->override_redirect = (*env)->GetIntField(env,lpObject,lpXwindowattributesFc->override_redirect);
+ lpXwindowattributes->screen = (Screen *)(*env)->GetIntField(env,lpObject,lpXwindowattributesFc->screen);
+}
+
+void setXwindowattributesFields(JNIEnv *env, jobject lpObject, XWindowAttributes *lpXwindowattributes, PXWINDOWATTRIBUTES_FID_CACHE lpXwindowattributesFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->x, lpXwindowattributes->x);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->y, lpXwindowattributes->y);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->width, lpXwindowattributes->width);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->height, lpXwindowattributes->height);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->border_width, lpXwindowattributes->border_width);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->depth, lpXwindowattributes->depth);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->visual, (int)lpXwindowattributes->visual);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->root, lpXwindowattributes->root);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->class, lpXwindowattributes->class);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->bit_gravity, lpXwindowattributes->bit_gravity);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->win_gravity, lpXwindowattributes->win_gravity);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->backing_store, lpXwindowattributes->backing_store);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->backing_planes, lpXwindowattributes->backing_planes);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->backing_pixel, lpXwindowattributes->backing_pixel);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->save_under, lpXwindowattributes->save_under);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->colormap, lpXwindowattributes->colormap);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->map_installed, lpXwindowattributes->map_installed);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->map_state, lpXwindowattributes->map_state);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->all_event_masks, lpXwindowattributes->all_event_masks);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->your_event_mask, lpXwindowattributes->your_event_mask);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->do_not_propagate_mask, lpXwindowattributes->do_not_propagate_mask);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->override_redirect, lpXwindowattributes->override_redirect);
+ (*env)->SetIntField(env,lpObject,lpXwindowattributesFc->screen, (int)lpXwindowattributes->screen);
+}
+
+void getXwindowchangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpXwindowchanges, PXWINDOWCHANGES_FID_CACHE lpXwindowchangesFc)
+{
+ lpXwindowchanges->x = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->x);
+ lpXwindowchanges->y = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->y);
+ lpXwindowchanges->width = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->width);
+ lpXwindowchanges->height = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->height);
+ lpXwindowchanges->border_width = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->border_width);
+ lpXwindowchanges->sibling = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->sibling);
+ lpXwindowchanges->stack_mode = (*env)->GetIntField(env,lpObject,lpXwindowchangesFc->stack_mode);
+}
+
+void setXwindowchangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpXwindowchanges, PXWINDOWCHANGES_FID_CACHE lpXwindowchangesFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->x, lpXwindowchanges->x);
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->y, lpXwindowchanges->y);
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->width, lpXwindowchanges->width);
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->height, lpXwindowchanges->height);
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->border_width, lpXwindowchanges->border_width);
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->sibling, lpXwindowchanges->sibling);
+ (*env)->SetIntField(env,lpObject,lpXwindowchangesFc->stack_mode, lpXwindowchanges->stack_mode);
+}
+
+void getXtwidgetgeometryFields(JNIEnv *env, jobject lpObject, XtWidgetGeometry *lpXtwidgetgeometry, PXTWIDGETGEOMETRY_FID_CACHE lpXtwidgetgeometryFc)
+{
+ lpXtwidgetgeometry->request_mode = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->request_mode);
+ lpXtwidgetgeometry->x = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->x);
+ lpXtwidgetgeometry->y = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->y);
+ lpXtwidgetgeometry->width = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->width);
+ lpXtwidgetgeometry->height = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->height);
+ lpXtwidgetgeometry->border_width = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->border_width);
+ lpXtwidgetgeometry->sibling = (Widget)(*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->sibling);
+ lpXtwidgetgeometry->stack_mode = (*env)->GetIntField(env,lpObject,lpXtwidgetgeometryFc->stack_mode);
+}
+
+void setXtwidgetgeometryFields(JNIEnv *env, jobject lpObject, XtWidgetGeometry *lpXtwidgetgeometry, PXTWIDGETGEOMETRY_FID_CACHE lpXtwidgetgeometryFc)
+{
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->request_mode, lpXtwidgetgeometry->request_mode);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->x, lpXtwidgetgeometry->x);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->y, lpXtwidgetgeometry->y);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->width, lpXtwidgetgeometry->width);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->height, lpXtwidgetgeometry->height);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->border_width, lpXtwidgetgeometry->border_width);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->sibling, (int)lpXtwidgetgeometry->sibling);
+ (*env)->SetIntField(env,lpObject,lpXtwidgetgeometryFc->stack_mode, lpXtwidgetgeometry->stack_mode);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.h
new file mode 100755
index 0000000000..27368d54e0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/structs.h
@@ -0,0 +1,459 @@
+/**
+ * JNI SWT object field getters and setters declarations for Motif structs
+ */
+
+#ifndef INC_structs_H
+#define INC_structs_H
+
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#include <X11/IntrinsicP.h>
+#include <X11/Intrinsic.h>
+#include <X11/Shell.h>
+#include <X11/keysym.h>
+
+#include <Xm/XmAll.h>
+#include <Mrm/MrmPublic.h>
+
+/* All globals declared in globals.h */
+#define FID_CACHE_GLOBALS \
+ VISUAL_FID_CACHE VisualFc; \
+ XANYEVENT_FID_CACHE XanyeventFc; \
+ XBUTTONEVENT_FID_CACHE XbuttoneventFc; \
+ XCHARSTRUCT_FID_CACHE XcharstructFc; \
+ XCOLOR_FID_CACHE XcolorFc; \
+ XCONFIGUREEVENT_FID_CACHE XconfigureeventFc; \
+ XCROSSINGEVENT_FID_CACHE XcrossingeventFc; \
+ XEXPOSEEVENT_FID_CACHE XexposeeventFc; \
+ XFOCUSCHANGEEVENT_FID_CACHE XfocuschangeeventFc; \
+ XFONTSTRUCT_FID_CACHE XfontstructFc; \
+ XGCVALUES_FID_CACHE XgcvaluesFc; \
+ XIMAGE_FID_CACHE XimageFc; \
+ XKEYEVENT_FID_CACHE XkeyeventFc; \
+ XMANYCALLBACKSTRUCT_FID_CACHE XmanycallbackstructFc; \
+ XMDRAGPROCCALLBACK_FID_CACHE XmdragproccallbackFc; \
+ XMDROPFINISHCALLBACK_FID_CACHE XmdropfinishcallbackFc; \
+ XMDROPPROCCALLBACK_FID_CACHE XmdropproccallbackFc; \
+ XMOTIONEVENT_FID_CACHE XmotioneventFc; \
+ XMTEXTBLOCKREC_FID_CACHE XmtextblockrecFc; \
+ XMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE XmtextverifycallbackstructFc; \
+ XRECTANGLE_FID_CACHE XrectangleFc; \
+ XSETWINDOWATTRIBUTES_FID_CACHE XsetwindowattributesFc; \
+ XTWIDGETGEOMETRY_FID_CACHE XtwidgetgeometryFc; \
+ XWINDOWATTRIBUTES_FID_CACHE XwindowattributesFc; \
+ XWINDOWCHANGES_FID_CACHE XwindowchangesFc;
+
+/* ----------- fid and class caches ----------- */
+/**
+ * Used for Java objects passed into JNI that are
+ * declared like:
+ *
+ * nativeFunction (Rectangle p1, Rectangle p2, Rectangle p3)
+ *
+ * and not like this
+ *
+ * nativeFunction (Object p1, Object p2, Object p3)
+ *
+ *
+ */
+
+/* VISUAL struct */
+typedef struct VISUAL_FID_CACHE {
+
+ int cached;
+ jclass visualClass;
+ jfieldID ext_data, visualid, c_class, red_mask, green_mask, blue_mask, bits_per_rgb, map_entries;
+
+} VISUAL_FID_CACHE;
+
+typedef VISUAL_FID_CACHE *PVISUAL_FID_CACHE;
+
+/* XANYEVENT struct */
+typedef struct XANYEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, pad[19];
+/*
+ pad0, pad1, pad2, pad3,
+ pad4, pad5, pad6, pad7, pad8, pad9, pad10, pad11, pad12, pad13
+ pad14, pad15, pad16, pad17, pad18;
+*/
+
+} XANYEVENT_FID_CACHE;
+
+typedef XANYEVENT_FID_CACHE *PXANYEVENT_FID_CACHE;
+
+/* XBUTTONEVENT struct */
+typedef struct XBUTTONEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, root, subwindow, time,
+ x, y, x_root, y_root, state, button, same_screen;
+
+} XBUTTONEVENT_FID_CACHE;
+
+typedef XBUTTONEVENT_FID_CACHE *PXBUTTONEVENT_FID_CACHE;
+
+/* XCHARSTRUCT struct */
+typedef struct XCHARSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass xcharstructClass;
+ jfieldID lbearing, rbearing, width, ascent, descent, attributes;
+
+} XCHARSTRUCT_FID_CACHE;
+
+typedef XCHARSTRUCT_FID_CACHE *PXCHARSTRUCT_FID_CACHE;
+
+/* XCONFIGUREEVENT struct */
+typedef struct XCONFIGUREEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, root, subwindow, time,
+ x, y, width, height, border_width, above, override_redirect;
+
+} XCONFIGUREEVENT_FID_CACHE;
+
+typedef XCONFIGUREEVENT_FID_CACHE *PXCONFIGUREEVENT_FID_CACHE;
+
+/* XCROSSINGEVENT struct */
+typedef struct XCROSSINGEVENT_FID_CACHE {
+
+ int cached;
+ jclass xcrossingeventClass;
+ jfieldID type, serial, send_event, display, window, root, subwindow, time,
+ x, y, x_root, y_root, mode, detail, same_screen, focus,
+ state, pad[8];
+/*
+ pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;
+*/
+
+} XCROSSINGEVENT_FID_CACHE;
+
+typedef XCROSSINGEVENT_FID_CACHE *PXCROSSINGEVENT_FID_CACHE;
+
+/* XEXPOSEEVENT struct */
+typedef struct XEXPOSEEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, root, subwindow, time,
+ x, y, width, height, count;
+
+} XEXPOSEEVENT_FID_CACHE;
+
+typedef XEXPOSEEVENT_FID_CACHE *PXEXPOSEEVENT_FID_CACHE;
+
+/* XFOCUSCHANGEEVENT struct */
+typedef struct XFOCUSCHANGEEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, mode, detail, pad[17];
+
+} XFOCUSCHANGEEVENT_FID_CACHE;
+
+typedef XFOCUSCHANGEEVENT_FID_CACHE *PXFOCUSCHANGEEVENT_FID_CACHE;
+
+/* XFONTSTRUCT struct */
+typedef struct XFONTSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass xfontstructClass;
+ jfieldID ext_data, fid, direction, min_char_or_byte2, max_char_or_byte2, \
+ min_byte1, max_byte1, all_chars_exist, default_char, n_properties, \
+ properties, min_bounds_lbearing, min_bounds_rbearing, min_bounds_width, \
+ min_bounds_ascent, min_bounds_descent, min_bounds_attributes, \
+ max_bounds_lbearing, max_bounds_rbearing, max_bounds_width, \
+ max_bounds_ascent, max_bounds_descent, max_bounds_attributes, per_char, \
+ ascent, descent;
+
+} XFONTSTRUCT_FID_CACHE;
+
+typedef XFONTSTRUCT_FID_CACHE *PXFONTSTRUCT_FID_CACHE;
+
+/* XIMAGE struct */
+typedef struct XIMAGE_FID_CACHE {
+
+ int cached;
+ jclass ximageClass;
+ jfieldID width, height, xoffset, format, data, byte_order, bitmap_unit,
+ bitmap_bit_order, bitmap_pad, depth, bytes_per_line, bits_per_pixel,
+ red_mask, green_mask, blue_mask, obdata, create_image, destroy_image,
+ get_pixel, put_pixel, sub_image, add_pixel;
+
+} XIMAGE_FID_CACHE;
+
+typedef XIMAGE_FID_CACHE *PXIMAGE_FID_CACHE;
+
+/* XKEYEVENT struct */
+typedef struct XKEYEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, root, subwindow, time,
+ x, y, x_root, y_root, state, keycode, same_screen;
+
+} XKEYEVENT_FID_CACHE;
+
+typedef XKEYEVENT_FID_CACHE *PXKEYEVENT_FID_CACHE;
+
+/* XMOTIONEVENT struct */
+typedef struct XMOTIONEVENT_FID_CACHE {
+
+ int cached;
+ jclass xeventClass;
+ jfieldID type, serial, send_event, display, window, root, subwindow, time,
+ x, y, x_root, y_root, state, is_hint, same_screen, pad[10];
+
+} XMOTIONEVENT_FID_CACHE;
+
+typedef XMOTIONEVENT_FID_CACHE *PXMOTIONEVENT_FID_CACHE;
+
+/* XCOLOR struct */
+typedef struct XCOLOR_FID_CACHE {
+
+ int cached;
+ jclass xcolorClass;
+ jfieldID pixel, red, green, blue, flags, pad;
+
+} XCOLOR_FID_CACHE;
+
+typedef XCOLOR_FID_CACHE *PXCOLOR_FID_CACHE;
+
+/* XGCVALUES struct */
+typedef struct XGCVALUES_FID_CACHE {
+
+ int cached;
+ jclass xgcvaluesClass;
+ jfieldID function, plane_mask, foreground, background, line_width, line_style, cap_style,
+ join_style, fill_style, fill_rule, arc_mode, tile, stipple, ts_x_origin, ts_y_origin,
+ font, subwindow_mode, graphics_exposures, clip_x_origin, clip_y_origin, clip_mask,
+ dash_offset, dashes;
+
+} XGCVALUES_FID_CACHE;
+
+typedef XGCVALUES_FID_CACHE *PXGCVALUES_FID_CACHE;
+
+/* XMANYCALLBACKSTRUCT struct */
+typedef struct XMANYCALLBACKSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass xmanycallbackstructClass;
+ jfieldID reason, event;
+
+} XMANYCALLBACKSTRUCT_FID_CACHE;
+
+typedef XMANYCALLBACKSTRUCT_FID_CACHE *PXMANYCALLBACKSTRUCT_FID_CACHE;
+
+/* XMDRAGPROCCALLBACK struct */
+typedef struct XMDRAGPROCCALLBACK_FID_CACHE {
+
+ int cached;
+ jclass xmdragproccallbackClass;
+ jfieldID reason, event, timeStamp, dragContext, x, y,
+ dropSiteStatus, operation, operations, animate;
+
+} XMDRAGPROCCALLBACK_FID_CACHE;
+
+typedef XMDRAGPROCCALLBACK_FID_CACHE *PXMDRAGPROCCALLBACK_FID_CACHE;
+
+/* XMDROPPROCCALLBACK struct */
+typedef struct XMDROPPROCCALLBACK_FID_CACHE {
+
+ int cached;
+ jclass xmdropproccallbackClass;
+ jfieldID reason, event, timeStamp, dragContext, x, y,
+ dropSiteStatus, operation, operations, dropAction;
+
+} XMDROPPROCCALLBACK_FID_CACHE;
+
+typedef XMDROPPROCCALLBACK_FID_CACHE *PXMDROPPROCCALLBACK_FID_CACHE;
+
+/* XMDROPFINISHCALLBACK struct */
+typedef struct XMDROPFINISHCALLBACK_FID_CACHE {
+
+ int cached;
+ jclass xmdropfinishcallbackClass;
+ jfieldID reason, event, timeStamp,
+ operation, operations, dropSiteStatus, dropAction, completionStatus;
+
+} XMDROPFINISHCALLBACK_FID_CACHE;
+
+typedef XMDROPFINISHCALLBACK_FID_CACHE *PXMDROPFINISHCALLBACK_FID_CACHE;
+
+/* XMTEXTBLOCKREC struct */
+typedef struct XMTEXTBLOCKREC_FID_CACHE {
+
+ int cached;
+ jclass xmtextblockrecClass;
+ jfieldID ptr, length, format;
+
+} XMTEXTBLOCKREC_FID_CACHE;
+
+typedef XMTEXTBLOCKREC_FID_CACHE *PXMTEXTBLOCKREC_FID_CACHE;
+
+/* XMTEXTVERIFYCALLBACKSTRUCT struct */
+typedef struct XMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass xmtextverifycallbackstructClass;
+ jfieldID reason, event, doit, currInsert, newInsert, startPos, endPos, text;
+
+} XMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE;
+
+typedef XMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE *PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE;
+
+/* XRECTANGLE struct */
+typedef struct XRECTANGLE_FID_CACHE {
+
+ int cached;
+ jclass xrectClass;
+ jfieldID x, y, width, height;
+
+} XRECTANGLE_FID_CACHE;
+
+typedef XRECTANGLE_FID_CACHE *PXRECTANGLE_FID_CACHE;
+
+/* XWINDOWCHANGES struct */
+typedef struct XWINDOWCHANGES_FID_CACHE {
+
+ int cached;
+ jclass xwindowchangesClass;
+ jfieldID x, y, width, height, border_width, sibling, stack_mode;
+
+} XWINDOWCHANGES_FID_CACHE;
+
+typedef XWINDOWCHANGES_FID_CACHE *PXWINDOWCHANGES_FID_CACHE;
+
+/* XSETWINDOWATTRIBUTES struct */
+typedef struct XSETWINDOWATTRIBUTES_FID_CACHE {
+
+ int cached;
+ jclass xsetwindowattributesClass;
+ jfieldID background_pixmap, background_pixel, border_pixmap, border_pixel, bit_gravity, win_gravity,
+ backing_store, backing_planes, backing_pixel, save_under, event_mask, do_not_propagate_mask,
+ override_redirect, colormap, cursor;
+
+} XSETWINDOWATTRIBUTES_FID_CACHE;
+
+typedef XSETWINDOWATTRIBUTES_FID_CACHE *PXSETWINDOWATTRIBUTES_FID_CACHE;
+
+/* XWINDOWATTRIBUTES struct */
+typedef struct XWINDOWATTRIBUTES_FID_CACHE {
+
+ int cached;
+ jclass xwindowattributesClass;
+ jfieldID x, y, width, height, border_width, depth, visual, root,
+ class, bit_gravity, win_gravity, backing_store, backing_planes,
+ backing_pixel, save_under, colormap, map_installed, map_state, all_event_masks,
+ your_event_mask, do_not_propagate_mask, override_redirect, screen;
+
+} XWINDOWATTRIBUTES_FID_CACHE;
+
+typedef XWINDOWATTRIBUTES_FID_CACHE *PXWINDOWATTRIBUTES_FID_CACHE;
+
+/* XTWIDGETGEOMETRY struct */
+typedef struct XTWIDGETGEOMETRY_FID_CACHE {
+
+ int cached;
+ jclass xtwidgetgeometryClass;
+ jfieldID request_mode, x, y, width, height, border_width, sibling, stack_mode;
+
+} XTWIDGETGEOMETRY_FID_CACHE;
+
+typedef XTWIDGETGEOMETRY_FID_CACHE *PXTWIDGETGEOMETRY_FID_CACHE;
+
+/* ----------- cache function prototypes ----------- */
+
+void cacheXimageFids(JNIEnv *env, jobject lpXimage, PXIMAGE_FID_CACHE lpCache);
+void cacheVisualFids(JNIEnv *env, jobject lpVisual, PVISUAL_FID_CACHE lpCache);
+void cacheXanyeventFids(JNIEnv *env, jobject lpXevent, PXANYEVENT_FID_CACHE lpCache);
+void cacheXbuttoneventFids(JNIEnv *env, jobject lpXevent, PXBUTTONEVENT_FID_CACHE lpCache);
+void cacheXcharstructFids(JNIEnv *env, jobject lpXcharstruct, PXCHARSTRUCT_FID_CACHE lpCache);
+void cacheXconfigureeventFids(JNIEnv *env, jobject lpXevent, PXCONFIGUREEVENT_FID_CACHE lpCache);
+void cacheXcrossingeventFids(JNIEnv *env, jobject lpXcrossingevent, PXCROSSINGEVENT_FID_CACHE lpCache);
+void cacheXexposeeventFids(JNIEnv *env, jobject lpXevent, PXEXPOSEEVENT_FID_CACHE lpCache);
+void cacheXfocuschangeeventFids(JNIEnv *env, jobject lpXevent, PXFOCUSCHANGEEVENT_FID_CACHE lpCache);
+void cacheXfontstructFids(JNIEnv *env, jobject lpXfontstruct, PXFONTSTRUCT_FID_CACHE lpCache);
+void cacheXkeyeventFids(JNIEnv *env, jobject lpXevent, PXKEYEVENT_FID_CACHE lpCache);
+void cacheXmotioneventFids(JNIEnv *env, jobject lpXevent, PXMOTIONEVENT_FID_CACHE lpCache);
+void cacheXanyeventFids(JNIEnv *env, jobject lpXevent, PXANYEVENT_FID_CACHE lpCache);
+void cacheXcolorFids(JNIEnv *env, jobject lpXcolor, PXCOLOR_FID_CACHE lpCache);
+void cacheXgcvaluesFids(JNIEnv *env, jobject lpXgcvalues, PXGCVALUES_FID_CACHE lpCache);
+void cacheXmanycallbackstructFids(JNIEnv *env, jobject lpXmanycallbackstruct, PXMANYCALLBACKSTRUCT_FID_CACHE lpCache);
+void cacheXmdragproccallbackFids(JNIEnv *env, jobject lpXmdragproccallback, PXMDRAGPROCCALLBACK_FID_CACHE lpCache);
+void cacheXmdropproccallbackFids(JNIEnv *env, jobject lpXmdropproccallback, PXMDROPPROCCALLBACK_FID_CACHE lpCache);
+void cacheXmdropfinishcallbackFids(JNIEnv *env, jobject lpXmdropfinishcallback, PXMDROPFINISHCALLBACK_FID_CACHE lpCache);
+void cacheXmtextblockrecFids(JNIEnv *env, jobject lpXmtextblockrec, PXMTEXTBLOCKREC_FID_CACHE lpCache);
+void cacheXmtextverifycallbackstructFids(JNIEnv *env, jobject lpXmtextverifycallbackstruct, PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE lpCache);
+void cacheXrectangleFids(JNIEnv *env, jobject lpRect, PXRECTANGLE_FID_CACHE lpCache);
+void cacheXwindowchangesFids(JNIEnv *env, jobject lpXwindowchanges, PXWINDOWCHANGES_FID_CACHE lpCache);
+void cacheXsetwindowattributesFids(JNIEnv *env, jobject lpXsetwindowattributes, PXSETWINDOWATTRIBUTES_FID_CACHE lpCache);
+void cacheXwindowattributesFids(JNIEnv *env, jobject lpXwindowattributes, PXWINDOWATTRIBUTES_FID_CACHE lpCache);
+void cacheXtwidgetgeometryFids(JNIEnv *env, jobject lpXtwidgetgeometry, PXTWIDGETGEOMETRY_FID_CACHE lpCache);
+
+/* ----------- getters and setters ----------- */
+/**
+ * These functions get or set object field ids assuming that the
+ * fids for these objects have already been cached.
+ *
+ * The header file just contains function prototypes
+ */
+
+void getVisualFields(JNIEnv *env, jobject lpObject, Visual *lpVisual, VISUAL_FID_CACHE *lpVisualFc);
+void setVisualFields(JNIEnv *env, jobject lpObject, Visual *lpVisual, VISUAL_FID_CACHE *lpVisualFc);
+void getXanyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XANYEVENT_FID_CACHE *lpXeventFc);
+void setXanyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XANYEVENT_FID_CACHE *lpXeventFc);
+void getXbuttoneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, PXBUTTONEVENT_FID_CACHE lpXbuttoneventFc);
+void setXbuttoneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, PXBUTTONEVENT_FID_CACHE lpXbuttoneventFc);
+void getXcharstructFields(JNIEnv *env, jobject lpObject, XCharStruct *lpXcharstruct, XCHARSTRUCT_FID_CACHE *lpXcharstructFc);
+void setXcharstructFields(JNIEnv *env, jobject lpObject, XCharStruct *lpXcharstruct, XCHARSTRUCT_FID_CACHE *lpXcharstructFc);
+void getXconfigureeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, PXCONFIGUREEVENT_FID_CACHE lpXconfigureeventFc);
+void setXconfigureeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, PXCONFIGUREEVENT_FID_CACHE lpXconfigureeventFc);
+void getXcrossingeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXcrossingevent, PXCROSSINGEVENT_FID_CACHE lpXcrossingeventFc);
+void setXcrossingeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXcrossingevent, PXCROSSINGEVENT_FID_CACHE lpXcrossingeventFc);
+void getXexposeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XEXPOSEEVENT_FID_CACHE *lpXexposeeventFc);
+void setXexposeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XEXPOSEEVENT_FID_CACHE *lpXexposeeventFc);
+void getXfocuschangeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XFOCUSCHANGEEVENT_FID_CACHE *lpXfocuschangeeventFc);
+void setXfocuschangeeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XFOCUSCHANGEEVENT_FID_CACHE *lpXfocuschangeeventFc);
+void getXfontstructFields(JNIEnv *env, jobject lpObject, XFontStruct *lpXfontstruct, XFONTSTRUCT_FID_CACHE *lpXfontstructFc);
+void setXfontstructFields(JNIEnv *env, jobject lpObject, XFontStruct *lpXfontstruct, XFONTSTRUCT_FID_CACHE *lpXfontstructFc);
+void getXimageFields(JNIEnv *env, jobject lpObject, XImage *lpXimage, XIMAGE_FID_CACHE *lpXimageFc);
+void setXimageFields(JNIEnv *env, jobject lpObject, XImage *lpXimage, XIMAGE_FID_CACHE *lpXimageFc);
+void getXkeyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XKEYEVENT_FID_CACHE *lpXkeyeventFc);
+void setXkeyeventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XKEYEVENT_FID_CACHE *lpXkeyeventFc);
+void getXmotioneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XMOTIONEVENT_FID_CACHE *lpXmotioneventFc);
+void setXmotioneventFields(JNIEnv *env, jobject lpObject, XEvent *lpXevent, XMOTIONEVENT_FID_CACHE *lpXmotioneventFc);
+void getXcolorFields(JNIEnv *env, jobject lpObject, XColor *lpXcolor, XCOLOR_FID_CACHE *lpXcolorFc);
+void setXcolorFields(JNIEnv *env, jobject lpObject, XColor *lpXcolor, XCOLOR_FID_CACHE *lpXcolorFc);
+void getXgcvaluesFields(JNIEnv *env, jobject lpObject, XGCValues *lpXgcvalues, PXGCVALUES_FID_CACHE lpXgcvaluesFc);
+void setXgcvaluesFields(JNIEnv *env, jobject lpObject, XGCValues *lpXgcvalues, PXGCVALUES_FID_CACHE lpXgcvaluesFc);
+void getXmanycallbackstructFields(JNIEnv *env, jobject lpObject, XmAnyCallbackStruct *lpXmanycallbackstruct, PXMANYCALLBACKSTRUCT_FID_CACHE lpXmanycallbackstructFc);
+void setXmanycallbackstructFields(JNIEnv *env, jobject lpObject, XmAnyCallbackStruct *lpXmanycallbackstruct, PXMANYCALLBACKSTRUCT_FID_CACHE lpXmanycallbackstructFc);
+void getXmdragproccallbackFields(JNIEnv *env, jobject lpObject, XmDragProcCallbackStruct *lpXmdragproccallback, PXMDRAGPROCCALLBACK_FID_CACHE lpXmdragproccallbackFc);
+void setXmdragproccallbackFields(JNIEnv *env, jobject lpObject, XmDragProcCallbackStruct *lpXmdragproccallback, PXMDRAGPROCCALLBACK_FID_CACHE lpXmdragproccallbackFc);
+void getXmdropproccallbackFields(JNIEnv *env, jobject lpObject, XmDropProcCallbackStruct *lpXmdropproccallback, PXMDROPPROCCALLBACK_FID_CACHE lpXmdropproccallbackFc);
+void setXmdropproccallbackFields(JNIEnv *env, jobject lpObject, XmDropProcCallbackStruct *lpXmdropproccallback, PXMDROPPROCCALLBACK_FID_CACHE lpXmdropproccallbackFc);
+void getXmdropfinishcallbackFields(JNIEnv *env, jobject lpObject, XmDropFinishCallbackStruct *lpXmdropfinishcallback, PXMDROPFINISHCALLBACK_FID_CACHE lpXmdropfinishcallbackFc);
+void setXmdropfinishcallbackFields(JNIEnv *env, jobject lpObject, XmDropFinishCallbackStruct *lpXmdropfinishcallback, PXMDROPFINISHCALLBACK_FID_CACHE lpXmdropfinishcallbackFc);
+void getXmtextblockrecFields(JNIEnv *env, jobject lpObject, XmTextBlockRec *lpXmtextblockrec, PXMTEXTBLOCKREC_FID_CACHE lpXmtextblockrecFc);
+void setXmtextblockrecFields(JNIEnv *env, jobject lpObject, XmTextBlockRec *lpXmtextblockrec, PXMTEXTBLOCKREC_FID_CACHE lpXmtextblockrecFc);
+void getXmtextverifycallbackstructFields(JNIEnv *env, jobject lpObject, XmTextVerifyCallbackStruct *lpXmtextverifycallbackstruct, PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE lpXmtextverifycallbackstructFc);
+void setXmtextverifycallbackstructFields(JNIEnv *env, jobject lpObject, XmTextVerifyCallbackStruct *lpXmtextverifycallbackstruct, PXMTEXTVERIFYCALLBACKSTRUCT_FID_CACHE lpXmtextverifycallbackstructFc);
+void getXrectangleFields(JNIEnv *env, jobject lpObject, XRectangle *lpXrect, PXRECTANGLE_FID_CACHE lpXrectFc);
+void setXrectangleFields(JNIEnv *env, jobject lpObject, XRectangle *lpXrect, PXRECTANGLE_FID_CACHE lpXrectFc);
+void getXsetwindowattributesFields(JNIEnv *env, jobject lpObject, XSetWindowAttributes *lpXsetwindowattributes, PXSETWINDOWATTRIBUTES_FID_CACHE lpXsetwindowattributesFc);
+void setXsetwindowattributesFields(JNIEnv *env, jobject lpObject, XSetWindowAttributes *lpXsetwindowattributes, PXSETWINDOWATTRIBUTES_FID_CACHE lpXsetwindowattributesFc);
+void getXwindowattributesFields(JNIEnv *env, jobject lpObject, XWindowAttributes *lpXwindowattributes, PXWINDOWATTRIBUTES_FID_CACHE lpXwindowattributesFc);
+void setXwindowattributesFields(JNIEnv *env, jobject lpObject, XWindowAttributes *lpXwindowattributes, PXWINDOWATTRIBUTES_FID_CACHE lpXwindowattributesFc);
+void getXwindowchangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpXwindowchanges, PXWINDOWCHANGES_FID_CACHE lpXwindowchangesFc);
+void setXwindowchangesFields(JNIEnv *env, jobject lpObject, XWindowChanges *lpXwindowchanges, PXWINDOWCHANGES_FID_CACHE lpXwindowchangesFc);
+void getXtwidgetgeometryFields(JNIEnv *env, jobject lpObject, XtWidgetGeometry *lpXtwidgetgeometry, PXTWIDGETGEOMETRY_FID_CACHE lpXtwidgetgeometryFc);
+void setXtwidgetgeometryFields(JNIEnv *env, jobject lpObject, XtWidgetGeometry *lpXtwidgetgeometry, PXTWIDGETGEOMETRY_FID_CACHE lpXtwidgetgeometryFc);
+
+#endif /* INC_structs_H */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
new file mode 100755
index 0000000000..0e58c2f576
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/library/swt.c
@@ -0,0 +1,7899 @@
+/**
+ * SWT OS natives implementation.
+ */
+
+/* #define PRINT_FAILED_RCODES */
+#define NDEBUG
+
+#include "globals.h"
+#include "structs.h"
+
+#include <stdio.h>
+#include <assert.h>
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_getSharedLibraryMajorVersionNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryMajorVersionNumber\n");
+#endif
+ return SWT_LIBRARY_MAJOR_VERSION;
+}
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_getSharedLibraryMinorVersionNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryMinorVersionNumber\n");
+#endif
+ return SWT_LIBRARY_MINOR_VERSION;
+}
+
+
+/*************************************************************************
+
+ Name : sleep_ms( unsigned int nmsecs)
+
+ Purpose : sleep for a given number of milli seconds
+ Parms : the number of milli seconds to sleep
+ Returns :
+
+*************************************************************************/
+/*
+void sleep_ms( unsigned int nmsecs)
+{
+ struct timeval tval;
+ tval.tv_sec = (nmsecs * 1000) / 1000000;
+ tval.tv_usec = (nmsecs * 1000) % 1000000;
+ select(0, NULL, NULL, NULL, &tval);
+}
+*/
+
+/* ------------------------------------- */
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XInitThreads
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XInitThreads
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XInitThreads\n");
+#endif
+
+ return (jint) XInitThreads();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: OverrideShellWidgetClass
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_OverrideShellWidgetClass
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OverrideShellWidgetClass\n");
+#endif
+ return (jint) (overrideShellWidgetClass);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: ShellWidgetClass
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_ShellWidgetClass
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ShellWidgetClass\n");
+#endif
+ return (jint) (shellWidgetClass);
+}
+
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_TopLevelShellWidgetClass
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "TopLevelShellWidgetClass\n");
+#endif
+ return (jint) (topLevelShellWidgetClass);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: TransientShellWidgetClass
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_TransientShellWidgetClass
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "TransientShellWidgetClass\n");
+#endif
+
+ return (jint) (transientShellWidgetClass);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/motif/XButtonEvent;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__ILorg_eclipse_swt_internal_motif_XButtonEvent_2I
+ (JNIEnv *env, jclass that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *src1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_motif_XButtonEvent_2I\n");
+#endif
+ if (src) {
+ src1=&xEvent;
+ cacheXbuttoneventFids(env, src, &PGLOB(XbuttoneventFc));
+ getXbuttoneventFields(env, src, src1, &PGLOB(XbuttoneventFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/motif/XImage;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__ILorg_eclipse_swt_internal_motif_XImage_2I
+ (JNIEnv *env, jclass that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XImage image, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_motif_XImage_2I\n");
+#endif
+
+ if (src) {
+ src1=&image;
+ cacheXimageFids(env, src, &PGLOB(XimageFc));
+ getXimageFields(env, src, src1, &PGLOB(XimageFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/motif/XmTextBlockRec;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__ILorg_eclipse_swt_internal_motif_XmTextBlockRec_2I
+ (JNIEnv *env, jclass that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmTextBlockRec xmtextblockrec, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_motif_XmTextBlockRec_2I\n");
+#endif
+
+ if (src) {
+ src1=&xmtextblockrec;
+ cacheXmtextblockrecFids(env, src, &PGLOB(XmtextblockrecFc));
+ getXmtextblockrecFields(env, src, src1, &PGLOB(XmtextblockrecFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__ILorg_eclipse_swt_internal_motif_XmTextVerifyCallbackStruct_2I
+ (JNIEnv *env, jclass that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmTextVerifyCallbackStruct xmtextverifycallbackstruct, *src1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_motif_XmTextVerifyCallbackStruct_2I\n");
+#endif
+
+ if (src) {
+ src1=&xmtextverifycallbackstruct;
+ cacheXmtextverifycallbackstructFids(env, src, &PGLOB(XmtextverifycallbackstructFc));
+ getXmtextverifycallbackstructFields(env, src, src1, &PGLOB(XmtextverifycallbackstructFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__I_3BI
+ (JNIEnv *env, jclass that, jint dest, jbyteArray src, jint count)
+{
+ jbyte *src1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__I_3BI\n");
+#endif
+
+ /* don't do anything if src pointer is NULL */
+ if (src) {
+ src1 = (*env)->GetByteArrayElements(env, src, NULL);
+ memmove((void *)dest, (void *)src1, count);
+ (*env)->ReleaseByteArrayElements(env, src, src1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__I_3II
+ (JNIEnv *env, jclass that, jint dest, jintArray src, jint count)
+{
+ jint *src1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__I_3II\n");
+#endif
+
+ /* don't do anything if src pointer is NULL */
+ if (src) {
+ src1 = (*env)->GetIntArrayElements(env, src, NULL);
+ memmove((void *)dest, (void *)src1, count);
+ (*env)->ReleaseIntArrayElements(env, src, src1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/Visual;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_Visual_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ Visual visual, *lpxVisual=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_Visual_2II\n");
+#endif
+
+ memmove((void *)&visual, (void *)src, count);
+ if (dest) {
+ lpxVisual=&visual;
+ cacheVisualFids(env, dest, &PGLOB(VisualFc));
+ setVisualFields(env, dest, lpxVisual, &PGLOB(VisualFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XButtonEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XButtonEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XButtonEvent_2II\n");
+#endif
+
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXbuttoneventFids(env, dest, &PGLOB(XbuttoneventFc));
+ setXbuttoneventFields(env, dest, lpxEvent, &PGLOB(XbuttoneventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XCharStruct;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XCharStruct_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XCharStruct xCharstruct, *lpxCharstruct=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XCharStruct_2II\n");
+#endif
+
+ memmove((void *)&xCharstruct, (void *)src, count);
+ if (dest) {
+ lpxCharstruct=&xCharstruct;
+ cacheXcharstructFids(env, dest, &PGLOB(XcharstructFc));
+ setXcharstructFields(env, dest, lpxCharstruct, &PGLOB(XcharstructFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XConfigureEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XConfigureEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XConfigureEvent_2II\n");
+#endif
+
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXconfigureeventFids(env, dest, &PGLOB(XconfigureeventFc));
+ setXconfigureeventFields(env, dest, lpxEvent, &PGLOB(XconfigureeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XCrossingEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XCrossingEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XCrossingEvent_2II\n");
+#endif
+
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXcrossingeventFids(env, dest, &PGLOB(XcrossingeventFc));
+ setXcrossingeventFields(env, dest, lpxEvent, &PGLOB(XcrossingeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XExposeEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XExposeEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XExposeEvent_2II\n");
+#endif
+
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXexposeeventFids(env, dest, &PGLOB(XexposeeventFc));
+ setXexposeeventFields(env, dest, lpxEvent, &PGLOB(XexposeeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XFocusChangeEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XFocusChangeEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XFocusChangeEvent_2II\n");
+#endif
+
+ assert(count <= sizeof(XEvent));
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXfocuschangeeventFids(env, dest, &PGLOB(XfocuschangeeventFc));
+ setXfocuschangeeventFields(env, dest, lpxEvent, &PGLOB(XfocuschangeeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XFontStruct;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XFontStruct_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XFontStruct fontStruct, *lpxFontStruct=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XFontStruct_2II\n");
+#endif
+
+ memmove((void *)&fontStruct, (void *)src, count);
+ if (dest) {
+ lpxFontStruct=&fontStruct;
+ cacheXfontstructFids(env, dest, &PGLOB(XfontstructFc));
+ setXfontstructFields(env, dest, lpxFontStruct, &PGLOB(XfontstructFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XImage;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XImage_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XImage image, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XImage_2II\n");
+#endif
+
+ memmove((void *)&image, (void *)src, count);
+ if (dest) {
+ dest1=&image;
+ cacheXimageFids(env, dest, &PGLOB(XimageFc));
+ setXimageFields(env, dest, dest1, &PGLOB(XimageFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XKeyEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XKeyEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XKeyEvent_2II\n");
+#endif
+
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXkeyeventFids(env, dest, &PGLOB(XkeyeventFc));
+ setXkeyeventFields(env, dest, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XKeyEvent;Lorg/eclipse/swt/internal/motif/XAnyEvent;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XKeyEvent_2Lorg_eclipse_swt_internal_motif_XAnyEvent_2I
+ (JNIEnv *env, jclass that, jobject dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent1, *src1=NULL, xEvent2, *dest1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XKeyEvent_2Lorg_eclipse_swt_internal_motif_XAnyEvent_2I\n");
+#endif
+ if (src) {
+ src1=&xEvent1;
+ cacheXanyeventFids(env, src, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, src, src1, &PGLOB(XanyeventFc));
+ }
+
+ memmove((void *)&xEvent2, (void *)src1, count);
+ if (dest) {
+ dest1=&xEvent2;
+ cacheXkeyeventFids(env, dest, &PGLOB(XkeyeventFc));
+ setXkeyeventFields(env, dest, dest1, &PGLOB(XkeyeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XMotionEvent;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XMotionEvent_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XMotionEvent_2II\n");
+#endif
+
+ memmove((void *)&xEvent, (void *)src, count);
+ if (dest) {
+ lpxEvent=&xEvent;
+ cacheXmotioneventFids(env, dest, &PGLOB(XmotioneventFc));
+ setXmotioneventFields(env, dest, lpxEvent, &PGLOB(XmotioneventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XmAnyCallbackStruct;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XmAnyCallbackStruct_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmAnyCallbackStruct xmanycallbackstruct, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XmAnyCallbackStruct_2II\n");
+#endif
+
+ memmove((void *)&xmanycallbackstruct, (void *)src, count);
+ if (dest) {
+ dest1=&xmanycallbackstruct;
+ cacheXmanycallbackstructFids(env, dest, &PGLOB(XmanycallbackstructFc));
+ setXmanycallbackstructFields(env, dest, dest1, &PGLOB(XmanycallbackstructFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/motif/XmDragProcCallback;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__ILorg_eclipse_swt_internal_motif_XmDragProcCallback_2I
+ (JNIEnv *env, jclass that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmDragProcCallbackStruct xmdragproccallback, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_motif_XmDragProcCallback_2I\n");
+#endif
+
+ if (src) {
+ src1=&xmdragproccallback;
+ cacheXmdragproccallbackFids(env, src, &PGLOB(XmdragproccallbackFc));
+ getXmdragproccallbackFields(env, src, src1, &PGLOB(XmdragproccallbackFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XmDragProcCallback;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XmDragProcCallback_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmDragProcCallbackStruct xmdragproccallback, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XmDragProcCallback_2II\n");
+#endif
+
+ memmove((void *)&xmdragproccallback, (void *)src, count);
+ if (dest) {
+ dest1=&xmdragproccallback;
+ cacheXmdragproccallbackFids(env, dest, &PGLOB(XmdragproccallbackFc));
+ setXmdragproccallbackFields(env, dest, dest1, &PGLOB(XmdragproccallbackFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XmDropProcCallback;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XmDropProcCallback_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmDropProcCallbackStruct xmdropproccallback, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XmDropProcCallback_2II\n");
+#endif
+
+ memmove((void *)&xmdropproccallback, (void *)src, count);
+ if (dest) {
+ dest1=&xmdropproccallback;
+ cacheXmdropproccallbackFids(env, dest, &PGLOB(XmdropproccallbackFc));
+ setXmdropproccallbackFields(env, dest, dest1, &PGLOB(XmdropproccallbackFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XmDropFinishCallback;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XmDropFinishCallback_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmDropFinishCallbackStruct xmdropfinishcallback, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XmDropFinishCallback_2II\n");
+#endif
+
+ memmove((void *)&xmdropfinishcallback, (void *)src, count);
+ if (dest) {
+ dest1=&xmdropfinishcallback;
+ cacheXmdropfinishcallbackFids(env, dest, &PGLOB(XmdropfinishcallbackFc));
+ setXmdropfinishcallbackFields(env, dest, dest1, &PGLOB(XmdropfinishcallbackFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XmTextBlockRec;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XmTextBlockRec_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmTextBlockRec xmTextBlockRec, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XmTextBlockRec_2II\n");
+#endif
+
+ memmove((void *)&xmTextBlockRec, (void *)src, count);
+ if (dest) {
+ dest1=&xmTextBlockRec;
+ cacheXmtextblockrecFids(env, dest, &PGLOB(XmtextblockrecFc));
+ setXmtextblockrecFields(env, dest, dest1, &PGLOB(XmtextblockrecFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove__Lorg_eclipse_swt_internal_motif_XmTextVerifyCallbackStruct_2II
+ (JNIEnv *env, jclass that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ XmTextVerifyCallbackStruct xmtextverifycallbackstruct, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_motif_XmTextVerifyCallbackStruct_2II\n");
+#endif
+
+ memmove((void *)&xmtextverifycallbackstruct, (void *)src, count);
+ if (dest) {
+ dest1=&xmtextverifycallbackstruct;
+ cacheXmtextverifycallbackstructFids(env, dest, &PGLOB(XmtextverifycallbackstructFc));
+ setXmtextverifycallbackstructFields(env, dest, dest1, &PGLOB(XmtextverifycallbackstructFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove___3BII
+ (JNIEnv *env, jclass that, jbyteArray dest, jint src, jint count)
+{
+ jbyte *dest1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove___3BII\n");
+#endif
+
+ /* don't do anything if dest pointer is NULL */
+ if (dest) {
+ dest1 = (*env)->GetByteArrayElements(env, dest, NULL);
+ memmove((void *)dest1, (void *)src, count);
+ (*env)->ReleaseByteArrayElements(env, dest, dest1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: memmove
+ * Signature: ([III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_memmove___3III
+ (JNIEnv *env, jclass that, jintArray dest, jint src, jint count)
+{
+ jint *dest1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove___3III\n");
+#endif
+
+ /* don't do anything if dest pointer is NULL */
+ if (dest) {
+ dest1 = (*env)->GetIntArrayElements(env, dest, NULL);
+ memmove((void *)dest1, (void *)src, count);
+ (*env)->ReleaseIntArrayElements(env, dest, dest1, 0);
+ }
+}
+
+/* end of custom built crap */
+
+/* ------------------------------------------------------------------------- */
+
+/* the following map directly to X calls */
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XAllocColor
+ * Signature: (IILorg/eclipse/swt/internal/motif/XColor;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XAllocColor
+ (JNIEnv *env, jclass that, jint display, jint colormap, jobject color)
+{
+ DECL_GLOB(pGlob)
+ XColor xColor, *lpColor=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XAllocColor\n");
+#endif
+
+ assert (color != 0);
+ if (color) {
+ lpColor = &xColor;
+ cacheXcolorFids(env, color, &PGLOB(XcolorFc));
+ getXcolorFields(env, color, lpColor, &PGLOB(XcolorFc));
+ }
+ rc = (jint) XAllocColor ((Display *)display, colormap, lpColor);
+
+#ifdef PRINT_FAILED_RCODES
+
+ if (rc == 0)
+ fprintf(stderr, "XAllocColor: call failed rc = %d\n", rc);
+#endif
+
+ if (color) {
+ setXcolorFields(env, color, lpColor, &PGLOB(XcolorFc));
+ }
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XBell
+ * Signature: (II)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XBell
+ (JNIEnv *env, jclass that, jint display, jint ms)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XBell\n");
+#endif
+ XBell ((Display *)display, ms);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XBitmapBitOrder
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XBitmapBitOrder
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XBitmapBitOrder\n");
+#endif
+ return (jint) XBitmapBitOrder((Display *) display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XBlackPixel
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XBlackPixel
+ (JNIEnv *env, jclass that, jint display, jint screen_number)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XBlackPixel\n");
+#endif
+ return (jint) XBlackPixel((Display *)display, screen_number);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XChangeGC
+ * Signature: (IIILorg/eclipse/swt/internal/motif/XGCValues;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XChangeGC
+ (JNIEnv *env, jclass that, jint display, jint gc, jint valuemask, jobject values)
+{
+ DECL_GLOB(pGlob)
+ XGCValues xgcValues, *lpxgcValues=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XChangeGC\n");
+#endif
+
+ if (values) {
+ lpxgcValues = &xgcValues;
+ cacheXgcvaluesFids(env, values, &PGLOB(XgcvaluesFc));
+ getXgcvaluesFields(env, values, lpxgcValues, &PGLOB(XgcvaluesFc));
+ }
+ rc = (jint) XChangeGC((Display *)display, (GC)gc, valuemask, lpxgcValues);
+
+ if (values) {
+ setXgcvaluesFields(env, values, lpxgcValues, &PGLOB(XgcvaluesFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XChangeWindowAttributes
+ * Signature: (IIILorg/eclipse/swt/internal/motif/XSetWindowAttributes;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XChangeWindowAttributes
+ (JNIEnv *env, jclass that, jint display, jint window, jint mask, jobject attributes)
+{
+ DECL_GLOB(pGlob)
+ XSetWindowAttributes xSetWindowAttributes, *lpxSetWindowAttributes;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XChangeWindowAttributes\n");
+#endif
+
+ if (attributes) {
+ lpxSetWindowAttributes = &xSetWindowAttributes;
+ cacheXsetwindowattributesFids(env, attributes, &PGLOB(XsetwindowattributesFc));
+ getXsetwindowattributesFields(env, attributes, lpxSetWindowAttributes, &PGLOB(XsetwindowattributesFc));
+ }
+
+ XChangeWindowAttributes((Display *)display, window, mask, lpxSetWindowAttributes);
+ if (attributes) {
+ setXsetwindowattributesFields(env, attributes, lpxSetWindowAttributes, &PGLOB(XsetwindowattributesFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCheckMaskEvent
+ * Signature: (IILorg/eclipse/swt/internal/motif/XAnyEvent;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XCheckMaskEvent
+ (JNIEnv *env, jclass that, jint display, jint mask, jobject event)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCheckMaskEvent\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ rc = (jboolean) XCheckMaskEvent((Display *)display, mask, lpxEvent);
+
+#ifdef PRINT_FAILED_RCODES
+
+ if (rc != True && rc != False)
+ fprintf(stderr, "XCheckMaskEvent: call failed rc = %d\n", rc);
+#endif
+
+ if (event) {
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCheckWindowEvent
+ * Signature: (IIILorg/eclipse/swt/internal/motif/XAnyEvent;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XCheckWindowEvent
+ (JNIEnv *env, jclass that, jint display, jint window, jint mask, jobject event)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCheckWindowEvent\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ rc = (jboolean)XCheckWindowEvent((Display *)display, window, mask, lpxEvent);
+
+#ifdef PRINT_FAILED_RCODES
+
+ if (rc != True && rc != False)
+ fprintf(stderr, "XCheckWindowEvent: call failed rc = %d\n", rc);
+#endif
+
+ if (event) {
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XClearArea
+ * Signature: (IIIIIIZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XClearArea
+ (JNIEnv *env, jclass that, jint display, jint window, jint x, jint y, jint width, jint height, jboolean exposures)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XClearArea\n");
+#endif
+ XClearArea((Display *)display, window, x, y, width, height, exposures);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XClipBox
+ * Signature: (ILorg/eclipse/swt/internal/motif/XRectangle;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XClipBox
+ (JNIEnv *env, jclass that, jint region, jobject rectangle)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XClipBox\n");
+#endif
+
+ if (rectangle) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, rectangle, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ XClipBox((Region)region, (XRectangle *)lpxRect);
+ if (rectangle) {
+ setXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCopyArea
+ * Signature: (IIIIIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XCopyArea
+ (JNIEnv *env, jclass that, jint display, jint src, jint dest, jint gc, jint src_x, jint src_y, jint width, jint height, jint dest_x, jint dest_y)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCopyArea\n");
+#endif
+ XCopyArea((Display *)display, src, dest, (GC)gc, src_x, src_y, width, height, dest_x, dest_y);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCopyPlane
+ * Signature: (IIIIIIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XCopyPlane
+ (JNIEnv *env, jclass that, jint display, jint src, jint dest, jint gc, jint src_x, jint src_y, jint width, jint height, jint dest_x, jint dest_y, jint plane)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCopyPlane\n");
+#endif
+ XCopyPlane((Display *)display, src, dest, (GC)gc, src_x, src_y, width, height, dest_x, dest_y, plane);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreateBitmapFromData
+ * Signature: (II[BII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateBitmapFromData
+ (JNIEnv *env, jclass that, jint display, jint drawable, jbyteArray data, jint width, jint height)
+{
+ jbyte *data1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreateBitmapFromData\n");
+#endif
+
+ if (data)
+ data1 = (*env)->GetByteArrayElements(env, data, NULL);
+
+ rc = (jint) XCreateBitmapFromData((Display *)display, drawable, (char *)data1, width, height);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XCreateBitmapFromData: call failed rc = %d\n", rc);
+#endif
+
+ if (data)
+ (*env)->ReleaseByteArrayElements(env, data, data1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreateFontCursor
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateFontCursor
+ (JNIEnv *env, jclass that, jint display, jint shape)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreateFontCursor\n");
+#endif
+ return (jint) XCreateFontCursor((Display *)display, shape);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreateGC
+ * Signature: (IIILorg/eclipse/swt/internal/motif/XGCValues;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateGC
+ (JNIEnv *env, jclass that, jint display, jint window, jint mask, jobject values)
+{
+ DECL_GLOB(pGlob)
+ XGCValues xgcValues, *lpxgcValues=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreateGC\n");
+#endif
+
+ if (values) {
+ lpxgcValues = &xgcValues;
+ cacheXgcvaluesFids(env, values, &PGLOB(XgcvaluesFc));
+ getXgcvaluesFields(env, values, lpxgcValues, &PGLOB(XgcvaluesFc));
+ }
+ rc = (jint) XCreateGC((Display *)display, window, mask, lpxgcValues);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XCreateGC: call failed rc = %d\n", rc);
+#endif
+
+ if (values) {
+ setXgcvaluesFields(env, values, lpxgcValues, &PGLOB(XgcvaluesFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreateImage
+ * Signature: (IIIIIIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateImage
+ (JNIEnv *env, jclass that, jint display, jint visual, jint depth, jint format, jint offset, jint data, jint width, jint height, jint bitmap_pad, jint bytes_per_line)
+{
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreateImage\n");
+#endif
+
+ rc = (jint) XCreateImage((Display *)display, (Visual *)visual, depth, format, offset, (char *)data, width, height, bitmap_pad, bytes_per_line);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XCreateImage: call failed rc = %d\n", rc);
+#endif
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreatePixmap
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreatePixmap
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint width, jint height, jint depth)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreatePixmap\n");
+#endif
+ return (jint) XCreatePixmap((Display *)display, drawable, width, height, depth);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreatePixmapCursor
+ * Signature: (IIILorg/eclipse/swt/internal/motif/XColor;Lorg/eclipse/swt/internal/motif/XColor;II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreatePixmapCursor
+ (JNIEnv *env, jclass that, jint display, jint source, jint mask, jobject foreground_color, jobject background_color, jint x, jint y)
+{
+ DECL_GLOB(pGlob)
+ XColor background_color1, foreground_color1;
+ XColor *lp_background_color = NULL, *lp_foreground_color = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreatePixmapCursor\n");
+#endif
+
+ assert(foreground_color != 0);
+ if (foreground_color) {
+ lp_foreground_color = &foreground_color1;
+ cacheXcolorFids(env, foreground_color, &PGLOB(XcolorFc));
+ getXcolorFields(env, foreground_color, lp_foreground_color, &PGLOB(XcolorFc));
+ }
+ if (background_color) {
+ lp_background_color = &background_color1;
+ cacheXcolorFids(env, background_color, &PGLOB(XcolorFc));
+ getXcolorFields(env, background_color, lp_background_color, &PGLOB(XcolorFc));
+ }
+
+ return (jint) XCreatePixmapCursor((Display *)display, (Pixmap)source, (Pixmap)mask, lp_foreground_color, lp_background_color, x, y);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreateRegion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateRegion
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreateRegion\n");
+#endif
+ return (jint) XCreateRegion();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultColormap
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultColormap
+ (JNIEnv *env, jclass that, jint display, jint screen_number)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultColormap\n");
+#endif
+ return (jint) XDefaultColormap((Display *)display, screen_number);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultDepthOfScreen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultDepthOfScreen
+ (JNIEnv *env, jclass that, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultDepthOfScreen\n");
+#endif
+ return (jint) XDefaultDepthOfScreen((Screen *)screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultRootWindow
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultRootWindow
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultRootWindow\n");
+#endif
+ return (jint) XDefaultRootWindow((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultScreen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultScreen
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultScreen\n");
+#endif
+ return (jint) XDefaultScreen((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultScreenOfDisplay
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultScreenOfDisplay
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultScreenOfDisplay\n");
+#endif
+ return (jint) XDefaultScreenOfDisplay((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultVisual
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultVisual
+ (JNIEnv *env, jclass that, jint display, jint screen_number)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultVisual\n");
+#endif
+ return (jint) XDefaultVisual((Display *)display, screen_number);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefineCursor
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefineCursor
+ (JNIEnv *env, jclass that, jint display, jint window, jint cursor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefineCursor\n");
+#endif
+ XDefineCursor((Display *)display, window, cursor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDestroyImage
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDestroyImage
+ (JNIEnv *env, jclass that, jint ximage)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDestroyImage\n");
+#endif
+ return (jint) XDestroyImage((XImage *)ximage);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDestroyRegion
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDestroyRegion
+ (JNIEnv *env, jclass that, jint region)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDestroyRegion\n");
+#endif
+ XDestroyRegion((Region)region);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDisplayHeight
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDisplayHeight
+ (JNIEnv *env, jclass that, jint display, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDisplayHeight\n");
+#endif
+ return (jint) XDisplayHeight((Display *)display, screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDisplayHeightMM
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDisplayHeightMM
+ (JNIEnv *env, jclass that, jint display, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDisplayHeightMM\n");
+#endif
+ return (jint) XDisplayHeightMM((Display *)display, screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDisplayWidth
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDisplayWidth
+ (JNIEnv *env, jclass that, jint display, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDisplayWidth\n");
+#endif
+ return (jint) XDisplayWidth((Display *)display, screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDisplayWidthMM
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDisplayWidthMM
+ (JNIEnv *env, jclass that, jint display, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDisplayWidthMM\n");
+#endif
+ return (jint) XDisplayWidthMM((Display *)display, screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDrawArc
+ * Signature: (IIIIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDrawArc
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jint x1, jint y1, jint x2, jint y2, jint a1, jint a2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDrawArc\n");
+#endif
+ XDrawArc((Display *)display, drawable, (GC)gc, x1, y1, x2, y2, a1, a2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDrawLine
+ * Signature: (IIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDrawLine
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jint x1, jint y1, jint x2, jint y2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDrawLine\n");
+#endif
+ XDrawLine((Display *)display, drawable, (GC)gc, x1, y1, x2, y2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDrawLines
+ * Signature: (III[SII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDrawLines
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jshortArray xPoints, jint nPoints, jint mode)
+{
+ jshort *xPoints1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDrawLines\n");
+#endif
+
+ if (xPoints)
+ xPoints1 = (*env)->GetShortArrayElements(env, xPoints, NULL);
+ XDrawLines((Display *)display, drawable, (GC)gc, (XPoint *)xPoints1, nPoints, mode);
+ if (xPoints)
+ (*env)->ReleaseShortArrayElements(env, xPoints, xPoints1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDrawRectangle
+ * Signature: (IIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDrawRectangle
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jint x, jint y, jint width, jint height)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "\n");
+#endif
+ XDrawRectangle((Display *)display, drawable, (GC)gc, x, y, width, height);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XEmptyRegion
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XEmptyRegion
+ (JNIEnv *env, jclass that, jint region)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XEmptyRegion\n");
+#endif
+ return (jboolean) XEmptyRegion((Region)region);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XEqualRegion
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XEqualRegion
+ (JNIEnv *env, jclass that, jint region1, jint region2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XEqualRegion\n");
+#endif
+ return (jboolean) XEqualRegion((Region)region1, (Region)region2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFillArc
+ * Signature: (IIIIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFillArc
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jint x1, jint y1, jint x2, jint y2, jint a1, jint a2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFillArc\n");
+#endif
+ XFillArc((Display *)display, drawable, (GC)gc, x1, y1, x2, y2, a1, a2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFillPolygon
+ * Signature: (III[SIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XFillPolygon
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jshortArray xPoints, jint nPoints, jint mode, jint style)
+{
+ jshort *xPoints1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFillPolygon\n");
+#endif
+ if (xPoints)
+ xPoints1 = (*env)->GetShortArrayElements(env, xPoints, NULL);
+ rc = XFillPolygon((Display *)display, drawable, (GC)gc, (XPoint *)xPoints1, nPoints, mode, style);
+ if (xPoints)
+ (*env)->ReleaseShortArrayElements(env, xPoints, xPoints1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFillRectangle
+ * Signature: (IIIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFillRectangle
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jint x, jint y, jint width, jint height)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFillRectangle\n");
+#endif
+ XFillRectangle((Display *)display, drawable, (GC)gc, x, y, width, height);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFilterEvent
+ * Signature: (Lorg/eclipse/swt/internal/motif/XAnyEvent;I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XFilterEvent
+ (JNIEnv *env, jclass that, jobject event, jint window)
+{
+ DECL_GLOB(pGlob)
+ XEvent xanyevent, *event1;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFilterEvent\n");
+#endif
+ if (event) {
+ event1=&xanyevent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, event1, &PGLOB(XanyeventFc));
+ }
+ rc = (jboolean) XFilterEvent(event1, (Window)window);
+ if (event) {
+ setXanyeventFields(env, event, event1, &PGLOB(XanyeventFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFlush
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFlush
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFlush\n");
+#endif
+ XFlush((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFontsOfFontSet
+ * Signature: (I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XFontsOfFontSet
+ (JNIEnv *env, jclass that, jint fontSet, jintArray fontStructs, jintArray fontNames)
+{
+ jint *fontStructs1=NULL,*fontNames1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFontsOfFontSet\n");
+#endif
+ if (fontStructs)
+ fontStructs1 = (*env)->GetIntArrayElements(env, fontStructs, NULL);
+ if (fontNames)
+ fontNames1 = (*env)->GetIntArrayElements(env, fontNames, NULL);
+
+ rc = (jint) XFontsOfFontSet((XFontSet)fontSet, (XFontStruct ***)fontStructs1, (char ***)fontNames1);
+
+ if (fontStructs)
+ (*env)->ReleaseIntArrayElements(env, fontStructs, fontStructs1, 0);
+ if (fontNames)
+ (*env)->ReleaseIntArrayElements(env, fontNames, fontNames1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFree
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XFree
+ (JNIEnv *env, jclass that, jint address)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFree\n");
+#endif
+ return (jint) XFree((char *)address);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFreeColors
+ * Signature: (II[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XFreeColors
+ (JNIEnv *env, jclass that, jint display, jint colormap, jintArray pixels, jint npixels, jint planes)
+{
+ jint *pixels1=NULL;
+ jint rc;
+ jint intArr[2]={250, 250};
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFreeColors\n");
+#endif
+
+ assert(pixels != 0);
+ assert(npixels > 0);
+ assert(npixels < 20);
+
+ if (pixels) {
+ pixels1 = (jint *)&intArr;
+ (*env)->GetIntArrayRegion(env, pixels, 0, npixels, pixels1);
+ }
+
+ assert(*pixels1 >= 0);
+ assert(*pixels1 < 65536);
+ assert(*(pixels1+1) >= 0);
+ assert(*(pixels1+1) < 65536);
+
+ rc = (jint) XFreeColors((Display *)display, colormap, (unsigned long *)pixels1, npixels, planes);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XCreateGC: call failed rc = %d\n", rc);
+#endif
+
+ assert(rc > 0);
+
+ if (pixels) {
+ (*env)->SetIntArrayRegion(env, pixels, 0, npixels, pixels1);
+ }
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFreeCursor
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFreeCursor
+ (JNIEnv *env, jclass that, jint display, jint pixmap)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFreeCursor\n");
+#endif
+ XFreeCursor((Display *)display, pixmap);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFreeFontNames
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFreeFontNames
+ (JNIEnv *env, jclass that, jint list)
+{
+ XFreeFontNames((char **)list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFreeGC
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFreeGC
+ (JNIEnv *env, jclass that, jint display, jint gc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFreeGC\n");
+#endif
+ XFreeGC((Display *)display, (GC)gc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XFreePixmap
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XFreePixmap
+ (JNIEnv *env, jclass that, jint display, jint pixmap)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XFreePixmap\n");
+#endif
+ XFreePixmap((Display *)display, pixmap);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XGetGCValues
+ * Signature: (IIILorg/eclipse/swt/internal/motif/XGCValues;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetGCValues
+ (JNIEnv *env, jclass that, jint display, jint gc, jint valuemask, jobject values)
+{
+ DECL_GLOB(pGlob)
+ XGCValues xgcValues, *lpxgcValues=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XGetGCValues\n");
+#endif
+
+ if (values) {
+ lpxgcValues = &xgcValues;
+ cacheXgcvaluesFids(env, values, &PGLOB(XgcvaluesFc));
+ getXgcvaluesFields(env, values, lpxgcValues, &PGLOB(XgcvaluesFc));
+ }
+ rc = (jint) XGetGCValues((Display *)display, (GC)gc, valuemask, lpxgcValues);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XGetGCValues: call failed rc = %d\n", rc);
+#endif
+
+ if (values) {
+ setXgcvaluesFields(env, values, lpxgcValues, &PGLOB(XgcvaluesFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XGetGeometry
+ * Signature: (II[I[I[I[I[I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetGeometry
+ (JNIEnv *env, jclass that, jint display, jint drawable, jintArray root_return, jintArray x_return, jintArray y_return, jintArray width_return, jintArray height_return, jintArray border_width_return, jintArray depth_return)
+{
+ jint *root_return1=NULL, *x_return1=NULL, *y_return1=NULL, *width_return1=NULL, *height_return1=NULL, *border_width_return1=NULL, *depth_return1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XGetGeometry\n");
+#endif
+
+ if (root_return)
+ root_return1 = (*env)->GetIntArrayElements(env, root_return, NULL);
+ if (x_return)
+ x_return1 = (*env)->GetIntArrayElements(env, x_return, NULL);
+ if (y_return)
+ y_return1 = (*env)->GetIntArrayElements(env, y_return, NULL);
+ if (width_return)
+ width_return1 = (*env)->GetIntArrayElements(env, width_return, NULL);
+ if (height_return)
+ height_return1 = (*env)->GetIntArrayElements(env, height_return, NULL);
+ if (border_width_return)
+ border_width_return1 = (*env)->GetIntArrayElements(env, border_width_return, NULL);
+ if (depth_return)
+ depth_return1 = (*env)->GetIntArrayElements(env, depth_return, NULL);
+
+ rc = (jint) XGetGeometry((Display *)display, drawable, (Window *)root_return1, (int *)x_return1, (int *)y_return1, (unsigned int *)width_return1, (unsigned int *)height_return1, (unsigned int *)border_width_return1, (unsigned int *)depth_return1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XGetGeometry: call failed rc = %d\n", rc);
+#endif
+
+ if (root_return)
+ (*env)->ReleaseIntArrayElements(env, root_return, root_return1, 0);
+ if (x_return)
+ (*env)->ReleaseIntArrayElements(env, x_return, x_return1, 0);
+ if (y_return)
+ (*env)->ReleaseIntArrayElements(env, y_return, y_return1, 0);
+ if (width_return)
+ (*env)->ReleaseIntArrayElements(env, width_return, width_return1, 0);
+ if (height_return)
+ (*env)->ReleaseIntArrayElements(env, height_return, height_return1, 0);
+ if (border_width_return)
+ (*env)->ReleaseIntArrayElements(env, border_width_return, border_width_return1, 0);
+ if (depth_return)
+ (*env)->ReleaseIntArrayElements(env, depth_return, depth_return1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XGetImage
+ * Signature: (IIIIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetImage
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint x, jint y, jint width, jint height, jint plane_mask, jint format)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XGetImage\n");
+#endif
+ return (jint) XGetImage((Display *)display, (Drawable)drawable, x, y, width, height, plane_mask, format);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XGetInputFocus
+ * Signature: (I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetInputFocus
+ (JNIEnv *env, jclass that, jint display, jintArray window, jintArray revert)
+{
+ jint *window1, *revert1;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XGetInputFocus\n");
+#endif
+
+ if (window)
+ window1 = (*env)->GetIntArrayElements(env, window, NULL);
+ if (revert)
+ revert1 = (*env)->GetIntArrayElements(env, revert, NULL);
+ rc = (jint) XGetInputFocus((Display *)display, (Window *)window1, (int *)revert1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XGetInputFocus: call failed rc = %d\n", rc);
+#endif
+
+ if (window)
+ (*env)->ReleaseIntArrayElements(env, window, window1, 0);
+ if (revert)
+ (*env)->ReleaseIntArrayElements(env, revert, revert1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XGetWindowAttributes
+ * Signature: (IILorg/eclipse/swt/internal/motif/XWindowAttributes;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetWindowAttributes
+ (JNIEnv *env, jclass that, jint display, jint window, jobject attributes)
+{
+ DECL_GLOB(pGlob)
+ XWindowAttributes xWindowAttributes, *lpxWindowAttributes;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XGetWindowAttributes\n");
+#endif
+
+ if (attributes) {
+ lpxWindowAttributes = &xWindowAttributes;
+ cacheXwindowattributesFids(env, attributes, &PGLOB(XwindowattributesFc));
+ getXwindowattributesFields(env, attributes, lpxWindowAttributes, &PGLOB(XwindowattributesFc));
+ }
+
+ rc = (jboolean) XGetWindowAttributes((Display *)display, window, lpxWindowAttributes);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XGetWindowAttributes: call failed rc = %d\n", rc);
+#endif
+
+ if (attributes) {
+ setXwindowattributesFields(env, attributes, lpxWindowAttributes, &PGLOB(XwindowattributesFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XGrabPointer
+ * Signature: (IIIIIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XGrabPointer
+ (JNIEnv *env, jclass that, jint display, jint grabWindow, jint ownerEvents, jint eventMask,
+ jint PointerMode, jint KeyboardMode, jint confineToWindow, jint cursor, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XGrabPointer\n");
+#endif
+ return (jint) XGrabPointer((Display *)display, grabWindow, ownerEvents, eventMask, PointerMode,
+ KeyboardMode, confineToWindow, cursor, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XKeysymToString
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XKeysymToString
+ (JNIEnv *env, jclass that, jint keysym)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XKeysymToString\n");
+#endif
+ return (jint) XKeysymToString(keysym);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XListFonts
+ * Signature: (I[BI[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XListFonts
+ (JNIEnv *env, jclass that, jint display, jbyteArray pattern, jint maxnames, jintArray actual_count_return)
+{
+ jbyte *pattern1 = NULL;
+ jint *actual_count_return1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XListFonts\n");
+#endif
+ if (pattern)
+ pattern1 = (*env)->GetByteArrayElements(env, pattern, NULL);
+ if (actual_count_return)
+ actual_count_return1 = (*env)->GetIntArrayElements(env, actual_count_return, NULL);
+
+ rc = (jint) XListFonts((Display *)display, (char *)pattern1, maxnames, (int *)actual_count_return1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XListFonts: call failed rc = %d\n", rc);
+#endif
+
+ if (pattern)
+ (*env)->ReleaseByteArrayElements(env, pattern, pattern1, 0);
+ if (actual_count_return)
+ (*env)->ReleaseIntArrayElements(env, actual_count_return, actual_count_return1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XLookupString
+ * Signature: (Lorg/eclipse/swt/internal/motif/XKeyEvent;[BI[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XLookupString
+ (JNIEnv *env, jclass that, jobject keyEvent, jbyteArray string, jint size, jintArray keysym, jintArray status)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jint *keysym1=NULL, *status1=NULL;
+ jbyte *string1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XLookupString\n");
+#endif
+
+ if (keyEvent) {
+ lpxEvent = &xEvent;
+ cacheXkeyeventFids(env, keyEvent, &PGLOB(XkeyeventFc));
+ getXkeyeventFields(env, keyEvent, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ if (keysym)
+ keysym1 = (*env)->GetIntArrayElements(env, keysym, NULL);
+ if (status)
+ status1 = (*env)->GetIntArrayElements(env, status, NULL);
+ rc = (jint) XLookupString((XKeyEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (XComposeStatus *)status1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc < 0)
+ fprintf(stderr, "XLookupString: call failed rc = %d\n", rc);
+#endif
+
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ if (keysym)
+ (*env)->ReleaseIntArrayElements(env, keysym, keysym1, 0);
+ if (status)
+ (*env)->ReleaseIntArrayElements(env, status, status1, 0);
+
+ if (keyEvent) {
+ setXkeyeventFields(env, keyEvent, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XLowerWindow
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XLowerWindow
+ (JNIEnv *env, jclass that, jint display, jint window)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XLowerWindow\n");
+#endif
+ return (jint) XLowerWindow((Display *)display, window);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XPointInRegion
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XPointInRegion
+ (JNIEnv *env, jclass that, jint region, jint x, jint y)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XPointInRegion\n");
+#endif
+ return (jboolean) XPointInRegion((Region)region, x, y);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XPutImage
+ * Signature: (IIIIIIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XPutImage
+ (JNIEnv *env, jclass that, jint display, jint drawable, jint gc, jint image, jint srcX, jint srcY, jint destX, jint destY, jint width, jint height)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XPutImage\n");
+#endif
+ return (jint) XPutImage((Display *)display, drawable, (GC)gc, (XImage *)image, srcX, srcY, destX, destY, width, height);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XQueryColor
+ * Signature: (IILorg/eclipse/swt/internal/motif/XColor;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XQueryColor
+ (JNIEnv *env, jclass that, jint display, jint colormap, jobject color)
+{
+ DECL_GLOB(pGlob)
+ XColor xColor, *lpColor=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XQueryColor\n");
+#endif
+
+ if (color) {
+ lpColor = &xColor;
+ cacheXcolorFids(env, color, &PGLOB(XcolorFc));
+ getXcolorFields(env, color, lpColor, &PGLOB(XcolorFc));
+ }
+
+ rc = (jint) XQueryColor((Display *)display, colormap, lpColor);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XQueryColor: call failed rc = %d\n", rc);
+#endif
+
+ if (color) {
+ setXcolorFields(env, color, lpColor, &PGLOB(XcolorFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XQueryPointer
+ * Signature: (II[I[I[I[I[I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XQueryPointer
+ (JNIEnv *env, jclass that, jint display, jint window, jintArray root, jintArray child,
+ jintArray rootX, jintArray rootY, jintArray windowX, jintArray windowY, jintArray mask)
+{
+ jint *root1=NULL, *child1=NULL, *rootX1=NULL, *rootY1=NULL, *windowX1=NULL, *windowY1=NULL, *mask1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XQueryPointer\n");
+#endif
+
+ if (root)
+ root1 = (*env)->GetIntArrayElements(env, root, NULL);
+ if (child)
+ child1 = (*env)->GetIntArrayElements(env, child, NULL);
+ if (rootX)
+ rootX1 = (*env)->GetIntArrayElements(env, rootX, NULL);
+ if (rootY)
+ rootY1 = (*env)->GetIntArrayElements(env, rootY, NULL);
+ if (windowX)
+ windowX1 = (*env)->GetIntArrayElements(env, windowX, NULL);
+ if (windowY)
+ windowY1 = (*env)->GetIntArrayElements(env, windowY, NULL);
+ if (mask)
+ mask1 = (*env)->GetIntArrayElements(env, mask, NULL);
+
+ rc = (jint) XQueryPointer((Display *)display, window, (Window *)root1, (Window *)child1, (int *)rootX1, (int *)rootY1, (int *)windowX1, (int *)windowY1, (unsigned int *)mask1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XQueryPointer: call failed rc = %d\n", rc);
+#endif
+
+ if (root)
+ (*env)->ReleaseIntArrayElements(env, root, root1, 0);
+ if (child)
+ (*env)->ReleaseIntArrayElements(env, child, child1, 0);
+ if (rootX)
+ (*env)->ReleaseIntArrayElements(env, rootX, rootX1, 0);
+ if (rootY)
+ (*env)->ReleaseIntArrayElements(env, rootY, rootY1, 0);
+ if (windowX)
+ (*env)->ReleaseIntArrayElements(env, windowX, windowX1, 0);
+ if (windowY)
+ (*env)->ReleaseIntArrayElements(env, windowY, windowY1, 0);
+ if (mask)
+ (*env)->ReleaseIntArrayElements(env, mask, mask1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XQueryTree
+ * Signature: (II[I[I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XQueryTree
+ (JNIEnv *env, jclass that, jint display, jint window, jintArray root_return, jintArray parent_return, jintArray children_return, jintArray nChildren_return)
+{
+ jint *root_return1=NULL, *parent_return1=NULL, *children_return1=NULL, *nChildren_return1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XQueryTree\n");
+#endif
+
+ if (root_return)
+ root_return1 = (*env)->GetIntArrayElements(env, root_return, NULL);
+ if (parent_return)
+ parent_return1 = (*env)->GetIntArrayElements(env, parent_return, NULL);
+ if (children_return)
+ children_return1 = (*env)->GetIntArrayElements(env, children_return, NULL);
+ if (nChildren_return)
+ nChildren_return1 = (*env)->GetIntArrayElements(env, nChildren_return, NULL);
+
+ rc = (jint) XQueryTree((Display *)display, window, (Window *)root_return1, (Window *)parent_return1, (Window **)children_return1, (unsigned int *)nChildren_return1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XQueryTree: call failed rc = %d\n", rc);
+#endif
+
+ if (root_return)
+ (*env)->ReleaseIntArrayElements(env, root_return, root_return1, 0);
+ if (parent_return)
+ (*env)->ReleaseIntArrayElements(env, parent_return, parent_return1, 0);
+ if (children_return)
+ (*env)->ReleaseIntArrayElements(env, children_return, children_return1, 0);
+ if (nChildren_return)
+ (*env)->ReleaseIntArrayElements(env, nChildren_return, nChildren_return1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XRaiseWindow
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XRaiseWindow
+ (JNIEnv *env, jclass that, jint display, jint window)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XRaiseWindow\n");
+#endif
+ return (jint) XRaiseWindow((Display *)display, window);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XReconfigureWMWindow
+ * Signature: (IIIILorg/eclipse/swt/internal/motif/XWindowChanges;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XReconfigureWMWindow
+ (JNIEnv *env, jclass that, jint display, jint window, jint screen, jint valueMask, jobject values)
+{
+ DECL_GLOB(pGlob)
+ XWindowChanges xWindowChanges, *lpWindowChanges1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XReconfigureWMWindow\n");
+#endif
+
+ if (values) {
+ lpWindowChanges1 = &xWindowChanges;
+ cacheXwindowchangesFids(env, values, &PGLOB(XwindowchangesFc));
+ getXwindowchangesFields(env, values, lpWindowChanges1, &PGLOB(XwindowchangesFc));
+ }
+ rc = (jint) XReconfigureWMWindow((Display *)display, window, screen, valueMask, lpWindowChanges1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XReconfigureWMWindow: call failed rc = %d\n", rc);
+#endif
+
+ if (values) {
+ setXwindowchangesFields(env, values, lpWindowChanges1, &PGLOB(XwindowchangesFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XRectInRegion
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XRectInRegion
+ (JNIEnv *env, jclass that, jint region, jint x, jint y, jint width, jint height)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XRectInRegion\n");
+#endif
+ return (jint) XRectInRegion((Region)region, x, y, width, height);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetBackground
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetBackground
+ (JNIEnv *env, jclass that, jint display, jint gc, jint background)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetBackground\n");
+#endif
+ XSetBackground((Display *)display, (GC)gc, background);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetClipMask
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetClipMask
+ (JNIEnv *env, jclass that, jint display, jint gc, jint pixmap)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetClipMask\n");
+#endif
+ XSetClipMask((Display *)display, (GC)gc, pixmap);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetClipRectangles
+ * Signature: (IIIILorg/eclipse/swt/internal/motif/XRectangle;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetClipRectangles
+ (JNIEnv *env, jclass that, jint display, jint gc, jint clip_x_origin, jint clip_y_origin, jobject rectangle, jint n, jint ordering)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetClipRectangles\n");
+#endif
+
+ if (rectangle) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, rectangle, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ XSetClipRectangles((Display *)display, (GC)gc, clip_x_origin, clip_y_origin, lpxRect, n, ordering);
+ if (rectangle) {
+ setXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetDashes
+ * Signature: (III[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetDashes
+ (JNIEnv *env, jclass that, jint display, jint gc, jint dash_offset, jbyteArray dash_list, jint n)
+{
+ jbyte *dash_list1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetDashes\n");
+#endif
+
+ if (dash_list)
+ dash_list1 = (*env)->GetByteArrayElements(env, dash_list, NULL);
+ rc = (jint) XSetDashes((Display *)display, (GC)gc, dash_offset, (char *)dash_list1, n);
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XSetDashes: call failed rc = %d\n", rc);
+#endif
+ if (dash_list)
+ (*env)->ReleaseByteArrayElements(env, dash_list, dash_list1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetErrorHandler
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetErrorHandler
+ (JNIEnv *env, jclass that, jint handler)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetErrorHandler\n");
+#endif
+ return (jint) XSetErrorHandler((XErrorHandler)handler);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetFillStyle
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetFillStyle
+ (JNIEnv *env, jclass that, jint display, jint gc, jint fill_style)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetFillStyle\n");
+#endif
+ XSetFillStyle((Display*)display, (GC)gc, fill_style);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetFont
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetFont
+ (JNIEnv *env, jclass that, jint display, jint gc, jint font)
+{
+ return (jint) XSetFont((Display *)display, (GC)gc, (Font)font);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetForeground
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetForeground
+ (JNIEnv *env, jclass that, jint display, jint gc, jint foreground)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetForeground\n");
+#endif
+ XSetForeground((Display *)display, (GC)gc, foreground);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetFunction
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetFunction
+ (JNIEnv *env, jclass that, jint display, jint gc, jint function)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetFunction\n");
+#endif
+ XSetFunction((Display *)display, (GC)gc, function);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetGraphicsExposures
+ * Signature: (IIZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetGraphicsExposures
+ (JNIEnv *env, jclass that, jint display, jint gc, jboolean graphics_exposures)
+{
+ XSetGraphicsExposures((Display *)display, (GC)gc, (Bool) graphics_exposures);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetInputFocus
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetInputFocus
+ (JNIEnv *env, jclass that, jint display, jint window, jint revert, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetInputFocus\n");
+#endif
+
+ return (jint) XSetInputFocus((Display *)display, window, revert, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetLineAttributes
+ * Signature: (IIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetLineAttributes
+ (JNIEnv *env, jclass that, jint display, jint gc, jint lineWidth, jint lineStyle, jint capStyle, jint joinStyle)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetLineAttributes\n");
+#endif
+ return (jint) XSetLineAttributes((Display *)display, (GC)gc, lineWidth, lineStyle, capStyle, joinStyle);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetRegion
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetRegion
+ (JNIEnv *env, jclass that, jint display, jint gc, jint region)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetRegion\n");
+#endif
+ XSetRegion((Display *)display, (GC)gc, (Region)region);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetStipple
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetStipple
+ (JNIEnv *env, jclass that, jint display, jint gc, jint pixmap)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetStipple\n");
+#endif
+ XSetStipple((Display*)display, (GC)gc, pixmap);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetSubwindowMode
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetSubwindowMode
+ (JNIEnv *env, jclass that, jint display, jint gc, jint subwindow_mode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetSubwindowMode\n");
+#endif
+ XSetSubwindowMode((Display*)display, (GC)gc, subwindow_mode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetWindowBorderWidth
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetWindowBorderWidth
+ (JNIEnv *env, jclass that, jint display, jint window, jint width)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetWindowBorderWidth\n");
+#endif
+ XSetWindowBorderWidth((Display *)display, window, width);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSubtractRegion
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSubtractRegion
+ (JNIEnv *env, jclass that, jint sra, jint srb, jint da_return)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSubtractRegion\n");
+#endif
+ XSubtractRegion((Region)sra, (Region)srb, (Region)da_return);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSync
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSync
+ (JNIEnv *env, jclass that, jint display, jboolean discard)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSync\n");
+#endif
+ XSync((Display *)display, (Bool)discard);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSynchronize
+ * Signature: (IZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSynchronize
+ (JNIEnv *env, jclass that, jint display, jboolean onoff)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSynchronize\n");
+#endif
+ return (jint) XSynchronize((Display *)display, (Bool)onoff);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XUndefineCursor
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XUndefineCursor
+ (JNIEnv *env, jclass that, jint display, jint window)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XUndefineCursor\n");
+#endif
+ XUndefineCursor((Display *)display, window);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XUngrabPointer
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XUngrabPointer
+ (JNIEnv *env, jclass that, jint display, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XUngrabPointer\n");
+#endif
+ return (jint) XUngrabPointer((Display *)display, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XUnionRectWithRegion
+ * Signature: (Lorg/eclipse/swt/internal/motif/XRectangle;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XUnionRectWithRegion
+ (JNIEnv *env, jclass that, jobject rectangle, jint src_region, jint dest_region)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XUnionRectWithRegion\n");
+#endif
+
+ if (rectangle) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, rectangle, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ XUnionRectWithRegion(lpxRect, (Region)src_region, (Region)dest_region);
+ if (rectangle) {
+ setXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XUnionRegion
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XUnionRegion
+ (JNIEnv *env, jclass that, jint sra, jint srb, jint dr_return)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XUnionRegion\n");
+#endif
+ XUnionRegion((Region)sra, (Region)srb, (Region)dr_return);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XWhitePixel
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XWhitePixel
+ (JNIEnv *env, jclass that, jint display, jint screenNum)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XWhitePixel\n");
+#endif
+ return (jint) XWhitePixel((Display *)display, screenNum);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XWithdrawWindow
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XWithdrawWindow
+ (JNIEnv *env, jclass that, jint display, jint window, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XWithdrawWindow\n");
+#endif
+ XWithdrawWindow((Display *)display, (Window)window, screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmAddWMProtocolCallback
+ * Signature: (IIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmAddWMProtocolCallback
+ (JNIEnv *env, jclass that, jint shell, jint protocol, jint callback, jint closure)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmAddWMProtocolCallback\n");
+#endif
+ XmAddWMProtocolCallback((Widget)shell, (Atom)protocol, (XtCallbackProc)callback, (XtPointer)closure);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmChangeColor
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmChangeColor
+ (JNIEnv *env, jclass that, jint widget, jint pixel)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmChangeColor\n");
+#endif
+ XmChangeColor((Widget)widget, pixel);
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmComboBoxAddItem
+ * Signature: (IIIZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmComboBoxAddItem
+ (JNIEnv *env, jclass that, jint combo, jint xmString, jint position, jboolean unique)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmComboBoxAddItem\n");
+#endif
+ XmComboBoxAddItem((Widget)combo, (XmString) xmString, position, unique);
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmComboBoxDeletePos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmComboBoxDeletePos
+ (JNIEnv *env, jclass that, jint combo, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmComboBoxDeletePos\n");
+#endif
+ XmComboBoxDeletePos((Widget)combo, position);
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmComboBoxSelectItem
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmComboBoxSelectItem
+ (JNIEnv *env, jclass that, jint combo, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmComboBoxSelectItem\n");
+#endif
+ XmComboBoxSelectItem((Widget)combo, (XmString) xmString);
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateArrowButton
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateArrowButton
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jint *name1=NULL, *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateArrowButton\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetIntArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateArrowButton((Widget)parent, (char *)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateArrowButton: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseIntArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateCascadeButtonGadget
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateCascadeButtonGadget
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateCascadeButtonGadget\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateCascadeButtonGadget((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateCascadeButtonGadget: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateComboBox
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateComboBox
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateComboBox\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateComboBox((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateComboBox: call failed rc = %d\n", rc);
+#endif
+
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateDialogShell
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateDialogShell
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateDialogShell\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateDialogShell((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateDialogShell: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateDrawingArea
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateDrawingArea
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateDrawingArea\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateDrawingArea((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateDrawingArea: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateErrorDialog
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateErrorDialog
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateErrorDialog\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateErrorDialog((struct _WidgetRec*)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateErrorDialog: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateFileSelectionDialog
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateFileSelectionDialog
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateFileSelectionDialog\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateFileSelectionDialog((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateFileSelectionDialog: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateForm
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateForm
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateForm\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateForm((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateForm: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateFrame
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateFrame
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateFrame\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateFrame((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateFrame: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateInformationDialog
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateInformationDialog
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateInformationDialog\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+
+ rc = (jint)XmCreateInformationDialog((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateInformationDialog: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateLabel
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateLabel
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateLabel\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateLabel((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateLabel: call failed rc = %d\n", rc);
+#endif
+
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateList
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateList
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *arglist1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateList\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint) XmCreateList((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateList: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateMainWindow
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateMainWindow
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateMainWindow\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateMainWindow((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateMainWindow: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateMenuBar
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateMenuBar
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateMenuBar\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateMenuBar((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateMenuBar: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateMessageDialog
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateMessageDialog
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateMessageDialog\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateMessageDialog((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateMessageDialog: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreatePopupMenu
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreatePopupMenu
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreatePopupMenu\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreatePopupMenu((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreatePopupMenu: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method:
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreatePulldownMenu
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreatePulldownMenu\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreatePulldownMenu((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreatePulldownMenu: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreatePushButton
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreatePushButton
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1 = NULL;
+ jint *argList1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreatePushButton\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+
+ rc = (jint) XmCreatePushButton((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreatePushButton: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreatePushButtonGadget
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreatePushButtonGadget
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreatePushButtonGadget\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreatePushButtonGadget((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreatePushButtonGadget: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateQuestionDialog
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateQuestionDialog
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateQuestionDialog\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateQuestionDialog((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateQuestionDialog: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateScale
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateScale
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateScale\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+
+ rc = (jint) XmCreateScale((Widget)parent, (String)name1, (ArgList) arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateScale: call failed rc = %d\n", rc);
+#endif
+
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateScrollBar
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateScrollBar
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateScrollBar\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateScrollBar((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateScrollBar: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateScrolledList
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateScrolledList
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateScrolledList\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateScrolledList((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateScrolledList: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateScrolledText
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateScrolledText
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateScrolledText\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateScrolledText((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateScrolledText: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateSeparator
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateSeparator
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateSeparator\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateSeparator((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateSeparator: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateSeparatorGadget
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateSeparatorGadget
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateSeparatorGadget\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateSeparatorGadget((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateSeparatorGadget: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateTextField
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateTextField
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateTextField\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateTextField((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateTextField: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateToggleButton
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateToggleButton
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateToggleButton\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateToggleButton((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateToggleButton: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateToggleButtonGadget
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateToggleButtonGadget
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateToggleButtonGadget\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateToggleButtonGadget((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateToggleButtonGadget: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateWarningDialog
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateWarningDialog
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateWarningDialog\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ rc = (jint)XmCreateWarningDialog((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateWarningDialog: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDragCancel
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDragCancel
+ (JNIEnv *env, jclass that, jint dragcontext)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDragCancel\n");
+#endif
+
+ XmDragCancel((Widget)dragcontext);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDragStart
+ * Signature: (II[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDragStart
+ (JNIEnv *env, jclass that, jint widget, jobject event, jintArray arglist, jint argcount)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jint *arglist1;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDragStart\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ if (arglist) {
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ }
+ rc = (jint) XmDragStart((Widget)widget, (XEvent *)lpxEvent, (ArgList)arglist1, (Cardinal)argcount);
+ if (event) {
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ if (arglist) {
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDropSiteRegister
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDropSiteRegister
+ (JNIEnv *env, jclass that, jint widget, jintArray arglist, jint argcount)
+{
+ jint *arglist1;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDropSiteRegister\n");
+#endif
+
+ if (arglist) {
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ }
+ XmDropSiteRegister((Widget)widget, (ArgList)arglist1, (Cardinal)argcount);
+ if (arglist) {
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDropSiteRetrieve
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDropSiteRetrieve
+ (JNIEnv *env, jclass that, jint widget, jintArray arglist, jint argcount)
+{
+ jint *arglist1;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDropSiteRetrieve\n");
+#endif
+
+ if (arglist) {
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ }
+ XmDropSiteRetrieve((Widget)widget, (ArgList)arglist1, (Cardinal)argcount);
+ if (arglist) {
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDropSiteUnregister
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDropSiteUnregister
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDropSiteUnregister\n");
+#endif
+ XmDropSiteUnregister((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDropSiteUpdate
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDropSiteUpdate
+ (JNIEnv *env, jclass that, jint widget, jintArray arglist, jint argcount)
+{
+ jint *arglist1;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDropSiteUpdate\n");
+#endif
+
+ if (arglist) {
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ }
+ XmDropSiteUpdate((Widget)widget, (ArgList)arglist1, (Cardinal)argcount);
+ if (arglist) {
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDropTransferAdd
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDropTransferAdd
+ (JNIEnv *env, jclass that, jint drop_transfer, jintArray transfers, jint num_transfers)
+{
+ jint *transfers1;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDropTransferAdd\n");
+#endif
+
+ if (transfers) {
+ transfers1 = (*env)->GetIntArrayElements(env, transfers, NULL);
+ }
+ XmDropTransferAdd((Widget)drop_transfer, (XmDropTransferEntryRec *)transfers1, (Cardinal)num_transfers);
+ if (transfers) {
+ (*env)->ReleaseIntArrayElements(env, transfers, transfers1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDropTransferStart
+ * Signature: (I[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDropTransferStart
+ (JNIEnv *env, jclass that, jint widget, jintArray arglist, jint argcount)
+{
+ jint *arglist1;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDropTransferStart\n");
+#endif
+
+ if (arglist) {
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+ }
+ rc = (jint) XmDropTransferStart((Widget)widget, (ArgList)arglist1, (Cardinal)argcount);
+ if (arglist) {
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFileSelectionBoxGetChild
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFileSelectionBoxGetChild
+ (JNIEnv *env, jclass that, jint widget, jint child)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFileSelectionBoxGetChild\n");
+#endif
+ return (jint) XmFileSelectionBoxGetChild((Widget)widget, child);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListAppendEntry
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListAppendEntry
+ (JNIEnv *env, jclass that, jint oldlist, jint entry)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListAppendEntry\n");
+#endif
+ return (jint) XmFontListAppendEntry((XmFontList)oldlist, (XmFontListEntry)entry);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListEntryFree
+ * Signature: ([I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListEntryFree
+ (JNIEnv *env, jclass that, jintArray entry)
+{
+ jint *entry1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListEntryFree\n");
+#endif
+
+ if (entry)
+ entry1 = (*env)->GetIntArrayElements(env, entry, NULL);
+ XmFontListEntryFree((XmFontListEntry *)entry1);
+ if (entry)
+ (*env)->ReleaseIntArrayElements(env, entry, entry1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListEntryGetFont
+ * Signature: (I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListEntryGetFont
+ (JNIEnv *env, jclass that, jint entry, jintArray type_return)
+{
+ jint *type_return1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListEntryGetFont\n");
+#endif
+
+ if (type_return)
+ type_return1 = (*env)->GetIntArrayElements(env, type_return, NULL);
+ rc = (jint) XmFontListEntryGetFont((XmFontListEntry)entry, (XmFontType *)type_return1);
+ if (type_return)
+ (*env)->ReleaseIntArrayElements(env, type_return, type_return1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListEntryLoad
+ * Signature: (I[BI[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListEntryLoad
+ (JNIEnv *env, jclass that, jint display, jbyteArray fontName, jint type, jbyteArray tag)
+{
+ char *fontName1=NULL, *tag1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListEntryLoad\n");
+#endif
+
+ if (fontName)
+ fontName1 = (char *)(*env)->GetByteArrayElements(env, fontName, NULL);
+ if (tag)
+ tag1 = (char *)(*env)->GetByteArrayElements(env, tag, NULL);
+ rc = (jint)XmFontListEntryLoad((Display *)display, fontName1, type, tag1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmFontListEntryLoad: call failed rc = %d\n", rc);
+#endif
+
+ if (fontName)
+ (*env)->ReleaseByteArrayElements(env, fontName, (jbyte *)fontName1, 0);
+ if (tag)
+ (*env)->ReleaseByteArrayElements(env, tag, (jbyte *)tag1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListFree
+ (JNIEnv *env, jclass that, jint list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListFree\n");
+#endif
+ XmFontListFree((XmFontList)list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListFreeFontContext
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListFreeFontContext
+ (JNIEnv *env, jclass that, jint context)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListFreeFontContext\n");
+#endif
+ XmFontListFreeFontContext((XmFontContext)context);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListInitFontContext
+ * Signature: ([II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListInitFontContext
+ (JNIEnv *env, jclass that, jintArray context, jint fontlist)
+{
+ jint *context1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListInitFontContext\n");
+#endif
+
+ if (context)
+ context1 = (*env)->GetIntArrayElements(env, context, NULL);
+ rc = XmFontListInitFontContext((XmFontContext *)context1, (XmFontList)fontlist);
+ if (context)
+ (*env)->ReleaseIntArrayElements(env, context, context1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListNextEntry
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListNextEntry
+ (JNIEnv *env, jclass that, jint context)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListNextEntry\n");
+#endif
+ return (jint) XmFontListNextEntry((XmFontContext) context);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmFontListCopy
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmFontListCopy
+ (JNIEnv *env, jclass that, jint fontlist)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmFontListCopy\n");
+#endif
+ return (jint) XmFontListCopy((XmFontList) fontlist);
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmGetAtomName
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetAtomName
+ (JNIEnv *env, jclass that, jint display, jint atom)
+{
+ return (jint) XmGetAtomName((Display *)display, (Atom)atom);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmGetFocusWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetFocusWidget
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmGetFocusWidget\n");
+#endif
+ return (jint) XmGetFocusWidget((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmGetXmDisplay
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetXmDisplay
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmGetXmDisplay\n");
+#endif
+ return (jint) XmGetXmDisplay((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmGetDragContext
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetDragContext
+ (JNIEnv *env, jclass that, jint widget, jint timestamp)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmGetDragContext\n");
+#endif
+ return (jint) XmGetDragContext((Widget)widget, (Time)timestamp);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmImMbLookupString
+ * Signature: (ILorg/eclipse/swt/internal/motif/XKeyEvent;[BI[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmImMbLookupString
+ (JNIEnv *env, jclass that, jint widget, jobject keyEvent, jbyteArray string, jint size, jintArray keysym, jintArray status)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jint *keysym1=NULL, *status1=NULL;
+ jbyte *string1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmImMbLookupString\n");
+#endif
+
+ if (keyEvent) {
+ lpxEvent = &xEvent;
+ cacheXkeyeventFids(env, keyEvent, &PGLOB(XkeyeventFc));
+ getXkeyeventFields(env, keyEvent, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ if (keysym)
+ keysym1 = (*env)->GetIntArrayElements(env, keysym, NULL);
+ if (status)
+ status1 = (*env)->GetIntArrayElements(env, status, NULL);
+
+ rc = (jint)XmImMbLookupString((Widget)widget, (XKeyPressedEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (int *)status1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmImMbLookupString: call failed rc = %d\n", rc);
+#endif
+
+ if (keyEvent) {
+ setXkeyeventFields(env, keyEvent, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ if (keysym)
+ keysym1 = (*env)->GetIntArrayElements(env, keysym, NULL);
+ if (status)
+ (*env)->ReleaseIntArrayElements(env, status, status1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmInternAtom
+ * Signature: (I[BZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmInternAtom
+ (JNIEnv *env, jclass that, jint display, jbyteArray name, jboolean only_if_exists)
+{
+ jbyte *name1;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmInternAtom\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ rc = (jint) XmInternAtom((Display *)display, (String)name1, only_if_exists);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmInternAtom: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListAddItemUnselected
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListAddItemUnselected
+ (JNIEnv *env, jclass that, jint list, jint xmString, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListAddItemUnselected\n");
+#endif
+ XmListAddItemUnselected((Widget)list, (XmString)xmString, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeleteAllItems
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeleteAllItems
+ (JNIEnv *env, jclass that, jint list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeleteAllItems\n");
+#endif
+ XmListDeleteAllItems((Widget)list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeleteItemsPos
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeleteItemsPos
+ (JNIEnv *env, jclass that, jint list, jint item_count, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeleteItemsPos\n");
+#endif
+ XmListDeleteItemsPos((Widget)list, item_count, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeletePos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeletePos
+ (JNIEnv *env, jclass that, jint list, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeletePos\n");
+#endif
+ XmListDeletePos((Widget)list, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeletePositions
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeletePositions
+ (JNIEnv *env, jclass that, jint list, jintArray position_list, jint position_count)
+{
+ jint *position_list1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeletePositions\n");
+#endif
+
+ if (position_list)
+ position_list1 = (*env)->GetIntArrayElements(env, position_list, NULL);
+ XmListDeletePositions((Widget)list, (int *)position_list1, position_count);
+ if (position_list)
+ (*env)->ReleaseIntArrayElements(env, position_list, position_list1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeselectAllItems
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeselectAllItems
+ (JNIEnv *env, jclass that, jint list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeselectAllItems\n");
+#endif
+ XmListDeselectAllItems((Widget)list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeselectPos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeselectPos
+ (JNIEnv *env, jclass that, jint list, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeselectPos\n");
+#endif
+ XmListDeselectPos((Widget)list, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListGetKbdItemPos
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListGetKbdItemPos
+ (JNIEnv *env, jclass that, jint list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListGetKbdItemPos\n");
+#endif
+ return (jint)XmListGetKbdItemPos((Widget)list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListGetSelectedPos
+ * Signature: (I[I[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListGetSelectedPos
+ (JNIEnv *env, jclass that, jint list, jintArray positions, jintArray count)
+{
+ jint *positions1=NULL, *count1=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListGetSelectedPos\n");
+#endif
+
+ if (positions)
+ positions1 = (*env)->GetIntArrayElements(env, positions, NULL);
+ if (count)
+ count1 = (*env)->GetIntArrayElements(env, count, NULL);
+ rc = (jboolean)XmListGetSelectedPos((Widget)list, (int **)positions1, (int *)count1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc != True && rc != False)
+ fprintf(stderr, "XmListGetSelectedPos: call failed rc = %d\n", rc);
+#endif
+
+ if (positions)
+ (*env)->ReleaseIntArrayElements(env, positions, positions1, 0);
+ if (count)
+ (*env)->ReleaseIntArrayElements(env, count, count1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListItemPos
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListItemPos
+ (JNIEnv *env, jclass that, jint list, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListItemPos\n");
+#endif
+ return (jint)XmListItemPos((Widget)list, (XmString)xmString);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListPosSelected
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListPosSelected
+ (JNIEnv *env, jclass that, jint list, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListPosSelected\n");
+#endif
+ return (jboolean)XmListPosSelected((Widget)list, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListReplaceItemsPosUnselected
+ * Signature: (I[III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListReplaceItemsPosUnselected
+ (JNIEnv *env, jclass that, jint list, jintArray newItems, jint item_count, jint position)
+{
+ jint *newItems1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListReplaceItemsPosUnselected\n");
+#endif
+
+ if (newItems)
+ newItems1 = (*env)->GetIntArrayElements(env, newItems, NULL);
+ XmListReplaceItemsPosUnselected((Widget)list, (XmString *)newItems1, item_count, position);
+ if (newItems)
+ (*env)->ReleaseIntArrayElements(env, newItems, newItems1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListSelectPos
+ * Signature: (IIZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListSelectPos
+ (JNIEnv *env, jclass that, jint list, jint position, jboolean notify)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListSelectPos\n");
+#endif
+ XmListSelectPos((Widget)list, position, notify);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListSetKbdItemPos
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListSetKbdItemPos
+ (JNIEnv *env, jclass that, jint list, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListSetKbdItemPos\n");
+#endif
+ return (jboolean)XmListSetKbdItemPos((Widget)list, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListSetPos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListSetPos
+ (JNIEnv *env, jclass that, jint list, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListSetPos\n");
+#endif
+ XmListSetPos((Widget)list, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListUpdateSelectedList
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListUpdateSelectedList
+ (JNIEnv *env, jclass that, jint list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListUpdateSelectedList\n");
+#endif
+ XmListUpdateSelectedList((Widget)list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmMainWindowSetAreas
+ * Signature: (IIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmMainWindowSetAreas
+ (JNIEnv *env, jclass that, jint widget, jint menu, jint command, jint hscroll, jint vscroll, jint wregion)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmMainWindowSetAreas\n");
+#endif
+ XmMainWindowSetAreas((Widget)widget, (Widget)menu, (Widget)command, (Widget)hscroll, (Widget)vscroll, (Widget)wregion);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmMenuShellWidgetClass
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmMenuShellWidgetClass
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmMenuShellWidgetClass\n");
+#endif
+ return (jint)xmMenuShellWidgetClass;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmMessageBoxGetChild
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmMessageBoxGetChild
+ (JNIEnv *env, jclass that, jint widget, jint child)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmMessageBoxGetChild\n");
+#endif
+ return (jint)XmMessageBoxGetChild((Widget)widget, child);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmProcessTraversal
+ * Signature: (II)
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmProcessTraversal
+ (JNIEnv *env, jclass that, jint widget, jint dir)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmProcessTraversal\n");
+#endif
+ return (jboolean) XmProcessTraversal((Widget)widget, dir);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmPushButtonWidgetClass
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmPushButtonWidgetClass
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmPushButtonWidgetClass\n");
+#endif
+ return (jint)xmPushButtonWidgetClass;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringCompare
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringCompare
+ (JNIEnv *env, jclass that, jint xmString1, jint xmString2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringCompare\n");
+#endif
+ return (jboolean) XmStringCompare((XmString)xmString1, (XmString)xmString2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringCreate
+ * Signature: ([B[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringCreate
+ (JNIEnv *env, jclass that, jbyteArray string, jbyteArray charset)
+{
+ jbyte *string1=NULL, *charset1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringCreate\n");
+#endif
+
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ if (charset)
+ charset1 = (*env)->GetByteArrayElements(env, charset, NULL);
+ rc = (jint) XmStringCreate((char *)string1, (char *)charset1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmStringCreate: call failed rc = %d\n", rc);
+#endif
+
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ if (charset)
+ (*env)->ReleaseByteArrayElements(env, charset, charset1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringCreateLocalized
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringCreateLocalized
+ (JNIEnv *env, jclass that, jbyteArray string)
+{
+ jbyte *string1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringCreateLocalized\n");
+#endif
+
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ rc = (jint)XmStringCreateLocalized((char *)string1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmStringCreateLocalized: call failed rc = %d\n", rc);
+#endif
+
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringCreateLtoR
+ * Signature: ([B[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringCreateLtoR
+ (JNIEnv *env, jclass that, jbyteArray string, jbyteArray charset)
+{
+ jbyte *string1=NULL, *charset1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringCreateLtoR\n");
+#endif
+
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ if (charset)
+ charset1 = (*env)->GetByteArrayElements(env, charset, NULL);
+ rc = (jint) XmStringCreateLtoR((char *)string1, (char *)charset1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmStringCreateLtoR: call failed rc = %d\n", rc);
+#endif
+
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ if (charset)
+ (*env)->ReleaseByteArrayElements(env, charset, charset1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringDraw
+ * Signature: (IIIIIIIIIILorg/eclipse/swt/internal/motif/XRectangle;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringDraw
+ (JNIEnv *env, jclass that, jint display, jint window, jint fontlist, jint xmString, jint gc, jint x, jint y, jint width, jint align, jint lay_dir, jobject clip)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "\n");
+#endif
+
+ if (clip) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, clip, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, clip, lpxRect, &PGLOB(XrectangleFc));
+ }
+ XmStringDraw((Display *)display, (Window)window, (XmFontList)fontlist, (XmString)xmString, (GC)gc, x, y, width, align, lay_dir, lpxRect);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringDrawImage
+ * Signature: (IIIIIIIIIILorg/eclipse/swt/internal/motif/XRectangle;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringDrawImage
+ (JNIEnv *env, jclass that, jint display, jint window, jint fontlist, jint xmString, jint gc, jint x, jint y, jint width, jint align, jint lay_dir, jobject clip)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringDrawImage\n");
+#endif
+
+ if (clip) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, clip, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, clip, lpxRect, &PGLOB(XrectangleFc));
+ }
+ XmStringDrawImage((Display *)display, window, (XmFontList)fontlist, (XmString)xmString, (GC)gc, x, y, width, align, lay_dir, lpxRect);
+ if (clip) {
+ setXrectangleFields(env, clip, lpxRect, &PGLOB(XrectangleFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringEmpty
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringEmpty
+ (JNIEnv *env, jclass that, jint s1)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringEmpty\n");
+#endif
+ return (jboolean) XmStringEmpty((XmString)s1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringFree
+ (JNIEnv *env, jclass that, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringFree\n");
+#endif
+ XmStringFree((XmString)xmString);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringGetLtoR
+ * Signature: (I[B[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringGetLtoR
+ (JNIEnv *env, jclass that, jint xmString, jbyteArray charset, jintArray text)
+{
+ jbyte *charset1=NULL;
+ jint *text1=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringGetLtoR\n");
+#endif
+
+ if (charset)
+ charset1 = (*env)->GetByteArrayElements(env, charset, NULL);
+ if (text)
+ text1 = (*env)->GetIntArrayElements(env, text, NULL);
+
+ rc = (jboolean) XmStringGetLtoR((XmString)xmString, (char *)charset1, (char **)text1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmStringGetLtoR: call failed rc = %d\n", rc);
+#endif
+
+ if (charset)
+ (*env)->ReleaseByteArrayElements(env, charset, charset1, 0);
+ if (text)
+ (*env)->ReleaseIntArrayElements(env, text, text1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringHeight
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringHeight
+ (JNIEnv *env, jclass that, jint fontlist, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringHeight\n");
+#endif
+ return (jint) XmStringHeight((XmFontList)fontlist, (XmString)xmString);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringWidth
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringWidth
+ (JNIEnv *env, jclass that, jint fontlist, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringWidth\n");
+#endif
+ return (jint) XmStringWidth((XmFontList)fontlist, (XmString)xmString);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextClearSelection
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextClearSelection
+ (JNIEnv *env, jclass that, jint widget, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextClearSelection\n");
+#endif
+ XmTextClearSelection((Widget)widget, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextCopy
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextCopy
+ (JNIEnv *env, jclass that, jint widget, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextCopy\n");
+#endif
+ return (jboolean)XmTextCopy((Widget)widget, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextCut
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextCut
+ (JNIEnv *env, jclass that, jint widget, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextCut\n");
+#endif
+ return (jboolean)XmTextCut((Widget)widget, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextDisableRedisplay
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextDisableRedisplay
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextDisableRedisplay\n");
+#endif
+ XmTextDisableRedisplay((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextEnableRedisplay
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextEnableRedisplay
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextEnableRedisplay\n");
+#endif
+ XmTextEnableRedisplay((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetInsertionPosition
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetInsertionPosition
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetInsertionPosition\n");
+#endif
+ return (jint) XmTextGetInsertionPosition((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetLastPosition
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetLastPosition
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetLastPosition\n");
+#endif
+ return (jint) XmTextGetLastPosition((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetMaxLength
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetMaxLength
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetMaxLength\n");
+#endif
+ return (jint) XmTextGetMaxLength((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetSelection
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetSelection
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetSelection\n");
+#endif
+ return (jint) XmTextGetSelection((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetSelectionPosition
+ * Signature: (I[I[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetSelectionPosition
+ (JNIEnv *env, jclass that, jint widget, jintArray left, jintArray right)
+{
+ jint *left1=NULL,*right1=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetSelectionPosition\n");
+#endif
+
+ if (left)
+ left1 = (*env)->GetIntArrayElements(env, left, NULL);
+ if (right)
+ right1 = (*env)->GetIntArrayElements(env, right, NULL);
+ rc = (jboolean) XmTextGetSelectionPosition((Widget)widget, (XmTextPosition *)left1, (XmTextPosition *)right1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc != True && rc != False)
+ fprintf(stderr, "XmTextGetSelectionPosition: call failed rc = %d\n", rc);
+#endif
+
+ if (left)
+ (*env)->ReleaseIntArrayElements(env, left, left1, 0);
+ if (right)
+ (*env)->ReleaseIntArrayElements(env, right, right1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetString
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetString
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetString\n");
+#endif
+ return (jint) XmTextGetString((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetSubstring
+ * Signature: (IIII[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetSubstring
+ (JNIEnv *env, jclass that, jint widget, jint start, jint num_chars, jint buffer_size, jbyteArray buffer)
+{
+ jbyte *buffer1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetSubstring\n");
+#endif
+
+ if (buffer)
+ buffer1 = (*env)->GetByteArrayElements(env, buffer, NULL);
+ rc = (jint)XmTextGetSubstring((Widget)widget, start, num_chars, buffer_size, (char *)buffer1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmTextGetSubstring: call failed rc = %d\n", rc);
+#endif
+
+ if (buffer)
+ (*env)->ReleaseByteArrayElements(env, buffer, buffer1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextGetSubstringWcs
+ * Signature: (IIII[C)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextGetSubstringWcs
+ (JNIEnv *env, jclass that, jint widget, jint start, jint num_chars, jint buffer_size, jcharArray buffer)
+{
+ jchar *buffer1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextGetSubstringWcs\n");
+#endif
+
+ if (buffer)
+ buffer1 = (*env)->GetCharArrayElements(env, buffer, NULL);
+
+ rc = (jint)XmTextGetSubstringWcs((Widget) widget, (XmTextPosition) start, num_chars, buffer_size, (wchar_t *) buffer1);
+
+ if (buffer)
+ (*env)->ReleaseCharArrayElements(env, buffer, buffer1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextInsert
+ * Signature: (II[B)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextInsert
+ (JNIEnv *env, jclass that, jint widget, jint position, jbyteArray value)
+{
+ jbyte *value1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextInsert\n");
+#endif
+
+ if (value)
+ value1 = (*env)->GetByteArrayElements(env, value, NULL);
+ XmTextInsert((Widget)widget, position, (char *)value1);
+ if (value)
+ (*env)->ReleaseByteArrayElements(env, value, value1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextPaste
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextPaste
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextPaste\n");
+#endif
+ (jboolean) XmTextPaste((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextFieldPaste
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextFieldPaste
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextFieldPaste\n");
+#endif
+ (jboolean) XmTextFieldPaste((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextRemove
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextRemove
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextRemove\n");
+#endif
+ return (jboolean) XmTextRemove((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextPosToXY
+ * Signature: (II[S[S)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextPosToXY
+ (JNIEnv *env, jclass that, jint widget, jint position, jshortArray x, jshortArray y)
+{
+ jshort *x1=NULL, *y1=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextPosToXY\n");
+#endif
+
+ if (x)
+ x1 = (*env)->GetShortArrayElements(env, x, NULL);
+ if (y)
+ y1 = (*env)->GetShortArrayElements(env, y, NULL);
+ rc = (jboolean) XmTextPosToXY((Widget)widget, (XmTextPosition)position, (Position *)x1, (Position *)y1);
+ if (y)
+ (*env)->ReleaseShortArrayElements(env, y, y1, 0);
+ if (x)
+ (*env)->ReleaseShortArrayElements(env, x, x1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextReplace
+ * Signature: (III[B)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextReplace
+ (JNIEnv *env, jclass that, jint widget, jint from_pos, jint to_pos, jbyteArray value)
+{
+ jbyte *value1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextReplace\n");
+#endif
+
+ if (value)
+ value1 = (*env)->GetByteArrayElements(env, value, NULL);
+
+ XmTextReplace((Widget)widget, from_pos, to_pos, (char *)value1);
+
+ if (value)
+ (*env)->ReleaseByteArrayElements(env, value, value1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextScroll
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextScroll
+ (JNIEnv *env, jclass that, jint widget, jint lines)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextScroll\n");
+#endif
+ XmTextScroll((Widget)widget, lines);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextSetEditable
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextSetEditable
+ (JNIEnv *env, jclass that, jint widget, jboolean editable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextSetEditable\n");
+#endif
+ XmTextSetEditable((Widget)widget, editable);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextSetHighlight
+ * Signature: (IIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextSetHighlight
+ (JNIEnv *env, jclass that, jint widget, jint left, jint right, jint mode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextSetHighlight\n");
+#endif
+ XmTextSetHighlight((Widget)widget, left, right, mode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextSetInsertionPosition
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextSetInsertionPosition
+ (JNIEnv *env, jclass that, jint widget, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextSetInsertionPosition\n");
+#endif
+ XmTextSetInsertionPosition((Widget)widget, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextSetMaxLength
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextSetMaxLength
+ (JNIEnv *env, jclass that, jint widget, jint max_length)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextSetMaxLength\n");
+#endif
+ XmTextSetMaxLength((Widget)widget, max_length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextSetSelection
+ * Signature: (IIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextSetSelection
+ (JNIEnv *env, jclass that, jint widget, jint first, jint last, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextSetSelection\n");
+#endif
+ XmTextSetSelection((Widget)widget, first, last, time);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextSetString
+ * Signature: (I[B)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextSetString
+ (JNIEnv *env, jclass that, jint widget, jbyteArray value)
+{
+ jbyte *value1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextSetString\n");
+#endif
+
+ if (value)
+ value1 = (*env)->GetByteArrayElements(env, value, NULL);
+ XmTextSetString((Widget)widget, (char *)value1);
+ if (value)
+ (*env)->ReleaseByteArrayElements(env, value, value1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method:
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextShowPosition
+ (JNIEnv *env, jclass that, jint widget, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextShowPosition\n");
+#endif
+ XmTextShowPosition((Widget)widget, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmUpdateDisplay
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmUpdateDisplay
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmUpdateDisplay\n");
+#endif
+ XmUpdateDisplay((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmWidgetGetDisplayRect
+ * Signature: (ILorg/eclipse/swt/internal/motif/XRectangle;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmWidgetGetDisplayRect
+ (JNIEnv *env, jclass that, jint region, jobject rectangle)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmWidgetGetDisplayRect\n");
+#endif
+
+ if (rectangle) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, rectangle, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ rc = (jboolean) XmWidgetGetDisplayRect((Widget)region, (XRectangle *)lpxRect);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmWidgetGetDisplayRect: call failed rc = %d\n", rc);
+#endif
+
+ if (rectangle) {
+ setXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmbLookupString
+ * Signature: (ILorg/eclipse/swt/internal/motif/XInputEvent;[BI[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmbLookupString
+ (JNIEnv *env, jclass that, jint widget, jobject event, jbyteArray string, jint size, jintArray keysym, jintArray status)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jint *keysym1=NULL, *status1=NULL;
+ jbyte *string1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmbLookupString\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXkeyeventFids(env, event, &PGLOB(XkeyeventFc));
+ getXkeyeventFields(env, event, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ if (keysym)
+ keysym1 = (*env)->GetIntArrayElements(env, keysym, NULL);
+ if (status)
+ status1 = (*env)->GetIntArrayElements(env, status, NULL);
+
+ rc = (jint)XmImMbLookupString((Widget)widget, (XKeyPressedEvent *)lpxEvent, (char *)string1, size, (KeySym *)keysym1, (int *)status1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmImMbLookupString: call failed rc = %d\n", rc);
+#endif
+
+ if (event) {
+ setXkeyeventFields(env, event, lpxEvent, &PGLOB(XkeyeventFc));
+ }
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ if (keysym)
+ keysym1 = (*env)->GetIntArrayElements(env, keysym, NULL);
+ if (status)
+ (*env)->ReleaseIntArrayElements(env, status, status1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAddCallback
+ * Signature: (IIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAddCallback
+ (JNIEnv *env, jclass that, jint widget, jint callback_name, jint callback, jint client_data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAddCallback\n");
+#endif
+ XtAddCallback((Widget)widget, (String)callback_name, (XtCallbackProc)callback, (XtPointer)client_data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAddEventHandler
+ * Signature: (IIZII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAddEventHandler
+ (JNIEnv *env, jclass that, jint widget, jint event_mask, jboolean nonmaskable, jint proc, jint client_data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAddEventHandler\n");
+#endif
+ XtAddEventHandler((Widget)widget, event_mask, nonmaskable, (XtEventHandler)proc, (XtPointer)client_data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAddExposureToRegion
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAddExposureToRegion
+ (JNIEnv *env, jclass that, jint event, jint region)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAddExposureToRegion\n");
+#endif
+ XtAddExposureToRegion((XEvent *)event, (Region)region);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppAddTimeOut
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppAddTimeOut
+ (JNIEnv *env, jclass that, jint applicationContext, jint interval, jint procedure, jint clientData)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppAddTimeOut\n");
+#endif
+ return (jint) XtAppAddTimeOut((XtAppContext)applicationContext, interval, (XtTimerCallbackProc)procedure, (XtPointer)clientData);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppCreateShell
+ * Signature: ([B[BII[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppCreateShell
+ (JNIEnv *env, jclass that, jbyteArray appName, jbyteArray appClass, jint widgetClass,
+ jint display, jintArray argList, jint argCount)
+{
+ jbyte *appName1 = NULL;
+ jbyte *appClass1 = NULL;
+ jint *argList1 = NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppCreateShell\n");
+#endif
+
+ if (appName)
+ appName1 = (*env)->GetByteArrayElements(env, appName, NULL);
+ if (appClass)
+ appClass1 = (*env)->GetByteArrayElements(env, appClass, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+
+/* fprintf(stderr, "XtAppCreateShell: appName1=%d appClass1=%d widgetClass=%d display=%d arglist1=%d argCount=%d\n",
+ appName1, appClass1, widgetClass, display, argList1, argCount);
+*/
+ rc = (jint) XtAppCreateShell((String)appName1, (String)appClass1, (WidgetClass)widgetClass, (Display *)display, (ArgList)argList1, argCount);
+
+/* fprintf(stderr, "After XtAppCreateShell: rc=%d\n", rc); */
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XtAppCreateShell: call failed rc = %d\n", rc);
+#endif
+
+ if (appName)
+ (*env)->ReleaseByteArrayElements(env, appName, appName1, 0);
+ if (appClass)
+ (*env)->ReleaseByteArrayElements(env, appClass, appClass1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppNextEvent
+ * Signature: (ILorg/eclipse/swt/internal/motif/XAnyEvent;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppNextEvent
+ (JNIEnv *env, jclass that, jint appContext, jobject event)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppNextEvent\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ XtAppNextEvent((XtAppContext)appContext, lpxEvent);
+
+#ifdef EVENT_TRACE
+ fprintf(stderr, "type = %d, serial = %d, send_event = %d, display = %x, window = %x \n",
+ xEvent.type, xEvent.xany.serial, xEvent.xany.send_event, xEvent.xany.display, xEvent.xany.window);
+#endif
+
+ if (event) {
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppPeekEvent
+ * Signature: (ILorg/eclipse/swt/internal/motif/XAnyEvent)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppPeekEvent
+ (JNIEnv *env, jclass that, jint appContext, jobject event)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jboolean rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppPeekEvent\n");
+#endif
+
+ rc = (jboolean) XtAppPeekEvent((XtAppContext)appContext, &xEvent);
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppPending
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppPending
+ (JNIEnv *env, jclass that, jint appContext)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppPending\n");
+#endif
+ return (jint) XtAppPending((XtAppContext)appContext);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppProcessEvent
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppProcessEvent
+ (JNIEnv *env, jclass that, jint appContext, jint inputMask)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppProcessEvent\n");
+#endif
+ XtAppProcessEvent((XtAppContext)appContext, inputMask);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppSetErrorHandler
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppSetErrorHandler
+ (JNIEnv *env, jclass that, jint app_context, jint handler)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppSetErrorHandler\n");
+#endif
+ return (jint) XtAppSetErrorHandler((XtAppContext)app_context, (XtErrorHandler)handler);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtAppSetWarningHandler
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtAppSetWarningHandler
+ (JNIEnv *env, jclass that, jint app_context, jint handler)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtAppSetWarningHandler\n");
+#endif
+ return (jint) XtAppSetWarningHandler((XtAppContext)app_context, (XtErrorHandler)handler);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtBuildEventMask
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtBuildEventMask
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtBuildEventMask\n");
+#endif
+ return (jint) XtBuildEventMask((Widget) widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCallActionProc
+ * Signature: (I[BLorg/eclipse/swt/internal/motif/XAnyEvent;[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCallActionProc
+ (JNIEnv *env, jclass that, jint widget, jbyteArray action, jobject event, jintArray params, jint num_params)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jbyte *action1=NULL;
+ jint *params1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCallActionProc\n");
+#endif
+ if (action)
+ action1 = (*env)->GetByteArrayElements(env, action, NULL);
+ if (params)
+ params1 = (*env)->GetIntArrayElements(env, params, NULL);
+
+ XtCallActionProc((Widget)widget, (String)action1, lpxEvent, (String *)params1, num_params);
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+
+ if (action)
+ (*env)->ReleaseByteArrayElements(env, action, action1, 0);
+ if (params)
+ (*env)->ReleaseIntArrayElements(env, params, params1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtClass
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtClass
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtClass\n");
+#endif
+ return (jint) XtClass((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtConfigureWidget
+ * Signature: (IIIIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtConfigureWidget
+ (JNIEnv *env, jclass that, jint widget, jint x, jint y, jint width, jint height, jint borderWidth)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtConfigureWidget\n");
+#endif
+ XtConfigureWidget((Widget)widget, x, y, width, height, borderWidth);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCreateApplicationContext
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCreateApplicationContext
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCreateApplicationContext\n");
+#endif
+ return (jint) XtCreateApplicationContext();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCreatePopupShell
+ * Signature: ([BII[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCreatePopupShell
+ (JNIEnv *env, jclass that, jbyteArray name, jint widgetClass, jint parent, jintArray argList, jint argCount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCreatePopupShell\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+
+ rc = (jint) XtCreatePopupShell((String)name1, (WidgetClass)widgetClass, (Widget)parent, (ArgList)argList1, argCount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XtCreatePopupShell: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtDestroyApplicationContext
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtDestroyApplicationContext
+ (JNIEnv *env, jclass that, jint appContext)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtDestroyApplicationContext\n");
+#endif
+ XtDestroyApplicationContext((XtAppContext)appContext);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtDestroyWidget
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtDestroyWidget
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtDestroyWidget\n");
+#endif
+ XtDestroyWidget((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtDispatchEvent
+ * Signature: (Lorg/eclipse/swt/internal/motif/XAnyEvent;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtDispatchEvent
+ (JNIEnv *env, jclass that, jobject event)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtDispatchEvent\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ #ifdef EVENT_TRACE
+ fprintf(stderr, "type = %d, serial = %d, send_event = %d, display = %x, window = %x \n",
+ xEvent.type, xEvent.xany.serial, xEvent.xany.send_event, xEvent.xany.display, xEvent.xany.window);
+ #endif
+ }
+ return (jboolean) XtDispatchEvent(lpxEvent);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtDisplay
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtDisplay
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtDisplay\n");
+#endif
+ return (jint) XtDisplay((Widget)widget);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtDisplayToApplicationContext
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtDisplayToApplicationContext
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtDisplayToApplicationContext\n");
+#endif
+ return (jint) XtDisplayToApplicationContext((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtFree
+ (JNIEnv *env, jclass that, jint ptr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtFree\n");
+#endif
+ XtFree((char *)ptr);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtGetMultiClickTime
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtGetMultiClickTime
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtGetMultiClickTime\n");
+#endif
+ return (jint) XtGetMultiClickTime((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtGetValues
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtGetValues
+ (JNIEnv *env, jclass that, jint widget, jintArray argList, jint numArgs)
+{
+ jint *argList1=NULL;
+
+#ifdef LINUX
+ int values[numArgs];
+ int zeros[numArgs];
+ int i;
+#endif
+
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtGetValues\n");
+#endif
+
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+
+#ifdef LINUX
+ for (i = 0; i < numArgs; i++) {
+ zeros[i] = 0;
+ values[i] = 0;
+ if (argList1[i * 2 + 1] == 0) {
+ zeros[i] = 1;
+ argList1[i * 2 + 1] = (int)&values[i];
+ }
+ }
+#endif
+
+ XtGetValues((Widget)widget, (ArgList)argList1, numArgs);
+
+#ifdef LINUX
+ for (i = 0; i < numArgs; i++) {
+ if (zeros[i]) {
+ argList1[i * 2 + 1] = values[i];
+ }
+ }
+#endif
+
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtIsManaged
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtIsManaged
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtIsManaged\n");
+#endif
+ return (jboolean) XtIsManaged((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtIsRealized
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtIsRealized
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtIsRealized\n");
+#endif
+ return (jboolean) XtIsRealized((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtIsSubclass
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtIsSubclass
+ (JNIEnv *env, jclass that, jint widget, jint widgetClass)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtIsSubclass\n");
+#endif
+ return (jboolean) XtIsSubclass((Widget)widget, (WidgetClass)widgetClass);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtIsTopLevelShell
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtIsTopLevelShell
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtIsTopLevelShell\n");
+#endif
+ return (jboolean) XtIsTopLevelShell((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtIsWidget
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtIsWidget
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtIsWidget\n");
+#endif
+ return (jboolean)XtIsWidget((Widget)widget);
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtLastTimestampProcessed
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtLastTimestampProcessed
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtLastTimestampProcessed\n");
+#endif
+ return (jint)XtLastTimestampProcessed((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtMalloc
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtMalloc
+ (JNIEnv *env, jclass that, jint size)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtMalloc\n");
+#endif
+ return (jint) XtMalloc(size);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtManageChild
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtManageChild
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtManageChild\n");
+#endif
+ XtManageChild((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtMapWidget
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtMapWidget
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtMapWidget\n");
+#endif
+ XtMapWidget((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtMoveWidget
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtMoveWidget
+ (JNIEnv *env, jclass that, jint widget, jint x, jint y)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtMoveWidget\n");
+#endif
+ XtMoveWidget((Widget)widget, x, y);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtOpenDisplay
+ * Signature: (I[B[B[BII[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtOpenDisplay
+ (JNIEnv *env, jclass that, jint xtAppContext, jbyteArray displayName, jbyteArray applicationName,
+ jbyteArray applicationClass, jint options, jint numOptions, jintArray argc, jint argv)
+{
+ jbyte *displayName1 = NULL;
+ jbyte *applicationName1 = NULL;
+ jbyte *applicationClass1 = NULL;
+ jint *argc1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtOpenDisplay\n");
+#endif
+ if (displayName)
+ displayName1 = (*env)->GetByteArrayElements(env, displayName, NULL);
+ if (applicationName)
+ applicationName1 = (*env)->GetByteArrayElements(env, applicationName, NULL);
+ if (applicationClass)
+ applicationClass1 = (*env)->GetByteArrayElements(env, applicationClass, NULL);
+ if (argc)
+ argc1 = (*env)->GetIntArrayElements(env, argc, NULL);
+
+
+ rc = (jint) XtOpenDisplay((XtAppContext)xtAppContext, (String)displayName1, (String)applicationName1, (String)applicationClass1,
+ (XrmOptionDescRec *)options, numOptions, (int *)argc1, (char **)argv);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XtOpenDisplay: call failed rc = %d\n", rc);
+#endif
+
+ if (displayName)
+ (*env)->ReleaseByteArrayElements(env, displayName, displayName1, 0);
+ if (applicationName)
+ (*env)->ReleaseByteArrayElements(env, applicationName, applicationName1, 0);
+ if (applicationClass)
+ (*env)->ReleaseByteArrayElements(env, applicationClass, applicationClass1, 0);
+ if (argc)
+ (*env)->ReleaseIntArrayElements(env, argc, argc1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtParent
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtParent
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtParent\n");
+#endif
+ return (jint) XtParent((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtPopdown
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtPopdown
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtPopdown\n");
+#endif
+ XtPopdown((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtPopup
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtPopup
+ (JNIEnv *env, jclass that, jint widget, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtPopup\n");
+#endif
+ XtPopup((Widget)widget, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtQueryGeometry
+ * Signature: (ILorg/eclipse/swt/internal/motif/XtWidgetGeometryLorg/eclipse/swt/internal/motif/XtWidgetGeometry;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtQueryGeometry
+ (JNIEnv *env, jclass that, jint widget, jobject intended, jobject preferred_return)
+{
+ DECL_GLOB(pGlob)
+
+ XtWidgetGeometry intended1, preferred_return1, *lpIntended=NULL, *lpPreferred_return=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtQueryGeometry\n");
+#endif
+ lpPreferred_return = &preferred_return1;
+
+ /* The objects passed in here are both XtWidgetGeometry structures
+ ** If either or both are passed in, we only want to cache the fids once.
+ */
+ if (intended)
+ cacheXtwidgetgeometryFids(env, intended, &PGLOB(XtwidgetgeometryFc));
+ else if (preferred_return)
+ cacheXtwidgetgeometryFids(env, preferred_return, &PGLOB(XtwidgetgeometryFc));
+
+ if (intended) {
+ lpIntended = &intended1;
+ /* intended and preferred_return are the same class XtWidgetGeometry */
+ getXtwidgetgeometryFields(env, intended, lpIntended, &PGLOB(XtwidgetgeometryFc));
+ }
+ rc = (jint)XtQueryGeometry((Widget)widget, lpIntended, &preferred_return1);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XtQueryGeometry: call failed rc = %d\n", rc);
+#endif
+
+ if (preferred_return) {
+ setXtwidgetgeometryFields(env, preferred_return, &preferred_return1, &PGLOB(XtwidgetgeometryFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtRealizeWidget
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtRealizeWidget
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtRealizeWidget\n");
+#endif
+ XtRealizeWidget((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtRemoveTimeOut
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtRemoveTimeOut
+ (JNIEnv *env, jclass that, jint id)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtRemoveTimeOut\n");
+#endif
+ XtRemoveTimeOut(id);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtResizeWidget
+ * Signature: (IIII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtResizeWidget
+ (JNIEnv *env, jclass that, jint widget, jint width, jint height, jint borderWidth)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtResizeWidget\n");
+#endif
+ XtResizeWidget((Widget)widget, width, height, borderWidth);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtResizeWindow
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtResizeWindow
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtResizeWindow\n");
+#endif
+ XtResizeWindow((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtSetLanguageProc
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtSetLanguageProc
+ (JNIEnv *env, jclass that, jint appContext, jint languageProc, jint pointer)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtSetLanguageProc\n");
+#endif
+ return (jint) XtSetLanguageProc((XtAppContext)appContext, (XtLanguageProc)languageProc, (XtPointer)pointer);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtSetMappedWhenManaged
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtSetMappedWhenManaged
+ (JNIEnv *env, jclass that, jint widget, jboolean flag)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtSetMappedWhenManaged\n");
+#endif
+ XtSetMappedWhenManaged((Widget)widget, flag);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtSetValues
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtSetValues
+ (JNIEnv *env, jclass that, jint widget, jintArray argList, jint numArgs)
+{
+ jint *argList1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtSetValues\n");
+#endif
+
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ XtSetValues((Widget)widget, (ArgList)argList1, numArgs);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtToolkitInitialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtToolkitInitialize
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtToolkitInitialize\n");
+#endif
+ XtToolkitInitialize();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtTranslateCoords
+ * Signature: (ISS[S[S)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtTranslateCoords
+ (JNIEnv *env, jclass that, jint widget, jshort x, jshort y, jshortArray root_x, jshortArray root_y)
+{
+ jshort *root_x1=NULL,*root_y1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtTranslateCoords\n");
+#endif
+ if (root_x)
+ root_x1 = (*env)->GetShortArrayElements(env, root_x, NULL);
+ if (root_y)
+ root_y1 = (*env)->GetShortArrayElements(env, root_y, NULL);
+ XtTranslateCoords((Widget)widget, x, y, root_x1, root_y1);
+ if (root_x)
+ (*env)->ReleaseShortArrayElements(env, root_x, root_x1, 0);
+ if (root_y)
+ (*env)->ReleaseShortArrayElements(env, root_y, root_y1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtUnmanageChild
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtUnmanageChild
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtUnmanageChild\n");
+#endif
+ XtUnmanageChild((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtUnmapWidget
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtUnmapWidget
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtUnmapWidget\n");
+#endif
+ XtUnmapWidget((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtWindow
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtWindow
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtWindow\n");
+#endif
+ return (jint) XtWindow((Widget)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtWindowToWidget
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtWindowToWidget
+ (JNIEnv *env, jclass that, jint display, jint window)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtWindowToWidget\n");
+#endif
+ return (jint) XtWindowToWidget((Display *)display, window);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: strlen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_strlen
+ (JNIEnv *env, jclass that, jint string)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "strlen\n");
+#endif
+ return (jint) strlen((char *)string);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardCopy
+ * Signature: (III[B[BII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardCopy
+ (JNIEnv *env, jclass that, jint display, jint window, jint item_id, jbyteArray format_name, jbyteArray buffer, jint length, jint private_id, jintArray data_id)
+{
+ jbyte *format_name1 = NULL;
+ jbyte *buffer1 = NULL;
+ jint *data_id1 = NULL;
+ jint rc;
+
+ if (format_name)
+ format_name1 = (*env)->GetByteArrayElements(env, format_name, NULL);
+
+ if (buffer)
+ buffer1 = (*env)->GetByteArrayElements(env, buffer, NULL);
+
+ if (data_id)
+ data_id1 = (*env)->GetIntArrayElements(env, data_id, NULL);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardCopy\n");
+#endif
+
+ rc = (jint) XmClipboardCopy((Display *)display, (Window)window, (long)item_id, (char *)format_name1, (char *)buffer1, (unsigned long)length, private_id, (void *)data_id1);
+
+ if (format_name)
+ (*env)->ReleaseByteArrayElements(env, format_name, format_name1, 0);
+
+ if (buffer)
+ (*env)->ReleaseByteArrayElements(env, buffer, buffer1, 0);
+
+ if (data_id)
+ (*env)->ReleaseIntArrayElements(env, data_id, data_id1, 0);
+
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardEndCopy
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardEndCopy
+ (JNIEnv *env, jclass that, jint display, jint window, jint item_id)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardEndCopy\n");
+#endif
+
+ return (jint) XmClipboardEndCopy((Display *)display, (Window)window, (long)item_id );
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardStartCopy
+ * Signature: (IIIIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardStartCopy
+ (JNIEnv *env, jclass that, jint display, jint window, jint clip_label, jint timestamp, jint widget, jint callback, jintArray item_id)
+{
+ jint *item_id1 = NULL;
+ jint rc;
+
+ if (item_id)
+ item_id1 = (*env)->GetIntArrayElements(env, item_id, NULL);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardStartCopy\n");
+#endif
+
+ rc = (jint) XmClipboardStartCopy((Display *)display, (Window)window, (XmString)clip_label, timestamp, (Widget)widget, (XmCutPasteProc)callback, (long *)item_id1);
+
+ if (item_id)
+ (*env)->ReleaseIntArrayElements(env, item_id, item_id1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardInquireLength
+ * Signature: (II[B[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardInquireLength
+ (JNIEnv *env, jclass that, jint display, jint window, jbyteArray format_name, jintArray length)
+{
+ jbyte *format_name1 = NULL;
+ jint *length1 = NULL;
+ jint rc;
+
+ if (format_name)
+ format_name1 = (*env)->GetByteArrayElements(env, format_name, NULL);
+
+ if (length)
+ length1 = (*env)->GetIntArrayElements(env, length, NULL);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardInquireLength\n");
+#endif
+ rc = (jint) XmClipboardInquireLength((Display *)display, (Window)window, (char *)format_name1, (unsigned long *)length1);
+
+ if (format_name)
+ (*env)->ReleaseByteArrayElements(env, format_name, format_name1, 0);
+
+ if (length)
+ (*env)->ReleaseIntArrayElements(env, length, length1, 0);
+
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardInquireFormat
+ * Signature: (III[BI[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardInquireFormat
+ (JNIEnv *env, jclass that, jint display, jint window, int index, jbyteArray format_name_buf, int buffer_len, jintArray copied_len)
+{
+ jbyte *format_name_buf1 = NULL;
+ jint *copied_len1 = NULL;
+ jint rc;
+
+ if (format_name_buf)
+ format_name_buf1 = (*env)->GetByteArrayElements(env, format_name_buf, NULL);
+
+ if (copied_len)
+ copied_len1 = (*env)->GetIntArrayElements(env, copied_len, NULL);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardInquireFormat\n");
+#endif
+ rc = (jint) XmClipboardInquireFormat((Display *)display, (Window)window, index, (char *)format_name_buf1, buffer_len, (unsigned long *)copied_len1);
+
+ if (format_name_buf)
+ (*env)->ReleaseByteArrayElements(env, format_name_buf, format_name_buf1, 0);
+
+ if (copied_len)
+ (*env)->ReleaseIntArrayElements(env, copied_len, copied_len1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardInquireCount
+ * Signature: (II[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardInquireCount
+ (JNIEnv *env, jclass that, jint display, jint window, jintArray count, jintArray max_format_name_length)
+{
+ jint *count1 = NULL;
+ jint *max_format_name_length1 = NULL;
+ jint rc;
+
+ if (count)
+ count1 = (*env)->GetIntArrayElements(env, count, NULL);
+
+ if (max_format_name_length)
+ max_format_name_length1 = (*env)->GetIntArrayElements(env, max_format_name_length, NULL);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardInquireCount\n");
+#endif
+ rc = (jint) XmClipboardInquireCount((Display *)display, (Window)window, (int *)count1, (unsigned long *)max_format_name_length1);
+
+ if (count)
+ (*env)->ReleaseIntArrayElements(env, count, count1, 0);
+
+ if (max_format_name_length)
+ (*env)->ReleaseIntArrayElements(env, max_format_name_length, max_format_name_length1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardStartRetrieve
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardStartRetrieve
+ (JNIEnv *env, jclass that, jint display, jint window, jint timestamp)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardStartRetrieve\n");
+#endif
+ return (jint) XmClipboardStartRetrieve((Display *)display, (Window)window, timestamp);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardRetrieve
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardRetrieve
+ (JNIEnv *env, jclass that, jint display, jint window, jbyteArray format_name, jbyteArray buffer, jint length, jintArray num_bytes, jintArray private_id)
+{
+ jbyte *format_name1 = NULL;
+ jbyte *buffer1 = NULL;
+ jint *num_bytes1 = NULL;
+ jint *private_id1 = NULL;
+ jint rc;
+
+ if (format_name)
+ format_name1 = (*env)->GetByteArrayElements(env, format_name, NULL);
+
+ if (buffer)
+ buffer1 = (*env)->GetByteArrayElements(env, buffer, NULL);
+
+ if (num_bytes)
+ num_bytes1 = (*env)->GetIntArrayElements(env, num_bytes, NULL);
+
+ if (private_id)
+ private_id1 = (*env)->GetIntArrayElements(env, private_id, NULL);
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardRetrieve\n");
+#endif
+
+ rc = (jint) XmClipboardRetrieve((Display *)display, (Window)window, (char *)format_name1, (char *)buffer1, (unsigned long)length, (unsigned long *)num_bytes1, (void *)private_id1);
+
+ if (format_name)
+ (*env)->ReleaseByteArrayElements(env, format_name, format_name1, 0);
+
+ if (buffer)
+ (*env)->ReleaseByteArrayElements(env, buffer, buffer1, 0);
+
+ if (num_bytes)
+ (*env)->ReleaseIntArrayElements(env, num_bytes, num_bytes1, 0);
+
+ if (private_id)
+ (*env)->ReleaseIntArrayElements(env, private_id, private_id1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmClipboardEndRetrieve
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmClipboardEndRetrieve
+ (JNIEnv *env, jclass that, jint display, jint window)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmClipboardEndRetrieve\n");
+#endif
+ return (jint) XmClipboardEndRetrieve((Display *)display, (Window)window);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpmReadFileToPixmap
+ * Signature: (II[B[I[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpmReadFileToPixmap
+ (JNIEnv *env, jclass that, jint display, jint drawable, jbyteArray fileName, jintArray pixmap_return, jintArray shapemask_return, jint attributes)
+{
+#ifdef XPM
+ jint rc;
+ jbyte *fileName1 = NULL;
+ jint *pixmap_return1 = NULL;
+ jint *shapemask_return1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpmReadFileToPixmap\n");
+#endif
+ if (fileName) fileName1 = (*env)->GetByteArrayElements(env, fileName, NULL);
+ if (pixmap_return) pixmap_return1 = (*env)->GetIntArrayElements(env, pixmap_return, NULL);
+ if (shapemask_return) shapemask_return1 = (*env)->GetIntArrayElements(env, shapemask_return, NULL);
+
+ rc = (jint) XpmReadFileToPixmap((Display *)display,
+ drawable,
+ fileName1,
+ (Pixmap*) pixmap_return1,
+ (Pixmap*) shapemask_return1,
+ attributes);
+
+ if (fileName) (*env)->ReleaseByteArrayElements(env, fileName, fileName1, 0);
+ if (pixmap_return) (*env)->ReleaseIntArrayElements(env, pixmap_return, pixmap_return1, 0);
+ if (shapemask_return) (*env)->ReleaseIntArrayElements(env, shapemask_return, shapemask_return1, 0);
+ return rc;
+#endif
+#ifndef XPM
+ return -1;
+#endif
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateDrawnButton
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateDrawnButton
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateDrawnButton\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+
+ rc = (jint)XmCreateDrawnButton((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateDrawnButton: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringGenerate
+ * Signature: ([B[BI[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringGenerate
+ (JNIEnv *env, jclass that, jbyteArray text, jbyteArray tag, jint type, jbyteArray rendition)
+{
+ jbyte *text1 = NULL;
+ jbyte *tag1 = NULL;
+ jbyte *rendition1 = NULL;
+ jint rc = 0;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringGenerate\n");
+#endif
+ if (text) text1 = (*env)->GetByteArrayElements(env, text, NULL);
+ if (tag) tag1 = (*env)->GetByteArrayElements(env, tag, NULL);
+ if (rendition) rendition1 = (*env)->GetByteArrayElements(env, rendition, NULL);
+
+ rc = (jint) XmStringGenerate((XtPointer) text1, (XmStringTag) tag1, type, (XmStringTag) rendition1);
+
+ if (text) (*env)->ReleaseByteArrayElements(env, text, text1, 0);
+ if (tag) (*env)->ReleaseByteArrayElements(env, tag, tag1, 0);
+ if (rendition) (*env)->ReleaseByteArrayElements(env, rendition, rendition1, 0);
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmRenderTableAddRenditions
+ * Signature: (I[III)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_XmRenderTableAddRenditions
+ (JNIEnv *env, jclass that, jint oldTable, jintArray renditions, jint renditionCount, jint mergeMode)
+{
+ jint *renditionArray = NULL;
+ jint renderTable = 0;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmRenderTableAddRenditions\n");
+#endif
+ if (renditions) renditionArray = (*env)->GetIntArrayElements(env, renditions, NULL);
+ renderTable = (int) XmRenderTableAddRenditions((XmRenderTable) oldTable, (XmRendition*) renditionArray, renditionCount, mergeMode);
+ if (renditions) (*env)->ReleaseIntArrayElements(env, renditions, renditionArray, 0);
+ return renderTable;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmRenderTableFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmRenderTableFree
+ (JNIEnv *env, jclass that, jint renderTable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmRenderTableFree\n");
+#endif
+ XmRenderTableFree((XmRenderTable) renderTable);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmRenditionCreate
+ * Signature: (I[B[II)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_XmRenditionCreate
+ (JNIEnv *env, jclass that, jint widget, jbyteArray renditionTag, jintArray argList, jint argCount)
+{
+ jbyte *renditionTag1 = NULL;
+ jint *argList1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmRenditionCreate\n");
+#endif
+ if (renditionTag) renditionTag1 = (*env)->GetByteArrayElements(env, renditionTag, NULL);
+ if (argList) argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmRenditionCreate((Widget) widget, (XmStringTag) renditionTag1, (ArgList) argList1, argCount);
+ if (renditionTag) (*env)->ReleaseByteArrayElements(env, renditionTag, renditionTag1, 0);
+ if (argList) (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmRenditionFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmRenditionFree
+ (JNIEnv *env, jclass that, jint rendition)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmRenditionFree\n");
+#endif
+ XmRenditionFree((XmRendition) rendition);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTabCreate
+ * Signature: (IBBB[B)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTabCreate
+ (JNIEnv *env, jclass that, jint value, jbyte units, jbyte offsetModel, jbyte alignment, jbyteArray decimal)
+{
+ jbyte *decimal1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTabCreate\n");
+#endif
+ if (decimal) decimal1 = (*env)->GetByteArrayElements(env, decimal, NULL);
+ rc = (jint) XmTabCreate(value, units, offsetModel, alignment, (char*) decimal1);
+ if (decimal) (*env)->ReleaseByteArrayElements(env, decimal, decimal1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTabFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTabFree
+ (JNIEnv *env, jclass that, jint tab)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTabFree\n");
+#endif
+ XmTabFree((XmTab) tab);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTabListFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTabListFree
+ (JNIEnv *env, jclass that, jint tabList)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTabListFree\n");
+#endif
+ XmTabListFree((XmTabList) tabList);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTabListInsertTabs
+ * Signature: (I[III)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTabListInsertTabs
+ (JNIEnv *env, jclass that, jint oldList, jintArray tabs, jint tab_count, jint position)
+{
+ jint *tabs1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTabListInsertTabs\n");
+#endif
+ if (tabs) tabs1 = (*env)->GetIntArrayElements(env, tabs, NULL);
+ rc = (jint) XmTabListInsertTabs((XmTabList) oldList, (XmTab*) tabs1, tab_count, position);
+ if (tabs) (*env)->ReleaseIntArrayElements(env, tabs, tabs1, 0);
+ return rc;
+}
+
+
+/* ---- unused OS calls, kept here in case we use them later ---- */
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XBlackPixel
+ * Signature: (II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XBlackPixel
+ (JNIEnv *env, jclass that, jint display, jint screenNum)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XBlackPixel\n");
+#endif
+ return (jint) XBlackPixel((Display *)display, screenNum);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XChangeActivePointerGrab
+ * Signature: (IIII)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XChangeActivePointerGrab
+ (JNIEnv *env, jclass that, jint display, jint eventMask, jint cursor, jint time)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XChangeActivePointerGrab\n");
+#endif
+ XChangeActivePointerGrab((Display *)display, eventMask, (Cursor)cursor, (Time)time);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultGC
+ * Signature: (II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultGC
+ (JNIEnv *env, jclass that, jint display, jint screen_number)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultGC\n");
+#endif
+ return (jint) XDefaultGC((Display *)display, screen_number);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XNoOp
+ * Signature: (I)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XNoOp
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XNoOp\n");
+#endif
+ XNoOp((Display *)display);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XRootWindowOfScreen
+ * Signature: (I)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XRootWindowOfScreen
+ (JNIEnv *env, jclass that, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XRootWindowOfScreen\n");
+#endif
+ return (jint) XRootWindowOfScreen((Screen *)screen);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSendEvent
+ * Signature: (Lorg/eclipse/swt/internal/motif/XAnyEvent;)Z
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSendEvent
+ (JNIEnv *env, jclass that, jint display, jint w, jboolean propagate, jint event_mask, jobject event)
+{
+ XEvent xEvent, *lpxEvent=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSendEvent\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &XanyeventFc);
+ getXanyeventFields(env, event, lpxEvent, &XanyeventFc);
+ }
+ return (jint) XSendEvent((Display *)display, w, propagate, event_mask, lpxEvent);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateCascadeButton
+ * Signature: (I[B[II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateCascadeButton
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateCascadeButton\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateCascadeButton((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateCascadeButton: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateDrawnButton
+ * Signature: (I[B[II)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateDrawnButton
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateDrawnButton\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+
+ rc = (jint)XmCreateDrawnButton((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateDrawnButton: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}*/
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateRowColumn
+ * Signature: (I[B[II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateRowColumn
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray arglist, jint argcount)
+{
+ jint *arglist1=NULL;
+ jbyte *name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateRowColumn\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (arglist)
+ arglist1 = (*env)->GetIntArrayElements(env, arglist, NULL);
+
+ rc = (jint)XmCreateRowColumn((Widget)parent, (String)name1, (ArgList)arglist1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateRowColumn: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (arglist)
+ (*env)->ReleaseIntArrayElements(env, arglist, arglist1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmCreateScrolledWindow
+ * Signature: (I[B[II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmCreateScrolledWindow
+ (JNIEnv *env, jclass that, jint parent, jbyteArray name, jintArray argList, jint argcount)
+{
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmCreateScrolledWindow\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmCreateScrolledWindow((Widget)parent, (String)name1, (ArgList)argList1, argcount);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmCreateScrolledWindow: call failed rc = %d\n", rc);
+#endif
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmDestroyPixmap
+ * Signature: (II)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmDestroyPixmap
+ (JNIEnv *env, jclass that, jint screen, jint pixmap)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmDestroyPixmap\n");
+#endif
+ return (jboolean) XmDestroyPixmap((Screen *)screen, pixmap);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmGetPixmapByDepth
+ * Signature: (I[BIII)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmGetPixmapByDepth
+ (JNIEnv *env, jclass that, jint screen, jbyteArray image_name, jint foreground, jint background, jint depth)
+{
+ jbyte *image_name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmGetPixmapByDepth\n");
+#endif
+
+ if (image_name)
+ image_name1 = (*env)->GetByteArrayElements(env, image_name, NULL);
+
+ rc = (jint)XmGetPixmapByDepth((Screen *)screen, (char *)image_name1, foreground, background, depth);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XmGetPixmapByDepth: call failed rc = %d\n", rc);
+#endif
+
+ if (image_name)
+ (*env)->ReleaseByteArrayElements(env, image_name, image_name1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListAddItemsUnselected
+ * Signature: (IIII)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListAddItemsUnselected
+ (JNIEnv *env, jclass that, jint list, jint xmStringTable, jint item_count, jint position)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListAddItemsUnselected\n");
+#endif
+ XmListAddItemsUnselected((Widget)list, (XmString *)xmStringTable, item_count, position);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeleteItem
+ * Signature: (II)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeleteItem
+ (JNIEnv *env, jclass that, jint list, jint item)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeleteItem\n");
+#endif
+ XmListDeleteItem((Widget)list, (XmString)item);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListDeselectItem
+ * Signature: (II)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListDeselectItem
+ (JNIEnv *env, jclass that, jint list, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListDeselectItem\n");
+#endif
+ XmListDeselectItem((Widget)list, (XmString)xmString);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmListSelectItem
+ * Signature: (IIZ)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmListSelectItem
+ (JNIEnv *env, jclass that, jint list, jint xmString, jboolean notify)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmListSelectItem\n");
+#endif
+ XmListSelectItem((Widget)list, (XmString)xmString, notify);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringDrawUnderline
+ * Signature: (IIIIIIIIIILorg/eclipse/swt/internal/motif/XRectangle;I)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringDrawUnderline
+ (JNIEnv *env, jclass that, jint display, jint window, jint fontlist, jint xmString, jint gc, jint x, jint y, jint width, jint align, jint lay_dir, jobject clip, jint xmStringUnderline)
+{
+ XRectangle xRect, *lpxRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringDrawUnderline\n");
+#endif
+
+ if (clip) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, clip, &XrectangleFc);
+ getXrectangleFields(env, clip, lpxRect, &XrectangleFc);
+ }
+ XmStringDrawUnderline((Display *)display, window, (XmFontList)fontlist, (XmString)xmString, (GC)gc, x, y, width, align, lay_dir, lpxRect, (XmString)xmStringUnderline);
+ if (clip) {
+ setXrectangleFields(env, clip, lpxRect, &XrectangleFc);
+ }
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringLineCount
+ * Signature: (I)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringLineCount
+ (JNIEnv *env, jclass that, jint xmString)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringLineCount\n");
+#endif
+ return (jint) XmStringLineCount((XmString)xmString);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmTextRemove
+ * Signature: (I)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XmTextRemove
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmTextRemove\n");
+#endif
+ return (jboolean) XmTextRemove((Widget)widget);
+}
+*/
+
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCloseDisplay
+ * Signature: (I)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCloseDisplay
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCloseDisplay\n");
+#endif
+ XtCloseDisplay((Display *)display);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCallActionProc
+ * Signature: (I[BLorg/eclipse/swt/internal/motif/XAnyEvent;[BI)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCallActionProc
+ (JNIEnv *env, jclass that, jint widget, jbyteArray action, jobject event, jbyteArray params, jint num_params)
+{
+ XEvent xEvent, *lpxEvent=NULL;
+ jbyte *action1, *params1;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCallActionProc\n");
+#endif
+ if (action)
+ action1 = (*env)->GetByteArrayElements(env, action, NULL);
+ if (params)
+ params1 = (*env)->GetByteArrayElements(env, params, NULL);
+
+ XtCallActionProc((Widget)widget, (String)action1, lpxEvent, (String *)params1, num_params);
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &XanyeventFc);
+ setXanyeventFields(env, event, lpxEvent, &XanyeventFc);
+ }
+
+ if (action)
+ (*env)->ReleaseByteArrayElements(env, action, action1, 0);
+ if (params)
+ (*env)->ReleaseByteArrayElements(env, params, params1, 0);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCloseDisplay
+ * Signature: (I)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCloseDisplay
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCloseDisplay\n");
+#endif
+ XtCloseDisplay((Display *)display);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtCreateWidget
+ * Signature: ([BII[II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtCreateWidget
+ (JNIEnv *env, jclass that, jbyteArray name, jint widgetClass, jint parent, jintArray argList, jint argCount)
+{
+
+ jbyte *name1=NULL;
+ jint *argList1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtCreateWidget\n");
+#endif
+
+ if (name)
+ name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ if (argList)
+ argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XtCreateWidget((String)name1, (WidgetClass)widgetClass, (Widget)parent, (ArgList)argList1, argCount);
+#ifdef PRINT_FAILED_RCODES
+ if (rc == 0)
+ fprintf(stderr, "XtCreateWidget: call failed rc = %d\n", rc);
+#endif
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+ if (argList)
+ (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtRemoveCallback
+ * Signature: (IIII)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtRemoveCallback
+ (JNIEnv *env, jclass that, jint widget, jint callback_name, jint callback, jint client_data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtRemoveCallback\n");
+#endif
+ XtRemoveCallback((Widget)widget, (char *)callback_name, (XtCallbackProc)callback, (XtPointer)client_data);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtRemoveEventHandler
+ * Signature: (IIZII)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtRemoveEventHandler
+ (JNIEnv *env, jclass that, jint widget, jint event_mask, jboolean nonmaskable, jint proc, jint client_data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtRemoveEventHandler\n");
+#endif
+ XtRemoveEventHandler((Widget)widget, event_mask, nonmaskable, (XtEventHandler)proc, (XtPointer)client_data);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtScreen
+ * Signature: (I)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtScreen
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtScreen\n");
+#endif
+ return (jint) XtScreen((Widget)widget);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSelectInput
+ * Signature: (III)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XSelectInput
+ (JNIEnv *env, jclass that, jint display, jint window, jint mask)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSelectInput\n");
+#endif
+ XSelectInput((Display *)display, (Window)window, mask);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtIsSensitive
+ * Signature: (I)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtIsSensitive
+ (JNIEnv *env, jclass that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtIsSensitive\n");
+#endif
+ return (jboolean) XtIsSensitive((Widget)widget);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtSetSensitive
+ * Signature: (IZ)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtSetSensitive
+ (JNIEnv *env, jclass that, jint widget, jboolean sensitive)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtSetSensitive\n");
+#endif
+ XtSetSensitive((Widget)widget, sensitive);
+}
+*/
+
+/* ---- unused OS calls end here ---- */
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmParseMappingCreate
+ * Signature: ([II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmParseMappingCreate
+ (JNIEnv *env, jclass that, jintArray argList, jint numArgs)
+{
+ jint *argList1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmParseMappingCreate\n");
+#endif
+ if (argList) argList1 = (*env)->GetIntArrayElements(env, argList, NULL);
+ rc = (jint) XmParseMappingCreate((ArgList)argList1, numArgs);
+ if (argList) (*env)->ReleaseIntArrayElements(env, argList, argList1, 0);
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmParseMappingFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmParseMappingFree
+ (JNIEnv *env, jclass that, jint parseMapping)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmParseMappingFree\n");
+#endif
+ XmParseMappingFree((XmParseMapping) parseMapping);
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmParseTableFree
+ * Signature: ([II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XmParseTableFree
+ (JNIEnv *env, jclass that, jintArray parseTable, jint mappingCount)
+{
+ jint *parseTable1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmParseTableFree\n");
+#endif
+ if (parseTable) {
+ parseTable1 = (*env)->GetIntArrayElements(env, parseTable, NULL);
+ XmParseTableFree((XmParseTable) parseTable1, mappingCount);
+ (*env)->ReleaseIntArrayElements(env, parseTable, parseTable1, 0);
+ }
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringComponentCreate
+ * Signature: (II[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringComponentCreate
+ (JNIEnv *env, jclass that, jint type, jint length, jbyteArray value)
+{
+ jbyte* value1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringComponentCreate\n");
+#endif
+ if (value) value1 = (*env)->GetByteArrayElements(env, value, NULL);
+ rc = (jint) XmStringComponentCreate(type, length, (XtPointer) value1);
+ if (value) (*env)->ReleaseByteArrayElements(env, value, value1, 0);
+
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringParseText
+ * Signature: ([BI[BI[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringParseText
+ (JNIEnv *env, jclass that, jbyteArray text, jint textEnd, jbyteArray tag, jint tagType, jintArray parseTable, jint parseCount, jint callData)
+{
+ jbyte* text1 = NULL;
+ jbyte* tag1 = NULL;
+ jint* parseTable1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringParseText\n");
+#endif
+ if (text) text1 = (*env)->GetByteArrayElements(env, text, NULL);
+ if (tag) tag1 = (*env)->GetByteArrayElements(env, tag, NULL);
+ if (parseTable) parseTable1 = (*env)->GetIntArrayElements(env, parseTable, NULL);
+ rc = (jint) XmStringParseText(
+ (XtPointer) text1,
+ (XtPointer*) textEnd,
+ (XmStringTag) tag1,
+ tagType,
+ (XmParseTable) parseTable1,
+ parseCount,
+ (XtPointer) callData);
+ if (text) (*env)->ReleaseByteArrayElements(env, text, text1, 0);
+ if (tag) (*env)->ReleaseByteArrayElements(env, tag, tag1, 0);
+ if (parseTable) (*env)->ReleaseIntArrayElements(env, parseTable, parseTable1, 0);
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XmStringUnparse
+ * Signature: (I[BII[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XmStringUnparse
+ (JNIEnv *env, jclass that, jint xmString, jbyteArray tag, jint tagType, jint outputType, jintArray parseTable, jint parseCount, jint parseModel)
+{
+ jbyte* tag1 = NULL;
+ jint* parseTable1 = NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XmStringUnparse\n");
+#endif
+ if (tag) tag1 = (*env)->GetByteArrayElements(env, tag, NULL);
+ if (parseTable) parseTable1 = (*env)->GetIntArrayElements(env, parseTable, NULL);
+ rc = (jint) XmStringUnparse((XmString) xmString,
+ (XmStringTag) tag1,
+ tagType,
+ outputType,
+ (XmParseTable) parseTable1,
+ parseCount,
+ parseModel);
+ if (tag) (*env)->ReleaseByteArrayElements(env, tag, tag1, 0);
+ if (parseTable) (*env)->ReleaseIntArrayElements(env, parseTable, parseTable1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtParseTranslationTable
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XtParseTranslationTable
+ (JNIEnv *env, jclass that, jbyteArray string)
+{
+ jint rc;
+ jbyte *string1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtParseTranslationTable\n");
+#endif
+ if (string) string1 = (*env)->GetByteArrayElements(env, string, NULL);
+ rc = (jint) XtParseTranslationTable((String) string1);
+ if (string) (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtOverrideTranslations
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XtOverrideTranslations
+ (JNIEnv *env, jclass that, jint w, jint translations)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtOverrideTranslations\n");
+#endif
+ XtOverrideTranslations((Widget) w, (XtTranslations) translations);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCheckIfEvent
+ * Signature: (ILorg/eclipse/swt/internal/motif/XAnyEvent;II)Z
+ */
+typedef Bool (*PredicateFunc)();
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XCheckIfEvent
+ (JNIEnv *env, jclass that, jint display, jobject event, jint predicate, jint arg)
+{
+ DECL_GLOB(pGlob)
+ XEvent xEvent, *lpxEvent=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCheckIfEvent\n");
+#endif
+
+ if (event) {
+ lpxEvent = &xEvent;
+ cacheXanyeventFids(env, event, &PGLOB(XanyeventFc));
+ getXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ rc = (jboolean)XCheckIfEvent((Display *)display, lpxEvent, (PredicateFunc) predicate, (void *) arg);
+
+#ifdef PRINT_FAILED_RCODES
+ if (rc != True && rc != False)
+ fprintf(stderr, "XCheckIfEvent: call failed rc = %d\n", rc);
+#endif
+
+ if (event) {
+ setXanyeventFields(env, event, lpxEvent, &PGLOB(XanyeventFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XtToolkitThreadInitialize
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_motif_OS_XtToolkitThreadInitialize
+ (JNIEnv *env, jclass that)
+{
+ DECL_GLOB(pGlob)
+ /*
+ * WARNING: When running under VA/Java, XtToolkitThreadInitialize
+ * is not called because this hangs VA/Java and SWT.
+ */
+ if (pGlob->vajava) return;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtToolkitThreadInitialize\n");
+#endif
+ return (jboolean) XtToolkitThreadInitialize ();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: Call
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_Call
+ (JNIEnv *env, jclass that, jint proc, jint arg0, jint arg1)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Call\n");
+#endif
+ return (*((jint (*)(jint, jint))proc)) (arg0, arg1);
+}
+
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XGetErrorText
+ (JNIEnv *env, jclass that, jint display, jint code, jbyteArray buffer_return, jint length)
+{
+ jint rc;
+ jbyte *buffer_return1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XtParseTranslationTable\n");
+#endif
+ if (buffer_return) buffer_return1 = (*env)->GetByteArrayElements(env, buffer_return, NULL);
+ XGetErrorText ((Display *)display, code, buffer_return1, length);
+ if (buffer_return) (*env)->ReleaseByteArrayElements(env, buffer_return, buffer_return1, 0);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XSetIOErrorHandler
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XSetIOErrorHandler
+ (JNIEnv *env, jclass that, jint handler)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XSetIOErrorHandler\n");
+#endif
+ return (jint) XSetIOErrorHandler((XIOErrorHandler)handler);
+}
+
+/*
+ * ======== Start printing functions ========
+ */
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpCreateContext
+ * Signature: (I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpCreateContext
+ (JNIEnv *env, jclass that, jint display, jbyteArray printer_name)
+{
+ jbyte *printer_name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpCreateContext\n");
+#endif
+ if (printer_name)
+ printer_name1 = (*env)->GetByteArrayElements(env, printer_name, NULL);
+ rc = (jint) XpCreateContext((Display *)display, (char *)printer_name1);
+ if (printer_name)
+ (*env)->ReleaseByteArrayElements(env, printer_name, printer_name1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpGetPrinterList
+ * Signature: (I[B[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpGetPrinterList
+ (JNIEnv *env, jclass that, jint display, jbyteArray printer_name, jintArray list_count)
+{
+ jbyte *printer_name1=NULL;
+ jint *list_count1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpGetPrinterList\n");
+#endif
+ if (printer_name)
+ printer_name1 = (*env)->GetByteArrayElements(env, printer_name, NULL);
+ if (list_count)
+ list_count1 = (*env)->GetIntArrayElements(env, list_count, NULL);
+ rc = (jint) XpGetPrinterList((Display *)display, (char *)printer_name1, (int *)list_count1);
+ if (printer_name)
+ (*env)->ReleaseByteArrayElements(env, printer_name, printer_name1, 0);
+ if (list_count)
+ (*env)->ReleaseIntArrayElements(env, list_count, list_count1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpFreePrinterList
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpFreePrinterList
+ (JNIEnv *env, jclass that, jint printer_list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpFreePrinterList\n");
+#endif
+ XpFreePrinterList((XPPrinterList)printer_list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpGetAttributes
+ * Signature: (IIB)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpGetAttributes
+ (JNIEnv *env, jclass that, jint display, jint print_context, jbyte type)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpGetAttributes\n");
+#endif
+ return (jint) XpGetAttributes((Display *)display, (XPContext)print_context, (XPAttributes)type);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpGetOneAttribute
+ * Signature: (IIB[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpGetOneAttribute
+ (JNIEnv *env, jclass that, jint display, jint print_context, jbyte type, jbyteArray attribute_name)
+{
+ jbyte *attribute_name1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpGetOneAttribute\n");
+#endif
+ if (attribute_name)
+ attribute_name1 = (*env)->GetByteArrayElements(env, attribute_name, NULL);
+ rc = (jint) XpGetOneAttribute((Display *)display, (XPContext)print_context, (XPAttributes)type, (char *)attribute_name1);
+ if (attribute_name)
+ (*env)->ReleaseByteArrayElements(env, attribute_name, attribute_name1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpSetAttributes
+ * Signature: (IIB[BB)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpSetAttributes
+ (JNIEnv *env, jclass that, jint display, jint print_context, jbyte type, jbyteArray pool, jbyte replacement_rule)
+{
+ jbyte *pool1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpSetAttributes\n");
+#endif
+ if (pool)
+ pool1 = (*env)->GetByteArrayElements(env, pool, NULL);
+ XpSetAttributes((Display *)display, (XPContext)print_context, (XPAttributes)type, (char *)pool1, (XPAttrReplacement)replacement_rule);
+ if (pool)
+ (*env)->ReleaseByteArrayElements(env, pool, pool1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpSetContext
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpSetContext
+ (JNIEnv *env, jclass that, jint display, jint print_context)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpSetContext\n");
+#endif
+ XpSetContext((Display *)display, (XPContext)print_context);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpGetScreenOfContext
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpGetScreenOfContext
+ (JNIEnv *env, jclass that, jint display, jint print_context)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpGetScreenOfContext\n");
+#endif
+ return (jint) XpGetScreenOfContext((Display *)display, (XPContext)print_context);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpDestroyContext
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpDestroyContext
+ (JNIEnv *env, jclass that, jint display, jint print_context)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpDestroyContext\n");
+#endif
+ XpDestroyContext((Display *)display, (XPContext)print_context);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpGetPageDimensions
+ * Signature: (II[S[SLorg/eclipse/swt/internal/motif/XRectangle;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpGetPageDimensions
+ (JNIEnv *env, jclass that, jint display, jint print_context, jshortArray width, jshortArray height, jobject rectangle)
+{
+ DECL_GLOB(pGlob)
+ XRectangle xRect, *lpxRect=NULL;
+ jshort *width1=NULL, *height1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpGetPageDimensions\n");
+#endif
+
+ if (rectangle) {
+ lpxRect = &xRect;
+ cacheXrectangleFids(env, rectangle, &PGLOB(XrectangleFc));
+ getXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ if (width)
+ width1 = (*env)->GetShortArrayElements(env, width, NULL);
+ if (height)
+ height1 = (*env)->GetShortArrayElements(env, height, NULL);
+ rc = (jint) XpGetPageDimensions((Display *)display, (XPContext)print_context,
+ (unsigned short *)width1, (unsigned short *)height1, (XRectangle *)lpxRect);
+ if (rectangle) {
+ setXrectangleFields(env, rectangle, lpxRect, &PGLOB(XrectangleFc));
+ }
+ if (width)
+ (*env)->ReleaseShortArrayElements(env, width, width1, 0);
+ if (height)
+ (*env)->ReleaseShortArrayElements(env, height, height1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpStartJob
+ * Signature: (IB)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpStartJob
+ (JNIEnv *env, jclass that, jint display, jbyte save_data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpStartJob\n");
+#endif
+ XpStartJob((Display *)display, (XPSaveData)save_data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpStartPage
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpStartPage
+ (JNIEnv *env, jclass that, jint display, jint window)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpStartPage\n");
+#endif
+ XpStartPage((Display *)display, (Window)window);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpEndPage
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpEndPage
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpEndPage\n");
+#endif
+ XpEndPage((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpEndJob
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpEndJob
+ (JNIEnv *env, jclass that, jint display)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpEndJob\n");
+#endif
+ XpEndJob((Display *)display);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpCancelJob
+ * Signature: (IZ)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XpCancelJob
+ (JNIEnv *env, jclass that, jint display, jboolean discard)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpCancelJob\n");
+#endif
+ XpCancelJob((Display *)display, discard);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultGCOfScreen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultGCOfScreen
+ (JNIEnv *env, jclass that, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultGCOfScreen\n");
+#endif
+ return (jint) XDefaultGCOfScreen((Screen *)screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDefaultColormapOfScreen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XDefaultColormapOfScreen
+ (JNIEnv *env, jclass that, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDefaultColormapOfScreen\n");
+#endif
+ return (jint) XDefaultColormapOfScreen((Screen *)screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XRootWindowOfScreen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XRootWindowOfScreen
+ (JNIEnv *env, jclass that, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XRootWindowOfScreen\n");
+#endif
+ return (jint) XRootWindowOfScreen((Screen *)screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XScreenNumberOfScreen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XScreenNumberOfScreen
+ (JNIEnv *env, jclass that, jint screen)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XScreenNumberOfScreen\n");
+#endif
+ return (jint) XScreenNumberOfScreen((Screen *)screen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XCreateWindow
+ * Signature: (IIIIIIIIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XCreateWindow
+ (JNIEnv *env, jclass that, jint display, jint parent, jint x, jint y, jint width, jint height,
+ jint border_width, jint depth, jint class, jint visual, jint value_mask, jint attributes)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XCreateWindow\n");
+#endif
+ return (jint) XCreateWindow((Display *)display, (Window)parent, x, y, width, height,
+ border_width, depth, class, (Visual *)visual, (long)value_mask, (XSetWindowAttributes *)attributes);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XDestroyWindow
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_motif_OS_XDestroyWindow
+ (JNIEnv *env, jclass that, jint display, jint w)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XDestroyWindow\n");
+#endif
+ XDestroyWindow((Display *)display, (Window)w);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_motif_OS
+ * Method: XpQueryVersion
+ * Signature: (I[S[S)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_motif_OS_XpQueryVersion
+ (JNIEnv *env, jclass that, jint display, jshortArray major_version, jshortArray minor_version)
+{
+ jshort *major_version1=NULL, *minor_version1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "XpQueryVersion\n");
+#endif
+
+ if (major_version)
+ major_version1 = (*env)->GetShortArrayElements(env, major_version, NULL);
+ if (minor_version)
+ minor_version1 = (*env)->GetShortArrayElements(env, minor_version, NULL);
+ rc = (jint) XpQueryVersion((Display *)display, (short *)major_version1, (short *)minor_version1);
+ if (major_version)
+ (*env)->ReleaseShortArrayElements(env, major_version, major_version1, 0);
+ if (minor_version)
+ (*env)->ReleaseShortArrayElements(env, minor_version, minor_version1, 0);
+
+ return rc;
+}
+
+/*
+ * ======== End printing functions ========
+ */
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/libswt-gnome0105.so b/bundles/org.eclipse.swt/Eclipse SWT/motif/libswt-gnome0105.so
new file mode 100755
index 0000000000..3c3ba7ecda
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/libswt-gnome0105.so
Binary files differ
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/libswt0105.so b/bundles/org.eclipse.swt/Eclipse SWT/motif/libswt0105.so
new file mode 100755
index 0000000000..7b68c6d57a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/libswt0105.so
Binary files differ
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java
new file mode 100755
index 0000000000..24b7b94242
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Color.java
@@ -0,0 +1,197 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Color {
+ /**
+ * The handle to the OS color resource.
+ * Warning: This field is platform dependent.
+ */
+ public XColor handle;
+
+ /**
+ * The device where this image was created.
+ */
+ Device device;
+
+Color() {
+}
+public Color (Device device, int red, int green, int blue) {
+ init(device, red, green, blue);
+}
+public Color (Device device, RGB rgb) {
+ if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, rgb.red, rgb.green, rgb.blue);
+}
+public void dispose() {
+ if (handle == null) return;
+ int xDisplay = device.xDisplay;
+ 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.xcolors[pixel] = null;
+ }
+ }
+ int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
+ OS.XFreeColors(xDisplay, colormap, new int[] { pixel }, 1, 0);
+ device = null;
+ handle = null;
+}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Color)) return false;
+ Color color = (Color)object;
+ XColor xColor = color.handle;
+ return device == color.device && handle.red == xColor.red &&
+ handle.green == xColor.green && handle.blue == xColor.blue;
+}
+public int getBlue () {
+ return (handle.blue >> 8) & 0xFF;
+}
+public int getGreen () {
+ return (handle.green >> 8) & 0xFF;
+}
+public int getRed () {
+ return (handle.red >> 8) & 0xFF;
+}
+public RGB getRGB () {
+ return new RGB((handle.red >> 8) & 0xFF, (handle.green >> 8) & 0xFF, (handle.blue >> 8) & 0xFF);
+}
+public int hashCode () {
+ return handle.red ^ handle.green ^ handle.blue;
+}
+void init(Device device, int red, int green, int blue) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if ((red > 255) || (red < 0) ||
+ (green > 255) || (green < 0) ||
+ (blue > 255) || (blue < 0)) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ XColor xColor = new XColor();
+ xColor.red = (short)((red & 0xFF) | ((red & 0xFF) << 8));
+ xColor.green = (short)((green & 0xFF) | ((green & 0xFF) << 8));
+ xColor.blue = (short)((blue & 0xFF) | ((blue & 0xFF) << 8));
+ handle = xColor;
+ int xDisplay = device.xDisplay;
+ int screen = OS.XDefaultScreen(xDisplay);
+ int colormap = OS.XDefaultColormap(xDisplay, screen);
+ /* 1. Try to allocate the color */
+ if (OS.XAllocColor(xDisplay, colormap, xColor) != 0) {
+ if (device.colorRefCount != null) {
+ /* Make a copy of the color to put in the colors array */
+ XColor colorCopy = new XColor();
+ colorCopy.red = xColor.red;
+ colorCopy.green = xColor.green;
+ colorCopy.blue = xColor.blue;
+ colorCopy.pixel = xColor.pixel;
+ device.xcolors[colorCopy.pixel] = colorCopy;
+ device.colorRefCount[xColor.pixel]++;
+ }
+ return;
+ }
+ /**
+ * 2. Allocation failed. Query the entire colormap and
+ * find the closest match which can be allocated.
+ * This should never occur on a truecolor display.
+ */
+ Visual visual = new Visual();
+ OS.memmove(visual, OS.XDefaultVisual(xDisplay, screen), Visual.sizeof);
+ int mapEntries = visual.map_entries;
+ XColor[] queried = new XColor[mapEntries];
+ int[] distances = new int[mapEntries];
+ /**
+ * Query all colors in the colormap and calculate the distance
+ * from each to the desired color.
+ */
+ for (int i = 0; i < mapEntries; i++) {
+ XColor color = new XColor();
+ color.pixel = i;
+ queried[i] = color;
+ OS.XQueryColor(xDisplay, colormap, color);
+ int r = red - ((color.red >> 8) & 0xFF);
+ int g = green - ((color.green >> 8) & 0xFF);
+ int b = blue - ((color.blue >> 8) & 0xFF);
+ distances[i] = r*r + g*g + b*b;
+ }
+ /**
+ * Try to allocate closest matching queried color.
+ * The allocation can fail if the closest matching
+ * color is allocated privately, so go through them
+ * in order of increasing distance.
+ */
+ for (int i = 0; i < mapEntries; i++) {
+ int minDist = 0x30000;
+ int minIndex = 0;
+ for (int j = 0; j < mapEntries; j++) {
+ if (distances[j] < minDist) {
+ minDist = distances[j];
+ minIndex = j;
+ }
+ }
+ XColor queriedColor = queried[minIndex];
+ XColor osColor = new XColor();
+ osColor.red = queriedColor.red;
+ osColor.green = queriedColor.green;
+ osColor.blue = queriedColor.blue;
+ if (OS.XAllocColor(xDisplay, colormap, osColor) != 0) {
+ /* Allocation succeeded. Copy the fields into the handle */
+ xColor.red = osColor.red;
+ xColor.green = osColor.green;
+ xColor.blue = osColor.blue;
+ xColor.pixel = osColor.pixel;
+ if (device.colorRefCount != null) {
+ /* Put osColor in the colors array */
+ device.xcolors[osColor.pixel] = osColor;
+ device.colorRefCount[osColor.pixel]++;
+ }
+ return;
+ }
+ /* The allocation failed; matching color is allocated privately */
+ distances[minIndex] = 0x30000;
+ }
+ /**
+ * 3. Couldn't allocate any of the colors in the colormap.
+ * This means all colormap entries were allocated privately
+ * by other applications. Give up and allocate black.
+ */
+ XColor osColor = new XColor();
+ OS.XAllocColor(xDisplay, colormap, osColor);
+ /* Copy the fields into the handle */
+ xColor.red = osColor.red;
+ xColor.green = osColor.green;
+ xColor.blue = osColor.blue;
+ xColor.pixel = osColor.pixel;
+ if (device.colorRefCount != null) {
+ /* Put osColor in the colors array */
+ device.xcolors[osColor.pixel] = osColor;
+ device.colorRefCount[osColor.pixel]++;
+ }
+}
+public boolean isDisposed() {
+ return handle == null;
+}
+public static Color motif_new(Device device, XColor xColor) {
+ if (device == null) device = Device.getDevice();
+ Color color = new Color();
+ color.handle = xColor;
+ color.device = device;
+ return color;
+}
+/**
+ * Return a string representation of the Color.
+ *
+ * @return a string representation of the Color
+ */
+public String toString () {
+ return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java
new file mode 100755
index 0000000000..88490e9fc1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Cursor.java
@@ -0,0 +1,154 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Cursor {
+ /**
+ * The handle to the OS cursor resource.
+ * Warning: This field is platform dependent.
+ */
+ public int handle;
+
+ /**
+ * The device where this image was created.
+ */
+ Device device;
+
+Cursor () {
+}
+public Cursor (Device device, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ int shape = 0;
+ switch (style) {
+ case SWT.CURSOR_ARROW: shape = OS.XC_left_ptr; break;
+ case SWT.CURSOR_WAIT: shape = OS.XC_watch; break;
+ case SWT.CURSOR_HAND: shape = OS.XC_hand2; break;
+ case SWT.CURSOR_CROSS: shape = OS.XC_cross; break;
+ case SWT.CURSOR_APPSTARTING: shape = OS.XC_watch; break;
+ case SWT.CURSOR_HELP: shape = OS.XC_question_arrow; break;
+ case SWT.CURSOR_SIZEALL: shape = OS.XC_diamond_cross; break;
+ case SWT.CURSOR_SIZENESW: shape = OS.XC_sizing; break;
+ case SWT.CURSOR_SIZENS: shape = OS.XC_double_arrow; break;
+ case SWT.CURSOR_SIZENWSE: shape = OS.XC_sizing; break;
+ case SWT.CURSOR_SIZEWE: shape = OS.XC_sb_h_double_arrow; break;
+ case SWT.CURSOR_SIZEN: shape = OS.XC_top_side; break;
+ case SWT.CURSOR_SIZES: shape = OS.XC_bottom_side; break;
+ case SWT.CURSOR_SIZEE: shape = OS.XC_right_side; break;
+ case SWT.CURSOR_SIZEW: shape = OS.XC_left_side; break;
+ case SWT.CURSOR_SIZENE: shape = OS.XC_top_right_corner; break;
+ case SWT.CURSOR_SIZESE: shape = OS.XC_bottom_right_corner; break;
+ case SWT.CURSOR_SIZESW: shape = OS.XC_bottom_left_corner; break;
+ case SWT.CURSOR_SIZENW: shape = OS.XC_top_left_corner; break;
+ case SWT.CURSOR_UPARROW: shape = OS.XC_sb_up_arrow; break;
+ case SWT.CURSOR_IBEAM: shape = OS.XC_xterm; break;
+ case SWT.CURSOR_NO: shape = OS.XC_X_cursor; break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.handle = OS.XCreateFontCursor(device.xDisplay, shape);
+}
+public Cursor (Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = 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 depths */
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (source.depth != 1) 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);
+ }
+ /* Swap the bits if necessary */
+ byte[] sourceData = new byte[source.data.length];
+ byte[] maskData = new byte[mask.data.length];
+ /* Swap the bits in each byte */
+ 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];
+ }
+ 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];
+ }
+ int xDisplay = device.xDisplay;
+ int drawable = OS.XDefaultRootWindow(xDisplay);
+ int sourcePixmap = OS.XCreateBitmapFromData(xDisplay, drawable, sourceData, source.width, source.height);
+ int maskPixmap = OS.XCreateBitmapFromData(xDisplay, drawable, maskData, source.width, source.height);
+ /* Get the colors */
+ int screenNum = OS.XDefaultScreen(xDisplay);
+ XColor foreground = new XColor();
+ foreground.pixel = OS.XBlackPixel(xDisplay, screenNum);
+ foreground.red = foreground.green = foreground.blue = 0;
+ XColor background = new XColor();
+ background.pixel = OS.XWhitePixel(xDisplay, screenNum);
+ background.red = background.green = background.blue = (short)0xFFFF;
+ /* Create the cursor */
+ handle = OS.XCreatePixmapCursor(xDisplay, maskPixmap, sourcePixmap, foreground, background, hotspotX, hotspotY);
+ /* Dispose the pixmaps */
+ OS.XFreePixmap(xDisplay, sourcePixmap);
+ OS.XFreePixmap(xDisplay, maskPixmap);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+public void dispose () {
+ if (handle != 0) OS.XFreeCursor(device.xDisplay, handle);
+ device = null;
+ handle = 0;
+}
+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;
+}
+public int hashCode () {
+ return handle;
+}
+public boolean isDisposed() {
+ return handle == 0;
+}
+public static Cursor motif_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Cursor cursor = new Cursor();
+ cursor.device = device;
+ cursor.handle = handle;
+ return cursor;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
new file mode 100755
index 0000000000..39737ff830
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Device.java
@@ -0,0 +1,434 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+public abstract class Device implements Drawable {
+ /**
+ * the handle to the X Display
+ * (Warning: This field is platform dependent)
+ */
+ public int xDisplay;
+
+ /* Arguments for XtOpenDisplay */
+ String display_name;
+ String application_name;
+ String application_class;
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ public boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ /* Colormap and reference count for this display */
+ XColor [] xcolors;
+ int [] colorRefCount;
+
+ /* System Colors */
+ 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;
+
+ /* Warning and Error Handlers */
+ boolean warnings = true;
+ Callback xErrorCallback, xtWarningCallback, xIOErrorCallback, xtErrorCallback;
+ int xErrorProc, xtWarningProc, xIOErrorProc, xtErrorProc;
+ int xNullErrorProc, xtNullWarningProc, xNullIOErrorProc, xtNullErrorProc;
+
+ public static String XDefaultPrintServer = ":1";
+ static {
+ /* Read the default print server name from
+ * the XPRINTER environment variable.
+ */
+ XDefaultPrintServer = ":1";
+ }
+ protected static int xPrinter;
+
+public Device(DeviceData data) {
+ create (data);
+ init ();
+ if (data != null) {
+ display_name = data.display_name;
+ application_name = data.application_name;
+ application_class = data.application_class;
+ tracking = data.tracking;
+ debug = data.debug;
+ }
+ if (tracking) {
+ errors = new Error [128];
+ objects = new Object [128];
+ }
+}
+
+/**
+ * Temporary code.
+ */
+static Device getDevice () {
+ Device device = null;
+ try {
+ Class clazz = Class.forName ("org.eclipse.swt.widgets.Display");
+ java.lang.reflect.Method method = clazz.getMethod("getCurrent", new Class[0]);
+ device = (Device) method.invoke(clazz, new Object[0]);
+ if (device == null) {
+ method = clazz.getMethod("getDefault", new Class[0]);
+ device = (Device)method.invoke(clazz, new Object[0]);
+ }
+ } catch (Throwable e) {};
+ return device;
+}
+
+protected void checkDevice () {
+ if (xDisplay == 0) SWT.error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+protected void create (DeviceData data) {
+}
+
+protected void destroy () {
+}
+
+public void dispose () {
+ if (isDisposed()) return;
+ checkDevice ();
+ release ();
+ destroy ();
+ xDisplay = 0;
+ if (tracking) {
+ objects = null;
+ errors = null;
+ }
+}
+
+void dispose_Object (Object object) {
+ for (int i=0; i<objects.length; i++) {
+ if (objects [i] == object) {
+ objects [i] = null;
+ errors [i] = null;
+ return;
+ }
+ }
+}
+
+public Rectangle getBounds () {
+ checkDevice ();
+ int screen = OS.XDefaultScreen (xDisplay);
+ int width = OS.XDisplayWidth (xDisplay, screen);
+ int height = OS.XDisplayHeight (xDisplay, screen);
+ return new Rectangle (0, 0, width, height);
+}
+
+public Rectangle getClientArea () {
+ return getBounds ();
+}
+
+public int getDepth () {
+ checkDevice ();
+ int xScreenPtr = OS.XDefaultScreenOfDisplay (xDisplay);
+ return OS.XDefaultDepthOfScreen (xScreenPtr);
+}
+
+public DeviceData getDeviceData () {
+ checkDevice ();
+ DeviceData data = new DeviceData ();
+ data.display_name = display_name;
+ data.application_name = application_name;
+ data.application_class = application_class;
+ data.debug = debug;
+ data.tracking = tracking;
+ int count = 0, length = 0;
+ if (tracking) 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++;
+ }
+ }
+ return data;
+}
+
+public Point getDPI () {
+ checkDevice ();
+ int xScreenNum = OS.XDefaultScreen (xDisplay);
+ int width = OS.XDisplayWidth (xDisplay, xScreenNum);
+ int height = OS.XDisplayHeight (xDisplay, xScreenNum);
+ int mmX = OS.XDisplayWidthMM (xDisplay, xScreenNum);
+ int mmY = OS.XDisplayHeightMM (xDisplay, xScreenNum);
+ /* 0.03937 mm/inch */
+ double inchesX = mmX * 0.03937;
+ double inchesY = mmY * 0.03937;
+ int x = (int)((width / inchesX) + 0.5);
+ int y = (int)((height / inchesY) + 0.5);
+ return new Point (x, y);
+}
+
+public FontData [] getFontList (String faceName, boolean scalable) {
+ checkDevice ();
+ String xlfd;
+ if (faceName == null) {
+ xlfd = "-*-*-*-*-*-*-*-*-*-*-*-*-*-*";
+ } else {
+ int dashIndex = faceName.indexOf('-');
+ if (dashIndex < 0) {
+ xlfd = "-*-" + faceName + "-*-*-*-*-*-*-*-*-*-*-*-*";
+ } else {
+ xlfd = "-" + faceName + "-*-*-*-*-*-*-*-*-*-*-*-*";
+ }
+ }
+ byte [] buffer1 = Converter.wcsToMbcs (null, xlfd, true);
+ int [] ret = new int [1];
+ int listPtr = OS.XListFonts (xDisplay, buffer1, 65535, ret);
+ int ptr = listPtr;
+ int [] intBuf = new int [1];
+ FontData [] fd = new FontData [ret [0]];
+ int fdIndex = 0;
+ for (int i = 0; i < ret [0]; i++) {
+ OS.memmove (intBuf, ptr, 4);
+ int charPtr = intBuf [0];
+ int length = OS.strlen (charPtr);
+ byte [] buffer2 = new byte [length];
+ OS.memmove (buffer2, charPtr, length);
+ char [] chars = Converter.mbcsToWcs (null, buffer2);
+ FontData data = FontData.motif_new (new String (chars));
+ boolean isScalable = data.averageWidth == 0 && data.pixels == 0 && data.points == 0;
+ if (isScalable == scalable) {
+ fd [fdIndex++] = data;
+ }
+ ptr += 4;
+ }
+ OS.XFreeFontNames (listPtr);
+ if (fdIndex == ret [0]) return fd;
+ FontData [] result = new FontData [fdIndex];
+ System.arraycopy (fd, 0, result, 0, fdIndex);
+ return result;
+}
+
+public Color getSystemColor (int id) {
+ checkDevice ();
+ XColor xColor = null;
+ 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;
+ }
+ if (xColor == null) return COLOR_BLACK;
+ return Color.motif_new (this, xColor);
+}
+
+public Font getSystemFont () {
+ checkDevice ();
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (null, null, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreateLabel (shellHandle, null, null, 0);
+ int [] argList = {OS.XmNfontList, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ /**
+ * Feature in Motif. Querying the font list from the widget and
+ * then destroying the shell (and the widget) could cause the
+ * font list to be freed as well. The fix is to make a copy of
+ * the font list, then to free it when the display is disposed.
+ */
+ int labelFont = OS.XmFontListCopy (argList [1]);
+ OS.XtDestroyWidget (shellHandle);
+ return Font.motif_new (this, labelFont);
+}
+
+public boolean getWarnings () {
+ checkDevice ();
+ return warnings;
+}
+
+protected void init () {
+
+ /* Create the warning and error callbacks */
+ xErrorCallback = new Callback (this, "xErrorProc", 2);
+ xNullErrorProc = xErrorCallback.getAddress ();
+ if (xNullErrorProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ xtWarningCallback = new Callback (this, "xtWarningProc", 1);
+ xtNullWarningProc = xtWarningCallback.getAddress ();
+ if (xtNullWarningProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ xIOErrorCallback = new Callback (this, "xIOErrorProc", 1);
+ xNullIOErrorProc = xIOErrorCallback.getAddress ();
+ if (xNullIOErrorProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+ xtErrorCallback = new Callback (this, "xtErrorProc", 1);
+ xtNullErrorProc = xtErrorCallback.getAddress ();
+ if (xtNullErrorProc == 0) SWT.error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ /* Set the warning and error handlers */
+ if (debug) OS.XSynchronize (xDisplay, true);
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ xErrorProc = OS.XSetErrorHandler (xNullErrorProc);
+ if (!debug) OS.XSetErrorHandler (xErrorProc);
+ xtWarningProc = OS.XtAppSetWarningHandler (xtContext, xtNullWarningProc);
+ if (!debug) OS.XtAppSetWarningHandler (xtContext, xtWarningProc);
+ xIOErrorProc = OS.XSetIOErrorHandler (xNullIOErrorProc);
+ if (!debug) OS.XSetIOErrorHandler (xIOErrorProc);
+ xtErrorProc = OS.XtAppSetErrorHandler (xtContext, xtNullErrorProc);
+ if (!debug) OS.XtAppSetErrorHandler (xtContext, xtErrorProc);
+
+ /* Only use palettes for <= 8 bpp default visual */
+ int xScreenPtr = OS.XDefaultScreenOfDisplay (xDisplay);
+ int defaultDepth = OS.XDefaultDepthOfScreen (xScreenPtr);
+ if (defaultDepth <= 8) {
+ int numColors = 1 << defaultDepth;
+ colorRefCount = new int [numColors];
+ xcolors = new XColor [numColors];
+ }
+
+ /*
+ * The following colors are listed in the Windows
+ * Programmer's Reference as the colors in the default
+ * palette.
+ */
+ 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);
+}
+
+public abstract int internal_new_GC (GCData data);
+
+public abstract void internal_dispose_GC (int handle, GCData data);
+
+public boolean isDisposed () {
+ return xDisplay == 0;
+}
+
+void new_Object (Object object) {
+ 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;
+}
+
+protected void release () {
+ /*
+ * Free the palette. Note that this disposes all colors on
+ * the display that were allocated using the Color constructor.
+ */
+ if (xcolors != null) {
+ int xScreen = OS.XDefaultScreen (xDisplay);
+ int xColormap = OS.XDefaultColormap (xDisplay, xScreen);
+ int [] pixel = new int [1];
+ for (int i = 0; i < xcolors.length; i++) {
+ XColor color = xcolors [i];
+ if (color != null) {
+ pixel [0] = color.pixel;
+ while (colorRefCount [i] > 0) {
+ OS.XFreeColors (xDisplay, xColormap, pixel, 1, 0);
+ --colorRefCount [i];
+ }
+ }
+ }
+ }
+ xcolors = 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;
+
+ /* Release the warning and error callbacks */
+ xtWarningCallback.dispose (); xtWarningCallback = null;
+ xtWarningProc = 0;
+ xErrorCallback.dispose (); xErrorCallback = null;
+ xErrorProc = 0;
+ xtErrorCallback.dispose (); xtErrorCallback = null;
+ xtErrorProc = 0;
+ xIOErrorCallback.dispose (); xIOErrorCallback = null;
+ xIOErrorProc = 0;
+}
+
+public void setWarnings (boolean warnings) {
+ checkDevice ();
+ this.warnings = warnings;
+ if (debug) return;
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ if (warnings) {
+ OS.XSetErrorHandler (xErrorProc);
+ OS.XtAppSetWarningHandler (xtContext, xtWarningProc);
+ } else {
+ OS.XSetErrorHandler (xNullErrorProc);
+ OS.XtAppSetWarningHandler (xtContext, xtNullWarningProc);
+ }
+}
+
+int xErrorProc (int xDisplay, int xErrorEvent) {
+ if (debug) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xErrorProc, xDisplay, xErrorEvent);
+ }
+ return 0;
+}
+
+int xIOErrorProc (int xDisplay) {
+ if (debug) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xIOErrorProc, xDisplay, 0);
+ }
+ return 0;
+}
+
+int xtErrorProc (int message) {
+ if (debug) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xtErrorProc, message, 0);
+ }
+ return 0;
+}
+
+int xtWarningProc (int message) {
+ if (debug) {
+ new SWTError ().printStackTrace ();
+ OS.Call (xtWarningProc, message, 0);
+ }
+ return 0;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/DeviceData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/DeviceData.java
new file mode 100755
index 0000000000..565fb06229
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/DeviceData.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class DeviceData {
+ /*
+ * Motif only fields.
+ */
+ 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;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
new file mode 100755
index 0000000000..b979ea2d42
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Font.java
@@ -0,0 +1,164 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Font {
+ /**
+ * The handle to the OS font resource.
+ * Warning: This field is platform dependent.
+ */
+ public int handle;
+
+ /**
+ * The device where this image was created.
+ */
+ Device device;
+
+Font () {
+}
+public Font (Device device, FontData fd) {
+ init(device, fd);
+}
+public Font (Device device, String fontFamily, int height, int style) {
+ if (fontFamily == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new FontData(fontFamily, height, style));
+}
+public void dispose () {
+ if (handle != 0) OS.XmFontListFree (handle);
+ handle = 0;
+}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Font)) return false;
+ Font font = (Font)object;
+ return device == font.device && handle == font.handle;
+}
+public FontData[] getFontData() {
+ int xDisplay = device.xDisplay;
+ /**
+ * Create a font context to iterate over each element in the font list.
+ * If a font context can not be created, return null.
+ */
+ int[] buffer = new int[1];
+ if (!OS.XmFontListInitFontContext(buffer, handle)) return null;
+ int context = buffer[0];
+ XFontStruct fontStruct = new XFontStruct();
+ int fontListEntry;
+ int[] fontStructPtr = new int[1];
+ int[] fontNamePtr = new int[1];
+ String[] xlfds = new String[0];
+ /* Go through each entry in the font list */
+ while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
+ if (buffer[0] == 0) {
+ /* FontList contains a single font */
+ OS.memmove(fontStruct,fontPtr,20 * 4);
+ int propPtr = fontStruct.properties;
+ for (int i = 0; i < fontStruct.n_properties; i++) {
+ /* Reef through properties looking for XAFONT */
+ int[] prop = new int[2];
+ OS.memmove(prop, propPtr, 8);
+ if (prop[0] == OS.XA_FONT) {
+ /* Found it, prop[1] points to the string */
+ StringBuffer stringBuffer = new StringBuffer();
+ int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
+ int length = OS.strlen(ptr);
+ byte[] nameBuf = new byte[length];
+ OS.memmove(nameBuf, ptr, length);
+ String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
+ /* Add the xlfd to the array */
+ String[] newXlfds = new String[xlfds.length + 1];
+ System.arraycopy(xlfds, 0, newXlfds, 0, xlfds.length);
+ newXlfds[newXlfds.length - 1] = xlfd;
+ xlfds = newXlfds;
+ OS.XtFree(ptr);
+ break;
+ }
+ propPtr += 8;
+ }
+ }
+ else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet(fontPtr,fontStructPtr,fontNamePtr);
+ int [] fontStructs = new int[nFonts];
+ OS.memmove(fontStructs,fontStructPtr[0],nFonts * 4);
+ for (int i = 0; i < nFonts; i++) { // Go through each fontStruct in the font set.
+ OS.memmove(fontStruct,fontStructs[i],20 * 4);
+ int propPtr = fontStruct.properties;
+ for (int j = 0; j < fontStruct.n_properties; j++) {
+ // Reef through properties looking for XAFONT
+ int[] prop = new int[2];
+ OS.memmove(prop, propPtr, 8);
+ if (prop[0] == OS.XA_FONT) {
+ /* Found it, prop[1] points to the string */
+ StringBuffer stringBuffer = new StringBuffer();
+ int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
+ int length = OS.strlen(ptr);
+ byte[] nameBuf = new byte[length];
+ OS.memmove(nameBuf, ptr, length);
+ String xlfd = new String(Converter.mbcsToWcs(null, nameBuf)).toLowerCase();
+ /* Add the xlfd to the array */
+ String[] newXlfds = new String[xlfds.length + 1];
+ System.arraycopy(xlfds, 0, newXlfds, 0, xlfds.length);
+ newXlfds[newXlfds.length - 1] = xlfd;
+ xlfds = newXlfds;
+ OS.XFree(ptr);
+ break;
+ }
+ propPtr += 8;
+ }
+ }
+ }
+ }
+ OS.XmFontListFreeFontContext(context);
+ if (xlfds.length == 0) return null;
+ FontData[] fontData = new FontData[xlfds.length];
+ /* Construct each fontData out of the xlfd */
+ try {
+ for (int i = 0; i < xlfds.length; i++) {
+ fontData[i] = FontData.motif_new(xlfds[i]);
+ }
+ } catch (Exception e) {
+ /**
+ * Some font servers, for example, xfstt, do not pass
+ * reasonable font properties to the client, so we
+ * cannot construct a FontData for these. Return null.
+ */
+ return null;
+ }
+ return fontData;
+}
+public int hashCode () {
+ return handle;
+}
+void init (Device device, FontData fd) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ byte[] buffer = Converter.wcsToMbcs(null, fd.getXlfd(), true);
+ boolean warnings = device.getWarnings();
+ device.setWarnings(false);
+ int fontListEntry = OS.XmFontListEntryLoad(device.xDisplay, buffer, 0, OS.XmFONTLIST_DEFAULT_TAG);
+ device.setWarnings(warnings);
+ if (fontListEntry == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ handle = OS.XmFontListAppendEntry(0, fontListEntry);
+ OS.XmFontListEntryFree(new int[]{fontListEntry});
+}
+public boolean isDisposed() {
+ return handle == 0;
+}
+public static Font motif_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Font font = new Font();
+ font.device = device;
+ font.handle = handle;
+ return font;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
new file mode 100755
index 0000000000..31494f022e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontData.java
@@ -0,0 +1,321 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class FontData {
+ /**
+ * The company that produced the font
+ * Warning: This field is platform dependent.
+ */
+ public String foundry;
+ /**
+ * The common name of the font
+ * Warning: This field is platform dependent.
+ */
+ public String fontFamily;
+ /**
+ * The weight ("normal", "bold")
+ * Warning: This field is platform dependent.
+ */
+ public String weight;
+ /**
+ * The slant ("o" for oblique, "i" for italic)
+ * Warning: This field is platform dependent.
+ */
+ public String slant;
+ /**
+ * The set width of the font
+ * Warning: This field is platform dependent.
+ */
+ public String setWidth;
+ /**
+ * Additional font styles
+ * Warning: This field is platform dependent.
+ */
+ public String addStyle;
+ /**
+ * The height of the font in pixels
+ * Warning: This field is platform dependent.
+ */
+ public int pixels;
+ /**
+ * The height of the font in tenths of a point
+ * Warning: This field is platform dependent.
+ */
+ public int points;
+ /**
+ * The horizontal screen resolution for which the font was designed
+ * Warning: This field is platform dependent.
+ */
+ public int horizontalResolution;
+ /**
+ * The vertical screen resolution for which the font was designed
+ * Warning: This field is platform dependent.
+ */
+ public int verticalResolution;
+ /**
+ * The font spacing ("m" for monospace, "p" for proportional)
+ * Warning: This field is platform dependent.
+ */
+ public String spacing;
+ /**
+ * The average character width for the font
+ * Warning: This field is platform dependent.
+ */
+ public int averageWidth;
+ /**
+ * The ISO character set registry
+ * Warning: This field is platform dependent.
+ */
+ public String characterSetRegistry;
+ /**
+ * The ISO character set name
+ * Warning: This field is platform dependent.
+ */
+ public String characterSetName;
+public FontData () {
+}
+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_NULL_ARGUMENT);
+ String version1 = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ String name = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int height = 0;
+ try {
+ height = Integer.parseInt(string.substring(start, end));
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int style = 0;
+ try {
+ style = Integer.parseInt(string.substring(start, end));
+ } catch (NumberFormatException e) {
+ SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ }
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ return;
+ }
+ String platform = string.substring(start, end);
+
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ return;
+ }
+ String version2 = string.substring(start, end);
+
+ if (platform.equals("MOTIF") && version2.equals("1")) {
+ start = end + 1;
+ end = string.length();
+ if (end == -1) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ return;
+ }
+ String xlfd = string.substring(start, end);
+ setXlfd(xlfd);
+ return;
+ }
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+}
+public FontData (String name, int height, int style) {
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (name != null) {
+ int dash = name.indexOf('-');
+ if (dash != -1) {
+ foundry = name.substring(0, dash);
+ fontFamily = name.substring(dash + 1);
+ } else {
+ fontFamily = name;
+ }
+ }
+ points = height * 10;
+ if ((style & SWT.BOLD) != 0)
+ weight = "bold";
+ else
+ weight = "medium";
+ if ((style & SWT.ITALIC) != 0)
+ slant = "i";
+ else
+ slant = "r";
+}
+public boolean equals (Object object) {
+ return (object == this) || ((object instanceof FontData) &&
+ getXlfd().equals(((FontData)object).getXlfd()));
+}
+public int getHeight() {
+ return points / 10;
+}
+public String getName() {
+ StringBuffer buffer = new StringBuffer();
+ if (foundry != null) {
+ buffer.append(foundry);
+ buffer.append("-");
+ }
+ if (fontFamily != null) buffer.append(fontFamily);
+ return buffer.toString();
+}
+public int getStyle() {
+ int style = 0;
+ if (weight.equals("bold"))
+ style |= SWT.BOLD;
+ if (slant.equals("i"))
+ style |= SWT.ITALIC;
+ return style;
+}
+String getXlfd() {
+ String s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14;
+ s1 = s2 = s3 = s4 = s5 = s6 = s7 = s8 = s9 = s10 = s11 = s12 = s13 = s14 = "*";
+
+ if (foundry != null) s1 = foundry;
+ if (fontFamily != null) s2 = fontFamily;
+ if (weight != null) s3 = weight;
+ if (slant != null) s4 = slant;
+ if (setWidth != null) s5 = setWidth;
+ if (addStyle != null) s6 = addStyle;
+ if (pixels != 0) s7 = Integer.toString(pixels);
+ if (points != 0) s8 = Integer.toString(points);
+ if (horizontalResolution != 0) s9 = Integer.toString(horizontalResolution);
+ if (verticalResolution != 0) s10 = Integer.toString(verticalResolution);
+ if (spacing != null) s11 = spacing;
+ if (averageWidth != 0) s12 = Integer.toString(averageWidth);
+ if (characterSetRegistry != null) s13 = characterSetRegistry;
+ if (characterSetName != null) s14 = characterSetName;
+
+ return "-" + s1+ "-" + s2 + "-" + s3 + "-" + s4 + "-" + s5 + "-" + s6 + "-" + s7 + "-" + s8 + "-"
+ + s9 + "-" + s10 + "-" + s11 + "-" + s12 + "-" + s13 + "-" + s14;
+}
+public int hashCode () {
+ return getXlfd().hashCode();
+}
+public static FontData motif_new(String xlfd) {
+ FontData fontData = new FontData();
+ fontData.setXlfd(xlfd);
+ return fontData;
+}
+public void setHeight(int height) {
+ if (height < 0) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ points = height * 10;
+}
+public void setName(String name) {
+ if (name == null) {
+ foundry = fontFamily = null;
+ return;
+ }
+ int dash = name.indexOf('-');
+ if (dash != -1) {
+ foundry = name.substring(0, dash);
+ fontFamily = name.substring(dash + 1);
+ } else {
+ fontFamily = name;
+ }
+}
+public void setStyle(int style) {
+ if ((style & SWT.BOLD) == SWT.BOLD)
+ weight = "bold";
+ else
+ weight = "normal";
+ if ((style & SWT.ITALIC) == SWT.ITALIC)
+ slant = "i";
+ else
+ slant = "r";
+}
+void setXlfd(String xlfd) {
+ int start, stop;
+ start = 1;
+ stop = xlfd.indexOf ("-", start);
+ foundry = xlfd.substring(start, stop);
+ if (foundry.equals("*")) foundry = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ fontFamily = xlfd.substring(start, stop);
+ if (fontFamily.equals("*")) fontFamily = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ weight = xlfd.substring(start, stop);
+ if (weight.equals("*")) weight = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ slant = xlfd.substring(start, stop);
+ if (slant.equals("*")) slant = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ setWidth = xlfd.substring(start, stop);
+ if (setWidth.equals("*")) setWidth = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ addStyle = xlfd.substring(start, stop);
+ if (addStyle.equals("*")) addStyle = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ String s = xlfd.substring(start, stop);
+ if (!s.equals("") && !s.equals("*"))
+ pixels = Integer.parseInt(s);
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ s = xlfd.substring(start, stop);
+ if (!s.equals("") && !s.equals("*"))
+ points = Integer.parseInt(s);
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ s = xlfd.substring(start, stop);
+ if (!s.equals("") && !s.equals("*"))
+ horizontalResolution = Integer.parseInt(s);
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ s = xlfd.substring(start, stop);
+ if (!s.equals("") && !s.equals("*"))
+ verticalResolution = Integer.parseInt(s);
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ spacing = xlfd.substring(start, stop);
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ s = xlfd.substring(start, stop);
+ if (!s.equals("") && !s.equals("*"))
+ averageWidth = Integer.parseInt(s);
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ characterSetRegistry = xlfd.substring(start, stop);
+ if (characterSetRegistry.equals("*")) characterSetRegistry = null;
+ start = stop + 1;
+ stop = xlfd.indexOf ("-", start);
+ characterSetName = xlfd.substring(start);
+ if (characterSetName.equals("*")) characterSetName = null;
+}
+public String toString() {
+ return "1|" + fontFamily + "|" + getHeight() + "|" + getStyle() + "|" +
+ "MOTIF|1|" + getXlfd();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontMetrics.java
new file mode 100755
index 0000000000..43d69ae41c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/FontMetrics.java
@@ -0,0 +1,47 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class FontMetrics {
+ int ascent, descent, averageCharWidth, leading, height;
+FontMetrics() {
+}
+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;
+}
+public int getAscent() {
+ return ascent;
+}
+public int getAverageCharWidth() {
+ return averageCharWidth;
+}
+public int getDescent() {
+ return descent;
+}
+public int getHeight() {
+ return height;
+}
+public int getLeading() {
+ return leading;
+}
+public int hashCode() {
+ return ascent ^ descent ^ averageCharWidth ^ leading ^ height;
+}
+public static FontMetrics motif_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;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
new file mode 100755
index 0000000000..b5dc6a73d8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GC.java
@@ -0,0 +1,1367 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class GC {
+ /**
+ * The handle to the OS GC resource.
+ * Warning: This field is platform dependent.
+ */
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+ static final byte[] _MOTIF_DEFAULT_LOCALE = Converter.wcsToMbcs(null, "_MOTIF_DEFAULT_LOCALE");
+
+GC() {
+}
+public GC (Drawable drawable) {
+ if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ GCData data = new GCData();
+ int xGC = drawable.internal_new_GC(data);
+ init(drawable, data, xGC);
+}
+
+public void copyArea(int x, int y, int width, int height, int destX, int destY) {
+ if (width <= 0 || height <= 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ OS.XSetGraphicsExposures (xDisplay, handle, true);
+ OS.XCopyArea(xDisplay, xDrawable, xDrawable, handle, x, y, width, height, destX, destY);
+ OS.XSetGraphicsExposures (xDisplay, handle, false);
+ boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);
+ if (data.image != null) return;
+ if (disjoint) {
+ OS.XClearArea (xDisplay, xDrawable, x, y, width, height, true);
+ } else {
+ if (deltaX != 0) {
+ int newX = destX - deltaX;
+ if (deltaX < 0) newX = destX + width;
+ OS.XClearArea (xDisplay, xDrawable, newX, y, Math.abs (deltaX), height, true);
+ }
+ if (deltaY != 0) {
+ int newY = destY - deltaY;
+ if (deltaY < 0) newY = destY + height;
+ OS.XClearArea (xDisplay, xDrawable, x, newY, width, Math.abs (deltaY), true);
+ }
+ }
+}
+public void copyArea(Image image, int x, int y) {
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ Rectangle rect = image.getBounds();
+ int xDisplay = data.display;
+ int xGC = OS.XCreateGC(xDisplay, image.pixmap, 0, null);
+ if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.XSetSubwindowMode (xDisplay, xGC, OS.IncludeInferiors);
+ OS.XCopyArea(xDisplay, data.drawable, image.pixmap, xGC, x, y, rect.width, rect.height, 0, 0);
+ OS.XFreeGC(xDisplay, xGC);
+}
+public void dispose () {
+ if (handle == 0) return;
+
+ /* Free resources */
+ int clipRgn = data.clipRgn;
+ if (clipRgn != 0) OS.XDestroyRegion(clipRgn);
+ Image image = data.image;
+ if (image != null) image.memGC = null;
+ int renderTable = data.renderTable;
+ if (renderTable != 0) OS.XmRenderTableFree(renderTable);
+
+ /* Dispose the GC */
+ drawable.internal_dispose_GC(handle, data);
+
+ data.display = data.drawable = data.colormap = data.fontList =
+ data.clipRgn = data.renderTable = 0;
+ drawable = null;
+ data.device = null;
+ data.image = null;
+ data = null;
+ handle = 0;
+}
+public void drawArc(int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ OS.XDrawArc(data.display,data.drawable,handle,x,y,width,height,startAngle * 64 ,endAngle * 64);
+}
+public void drawFocus (int x, int y, int width, int height) {
+ /*
+ * When the drawable is not a widget, the highlight
+ * color is zero.
+ */
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ int highlightColor = 0;
+ int widget = OS.XtWindowToWidget (xDisplay, xDrawable);
+ if (widget != 0) {
+ int [] argList = {OS.XmNhighlightColor, 0};
+ OS.XtGetValues (widget, argList, argList.length / 2);
+ highlightColor = argList [1];
+ }
+
+ /* Draw the focus rectangle */
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (xDisplay, handle, OS.GCForeground, values);
+ OS.XSetForeground (xDisplay, handle, highlightColor);
+ OS.XDrawRectangle (xDisplay, xDrawable, handle, x, y, width - 1, height - 1);
+ OS.XSetForeground (xDisplay, handle, values.foreground);
+}
+public void drawImage(Image image, int x, int y) {
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ 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);
+ 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];
+ int[] depth = new int[1];
+ int[] unused = new int[1];
+ OS.XGetGeometry(data.display, srcImage.pixmap, unused, unused, unused, width, height, unused, depth);
+ 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);
+ }
+ }
+ if (srcImage.alpha != -1 || srcImage.alphaData != null) {
+ drawImageAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, depth[0]);
+ } else if (srcImage.transparentPixel != -1 || srcImage.mask != 0) {
+ drawImageMask(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, depth[0]);
+ } else {
+ drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, depth[0]);
+ }
+}
+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, int depth) {
+ /* Simple cases */
+ if (srcImage.alpha == 0) return;
+ if (srcImage.alpha == 255) {
+ drawImage(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, imgWidth, imgHeight, depth);
+ return;
+ }
+
+ /* Check the clipping */
+ Rectangle rect = getClipping();
+ rect = rect.intersection(new Rectangle(destX, destY, destWidth, destHeight));
+ if (rect.isEmpty()) return;
+
+ /* Optimization. Recalculate the src and dest rectangles so that
+ * only the clipping area is drawn.
+ */
+ rect.width = Math.max(rect.width, (int)Math.ceil(destWidth / (float)srcWidth));
+ rect.height = Math.max(rect.height, (int)Math.ceil(destHeight / (float)srcHeight));
+ int sx1 = srcX + (((rect.x - destX) * srcWidth) / destWidth);
+ int sx2 = srcX + ((((rect.x + rect.width) - destX) * srcWidth) / destWidth);
+ int sy1 = srcY + (((rect.y - destY) * srcHeight) / destHeight);
+ int sy2 = srcY + ((((rect.y + rect.height) - destY) * srcHeight) / destHeight);
+ destX = rect.x;
+ destY = rect.y;
+ destWidth = rect.width;
+ destHeight = rect.height;
+ srcX = sx1;
+ srcY = sy1;
+ srcWidth = sx2 - sx1;
+ srcHeight = sy2 - sy1;
+
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ int xDestImagePtr = 0, xSrcImagePtr = 0;
+ try {
+ /* Get the background pixels */
+ xDestImagePtr = OS.XGetImage(xDisplay, xDrawable, destX, destY, destWidth, destHeight, OS.AllPlanes, OS.ZPixmap);
+ if (xDestImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ XImage xDestImage = new XImage();
+ OS.memmove(xDestImage, xDestImagePtr, XImage.sizeof);
+ byte[] destData = new byte[xDestImage.bytes_per_line * xDestImage.height];
+ OS.memmove(destData, xDestImage.data, destData.length);
+
+ /* Get the foreground pixels */
+ xSrcImagePtr = OS.XGetImage(xDisplay, srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, OS.AllPlanes, OS.ZPixmap);
+ if (xSrcImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ XImage xSrcImage = new XImage();
+ OS.memmove(xSrcImage, xSrcImagePtr, XImage.sizeof);
+ byte[] srcData = new byte[xSrcImage.bytes_per_line * xSrcImage.height];
+ OS.memmove(srcData, xSrcImage.data, srcData.length);
+
+ /* Compose the pixels */
+ int srcOrder = xSrcImage.byte_order == OS.MSBFirst ? ImageData.MSB_FIRST : ImageData.LSB_FIRST;
+ int destOrder = xDestImage.byte_order == OS.MSBFirst ? ImageData.MSB_FIRST : ImageData.LSB_FIRST;
+ if (xSrcImage.depth <= 8) {
+ XColor[] xcolors = data.device.xcolors;
+ if (xcolors == null) SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ byte[] reds = new byte[xcolors.length];
+ byte[] greens = new byte[xcolors.length];
+ byte[] blues = new byte[xcolors.length];
+ for (int i = 0; i < xcolors.length; i++) {
+ XColor color = xcolors[i];
+ if (color == null) continue;
+ reds[i] = (byte)((color.red >> 8) & 0xFF);
+ greens[i] = (byte)((color.green >> 8) & 0xFF);
+ blues[i] = (byte)((color.blue >> 8) & 0xFF);
+ }
+ ImageData.blit(ImageData.BLIT_ALPHA,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, reds, greens, blues, srcImage.alpha, srcImage.alphaData, imgWidth,
+ destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, reds, greens, blues,
+ false, false);
+ } else {
+ ImageData.blit(ImageData.BLIT_ALPHA,
+ srcData, xSrcImage.bits_per_pixel, xSrcImage.bytes_per_line, srcOrder, 0, 0, srcWidth, srcHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask, srcImage.alpha, srcImage.alphaData, imgWidth,
+ destData, xDestImage.bits_per_pixel, xDestImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xDestImage.red_mask, xDestImage.green_mask, xDestImage.blue_mask,
+ false, false);
+ }
+
+ /* Draw the composed pixels */
+ OS.memmove(xDestImage.data, destData, destData.length);
+ OS.XPutImage(xDisplay, xDrawable, handle, xDestImagePtr, 0, 0, destX, destY, destWidth, destHeight);
+ } finally {
+ if (xSrcImagePtr != 0) OS.XDestroyImage(xSrcImagePtr);
+ if (xDestImagePtr != 0) OS.XDestroyImage(xDestImagePtr);
+ }
+}
+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 depth) {
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ int colorPixmap = srcImage.pixmap;
+ /* Generate the mask if necessary. */
+ if (srcImage.transparentPixel != -1) srcImage.createMask();
+ int maskPixmap = srcImage.mask;
+ int foreground = 0x00000000;
+ if (!(simple || (srcWidth == destWidth && srcHeight == destHeight))) {
+ /* Stretch the color and mask*/
+ int xImagePtr = scalePixmap(xDisplay, colorPixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false);
+ int xMaskPtr = scalePixmap(xDisplay, maskPixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false);
+
+ /* Create color scaled pixmaps */
+ colorPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, depth);
+ int tempGC = OS.XCreateGC(xDisplay, colorPixmap, 0, null);
+ OS.XPutImage(xDisplay, colorPixmap, tempGC, xImagePtr, 0, 0, 0, 0, destWidth, destHeight);
+ OS.XDestroyImage(xImagePtr);
+ OS.XFreeGC(xDisplay, tempGC);
+
+ /* Create mask scaled pixmaps */
+ maskPixmap = OS.XCreatePixmap(xDisplay, xDrawable, destWidth, destHeight, 1);
+ tempGC = OS.XCreateGC(xDisplay, maskPixmap, 0, null);
+ OS.XPutImage(xDisplay, maskPixmap, tempGC, xMaskPtr, 0, 0, 0, 0, destWidth, destHeight);
+ OS.XDestroyImage(xMaskPtr);
+ OS.XFreeGC(xDisplay, tempGC);
+
+ /* Change the source rectangle */
+ srcX = srcY = 0;
+ srcWidth = destWidth;
+ srcHeight = destHeight;
+
+ foreground = ~foreground;
+ }
+
+ /* Do the blts */
+ XGCValues values = new XGCValues();
+ OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS. GCBackground | OS.GCFunction, values);
+ OS.XSetFunction(xDisplay, handle, OS.GXxor);
+ OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY);
+ OS.XSetForeground(xDisplay, handle, foreground);
+ OS.XSetBackground(xDisplay, handle, ~foreground);
+ OS.XSetFunction(xDisplay, handle, OS.GXand);
+ OS.XCopyPlane(xDisplay, maskPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY, 1);
+ OS.XSetFunction(xDisplay, handle, OS.GXxor);
+ OS.XCopyArea(xDisplay, colorPixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY);
+ OS.XSetForeground(xDisplay, handle, values.foreground);
+ OS.XSetBackground(xDisplay, handle, values.background);
+ OS.XSetFunction(xDisplay, handle, values.function);
+
+ /* Destroy scaled pixmaps */
+ if (srcImage.pixmap != colorPixmap) OS.XFreePixmap(xDisplay, colorPixmap);
+ if (srcImage.mask != maskPixmap) OS.XFreePixmap(xDisplay, 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 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, int depth) {
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ /* Simple case: no stretching */
+ if ((srcWidth == destWidth) && (srcHeight == destHeight)) {
+ OS.XCopyArea(xDisplay, srcImage.pixmap, xDrawable, handle, srcX, srcY, srcWidth, srcHeight, destX, destY);
+ return;
+ }
+
+ /* Streching case */
+ int xImagePtr = scalePixmap(xDisplay, srcImage.pixmap, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false, false);
+ OS.XPutImage(xDisplay, xDrawable, handle, xImagePtr, 0, 0, destX, destY, destWidth, destHeight);
+ OS.XDestroyImage(xImagePtr);
+}
+static int scalePixmap(int display, int pixmap, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean flipX, boolean flipY) {
+ int xSrcImagePtr = OS.XGetImage(display, pixmap, srcX, srcY, srcWidth, srcHeight, OS.AllPlanes, OS.ZPixmap);
+ if (xSrcImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ XImage xSrcImage = new XImage();
+ OS.memmove(xSrcImage, xSrcImagePtr, XImage.sizeof);
+ byte[] srcData = new byte[xSrcImage.bytes_per_line * xSrcImage.height];
+ OS.memmove(srcData, xSrcImage.data, srcData.length);
+ int error = 0, xImagePtr = 0;
+ int visual = OS.XDefaultVisual(display, OS.XDefaultScreen(display));
+ switch (xSrcImage.bits_per_pixel) {
+ case 1: {
+ int bitOrder = xSrcImage.bitmap_bit_order == OS.MSBFirst ? ImageData.MSB_FIRST : ImageData.LSB_FIRST;
+ int bplX = ((destWidth + 7) / 8 + 3) & 0xFFFC;
+ int bufSize = bplX * destHeight;
+ byte[] buf = new byte[bufSize];
+ ImageData.stretch1(srcData, xSrcImage.bytes_per_line, bitOrder, 0, 0, srcWidth, srcHeight, buf, bplX, bitOrder, 0, 0, destWidth, destHeight, flipX, flipY);
+ int bufPtr = OS.XtMalloc(bufSize);
+ OS.memmove(bufPtr, buf, bufSize);
+ xImagePtr = OS.XCreateImage(display, visual, 1, OS.XYBitmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
+ if (xImagePtr == 0) break;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ xImage.byte_order = OS.MSBFirst;
+ xImage.bitmap_unit = 8;
+ xImage.bitmap_bit_order = xSrcImage.bitmap_bit_order;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ break;
+ }
+ case 4: {
+ /* Untested */
+ int bplX = (destWidth + 3) & 0xFFFC;
+ int bufSize = bplX * destHeight;
+ byte[] buf = new byte[bufSize];
+ ImageData.stretch4(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, bplX, 0, 0, destWidth, destHeight, null, flipX, flipY);
+ int bufPtr = OS.XtMalloc(bufSize);
+ OS.memmove(bufPtr, buf, bufSize);
+ xImagePtr = OS.XCreateImage(display, visual, 4, OS.ZPixmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
+ break;
+ }
+ case 8: {
+ int bplX = (destWidth + 3) & 0xFFFC;
+ int bufSize = bplX * destHeight;
+ byte[] buf = new byte[bufSize];
+ ImageData.stretch8(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, bplX, 0, 0, destWidth, destHeight, null, flipX, flipY);
+ int bufPtr = OS.XtMalloc(bufSize);
+ OS.memmove(bufPtr, buf, bufSize);
+ xImagePtr = OS.XCreateImage(display, visual, 8, OS.ZPixmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
+ break;
+ }
+ case 16: {
+ xImagePtr = OS.XCreateImage(display, visual, 16, OS.ZPixmap, 0, 0, destWidth, destHeight, 32, 0);
+ if (xImagePtr == 0) break;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ int bufSize = xImage.bytes_per_line * destHeight;
+ byte[] buf = new byte[bufSize];
+ ImageData.stretch16(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);
+ int bufPtr = OS.XtMalloc(bufSize);
+ OS.memmove(bufPtr, buf, bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ break;
+ }
+ case 24: {
+ xImagePtr = OS.XCreateImage(display, visual, 24, OS.ZPixmap, 0, 0, destWidth, destHeight, 32, 0);
+ if (xImagePtr == 0) break;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ int bufSize = xImage.bytes_per_line * destHeight;
+ byte[] buf = new byte[bufSize];
+ ImageData.stretch24(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);
+ int bufPtr = OS.XtMalloc(bufSize);
+ OS.memmove(bufPtr, buf, bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ break;
+ }
+ case 32: {
+ xImagePtr = OS.XCreateImage(display, visual, 24, OS.ZPixmap, 0, 0, destWidth, destHeight, 32, 0);
+ if (xImagePtr == 0) break;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ int bufSize = xImage.bytes_per_line * destHeight;
+ byte[] buf = new byte[bufSize];
+ ImageData.stretch32(srcData, xSrcImage.bytes_per_line, 0, 0, srcWidth, srcHeight, buf, xImage.bytes_per_line, 0, 0, destWidth, destHeight, flipX, flipY);
+ int bufPtr = OS.XtMalloc(bufSize);
+ OS.memmove(bufPtr, buf, bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ break;
+ }
+ default:
+ error = SWT.ERROR_UNSUPPORTED_DEPTH;
+ }
+ OS.XDestroyImage(xSrcImagePtr);
+ if (xImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (error != 0) {
+ if (xImagePtr != 0) OS.XDestroyImage(xImagePtr);
+ SWT.error(error);
+ }
+ return xImagePtr;
+}
+public void drawLine (int x1, int y1, int x2, int y2) {
+ OS.XDrawLine (data.display, data.drawable, handle, x1, y1, x2, y2);
+}
+public void drawOval(int x, int y, int width, int height) {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ OS.XDrawArc(data.display, data.drawable, handle, x, y, width, height, 0, 23040);
+}
+public void drawPolygon(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ // Motif does not have a native drawPolygon() call. Instead we ensure
+ // that the first and last points are the same and call drawPolyline().
+
+ int length = pointArray.length;
+
+ // Need at least 3 points to define the polygon. If 2 or fewer points
+ // passed in, it is either a line or point so just call drawPolyline().
+ // Check what happens when XOR is implemented. We may not be able to
+ // do this optimization.
+
+ if (length < 4) {
+ drawPolyline(pointArray);
+ return;
+ }
+
+ // If first and last points are the same, the polygon is already closed.
+ // Just call drawPolyline().
+ //
+ // Check what happens when XOR is implemented. We may not be able to
+ // do this optimization.
+
+ if (pointArray[0] == pointArray[length - 2] && (pointArray[1] == pointArray[length - 1])) {
+ drawPolyline(pointArray);
+ return;
+ }
+
+ // Grow the list of points by one element and make sure the first and last
+ // points are the same. This will close the polygon and we can use the
+ // drawPolyline() call.
+
+ int newPoints[] = new int[length + 2];
+ for (int i = 0; i < length ; i++)
+ newPoints[i] = pointArray[i];
+ newPoints[length] = pointArray[0];
+ newPoints[length + 1] = pointArray[1];
+
+ drawPolyline(newPoints);
+}
+public void drawPolyline(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ short[] xPoints = new short[pointArray.length];
+ for (int i = 0; i<pointArray.length;i++) {
+ xPoints[i] = (short) pointArray[i];
+ }
+ OS.XDrawLines(data.display,data.drawable,handle,xPoints,xPoints.length / 2, OS.CoordModeOrigin);
+}
+public void drawRectangle (int x, int y, int width, int height) {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ OS.XDrawRectangle (data.display, data.drawable, handle, x, y, width, height);
+}
+public void drawRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+
+ // X does not have a native for drawing round rectangles. Do the work in Java
+ // and use drawLine() drawArc() calls.
+
+ 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 naw2 = naw / 2;
+ int nah2 = nah / 2;
+
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx,ny,naw,nah,5760,5760);
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx,ny + nh - nah,naw,nah,11520,5760);
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx + nw - naw, ny + nh - nah, naw, nah,17280,5760);
+ OS.XDrawArc(xDisplay,xDrawable,handle,nx + nw - naw, ny, naw, nah, 0, 5760);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx + naw2, ny, nx + nw - naw2, ny);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx,ny + nah2, nx, ny + nh - nah2);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx + naw2, ny + nh, nx + nw - naw2, ny + nh);
+ OS.XDrawLine(xDisplay,xDrawable,handle,nx + nw, ny + nah2, nx + nw, ny + nh - nah2);
+}
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
+/**
+ * Draws the given string, using this graphics context's
+ * current font and foreground color.
+ * No tab expansion or CR processing will be performed.
+ *
+ * @param string the string to be drawn.
+ * @param x the <i>x</i> coordinate.
+ * @param y the <i>y</i> coordinate.
+ * @param isTransparent if true, the background will be transparent.
+ */
+public void drawString (String string, int x, int y, boolean isTransparent) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreate (buffer, OS.XmFONTLIST_DEFAULT_TAG);
+ if (isTransparent) {
+ OS.XmStringDraw (data.display, data.drawable, data.fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);
+ } else {
+ OS.XmStringDrawImage (data.display, data.drawable, data.fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);
+ }
+// OS.XmStringDrawUnderline (display, drawable, fontList, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null, 0);
+ OS.XmStringFree (xmString);
+}
+void createRenderTable() {
+ int xDisplay = data.display;
+ int fontList = data.fontList;
+ /* Get the width of the tabs */
+ byte[] buffer = {(byte)' ', 0};
+ int xmString = OS.XmStringCreate(buffer, OS.XmFONTLIST_DEFAULT_TAG);
+ int tabWidth = OS.XmStringWidth(fontList, xmString) * 8;
+ OS.XmStringFree(xmString);
+
+ /* Create the tab list */
+ int [] tabs = new int[16];
+ int tab = OS.XmTabCreate(tabWidth, (byte) OS.XmPIXELS, (byte) OS.XmRELATIVE, (byte) OS.XmALIGNMENT_BEGINNING, null);
+ for (int i = 0; i < tabs.length; i++) tabs[i] = tab;
+ int tabList = OS.XmTabListInsertTabs(0, tabs, tabs.length, 0);
+
+ /* Create a font context to iterate over the elements in the font list */
+ int[] fontBuffer = new int[1];
+ if (!OS.XmFontListInitFontContext(fontBuffer, fontList)) {
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ int context = fontBuffer[0], fontListEntry = 0;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ int[] renditions = new int[4]; int renditionCount = 0;
+
+ /* Create a rendition for each entry in the font list */
+ int shellHandle = OS.XtAppCreateShell (null, null, widgetClass, xDisplay, null, 0);
+ while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, fontBuffer);
+ int fontType = (fontBuffer [0] == 0) ? OS.XmFONT_IS_FONT : OS.XmFONT_IS_FONTSET;
+ if (fontPtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int [] argList = {
+ OS.XmNtabList, tabList,
+ OS.XmNfont, fontPtr,
+ OS.XmNfontType, fontType,
+ };
+ int rendition = OS.XmRenditionCreate(shellHandle, _MOTIF_DEFAULT_LOCALE, argList, argList.length / 2);
+ renditions[renditionCount++] = rendition;
+ if (renditionCount == renditions.length) {
+ int[] newArray = new int[renditions.length + 4];
+ System.arraycopy(newArray, 0, renditions, 0, renditionCount);
+ renditions = newArray;
+ }
+ }
+ OS.XmFontListFreeFontContext(context);
+ OS.XmTabFree(tab);
+ OS.XmTabListFree(tabList);
+ OS.XtDestroyWidget (shellHandle);
+
+ /* Create the render table from the renditions */
+ data.renderTable = OS.XmRenderTableAddRenditions(0, renditions, renditionCount, OS.XmMERGE_REPLACE);
+ for (int i = 0; i < renditionCount; i++) OS.XmRenditionFree(renditions[i]);
+}
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, false);
+}
+/**
+ * Draws the text given by the specified string, using this
+ * graphics context's current font and foreground color.
+ * The string will be formatted with tab expansion and CR processing.
+ *
+ * @param string the string to be drawn.
+ * @param x the <i>x</i> coordinate.
+ * @param y the <i>y</i> coordinate.
+ * @param isTransparent if true, the background will be transparent.
+ */
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (data.renderTable == 0) createRenderTable();
+ int renderTable = data.renderTable;
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringGenerate(textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);
+ if (isTransparent) {
+ OS.XmStringDraw (data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);
+ } else {
+ OS.XmStringDrawImage (data.display, data.drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null);
+ }
+// OS.XmStringDrawUnderline (display, drawable, renderTable, xmString, handle, x, y, 0x7FFFFFFF, OS.XmALIGNMENT_BEGINNING, 0, null, 0);
+ OS.XmStringFree (xmString);
+}
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof GC)) return false;
+ GC gc = (GC)object;
+ return data.device == gc.data.device && handle == gc.handle;
+}
+public void fillArc(int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground (xDisplay, handle, values.background);
+ OS.XFillArc(xDisplay,data.drawable,handle,x,y,width,height,startAngle * 64 ,endAngle * 64);
+ OS.XSetForeground (xDisplay, handle, values.foreground);
+}
+public void fillOval (int x, int y, int width, int height) {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ int display = data.display;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (display, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground (display, handle, values.background);
+ OS.XFillArc (display, data.drawable, handle, x, y, width, height, 0, 23040);
+ OS.XSetForeground (display, handle, values.foreground);
+}
+public void fillPolygon(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ short[] xPoints = new short[pointArray.length];
+ for (int i = 0; i<pointArray.length;i++) {
+ xPoints[i] = (short) pointArray[i];
+ }
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground (xDisplay, handle, values.background);
+ OS.XFillPolygon(xDisplay, data.drawable, handle,xPoints, xPoints.length / 2, OS.Convex, OS.CoordModeOrigin);
+ OS.XSetForeground (xDisplay, handle, values.foreground);
+}
+public void fillRectangle (int x, int y, int width, int height) {
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground (xDisplay, handle, values.background);
+ OS.XFillRectangle (xDisplay, data.drawable, handle, x, y, width, height);
+ OS.XSetForeground (xDisplay, handle, values.foreground);
+}
+public void fillRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground (xDisplay, handle, values.background);
+ OS.XFillRectangle (xDisplay, data.drawable, handle, rect.x, rect.y, rect.width, rect.height);
+ OS.XSetForeground (xDisplay, handle, values.foreground);
+}
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ 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;
+
+ naw = naw < nw ? naw : nw;
+ nah = nah < nh ? nah : nh;
+
+ int naw2 = naw / 2;
+ int nah2 = nah / 2;
+
+ int xDisplay = data.display;
+ int xDrawable = data.drawable;
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues(xDisplay, handle, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground(xDisplay, handle, values.background);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx,ny,naw,nah,5760,5760);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx,ny + nh - nah,naw,nah,11520,5760);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx + nw - naw, ny + nh - nah, naw, nah,17280,5760);
+ OS.XFillArc(xDisplay,xDrawable,handle,nx + nw - naw, ny, naw, nah, 0, 5760);
+ OS.XFillRectangle(xDisplay,xDrawable,handle,nx + naw2, ny, nw - naw, nh);
+ OS.XFillRectangle(xDisplay,xDrawable,handle,nx,ny + nah2, naw2, nh - nah);
+ OS.XFillRectangle(xDisplay,xDrawable,handle,nx + nw - (naw / 2), ny + nah2, naw2, nh -nah);
+ OS.XSetForeground(xDisplay, handle, values.foreground);
+}
+public int getAdvanceWidth(char ch) {
+ int fontList = data.fontList;
+ byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch }, false);
+ int val = charBuffer[0] & 0xFF;
+ /* Create a font context to iterate over each element in the font list */
+ int[] buffer = new int[1];
+ if (!OS.XmFontListInitFontContext(buffer, fontList)) {
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ int context = buffer[0];
+ XFontStruct fontStruct = new XFontStruct();
+ XCharStruct charStruct = new XCharStruct();
+ int fontListEntry;
+ int[] fontStructPtr = new int[1];
+ int[] fontNamePtr = new int[1];
+ /* Go through each entry in the font list. */
+ while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
+ if (buffer[0] == 0) {
+ OS.memmove(fontStruct, fontPtr, XFontStruct.sizeof);
+ /* FontList contains a single font */
+ if (fontStruct.min_byte1 == 0 && fontStruct.max_byte1 == 0) {
+ /* Single byte fontStruct */
+ if (fontStruct.min_char_or_byte2 <= val && val <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ OS.memmove(charStruct, fontStruct.per_char + ((val - fontStruct.min_char_or_byte2) * XCharStruct.sizeof), XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.width;
+ }
+ }
+ } else {
+ /* Double byte fontStruct */
+ int charsPerRow = fontStruct.max_char_or_byte2 - fontStruct.min_char_or_byte2 + 1;
+ int row = 0;
+ if (charBuffer.length > 1) row = charBuffer[1] - fontStruct.min_byte1;
+ int col = charBuffer[0] - fontStruct.min_char_or_byte2;
+ if (row <= fontStruct.max_byte1 && col <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ int offset = row * charsPerRow + col;
+ OS.memmove(charStruct, fontStruct.per_char + offset * XCharStruct.sizeof, XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.width;
+ }
+ }
+ }
+ } else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet(fontPtr, fontStructPtr, fontNamePtr);
+ int [] fontStructs = new int[nFonts];
+ OS.memmove(fontStructs, fontStructPtr[0], nFonts * 4);
+ /* Go through each fontStruct in the font set */
+ for (int i = 0; i < nFonts; i++) {
+ OS.memmove(fontStruct, fontStructs[i], XFontStruct.sizeof);
+ if (fontStruct.min_byte1 == 0 && fontStruct.max_byte1 == 0) {
+ /* Single byte fontStruct */
+ if (fontStruct.min_char_or_byte2 <= val && val <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ OS.memmove(charStruct, fontStruct.per_char + (val - fontStruct.min_char_or_byte2 * XCharStruct.sizeof), XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.width;
+ }
+ }
+ } else {
+ /* Double byte fontStruct */
+ int charsPerRow = fontStruct.max_char_or_byte2 - fontStruct.min_char_or_byte2 + 1;
+ int row = 0;
+ if (charBuffer.length > 1) row = charBuffer[1] - fontStruct.min_byte1;
+ int col = charBuffer[0] - fontStruct.min_char_or_byte2;
+ if (row <= fontStruct.max_byte1 && col <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ int offset = row * charsPerRow + col;
+ OS.memmove(charStruct, fontStruct.per_char + offset * XCharStruct.sizeof, XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.width;
+ }
+ }
+ }
+ }
+ }
+ }
+ OS.XmFontListFreeFontContext(context);
+ return 0;
+}
+public Color getBackground() {
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues();
+ if (OS.XGetGCValues(xDisplay, handle, OS.GCBackground, values) == 0) {
+ // Check error case here. If a palette has been set we may be able
+ // to do a better job.
+ return null;
+ }
+ XColor xColor = new XColor();
+ xColor.pixel = values.background;
+ OS.XQueryColor(xDisplay,data.colormap,xColor);
+ return Color.motif_new(data.device, xColor);
+
+}
+public int getCharWidth(char ch) {
+ int fontList = data.fontList;
+ byte[] charBuffer = Converter.wcsToMbcs(null, new char[] { ch }, false);
+ int val = charBuffer[0] & 0xFF;
+ /* Create a font context to iterate over each element in the font list */
+ int[] buffer = new int[1];
+ if (!OS.XmFontListInitFontContext(buffer, fontList)) {
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ int context = buffer[0];
+ XFontStruct fontStruct = new XFontStruct();
+ XCharStruct charStruct = new XCharStruct();
+ int fontListEntry;
+ int[] fontStructPtr = new int[1];
+ int[] fontNamePtr = new int[1];
+ /* Go through each entry in the font list. */
+ while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
+ if (buffer[0] == 0) {
+ OS.memmove(fontStruct, fontPtr, XFontStruct.sizeof);
+ /* FontList contains a single font */
+ if (fontStruct.min_byte1 == 0 && fontStruct.max_byte1 == 0) {
+ /* Single byte fontStruct */
+ if (fontStruct.min_char_or_byte2 <= val && val <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ OS.memmove(charStruct, fontStruct.per_char + ((val - fontStruct.min_char_or_byte2) * XCharStruct.sizeof), XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.rbearing - charStruct.lbearing;
+ }
+ }
+ } else {
+ /* Double byte fontStruct */
+ int charsPerRow = fontStruct.max_char_or_byte2 - fontStruct.min_char_or_byte2 + 1;
+ int row = 0;
+ if (charBuffer.length > 1) row = charBuffer[1] - fontStruct.min_byte1;
+ int col = charBuffer[0] - fontStruct.min_char_or_byte2;
+ if (row <= fontStruct.max_byte1 && col <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ int offset = row * charsPerRow + col;
+ OS.memmove(charStruct, fontStruct.per_char + offset * XCharStruct.sizeof, XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.rbearing - charStruct.lbearing;
+ }
+ }
+ }
+ } else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet(fontPtr, fontStructPtr, fontNamePtr);
+ int [] fontStructs = new int[nFonts];
+ OS.memmove(fontStructs, fontStructPtr[0], nFonts * 4);
+ /* Go through each fontStruct in the font set */
+ for (int i = 0; i < nFonts; i++) {
+ OS.memmove(fontStruct, fontStructs[i], XFontStruct.sizeof);
+ if (fontStruct.min_byte1 == 0 && fontStruct.max_byte1 == 0) {
+ /* Single byte fontStruct */
+ if (fontStruct.min_char_or_byte2 <= val && val <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ OS.memmove(charStruct, fontStruct.per_char + (val - fontStruct.min_char_or_byte2 * XCharStruct.sizeof), XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.rbearing - charStruct.lbearing;
+ }
+ }
+ } else {
+ /* Double byte fontStruct */
+ int charsPerRow = fontStruct.max_char_or_byte2 - fontStruct.min_char_or_byte2 + 1;
+ int row = 0;
+ if (charBuffer.length > 1) row = charBuffer[1] - fontStruct.min_byte1;
+ int col = charBuffer[0] - fontStruct.min_char_or_byte2;
+ if (row <= fontStruct.max_byte1 && col <= fontStruct.max_char_or_byte2) {
+ /* The font contains the character */
+ int offset = row * charsPerRow + col;
+ OS.memmove(charStruct, fontStruct.per_char + offset * XCharStruct.sizeof, XCharStruct.sizeof);
+ if (charStruct.width != 0) {
+ OS.XmFontListFreeFontContext(context);
+ return charStruct.rbearing - charStruct.lbearing;
+ }
+ }
+ }
+ }
+ }
+ }
+ OS.XmFontListFreeFontContext(context);
+ return 0;
+}
+public Rectangle getClipping() {
+ int clipRgn = data.clipRgn;
+ if (clipRgn == 0) {
+ int[] width = new int[1]; int[] height = new int[1];
+ int[] unused = new int[1];
+ OS.XGetGeometry(data.display, data.drawable, unused, unused, unused, width, height, unused, unused);
+ return new Rectangle(0, 0, width[0], height[0]);
+ }
+ XRectangle rect = new XRectangle();
+ OS.XClipBox(clipRgn, rect);
+ return new Rectangle(rect.x, rect.y, rect.width, rect.height);
+}
+public void getClipping(Region region) {
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int hRegion = region.handle;
+ int clipRgn = data.clipRgn;
+ if (clipRgn == 0) {
+ int[] width = new int[1]; int[] height = new int[1];
+ int[] unused = new int[1];
+ OS.XGetGeometry(data.display, data.drawable, unused, unused, unused, width, height, unused, unused);
+ OS.XSubtractRegion (hRegion, hRegion, hRegion);
+ XRectangle rect = new XRectangle();
+ rect.x = 0; rect.y = 0;
+ rect.width = (short)width[0]; rect.height = (short)height[0];
+ OS.XUnionRectWithRegion(rect, hRegion, hRegion);
+ return;
+ }
+ OS.XSubtractRegion (hRegion, hRegion, hRegion);
+ OS.XUnionRegion (clipRgn, hRegion, hRegion);
+}
+public Font getFont () {
+ return Font.motif_new(data.device, data.fontList);
+}
+int getFontHeight () {
+ int fontList = data.fontList;
+ /* Create a font context to iterate over each element in the font list */
+ int [] buffer = new int [1];
+ if (!OS.XmFontListInitFontContext (buffer, fontList)) {
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ int context = buffer [0];
+
+ /* Values discovering during iteration */
+ int height = 0;
+ XFontStruct fontStruct = new XFontStruct ();
+ int fontListEntry;
+ int [] fontStructPtr = new int [1];
+ int [] fontNamePtr = new int [1];
+
+ /* Go through each entry in the font list. */
+ while ((fontListEntry = OS.XmFontListNextEntry (context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont (fontListEntry, buffer);
+ if (buffer [0] == 0) {
+ /* FontList contains a single font */
+ OS.memmove (fontStruct, fontPtr, XFontStruct.sizeof);
+ int fontHeight = fontStruct.ascent + fontStruct.descent;
+ if (fontHeight > height) height = fontHeight;
+ } else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet (fontPtr, fontStructPtr, fontNamePtr);
+ int [] fontStructs = new int [nFonts];
+ OS.memmove (fontStructs, fontStructPtr [0], nFonts * 4);
+
+ /* Go through each fontStruct in the font set */
+ for (int i=0; i<nFonts; i++) {
+ OS.memmove (fontStruct, fontStructs[i], XFontStruct.sizeof);
+ int fontHeight = fontStruct.ascent + fontStruct.descent;
+ if (fontHeight > height) height = fontHeight;
+ }
+ }
+ }
+
+ OS.XmFontListFreeFontContext (context);
+ return height;
+}
+public FontMetrics getFontMetrics() {
+ int xDisplay = data.display;
+ int fontList = data.fontList;
+ /* Create a font context to iterate over each element in the font list */
+ int[] buffer = new int[1];
+ if (!OS.XmFontListInitFontContext(buffer, fontList)) {
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ int context = buffer[0];
+ /* Values discovering during iteration */
+ int ascent = 0;
+ int descent = 0;
+ int averageCharWidth = 0, numAverageCharWidth = 0;
+ int leading = 0;
+ int height = 0;
+
+ XFontStruct fontStruct = new XFontStruct();
+ int fontListEntry;
+ int[] fontStructPtr = new int[1];
+ int[] fontNamePtr = new int[1];
+ /* Go through each entry in the font list. */
+ while ((fontListEntry = OS.XmFontListNextEntry(context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont(fontListEntry, buffer);
+ if (buffer[0] == 0) {
+ /* FontList contains a single font */
+ OS.memmove(fontStruct, fontPtr, XFontStruct.sizeof);
+ ascent = ascent > fontStruct.max_bounds_ascent ? ascent : fontStruct.max_bounds_ascent;
+ descent = descent > fontStruct.descent ? descent : fontStruct.descent;
+ int tmp = fontStruct.ascent + fontStruct.descent;
+ height = height > tmp ? height : tmp;
+ tmp = fontStruct.ascent - fontStruct.max_bounds_ascent;
+ leading = leading > tmp ? leading : tmp;
+ /* Calculate average character width */
+ int propPtr = fontStruct.properties;
+ for (int i = 0; i < fontStruct.n_properties; i++) {
+ /* Reef through properties looking for XAFONT */
+ int[] prop = new int[2];
+ OS.memmove(prop, propPtr, 8);
+ if (prop[0] == OS.XA_FONT) {
+ /* Found it, prop[1] points to the string */
+ StringBuffer stringBuffer = new StringBuffer();
+ int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
+ int strPtr = ptr;
+ byte[] c = new byte[1];
+ OS.memmove(c, strPtr, 1);
+ while (c[0] != 0) {
+ stringBuffer.append((char)c[0]);
+ strPtr++;
+ OS.memmove(c, strPtr, 1);
+ }
+ String xlfd = stringBuffer.toString().toLowerCase();
+ int avg = FontData.motif_new(xlfd).averageWidth / 10;
+ OS.XtFree(ptr);
+ if (avg == 0) {
+ /**
+ * Not all fonts have average character width encoded
+ * in the xlfd. This one doesn't, so do it the hard
+ * way by averaging all the character widths.
+ */
+ int sum = 0, count = 0;
+ int cols = fontStruct.max_char_or_byte2 - fontStruct.min_char_or_byte2 + 1;
+ int perCharPtr = fontStruct.per_char;
+ XCharStruct struct = new XCharStruct();
+ for (int index = 0; index < cols; index++) {
+ OS.memmove(struct, perCharPtr + (index * XCharStruct.sizeof), XCharStruct.sizeof);
+ int w = struct.width;
+ if (w != 0) {
+ sum += w;
+ count++;
+ }
+ }
+ averageCharWidth += sum / count;
+ } else {
+ /* Average character width was in the xlfd */
+ averageCharWidth += avg;
+ }
+ numAverageCharWidth++;
+ break;
+ }
+ propPtr += 8;
+ }
+ }
+ else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet(fontPtr, fontStructPtr, fontNamePtr);
+ int [] fontStructs = new int[nFonts];
+ OS.memmove(fontStructs, fontStructPtr[0], nFonts * 4);
+ /* Go through each fontStruct in the font set */
+ for (int i = 0; i < nFonts; i++) {
+ OS.memmove(fontStruct, fontStructs[i], XFontStruct.sizeof);
+ ascent = ascent > fontStruct.max_bounds_ascent ? ascent : fontStruct.max_bounds_ascent;
+ descent = descent > fontStruct.descent ? descent : fontStruct.descent;
+ int tmp = fontStruct.ascent + fontStruct.descent;
+ height = height > tmp ? height : tmp;
+ tmp = fontStruct.ascent - fontStruct.max_bounds_ascent;
+ leading = leading > tmp ? leading : tmp;
+ /* Calculate average character width */
+ int propPtr = fontStruct.properties;
+ for (int j = 0; j < fontStruct.n_properties; j++) {
+ /* Reef through properties looking for XAFONT */
+ int[] prop = new int[2];
+ OS.memmove(prop, propPtr, 8);
+ if (prop[0] == OS.XA_FONT) {
+ /* Found it, prop[1] points to the string */
+ StringBuffer stringBuffer = new StringBuffer();
+ int ptr = OS.XmGetAtomName(xDisplay, prop[1]);
+ int strPtr = ptr;
+ byte[] c = new byte[1];
+ OS.memmove(c, strPtr, 1);
+ while (c[0] != 0) {
+ stringBuffer.append((char)c[0]);
+ strPtr++;
+ OS.memmove(c, strPtr, 1);
+ }
+ String xlfd = stringBuffer.toString().toLowerCase();
+ int avg = FontData.motif_new(xlfd).averageWidth / 10;
+ OS.XFree(ptr);
+ if (avg == 0) {
+ /**
+ * Not all fonts have average character width encoded
+ * in the xlfd. This one doesn't, so do it the hard
+ * way by averaging all the character widths.
+ */
+ int sum = 0, count = 0;
+ int cols = fontStruct.max_char_or_byte2 - fontStruct.min_char_or_byte2 + 1;
+ int perCharPtr = fontStruct.per_char;
+ XCharStruct struct = new XCharStruct();
+ for (int index = 0; index < cols; index++) {
+ OS.memmove(struct, perCharPtr + (index * XCharStruct.sizeof), XCharStruct.sizeof);
+ int w = struct.width;
+ if (w != 0) {
+ sum += w;
+ count++;
+ }
+ }
+ averageCharWidth += sum / count;
+ } else {
+ /* Average character width was in the xlfd */
+ averageCharWidth += avg;
+ }
+ numAverageCharWidth++;
+ break;
+ }
+ propPtr += 8;
+ }
+ }
+ }
+ }
+ OS.XmFontListFreeFontContext(context);
+ return FontMetrics.motif_new(ascent, descent, averageCharWidth / numAverageCharWidth, leading, height);
+}
+public Color getForeground() {
+ int xDisplay = data.display;
+ XGCValues values = new XGCValues();
+ if (OS.XGetGCValues(xDisplay, handle, OS.GCForeground, values) == 0) {
+ // Check error case here. If a palette has been set we may be able
+ // to do a better job.
+ return null;
+ }
+ XColor xColor = new XColor();
+ xColor.pixel = values.foreground;
+ OS.XQueryColor(xDisplay,data.colormap,xColor);
+ return Color.motif_new(data.device, xColor);
+
+}
+public int getLineStyle() {
+ return data.lineStyle;
+}
+public int getLineWidth() {
+ XGCValues values = new XGCValues();
+ OS.XGetGCValues(data.display, handle, OS.GCLineWidth, values);
+ return values.line_width;
+}
+public boolean getXORMode() {
+ XGCValues values = new XGCValues ();
+ OS.XGetGCValues (data.display, handle, OS.GCFunction, values);
+ return values.function == OS.GXxor;
+}
+public int hashCode () {
+ return handle;
+}
+void init(Drawable drawable, GCData data, int xGC) {
+ int xDisplay = data.display;
+ int foreground = data.foreground;
+ if (foreground != -1) OS.XSetForeground (xDisplay, xGC, foreground);
+ int background = data.background;
+ if (background != -1) OS.XSetBackground (xDisplay, xGC, background);
+ 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 = xGC;
+}
+public boolean isClipped() {
+ return data.clipRgn != 0;
+}
+public boolean isDisposed() {
+ return handle == 0;
+}
+public static GC motif_new(Drawable drawable, GCData data) {
+ GC gc = new GC();
+ int xGC = drawable.internal_new_GC(data);
+ gc.init(drawable, data, xGC);
+ return gc;
+}
+public void setBackground (Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.XSetBackground(data.display, handle, color.handle.pixel);
+}
+public void setClipping (int x, int y, int width, int height) {
+ int clipRgn = data.clipRgn;
+ if (clipRgn == 0) {
+ clipRgn = OS.XCreateRegion ();
+ } else {
+ OS.XSubtractRegion (clipRgn, clipRgn, clipRgn);
+ }
+ XRectangle rect = new XRectangle ();
+ rect.x = (short) x; rect.y = (short) y;
+ rect.width = (short) width; rect.height = (short) height;
+ OS.XSetClipRectangles (data.display, handle, 0, 0, rect, 1, OS.Unsorted);
+ OS.XUnionRectWithRegion(rect, clipRgn, clipRgn);
+}
+public void setClipping (Rectangle rect) {
+ if (rect == null) {
+ OS.XSetClipMask (data.display, handle, OS.None);
+ return;
+ }
+ setClipping (rect.x, rect.y, rect.width, rect.height);
+}
+public void setClipping (Region region) {
+ int clipRgn = data.clipRgn;
+ if (region == null) {
+ OS.XSetClipMask (data.display, handle, OS.None);
+ if (clipRgn != 0) {
+ OS.XDestroyRegion (clipRgn);
+ clipRgn = 0;
+ }
+ } else {
+ if (clipRgn == 0) {
+ clipRgn = OS.XCreateRegion ();
+ } else {
+ OS.XSubtractRegion (clipRgn, clipRgn, clipRgn);
+ }
+ OS.XUnionRegion (region.handle, clipRgn, clipRgn);
+ OS.XSetRegion (data.display, handle, region.handle);
+ }
+}
+public void setFont (Font font) {
+ if (font == null) font = data.device.getSystemFont ();
+ if (font.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ data.fontList = font.handle;
+ if (data.renderTable != 0) OS.XmRenderTableFree(data.renderTable);
+ data.renderTable = 0;
+}
+public void setForeground (Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ OS.XSetForeground(data.display, handle, color.handle.pixel);
+}
+public void setLineStyle(int lineStyle) {
+ int xDisplay = data.display;
+ switch (lineStyle) {
+ case SWT.LINE_SOLID:
+ data.lineStyle = lineStyle;
+ OS.XSetLineAttributes(xDisplay, handle, 0, OS.LineSolid, OS.CapButt, OS.JoinMiter);
+ return;
+ case SWT.LINE_DASH:
+ OS.XSetDashes(xDisplay,handle,0, new byte[] {6, 2},2);
+ break;
+ case SWT.LINE_DOT:
+ OS.XSetDashes(xDisplay,handle,0, new byte[] {3, 1},2);
+ break;
+ case SWT.LINE_DASHDOT:
+ OS.XSetDashes(xDisplay,handle,0, new byte[] {6, 2, 3, 1},4);
+ break;
+ case SWT.LINE_DASHDOTDOT:
+ OS.XSetDashes(xDisplay,handle,0, new byte[] {6, 2, 3, 1, 3, 1},6);
+ break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ data.lineStyle = lineStyle;
+ OS.XSetLineAttributes(xDisplay, handle, 0, OS.LineDoubleDash, OS.CapButt, OS.JoinMiter);
+
+}
+public void setLineWidth(int width) {
+ if (data.lineStyle == SWT.LINE_SOLID) {
+ OS.XSetLineAttributes(data.display, handle, width, OS.LineSolid, OS.CapButt, OS.JoinMiter);
+ } else {
+ OS.XSetLineAttributes(data.display, handle, width, OS.LineDoubleDash, OS.CapButt, OS.JoinMiter);
+ }
+}
+public void setXORMode(boolean val) {
+ if (val)
+ OS.XSetFunction(data.display, handle, OS.GXxor);
+ else
+ OS.XSetFunction(data.display, handle, OS.GXcopy);
+}
+public Point stringExtent(String string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (string.length () == 0) return new Point(0, getFontHeight());
+ byte[] buffer = Converter.wcsToMbcs(null, string, true);
+ int xmString = OS.XmStringCreate(buffer, OS.XmFONTLIST_DEFAULT_TAG);
+ int fontList = data.fontList;
+ int width = OS.XmStringWidth(fontList, xmString);
+ int height = OS.XmStringHeight(fontList, xmString);
+ OS.XmStringFree(xmString);
+ return new Point(width, height);
+}
+public Point textExtent(String string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (string.length () == 0) return new Point(0, getFontHeight());
+ byte [] textBuffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringGenerate(textBuffer, null, OS.XmCHARSET_TEXT, _MOTIF_DEFAULT_LOCALE);
+ if (data.renderTable == 0) createRenderTable();
+ int renderTable = data.renderTable;
+ int width = OS.XmStringWidth(renderTable, xmString);
+ int height = OS.XmStringHeight(renderTable, xmString);
+ OS.XmStringFree(xmString);
+ return new Point(width, height);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java
new file mode 100755
index 0000000000..410257e4af
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/GCData.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+
+public final class GCData {
+ public Device device;
+ public Image image;
+ public int display;
+ public int drawable;
+ public int foreground = -1;
+ public int background = -1;
+ public int fontList;
+ public int colormap;
+ public int clipRgn;
+ public int lineStyle = SWT.LINE_SOLID;
+ public int renderTable;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
new file mode 100755
index 0000000000..6d43261abd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Image.java
@@ -0,0 +1,872 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import java.io.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Image implements Drawable {
+ /**
+ * Specifies whether the receiver is a bitmap or an icon.
+ * Values: SWT.BITMAP, SWT.ICON
+ */
+ public int type;
+
+ /**
+ * The handle to the OS pixmap resource.
+ * Warning: This field is platform dependent.
+ */
+ public int pixmap;
+
+ /**
+ * The handle to the OS mask resource.
+ * Warning: This field is platform dependent.
+ */
+ public int mask;
+
+ /**
+ * The device where this image was created.
+ */
+ Device device;
+
+ /**
+ * specifies the transparent pixel
+ * (Warning: This field is platform dependent)
+ */
+ int transparentPixel = -1;
+
+ /**
+ * The GC the image is currently selected in.
+ * Warning: This field is platform dependent.
+ */
+ GC memGC;
+
+ /**
+ * The alpha data of the image.
+ * Warning: This field is platform dependent.
+ */
+ byte[] alphaData;
+
+ /**
+ * The global alpha value to be used for every pixel.
+ * Warning: This field is platform dependent.
+ */
+ int alpha = -1;
+
+ /**
+ * Specifies the default scanline padding.
+ * Warning: This field is platform dependent.
+ */
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image() {
+}
+public Image(Device device, int width, int height) {
+ init(device, width, height);
+}
+public Image(Device device, Image srcImage, int flag) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int xDisplay = device.xDisplay;
+ this.type = srcImage.type;
+ this.mask = 0;
+ int[] unused = new int[1];
+ int[] w = new int[1];
+ int[] h = new int[1];
+ OS.XGetGeometry(xDisplay, srcImage.pixmap, unused, unused, unused, w, h, unused, unused);
+ int width = w[0];
+ int height = h[0];
+ int drawable = OS.XDefaultRootWindow(xDisplay);
+ /* Don't create the mask here if flag is SWT.IMAGE_GRAY. See below.*/
+ if (flag != SWT.IMAGE_GRAY && srcImage.mask != 0) {
+ /* Generate the mask if necessary. */
+ if (srcImage.transparentPixel != -1) srcImage.createMask();
+ int mask = OS.XCreatePixmap(xDisplay, drawable, width, height, 1);
+ int gc = OS.XCreateGC(xDisplay, mask, 0, null);
+ OS.XCopyArea(xDisplay, srcImage.mask, mask, gc, 0, 0, width, height, 0, 0);
+ OS.XFreeGC(xDisplay, gc);
+ 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();
+ }
+ switch (flag) {
+ case SWT.IMAGE_COPY:
+ int[] depth = new int[1];
+ OS.XGetGeometry(xDisplay, srcImage.pixmap, unused, unused, unused, unused, unused, unused, depth);
+ int pixmap = OS.XCreatePixmap(xDisplay, drawable, width, height, depth[0]);
+ int gc = OS.XCreateGC(xDisplay, pixmap, 0, null);
+ OS.XCopyArea(xDisplay, srcImage.pixmap, pixmap, gc, 0, 0, width, height, 0, 0);
+ OS.XFreeGC(xDisplay, gc);
+ this.pixmap = pixmap;
+ 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);
+ }
+ return;
+ case SWT.IMAGE_DISABLE:
+ /* Get src image data */
+ XImage srcXImage = new XImage();
+ int srcXImagePtr = OS.XGetImage(xDisplay, srcImage.pixmap, 0, 0, width, height, OS.AllPlanes, OS.ZPixmap);
+ OS.memmove(srcXImage, srcXImagePtr, XImage.sizeof);
+ byte[] srcData = new byte[srcXImage.bytes_per_line * srcXImage.height];
+ OS.memmove(srcData, srcXImage.data, srcData.length);
+ /* Create destination image */
+ int destPixmap = OS.XCreatePixmap(xDisplay, drawable, width, height, srcXImage.depth);
+ XImage destXImage = new XImage();
+ int destXImagePtr = OS.XGetImage(xDisplay, drawable, 0, 0, width, height, OS.AllPlanes, OS.ZPixmap);
+ OS.memmove(destXImage, destXImagePtr, XImage.sizeof);
+ byte[] destData = new byte[destXImage.bytes_per_line * destXImage.height];
+ /* Find the colors to map to */
+ Color zeroColor = device.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ Color oneColor = device.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+ int zeroPixel = zeroColor.handle.pixel;
+ int onePixel = oneColor.handle.pixel;
+ switch (srcXImage.bits_per_pixel) {
+ case 1:
+ /**
+ * Nothing we can reasonably do here except copy
+ * the bitmap; we can't make it a higher color depth.
+ * Short-circuit the rest of the code and return.
+ */
+ gc = OS.XCreateGC(xDisplay, drawable, 0, null);
+ pixmap = OS.XCreatePixmap(xDisplay, drawable, width, height, 1);
+ OS.XCopyArea(xDisplay, srcImage.pixmap, pixmap, gc, 0, 0, width, height, 0, 0);
+ OS.XDestroyImage(srcXImagePtr);
+ OS.XDestroyImage(destXImagePtr);
+ OS.XFreeGC(xDisplay, gc);
+ return;
+ case 4:
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ break;
+ case 8:
+ int index = 0;
+ int srcPixel, r, g, b;
+ XColor[] colors = new XColor[256];
+ int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
+ for (int y = 0; y < srcXImage.height; y++) {
+ for (int x = 0; x < srcXImage.bytes_per_line; x++) {
+ srcPixel = srcData[index + x] & 0xFF;
+ /* Get the RGB values of srcPixel */
+ if (colors[srcPixel] == null) {
+ XColor color = new XColor();
+ color.pixel = srcPixel;
+ OS.XQueryColor(xDisplay, colormap, color);
+ colors[srcPixel] = color;
+ }
+ XColor xColor = colors[srcPixel];
+ r = (xColor.red >> 8) & 0xFF;
+ g = (xColor.green >> 8) & 0xFF;
+ b = (xColor.blue >> 8) & 0xFF;
+ /* See if the rgb maps to 0 or 1 */
+ if ((r * r + g * g + b * b) < 98304) {
+ /* Map down to 0 */
+ destData[index + x] = (byte)zeroPixel;
+ } else {
+ /* Map up to 1 */
+ destData[index + x] = (byte)onePixel;
+ }
+ }
+ index += srcXImage.bytes_per_line;
+ }
+ break;
+ case 16:
+ index = 0;
+ /* Get masks */
+ Visual visual = new Visual();
+ int screenNum = OS.XDefaultScreen(xDisplay);
+ int visualPtr = OS.XDefaultVisual(xDisplay, screenNum);
+ OS.memmove(visual, visualPtr, Visual.sizeof);
+ int redMask = visual.red_mask;
+ int greenMask = visual.green_mask;
+ int blueMask = visual.blue_mask;
+ /* Calculate mask shifts */
+ int[] shift = new int[1];
+ getOffsetForMask(16, redMask, srcXImage.byte_order, shift);
+ int rShift = 24 - shift[0];
+ getOffsetForMask(16, greenMask, srcXImage.byte_order, shift);
+ int gShift = 24 - shift[0];
+ getOffsetForMask(16, blueMask, srcXImage.byte_order, shift);
+ int bShift = 24 - shift[0];
+ byte zeroLow = (byte)(zeroPixel & 0xFF);
+ byte zeroHigh = (byte)((zeroPixel >> 8) & 0xFF);
+ byte oneLow = (byte)(onePixel & 0xFF);
+ byte oneHigh = (byte)((onePixel >> 8) & 0xFF);
+ for (int y = 0; y < srcXImage.height; y++) {
+ int xIndex = 0;
+ for (int x = 0; x < srcXImage.bytes_per_line; x += 2) {
+ srcPixel = ((srcData[index + xIndex + 1] & 0xFF) << 8) | (srcData[index + xIndex] & 0xFF);
+ r = (srcPixel & redMask) << rShift >> 16;
+ g = (srcPixel & greenMask) << gShift >> 16;
+ b = (srcPixel & blueMask) << bShift >> 16;
+ /* See if the rgb maps to 0 or 1 */
+ if ((r * r + g * g + b * b) < 98304) {
+ /* Map down to 0 */
+ destData[index + xIndex] = zeroLow;
+ destData[index + xIndex + 1] = zeroHigh;
+ } else {
+ /* Map up to 1 */
+ destData[index + xIndex] = oneLow;
+ destData[index + xIndex + 1] = oneHigh;
+ }
+ xIndex += srcXImage.bits_per_pixel / 8;
+ }
+ index += srcXImage.bytes_per_line;
+ }
+ break;
+ case 24:
+ case 32:
+ index = 0;
+ /* Get masks */
+ visual = new Visual();
+ screenNum = OS.XDefaultScreen(xDisplay);
+ visualPtr = OS.XDefaultVisual(xDisplay, screenNum);
+ OS.memmove(visual, visualPtr, Visual.sizeof);
+ redMask = visual.red_mask;
+ greenMask = visual.green_mask;
+ blueMask = visual.blue_mask;
+ /* Calculate mask shifts */
+ shift = new int[1];
+ getOffsetForMask(srcXImage.bits_per_pixel, redMask, srcXImage.byte_order, shift);
+ rShift = shift[0];
+ getOffsetForMask(srcXImage.bits_per_pixel, greenMask, srcXImage.byte_order, shift);
+ gShift = shift[0];
+ getOffsetForMask(srcXImage.bits_per_pixel, blueMask, srcXImage.byte_order, shift);
+ bShift = shift[0];
+ byte zeroR = (byte)zeroColor.getRed();
+ byte zeroG = (byte)zeroColor.getGreen();
+ byte zeroB = (byte)zeroColor.getBlue();
+ byte oneR = (byte)oneColor.getRed();
+ byte oneG = (byte)oneColor.getGreen();
+ byte oneB = (byte)oneColor.getBlue();
+ for (int y = 0; y < srcXImage.height; y++) {
+ int xIndex = 0;
+ for (int x = 0; x < srcXImage.width; x++) {
+ r = srcData[index + xIndex + rShift] & 0xFF;
+ g = srcData[index + xIndex + gShift] & 0xFF;
+ b = srcData[index + xIndex + bShift] & 0xFF;
+ /* See if the rgb maps to 0 or 1 */
+ if ((r * r + g * g + b * b) < 98304) {
+ /* Map down to 0 */
+ destData[index + xIndex + rShift] = zeroR;
+ destData[index + xIndex + gShift] = zeroG;
+ destData[index + xIndex + bShift] = zeroB;
+ } else {
+ /* Map up to 1 */
+ destData[index + xIndex + rShift] = oneR;
+ destData[index + xIndex + gShift] = oneG;
+ destData[index + xIndex + bShift] = oneB;
+ }
+ xIndex += destXImage.bits_per_pixel / 8;
+ }
+ index += srcXImage.bytes_per_line;
+ }
+ break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ }
+ OS.memmove(destXImage.data, destData, destData.length);
+ gc = OS.XCreateGC(xDisplay, destPixmap, 0, null);
+ OS.XPutImage(xDisplay, destPixmap, gc, destXImagePtr, 0, 0, 0, 0, width, height);
+ OS.XDestroyImage(destXImagePtr);
+ OS.XDestroyImage(srcXImagePtr);
+ OS.XFreeGC(xDisplay, gc);
+ this.pixmap = destPixmap;
+ return;
+ case SWT.IMAGE_GRAY:
+ ImageData data = srcImage.getImageData();
+ PaletteData palette = data.palette;
+ ImageData newData = data;
+ if (!palette.isDirect) {
+ /* Convert the palette entries to gray. */
+ RGB [] rgbs = palette.getRGBs();
+ for (int i=0; i<rgbs.length; i++) {
+ if (data.transparentPixel != i) {
+ RGB color = rgbs [i];
+ int red = color.red;
+ int green = color.green;
+ int blue = color.blue;
+ int intensity = (red+red+green+green+green+green+green+blue) >> 3;
+ color.red = color.green = color.blue = intensity;
+ }
+ }
+ newData.palette = new PaletteData(rgbs);
+ } else {
+ /* Create a 8 bit depth image data with a gray palette. */
+ RGB[] rgbs = new RGB[256];
+ for (int i=0; i<rgbs.length; i++) {
+ rgbs[i] = new RGB(i, i, i);
+ }
+ newData = new ImageData(width, height, 8, new PaletteData(rgbs));
+ newData.maskData = data.maskData;
+ newData.maskPad = data.maskPad;
+
+ /* Convert the pixels. */
+ int[] scanline = new int[width];
+ 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 y=0; y<height; y++) {
+ int offset = y * newData.bytesPerLine;
+ data.getPixels(0, y, width, scanline, 0);
+ for (int x=0; x<width; x++) {
+ int pixel = scanline[x];
+ int red = pixel & redMask;
+ red = (redShift < 0) ? red >>> -redShift : red << redShift;
+ int green = pixel & greenMask;
+ green = (greenShift < 0) ? green >>> -greenShift : green << greenShift;
+ int blue = pixel & blueMask;
+ blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift;
+ newData.data[offset++] =
+ (byte)((red+red+green+green+green+green+green+blue) >> 3);
+ }
+ }
+ }
+ init (device, newData);
+ break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+public Image(Device device, Rectangle bounds) {
+ if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, bounds.width, bounds.height);
+}
+public Image(Device device, ImageData image) {
+ init(device, image);
+}
+public Image(Device device, ImageData source, ImageData mask) {
+ 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);
+ }
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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(device, image);
+}
+public Image(Device device, InputStream stream) {
+ init(device, new ImageData(stream));
+}
+public Image(Device device, String filename) {
+ init(device, new ImageData(filename));
+}
+/**
+ * Create the receiver's mask if necessary.
+ */
+void createMask() {
+ if (mask != 0) return;
+ int xDisplay = device.xDisplay;
+ int drawable = OS.XDefaultRootWindow(xDisplay);
+ int screenDepth = OS.XDefaultDepthOfScreen(OS.XDefaultScreenOfDisplay(xDisplay));
+ int visual = OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay));
+ ImageData maskImage = getImageData().getTransparencyMask();
+ int maskPixmap = OS.XCreatePixmap(xDisplay, drawable, maskImage.width, maskImage.height, 1);
+ XColor[] xcolors = device.xcolors;
+ int gc = OS.XCreateGC(xDisplay, maskPixmap, 0, null);
+ int error = Image.putImage(maskImage, 0, 0, maskImage.width, maskImage.height, 0, 0, maskImage.width, maskImage.height, xDisplay, visual, screenDepth, xcolors, null, maskPixmap, gc);
+ OS.XFreeGC(xDisplay, gc);
+ this.mask = maskPixmap;
+}
+public void dispose () {
+ if (pixmap == 0) return;
+ int xDisplay = device.xDisplay;
+ if (pixmap != 0) OS.XFreePixmap (xDisplay, pixmap);
+ if (mask != 0) OS.XFreePixmap (xDisplay, mask);
+ device = null;
+ memGC = null;
+ pixmap = mask = 0;
+}
+/**
+ * Destroy the receiver's mask if it exists.
+ */
+void destroyMask() {
+ if (mask == 0) return;
+ OS.XFreePixmap (device.xDisplay, mask);
+ mask = 0;
+}
+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 &&
+ transparentPixel == image.transparentPixel &&
+ mask == image.mask;
+}
+public Color getBackground() {
+ if (transparentPixel == -1) return null;
+ XColor xColor = new XColor();
+ xColor.pixel = transparentPixel;
+ int xDisplay = device.xDisplay;
+ int colormap = OS.XDefaultColormap(xDisplay, OS.XDefaultScreen(xDisplay));
+ OS.XQueryColor(xDisplay, colormap, xColor);
+ return Color.motif_new(device, xColor);
+}
+public Rectangle getBounds () {
+ if (pixmap == 0) return new Rectangle(0, 0, 0, 0);
+ int [] unused = new int [1]; int [] width = new int [1]; int [] height = new int [1];
+ OS.XGetGeometry (device.xDisplay, pixmap, unused, unused, unused, width, height, unused, unused);
+ return new Rectangle(0, 0, width [0], height [0]);
+}
+public ImageData getImageData() {
+ Rectangle srcBounds = getBounds();
+ int width = srcBounds.width;
+ int height = srcBounds.height;
+ int xDisplay = device.xDisplay;
+ int xSrcImagePtr = OS.XGetImage(xDisplay, pixmap, 0, 0, width, height, OS.AllPlanes, OS.ZPixmap);
+ if (xSrcImagePtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ XImage xSrcImage = new XImage();
+ OS.memmove(xSrcImage, xSrcImagePtr, XImage.sizeof);
+ /* Calculate the palette depending on the display attributes */
+ PaletteData palette = null;
+ switch (xSrcImage.depth) {
+ case 1:
+ palette = new PaletteData(new RGB[] {
+ new RGB(0, 0, 0),
+ new RGB(255, 255, 255)
+ });
+ break;
+ case 4:
+ /**
+ * We currently don't run on a 4-bit server, so 4-bit images
+ * should not exist.
+ */
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ case 8:
+ /* Use the RGBs from the display to make the palette */
+ XColor[] xcolors = device.xcolors;
+ RGB[] rgbs = new RGB[xcolors.length];
+ for (int i = 0; i < rgbs.length; i++) {
+ XColor xcolor = xcolors[i];
+ if (xcolor == null) rgbs[i] = new RGB(0, 0, 0);
+ else rgbs[i] = new RGB((xcolor.red >> 8) & 0xFF, (xcolor.green >> 8) & 0xFF, (xcolor.blue >> 8) & 0xFF);
+ }
+ palette = new PaletteData(rgbs);
+ break;
+ case 16:
+ /**
+ * For some reason, the XImage does not have the mask information.
+ * We must get it from the visual.
+ */
+ int visual = OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay));
+ Visual v = new Visual();
+ OS.memmove(v, visual, Visual.sizeof);
+ palette = new PaletteData(v.red_mask, v.green_mask, v.blue_mask);
+ break;
+ case 24:
+ /* We always create 24-bit ImageData with the following palette */
+ palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ ImageData data = new ImageData(width, height, xSrcImage.depth, palette);
+ int length = xSrcImage.bytes_per_line * xSrcImage.height;
+ data.data = new byte[length];
+ OS.memmove(data.data, xSrcImage.data, length);
+ if (xSrcImage.bits_per_pixel == 32) {
+ /**
+ * If bits per pixel is 32, scale the data down to 24, since we do not
+ * support 32-bit images
+ */
+ byte[] oldData = data.data;
+ int bytesPerLine = (xSrcImage.width * xSrcImage.depth + 7) / 8;
+ bytesPerLine = (bytesPerLine + 3) / 4 * 4;
+ byte[] newData = new byte[bytesPerLine * xSrcImage.height];
+ int destIndex = 0;
+ int srcIndex = 0;
+ int rOffset = 0, gOffset = 1, bOffset = 2;
+ if (xSrcImage.byte_order == OS.MSBFirst) {
+ rOffset = 2; gOffset = 1; bOffset = 0;
+ }
+ for (int y = 0; y < height; y++) {
+ destIndex = y * bytesPerLine;
+ srcIndex = y * xSrcImage.bytes_per_line;
+ for (int x = 0; x < width; x++) {
+ newData[destIndex] = oldData[srcIndex + rOffset];
+ newData[destIndex + 1] = oldData[srcIndex + gOffset];
+ newData[destIndex + 2] = oldData[srcIndex + bOffset];
+ srcIndex += 4;
+ destIndex += 3;
+ }
+ }
+ data.data = newData;
+ }
+ if (transparentPixel == -1 && type == SWT.ICON && mask != 0) {
+ /* Get the icon data */
+ data.maskPad = 4;
+ int xMaskPtr = OS.XGetImage(xDisplay, mask, 0, 0, width, height, OS.AllPlanes, OS.ZPixmap);
+ if (xMaskPtr == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ XImage xMask = new XImage();
+ OS.memmove(xMask, xMaskPtr, XImage.sizeof);
+ data.maskData = new byte[xMask.bytes_per_line * xMask.height];
+ OS.memmove(data.maskData, xMask.data, data.maskData.length);
+ OS.XDestroyImage(xMaskPtr);
+ /* Bit swap the mask data if necessary */
+ if (xMask.bitmap_bit_order == OS.LSBFirst) {
+ byte[] maskData = data.maskData;
+ 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.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);
+ }
+ OS.XDestroyImage(xSrcImagePtr);
+ return data;
+}
+/**
+ * Get the offset for the given mask.
+ *
+ * For 24 and 32-bit masks, the offset indicates which byte holds the
+ * data for the given mask (indexed from 0).
+ * For example, in 0x0000FF00, the byte offset is 1.
+ *
+ * For 16-bit masks, the offset indicates which bit holds the most significant
+ * data for the given mask (indexed from 1).
+ * For example, in 0x7E0, the bit offset is 11.
+ *
+ * The different semantics are necessary because 24- and 32-bit images
+ * have their color components aligned on byte boundaries, and 16-bit images
+ * do not.
+ */
+static boolean getOffsetForMask(int bitspp, int mask, int byteOrder, int[] poff) {
+ if (bitspp % 8 != 0) {
+ return false;
+ }
+ switch (mask) {
+ /* 24-bit and 32-bit masks */
+ case 0x000000FF:
+ poff[0] = 0;
+ break;
+ case 0x0000FF00:
+ poff[0] = 1;
+ break;
+ case 0x00FF0000:
+ poff[0] = 2;
+ break;
+ case 0xFF000000:
+ poff[0] = 3;
+ break;
+ /* 16-bit masks */
+ case 0x001F:
+ poff[0] = 5;
+ break;
+ case 0x03E0:
+ poff[0] = 10;
+ break;
+ case 0x07E0:
+ poff[0] = 11;
+ break;
+ case 0x7C00:
+ poff[0] = 15;
+ break;
+ case 0xF800:
+ poff[0] = 16;
+ break;
+ default:
+ return false;
+ }
+ if (bitspp == 16) {
+ return true;
+ }
+ if (poff[0] >= bitspp / 8) {
+ return false;
+ }
+ if (byteOrder == OS.MSBFirst) {
+ poff[0] = (bitspp/8 - 1) - poff[0];
+ }
+ return true;
+}
+public int hashCode () {
+ return pixmap;
+}
+void init(Device device, int width, int height) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ /* Create the pixmap */
+ if (width <= 0 | height <= 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ this.type = SWT.BITMAP;
+ int xDisplay = device.xDisplay;
+ int screen = OS.XDefaultScreenOfDisplay(xDisplay);
+ int depth = OS.XDefaultDepthOfScreen(screen);
+ int screenNum = OS.XDefaultScreen(xDisplay);
+ int drawable = OS.XDefaultRootWindow(xDisplay);
+ int xGC = OS.XCreateGC(xDisplay, drawable, 0, null);
+ this.pixmap = OS.XCreatePixmap(xDisplay, drawable, width, height, depth);
+ /* Fill the bitmap with white */
+ OS.XSetForeground(xDisplay, xGC, OS.XWhitePixel(xDisplay, screenNum));
+ OS.XFillRectangle(xDisplay, pixmap, xGC, 0, 0, width, height);
+ OS.XFreeGC(xDisplay, xGC);
+}
+void init(Device device, ImageData image) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int xDisplay = device.xDisplay;
+ int drawable = OS.XDefaultRootWindow(xDisplay);
+ int screenDepth = OS.XDefaultDepthOfScreen(OS.XDefaultScreenOfDisplay(xDisplay));
+ int visual = OS.XDefaultVisual(xDisplay, OS.XDefaultScreen(xDisplay));
+ int pixmap = OS.XCreatePixmap(xDisplay, drawable, image.width, image.height, screenDepth);
+ int gc = OS.XCreateGC(xDisplay, pixmap, 0, null);
+ int[] transPixel = null;
+ if (image.transparentPixel != -1) transPixel = new int[]{image.transparentPixel};
+ int error = putImage(image, 0, 0, image.width, image.height, 0, 0, image.width, image.height, xDisplay, visual, screenDepth, device.xcolors, transPixel, pixmap, gc);
+ OS.XFreeGC(xDisplay, gc);
+ if (error != 0) {
+ OS.XFreePixmap (xDisplay, pixmap);
+ SWT.error(error);
+ }
+ if (image.getTransparencyType() == SWT.TRANSPARENCY_MASK || image.transparentPixel != -1) {
+ if (image.transparentPixel != -1) transparentPixel = transPixel[0];
+ ImageData maskImage = image.getTransparencyMask();
+ int mask = OS.XCreatePixmap(xDisplay, drawable, image.width, image.height, 1);
+ gc = OS.XCreateGC(xDisplay, mask, 0, null);
+ error = putImage(maskImage, 0, 0, maskImage.width, maskImage.height, 0, 0, maskImage.width, maskImage.height, xDisplay, visual, screenDepth, device.xcolors, null, mask, gc);
+ OS.XFreeGC(xDisplay, gc);
+ if (error != 0) {
+ OS.XFreePixmap (xDisplay, pixmap);
+ OS.XFreePixmap (xDisplay, mask);
+ SWT.error(error);
+ }
+ this.mask = mask;
+ if (image.getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ 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);
+ }
+ }
+ this.pixmap = pixmap;
+}
+public int internal_new_GC (GCData data) {
+ if (type != SWT.BITMAP || memGC != null) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int xDisplay = device.xDisplay;
+ int xGC = OS.XCreateGC (xDisplay, pixmap, 0, null);
+ if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ data.device = device;
+ data.display = xDisplay;
+ data.drawable = pixmap;
+ data.fontList = device.getSystemFont ().handle;
+ data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
+ data.image = this;
+ }
+ return xGC;
+}
+public void internal_dispose_GC (int gc, GCData data) {
+ int xDisplay = device.xDisplay;
+ OS.XFreeGC(xDisplay, gc);
+}
+public boolean isDisposed() {
+ return pixmap == 0;
+}
+public static Image motif_new(Device device, int type, int pixmap, int mask) {
+ if (device == null) device = Device.getDevice();
+ Image image = new Image();
+ image.device = device;
+ image.type = type;
+ image.pixmap = pixmap;
+ image.mask = mask;
+ return image;
+}
+/**
+ * Put a device-independent image of any depth into a drawable of any depth,
+ * stretching if necessary.
+ */
+static int putImage(ImageData image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, int display, int visual, int screenDepth, XColor[] xcolors, int[] transparentPixel, int drawable, int gc) {
+ PaletteData palette = image.palette;
+ if (!(((image.depth == 1 || image.depth == 2 || image.depth == 4 || image.depth == 8) && !palette.isDirect) ||
+ ((image.depth == 16 || image.depth == 24) && palette.isDirect)))
+ return SWT.ERROR_UNSUPPORTED_DEPTH;
+
+ boolean flipX = destWidth < 0;
+ boolean flipY = destHeight < 0;
+ if (flipX) {
+ destWidth = -destWidth;
+ destX = destX - destWidth;
+ }
+ if (flipY) {
+ destHeight = -destHeight;
+ destY = destY - destHeight;
+ }
+ byte[] srcReds = null, srcGreens = null, srcBlues = null;
+ if (image.depth <= 8) {
+ int length = palette.getRGBs().length;
+ srcReds = new byte[length];
+ srcGreens = new byte[length];
+ srcBlues = new byte[length];
+ RGB[] rgbs = palette.getRGBs();
+ 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;
+ }
+ }
+ byte[] destReds = null, destGreens = null, destBlues = null;
+ int destRedMask = 0, destGreenMask = 0, destBlueMask = 0;
+ if (screenDepth <= 8) {
+ if (xcolors == null) return SWT.ERROR_UNSUPPORTED_DEPTH;
+ destReds = new byte[xcolors.length];
+ destGreens = new byte[xcolors.length];
+ destBlues = new byte[xcolors.length];
+ for (int i = 0; i < xcolors.length; i++) {
+ XColor color = xcolors[i];
+ if (color == null) continue;
+ destReds[i] = (byte)((color.red >> 8) & 0xFF);
+ destGreens[i] = (byte)((color.green >> 8) & 0xFF);
+ destBlues[i] = (byte)((color.blue >> 8) & 0xFF);
+ }
+ } else {
+ Visual xVisual = new Visual();
+ OS.memmove(xVisual, visual, Visual.sizeof);
+ destRedMask = xVisual.red_mask;
+ destGreenMask = xVisual.green_mask;
+ destBlueMask = xVisual.blue_mask;
+ }
+ if (transparentPixel != null) {
+ RGB rgb = image.palette.getRGB(transparentPixel[0]);
+ transparentPixel[0] = ImageData.closestMatch(screenDepth, (byte)rgb.red, (byte)rgb.green, (byte)rgb.blue,
+ destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
+ }
+
+ /* Depth 1 */
+ if (image.depth == 1) {
+ int bplX = ((destWidth + 7) / 8 + 3) & 0xFFFC;
+ int bufSize = bplX * destHeight;
+ byte[] buf = new byte[bufSize];
+ int bufPtr = OS.XtMalloc(bufSize);
+ int xImagePtr = OS.XCreateImage(display, visual, 1, OS.XYBitmap, 0, bufPtr, destWidth, destHeight, 32, bplX);
+ if (xImagePtr == 0) {
+ OS.XtFree(bufPtr);
+ return SWT.ERROR_NO_HANDLES;
+ }
+ int foreground = 0, background = 0;
+ if (srcReds.length > 1) {
+ foreground = ImageData.closestMatch(screenDepth, srcReds[1], srcGreens[1], srcBlues[1],
+ destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
+ }
+ if (srcReds.length > 0) {
+ background = ImageData.closestMatch(screenDepth, srcReds[0], srcGreens[0], srcBlues[0],
+ destRedMask, destGreenMask, destBlueMask, destReds, destGreens, destBlues);
+ }
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ xImage.byte_order = OS.MSBFirst;
+ xImage.bitmap_unit = 8;
+ xImage.bitmap_bit_order = OS.MSBFirst;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ int destOrder = ImageData.MSB_FIRST;
+ ImageData.stretch1(image.data, image.bytesPerLine, ImageData.MSB_FIRST, srcX, srcY, srcWidth, srcHeight,
+ buf, bplX, ImageData.MSB_FIRST, 0, 0, destWidth, destHeight, flipX, flipY);
+ OS.memmove(xImage.data, buf, bufSize);
+ XGCValues values = new XGCValues();
+ OS.XGetGCValues(display, gc, OS.GCForeground | OS.GCBackground, values);
+ OS.XSetForeground(display, gc, foreground);
+ OS.XSetBackground(display, gc, background);
+ OS.XPutImage(display, drawable, gc, xImagePtr, 0, 0, destX, destY, destWidth, destHeight);
+ OS.XSetForeground(display, gc, values.foreground);
+ OS.XSetBackground(display, gc, values.background);
+ OS.XDestroyImage(xImagePtr);
+ return 0;
+ }
+
+ /* Depths other than 1 */
+ int xImagePtr = OS.XCreateImage(display, visual, screenDepth, OS.ZPixmap, 0, 0, destWidth, destHeight, 32, 0);
+ if (xImagePtr == 0) return SWT.ERROR_NO_HANDLES;
+ XImage xImage = new XImage();
+ OS.memmove(xImage, xImagePtr, XImage.sizeof);
+ int bufSize = xImage.bytes_per_line * destHeight;
+ byte[] buf = new byte[bufSize];
+ int bufPtr = OS.XtMalloc(bufSize);
+ xImage.data = bufPtr;
+ OS.memmove(xImagePtr, xImage, XImage.sizeof);
+ int srcOrder = image.depth == 16 ? ImageData.LSB_FIRST : ImageData.MSB_FIRST;
+ int destOrder = xImage.byte_order == OS.MSBFirst ? ImageData.MSB_FIRST : ImageData.LSB_FIRST;
+ if (image.depth > 8 && screenDepth > 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
+ flipX, flipY);
+ } else if (image.depth <= 8 && screenDepth > 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, xImage.red_mask, xImage.green_mask, xImage.blue_mask,
+ flipX, flipY);
+ } else if (image.depth > 8 && screenDepth <= 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, palette.redMask, palette.greenMask, palette.blueMask, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
+ flipX, flipY);
+ } else if (image.depth <= 8 && screenDepth <= 8) {
+ ImageData.blit(ImageData.BLIT_SRC,
+ image.data, image.depth, image.bytesPerLine, srcOrder, srcX, srcY, srcWidth, srcHeight, srcReds, srcGreens, srcBlues, -1, null, 0,
+ buf, xImage.bits_per_pixel, xImage.bytes_per_line, destOrder, 0, 0, destWidth, destHeight, destReds, destGreens, destBlues,
+ flipX, flipY);
+ }
+ OS.memmove(xImage.data, buf, bufSize);
+ OS.XPutImage(display, drawable, gc, xImagePtr, 0, 0, destX, destY, destWidth, destHeight);
+ OS.XDestroyImage(xImagePtr);
+ return 0;
+}
+public void setBackground(Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (color.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (transparentPixel == -1) return;
+ /* Generate the mask if necessary. */
+ if (mask == 0) createMask();
+ Rectangle bounds = getBounds();
+ int[] unused = new int[1];
+ int[] depth = new int[1];
+ int xDisplay = device.xDisplay;
+ OS.XGetGeometry(xDisplay, pixmap, unused, unused, unused, unused, unused, unused, depth);
+ int drawable = OS.XDefaultRootWindow(xDisplay);
+ int tempPixmap = OS.XCreatePixmap(xDisplay, drawable, bounds.width, bounds.height, depth[0]);
+ int xGC = OS.XCreateGC(xDisplay, tempPixmap, 0, null);
+ OS.XSetForeground(xDisplay, xGC, color.handle.pixel);
+ OS.XFillRectangle(xDisplay, tempPixmap, xGC, 0, 0, bounds.width, bounds.height);
+ OS.XSetClipMask(xDisplay, xGC, mask);
+ OS.XCopyArea(xDisplay, pixmap, tempPixmap, xGC, 0, 0, bounds.width, bounds.height, 0, 0);
+ OS.XSetClipMask(xDisplay, xGC, OS.None);
+ OS.XCopyArea(xDisplay, tempPixmap, pixmap, xGC, 0, 0, bounds.width, bounds.height, 0, 0);
+ OS.XFreePixmap(xDisplay, tempPixmap);
+ OS.XFreeGC(xDisplay, xGC);
+ /* Destroy the receiver's mask if the there is a GC created on it */
+ if (memGC != null) destroyMask();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
new file mode 100755
index 0000000000..9558cca0cc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/graphics/Region.java
@@ -0,0 +1,79 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Region {
+ /**
+ * The handle to the OS region resource.
+ * Warning: This field is platform dependent.
+ */
+ public int handle;
+public Region () {
+ handle = OS.XCreateRegion ();
+}
+Region (int handle) {
+ this.handle = handle;
+}
+public void add (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ XRectangle xRect = new XRectangle();
+ xRect.x = (short)rect.x;
+ xRect.y = (short)rect.y;
+ xRect.width = (short)rect.width;
+ xRect.height = (short)rect.height;
+ OS.XUnionRectWithRegion(xRect, handle, handle);
+}
+public void add (Region region) {
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ OS.XUnionRegion(handle, region.handle, handle);
+}
+public boolean contains (int x, int y) {
+ return OS.XPointInRegion(handle, x, y);
+}
+public boolean contains (Point pt) {
+ if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return contains(pt.x, pt.y);
+}
+public void dispose () {
+ if (handle != 0) OS.XDestroyRegion(handle);
+ handle = 0;
+}
+public boolean equals (Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ int xRegion = ((Region)object).handle;
+ if (handle == xRegion) return true;
+ if (xRegion == 0) return false;
+ return OS.XEqualRegion(handle, xRegion);
+}
+public Rectangle getBounds() {
+ XRectangle rect = new XRectangle();
+ OS.XClipBox(handle, rect);
+ return new Rectangle(rect.x, rect.y, rect.width, rect.height);
+}
+public int hashCode () {
+ return handle;
+}
+public boolean intersects (int x, int y, int width, int height) {
+ return OS.XRectInRegion (handle, x, y, width, height) != OS.RectangleOut;
+}
+public boolean intersects (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+public boolean isDisposed() {
+ return handle == 0;
+}
+public boolean isEmpty () {
+ return OS.XEmptyRegion(handle);
+}
+public static Region motif_new(int handle) {
+ return new Region(handle);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
new file mode 100755
index 0000000000..682f69081f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/Converter.java
@@ -0,0 +1,71 @@
+package org.eclipse.swt.internal;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Converter {
+ public static final byte [] NullByteArray = new byte [1];
+ public static final char [] NullCharArray = new char [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
+public static String defaultCodePage () {
+ /*
+ | ptr cp |
+ DefaultCodePage == nil ifFalse: [^DefaultCodePage].
+ cp := ''. "$NON-NLS$"
+ (ptr := OSStringZ address: (NlLanginfo callWith: 49)) isNull
+ ifFalse: [cp := String copyFromOSMemory: ptr].
+ cp isEmpty ifFalse: [
+ IsSunOS ifTrue: [
+ (cp size > 3 and: [(cp copyFrom: 1 to: 3) = 'ISO'])
+ ifTrue: [cp := cp copyFrom: 4 to: cp size]].
+ ^DefaultCodePage := cp].
+ IsAIX ifTrue: [^DefaultCodePage := 'ISO8859-1'].
+ IsSunOS ifTrue: [^DefaultCodePage := '8859-1'].
+ ^DefaultCodePage := 'iso8859_1'
+ */
+ return null;
+}
+static boolean is7BitAscii (byte [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if ((buffer [i] & 0xFF) > 0x7F) return false;
+ }
+ return true;
+}
+static boolean is7BitAscii (char [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if (buffer [i] > 0x7F) return false;
+ }
+ return true;
+}
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+ //SLOW AND BOGUS
+ return new String (buffer).toCharArray ();
+}
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, String string) {
+ return wcsToMbcs (codePage, string, false);
+}
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ //SLOW AND BOGUS
+ int count = string.length ();
+ if (terminate) count++;
+ char [] buffer = new char [count];
+ string.getChars (0, string.length (), buffer, 0);
+ return wcsToMbcs (codePage, buffer, false);
+}
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, char [] buffer) {
+ return wcsToMbcs (codePage, buffer, false);
+}
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+ //SLOW AND BOGUS
+ if (!terminate) return new String (buffer).getBytes ();
+ byte [] buffer1 = new String (buffer).getBytes ();
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/GNOME.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/GNOME.java
new file mode 100755
index 0000000000..fe586144f2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/GNOME.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class GNOME extends OS {
+
+public static final native int g_get_home_dir();
+public static final native int gnome_datadir_file(byte[] fileName);
+public static final native void gnome_desktop_entry_free(int entry);
+public static final native int gnome_desktop_entry_load(byte[] fileName);
+public static final native int gnome_mime_get_value(byte[] mimeType, byte[] key);
+public static final native int gnome_mime_type(byte[] fileName);
+public static final native int gnome_pixmap_file(byte[] fileName);
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
new file mode 100755
index 0000000000..af9a2fb618
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/KDE.java
@@ -0,0 +1,54 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class KDE extends OS {
+
+public static final int KICON_SMALL = 0;
+
+public static final native int KApplication_new(int qcString);
+
+public static final native int KGlobal_iconLoader();
+
+public static final native int KIconLoader_iconPath(int receiver, int iconQString, int iconType, int canReturnNull);
+
+public static final native int KMimeType_findByURL(int kurl);
+public static final native int KMimeType_icon(int receiver, int unused1, int unused2);
+public static final native int KMimeType_name(int receiver);
+
+public static final native int KService_allServices();
+public static final native int KService_exec(int receiver);
+public static final native int KService_icon(int receiver);
+public static final native int KService_name(int receiver);
+public static final native int KService_serviceByName(int serviceName);
+public static final native int KService_type(int receiver);
+
+public static final native int KServiceTypeProfile_preferredService(int mimeTypeQString, int needApp);
+
+public static final native void KURL_delete(int receiver);
+
+public static final native int KURL_new(int qString);
+
+public static final native int KServiceList_begin(int receiver);
+public static final native int KServiceList_delete(int receiver);
+public static final native int KServiceList_end(int receiver);
+
+public static final native int QCString_data(int receiver);
+public static final native int QCString_delete(int receiver);
+public static final native int QCString_new(byte[] string);
+
+public static final native int QString_delete(int receiver);
+public static final native int QString_equals(int receiver, int object);
+public static final native int QString_new(byte[] string);
+public static final native int QString_utf8(int receiver);
+
+public static final native int KServiceListIterator_delete(int receiver);
+public static final native int KServiceListIterator_dereference(int receiver);
+public static final native void KServiceListIterator_increment(int receiver);
+public static final native int KServiceListIterator_new(int listBeginning);
+public static final native int KServiceListIterator_equals(int receiver, int object);
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
new file mode 100755
index 0000000000..0aab013563
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/OS.java
@@ -0,0 +1,1250 @@
+package org.eclipse.swt.internal.motif;
+
+import org.eclipse.swt.internal.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class OS {
+
+ /* Load the SWT library. */
+ static {
+ Callback.loadLibrary ();
+ }
+
+ /* X/Xt/Xm Constants */
+ public static final byte [] XmFONTLIST_DEFAULT_TAG = {0x46, 0x4F, 0x4E, 0x54, 0x4C, 0x49, 0x53, 0x54, 0x5F, 0x44, 0x45, 0x46, 0x41, 0x55, 0x4C, 0x54, 0x5F, 0x54, 0x41, 0x47, 0x5F, 0x53, 0x54, 0x52, 0x49, 0x4E, 0x47, 0x0};
+ public static final int Above = 0;
+ public static final int AllPlanes = 0xFFFFFFFF;
+ public static final int AlreadyGrabbed = 1;
+// public static final int ArcChord = 0x0;
+// public static final int ArcPieSlice = 0x1;
+ public static final int Below = 1;
+// public static final int BottomIf = 3;
+ public static final int Button1Mask = (1<<8);
+// public static final int Button1MotionMask = 1 << 8;
+ public static final int Button2Mask = (1<<9);
+// public static final int Button2MotionMask = 1 << 9;
+ public static final int Button3Mask = (1<<10);
+// public static final int Button3MotionMask = 1 << 10;
+// public static final int Button4Mask = (1<<11);
+// public static final int Button4MotionMask = 1 << 11;
+// public static final int Button5Mask = (1<<12);
+// public static final int Button5MotionMask = 1 << 12;
+// public static final int ButtonMotionMask = 1 << 13;
+ public static final int ButtonPress = 4;
+ public static final int ButtonPressMask = 1 << 2;
+ public static final int ButtonRelease = 5;
+ public static final int ButtonReleaseMask = 1 << 3;
+ public static final int CapButt = 0x1;
+// public static final int CapNotLast = 0x0;
+// public static final int CapProjecting = 0x3;
+// public static final int CapRound = 0x2;
+// public static final int CenterGravity = 5;
+// public static final int CirculateNotify = 26;
+// public static final int CirculateRequest = 27;
+// public static final int ClientMessage = 33;
+// public static final int ClipByChildren = 0x0;
+// public static final int ColormapChangeMask = 1 << 23;
+// public static final int ColormapNotify = 32;
+// public static final int Complex = 0;
+ public static final int ConfigureNotify = 22;
+// public static final int ConfigureRequest = 23;
+ public static final int ControlMask = (1<<2);
+ public static final int Convex = 2;
+ public static final int CoordModeOrigin = 0x0;
+// public static final int CoordModePrevious = 0x1;
+// public static final int CreateNotify = 16;
+ public static final int CurrentTime = 0;
+// public static final int CWBackingPixel = 0x100;
+// public static final int CWBackingPlanes = 0x80;
+// public static final int CWBackingStore = 0x40;
+// public static final int CWBackPixel = 0x2;
+ public static final int CWBackPixmap = 0x1;
+ public static final int CWBitGravity = 0x10;
+// public static final int CWBorderPixel = 0x8;
+// public static final int CWBorderPixmap = 0x4;
+// public static final int CWBorderWidth = 0x10;
+// public static final int CWColormap = 0x2000;
+// public static final int CWCursor = 0x4000;
+ public static final int CWDontPropagate = 0x1000;
+ public static final int CWEventMask = 0x800;
+ public static final int CWHeight = 0x8;
+// public static final int CWOverrideRedirect = 0x200;
+// public static final int CWSaveUnder = 0x400;
+ public static final int CWSibling = 0x20;
+ public static final int CWStackMode = 0x40;
+ public static final int CWWidth = 0x4;
+// public static final int CWWinGravity = 0x20;
+// public static final int CWX = 0x1;
+// public static final int CWY = 0x2;
+// public static final int DestroyNotify = 17;
+// public static final int EastGravity = 6;
+// public static final int EnterNotify = 7;
+ public static final int EnterWindowMask = 1 << 4;
+// public static final int EvenOddRule = 0x0;
+ public static final int Expose = 12;
+ public static final int ExposureMask = 1 << 15;
+// public static final int FillOpaqueStippled = 0x3;
+// public static final int FillSolid = 0x0;
+ public static final int FillStippled = 0x2;
+// public static final int FillTiled = 0x1;
+ public static final int FocusChangeMask = 1 << 21;
+ public static final int FocusIn = 9;
+ public static final int FocusOut = 10;
+ public static final int ForgetGravity = 0;
+// public static final int GCArcMode = 0x400000;
+ public static final int GCBackground = 0x8;
+// public static final int GCCapStyle = 0x40;
+// public static final int GCClipMask = 0x80000;
+// public static final int GCClipXOrigin = 0x20000;
+// public static final int GCClipYOrigin = 0x40000;
+// public static final int GCDashList = 0x200000;
+// public static final int GCDashOffset = 0x100000;
+// public static final int GCFillRule = 0x200;
+// public static final int GCFillStyle = 0x100;
+// public static final int GCFont = 0x4000;
+ public static final int GCForeground = 0x4;
+ public static final int GCFunction = 0x1;
+// public static final int GCGraphicsExposures = 0x10000;
+// public static final int GCJoinStyle = 0x80;
+// public static final int GCLastBit = 0x16;
+// public static final int GCLineStyle = 0x20;
+ public static final int GCLineWidth = 0x10;
+// public static final int GCPlaneMask = 0x2;
+// public static final int GCStipple = 0x800;
+ public static final int GCSubwindowMode = 0x8000;
+// public static final int GCTile = 0x400;
+// public static final int GCTileStipXOrigin = 0x1000;
+// public static final int GCTileStipYOrigin = 0x2000;
+// public static final int GrabFrozen = 4;
+// public static final int GrabInvalidTime = 2;
+ public static final int GrabModeAsync = 1;
+// public static final int GrabModeSync = 0;
+// public static final int GrabNotViewable = 3;
+// public static final int GrabSuccess = 0;
+ public static final int GraphicsExpose = 13;
+// public static final int GravityNotify = 24;
+ public static final int GXand = 0x1;
+// public static final int GXandInverted = 0x4;
+// public static final int GXandReverse = 0x2;
+// public static final int GXclear = 0x0;
+ public static final int GXcopy = 0x3;
+// public static final int GXcopy = 0x3;
+// public static final int GXcopyInverted = 0xC;
+// public static final int GXequiv = 0x9;
+// public static final int GXinvert = 0xA;
+// public static final int GXnand = 0xE;
+// public static final int GXnoop = 0x5;
+// public static final int GXnor = 0x8;
+ public static final int GXor = 0x7;
+// public static final int GXorInverted = 0xD;
+// public static final int GXorReverse = 0xB;
+// public static final int GXset = 0xF;
+ public static final int GXxor = 0x6;
+ public static final int IncludeInferiors = 0x1;
+// public static final int IsUnmapped = 0x0;
+ public static final int IsUnviewable = 0x1;
+ public static final int IsViewable = 0x2;
+// public static final int JoinBevel = 0x2;
+ public static final int JoinMiter = 0x0;
+// public static final int JoinRound = 0x1;
+// public static final int KeymapNotify = 11;
+// public static final int KeymapStateMask = 1 << 14;
+ public static final int KeyPress = 2;
+ public static final int KeyPressMask = 1 << 0;
+// public static final int KeyRelease = 3;
+ public static final int KeyReleaseMask = 1 << 1;
+// public static final int LeaveNotify = 8;
+ public static final int LeaveWindowMask = 1 << 5;
+ public static final int LineDoubleDash = 0x2;
+// public static final int LineOnOffDash = 0x1;
+ public static final int LineSolid = 0x0;
+// public static final int LockMask = (1<<1);
+ public static final int LSBFirst = 0;
+ public static final int MapNotify = 19;
+// public static final int MappingNotify = 34;
+// public static final int MapRequest = 20;
+ public static final int Mod1Mask = (1<<3);
+// public static final int Mod2Mask = (1<<4);
+// public static final int Mod3Mask = (1<<5);
+// public static final int Mod4Mask = (1<<6);
+// public static final int Mod5Mask = (1<<7);
+ public static final int MotionNotify = 6;
+ public static final int MSBFirst = 1;
+// public static final int MWM_DECOR_ALL = 0x1;
+ public static final int MWM_DECOR_BORDER = 0x2;
+ public static final int MWM_DECOR_MAXIMIZE = 0x40;
+ public static final int MWM_DECOR_MENU = 0x10;
+ public static final int MWM_DECOR_MINIMIZE = 0x20;
+ public static final int MWM_DECOR_RESIZEH = 0x4;
+ public static final int MWM_DECOR_TITLE = 0x8;
+// public static final int MWM_FUNC_ALL = 0x1;
+// public static final int MWM_FUNC_CLOSE = 0x20;
+// public static final int MWM_FUNC_MAXIMIZE = 0x10;
+// public static final int MWM_FUNC_MINIMIZE = 0x8;
+// public static final int MWM_FUNC_MOVE = 0x4;
+// public static final int MWM_FUNC_RESIZE = 0x2;
+// public static final int MWM_HINTS_DECORATIONS = 0x2;
+// public static final int MWM_HINTS_FUNCTIONS = 0x1;
+// public static final int MWM_HINTS_INPUT_MODE = 0x4;
+// public static final int MWM_HINTS_STATUS = 0x8;
+// public static final int MWM_INFO_STARTUP_CUSTOM = 0x2;
+// public static final int MWM_INFO_STARTUP_STANDARD = 0x1;
+ public static final int MWM_INPUT_FULL_APPLICATION_MODAL = 0x3;
+ public static final int MWM_INPUT_MODELESS = 0x0;
+ public static final int MWM_INPUT_PRIMARY_APPLICATION_MODAL = 0x1;
+ public static final int MWM_INPUT_SYSTEM_MODAL = 0x2;
+// public static final int MWM_TEAR_OFF_WINDOW = 0x1;
+// public static final int NoEventMask = 0;
+// public static final int NoExpose = 14;
+// public static final int Nonconvex = 1;
+ public static final int None = 0;
+// public static final int NorthEastGravity = 3;
+// public static final int NorthGravity = 2;
+ public static final int NorthWestGravity = 1;
+// public static final int NorthWestGravity = 1;
+ public static final int NotifyAncestor = 0x0;
+// public static final int NotifyDetailNone = 0x7;
+// public static final int NotifyGrab = 0x1;
+// public static final int NotifyHint = 0x1;
+ public static final int NotifyInferior = 0x2;
+ public static final int NotifyNonlinear = 0x3;
+// public static final int NotifyNonlinearVirtual = 0x4;
+ public static final int NotifyNormal = 0x0;
+// public static final int NotifyPointer = 0x5;
+// public static final int NotifyPointerRoot = 0x6;
+// public static final int NotifyUngrab = 0x2;
+// public static final int NotifyVirtual = 0x1;
+// public static final int NotifyWhileGrabbed = 0x3;
+// public static final int Opposite = 4;
+// public static final int OwnerGrabButtonMask = 1 << 24;
+// public static final int PointerMotionHintMask = 1 << 7;
+ public static final int PointerMotionMask = 1 << 6;
+// public static final int PropertyChangeMask = 1 << 22;
+// public static final int PropertyNotify = 28;
+// public static final int RectangleIn = 0x1;
+ public static final int RectangleOut = 0x0;
+// public static final int RectanglePart = 0x2;
+ public static final int ReparentNotify = 21;
+ public static final int ResizeRedirectMask = 1 << 18;
+// public static final int ResizeRequest = 25;
+// public static final int RevertToNone = 0x0;
+ public static final int RevertToParent = 0x2;
+// public static final int RevertToPointerRoot = 0x1;
+// public static final int SelectionClear = 29;
+// public static final int SelectionNotify = 31;
+// public static final int SelectionRequest = 30;
+ public static final int ShiftMask = (1<<0);
+// public static final int SouthEastGravity = 9;
+// public static final int SouthGravity = 8;
+// public static final int SouthWestGravity = 7;
+// public static final int StaticGravity = 10;
+ public static final int StructureNotifyMask = 1 << 17;
+ public static final int SubstructureNotifyMask = 1 << 19;
+ public static final int SubstructureRedirectMask = 1 << 20;
+// public static final int TopIf = 2;
+ public static final int UnmapNotify = 18;
+ public static final int Unsorted = 0x0;
+// public static final int VisibilityChangeMask = 1 << 16;
+// public static final int VisibilityNotify = 15;
+// public static final int WestGravity = 4;
+// public static final int WindingRule = 0x1;
+ public static final int XA_FONT = 18;
+ public static final int XBufferOverflow = 0xFFFFFFFF;
+// public static final int XC_arrow = 2;
+// public static final int XC_based_arrow_down = 4;
+// public static final int XC_based_arrow_up = 6;
+// public static final int XC_boat = 8;
+// public static final int XC_bogosity= 10;
+ public static final int XC_bottom_left_corner = 12;
+ public static final int XC_bottom_right_corner = 14;
+ public static final int XC_bottom_side = 16;
+// public static final int XC_bottom_tee = 18;
+// public static final int XC_box_spiral = 20;
+// public static final int XC_center_ptr = 22;
+// public static final int XC_circle = 24;
+// public static final int XC_clock = 26;
+// public static final int XC_coffee_mug = 28;
+ public static final int XC_cross = 30;
+// public static final int XC_cross_reverse = 32;
+// public static final int XC_crosshair = 34;
+ public static final int XC_diamond_cross = 36;
+// public static final int XC_dot = 38;
+// public static final int XC_dotbox = 40;
+ public static final int XC_double_arrow = 42;
+// public static final int XC_draft_large = 44;
+// public static final int XC_draft_small = 46;
+// public static final int XC_draped_box = 48;
+// public static final int XC_exchange = 50;
+// public static final int XC_fleur = 52;
+// public static final int XC_gobbler = 54;
+// public static final int XC_gumby = 56;
+// public static final int XC_hand1 = 58;
+ public static final int XC_hand2 = 60;
+// public static final int XC_heart = 62;
+// public static final int XC_icon = 64;
+// public static final int XC_iron_cross = 66;
+ public static final int XC_left_ptr = 68;
+ public static final int XC_left_side = 70;
+// public static final int XC_left_tee = 72;
+// public static final int XC_leftbutton = 74;
+// public static final int XC_ll_angle = 76;
+// public static final int XC_lr_angle = 78;
+// public static final int XC_man = 80;
+// public static final int XC_middlebutton = 82;
+// public static final int XC_mouse = 84;
+// public static final int XC_num_glyphs = 154;
+// public static final int XC_pencil = 86;
+// public static final int XC_pirate = 88;
+// public static final int XC_plus = 90;
+ public static final int XC_question_arrow = 92;
+// public static final int XC_right_ptr = 94;
+ public static final int XC_right_side = 96;
+// public static final int XC_right_tee = 98;
+// public static final int XC_rightbutton = 100;
+// public static final int XC_rtl_logo = 102;
+// public static final int XC_sailboat = 104;
+// public static final int XC_sb_down_arrow = 106;
+ public static final int XC_sb_h_double_arrow = 108;
+// public static final int XC_sb_left_arrow = 110;
+// public static final int XC_sb_right_arrow = 112;
+ public static final int XC_sb_up_arrow = 114;
+ public static final int XC_sb_v_double_arrow = 116;
+// public static final int XC_shuttle = 118;
+ public static final int XC_sizing = 120;
+// public static final int XC_spider = 122;
+// public static final int XC_spraycan = 124;
+// public static final int XC_star = 126;
+// public static final int XC_target = 128;
+// public static final int XC_tcross = 130;
+// public static final int XC_top_left_arrow = 132;
+ public static final int XC_top_left_corner = 134;
+ public static final int XC_top_right_corner = 136;
+ public static final int XC_top_side = 138;
+// public static final int XC_top_tee = 140;
+// public static final int XC_trek = 142;
+// public static final int XC_ul_angle = 144;
+// public static final int XC_umbrella = 146;
+// public static final int XC_ur_angle = 148;
+ public static final int XC_watch = 150;
+ public static final int XC_X_cursor = 0;
+ public static final int XC_xterm = 152;
+ public static final int XK_Alt_L = 0xFFE9;
+ public static final int XK_Alt_R = 0xFFEA;
+ public static final int XK_Cancel = 0xFF69;
+ public static final int XK_Control_L = 0xFFE3;
+ public static final int XK_Control_R = 0xFFE4;
+// public static final int XK_Delete = 0xFFFF;
+ public static final int XK_Down = 0xFF54;
+ public static final int XK_End = 0xFF57;
+ public static final int XK_Escape = 0xFF1B;
+ public static final int XK_F1 = 0xFFBE;
+ public static final int XK_F10 = 0xFFC7;
+ public static final int XK_F11 = 0xFFC8;
+ public static final int XK_F12 = 0xFFC9;
+ public static final int XK_F2 = 0xFFBF;
+ public static final int XK_F3 = 0xFFC0;
+ public static final int XK_F4 = 0xFFC1;
+ public static final int XK_F5 = 0xFFC2;
+ public static final int XK_F6 = 0xFFC3;
+ public static final int XK_F7 = 0xFFC4;
+ public static final int XK_F8 = 0xFFC5;
+ public static final int XK_F9 = 0xFFC6;
+ public static final int XK_Home = 0xFF50;
+ public static final int XK_Insert = 0xFF63;
+// public static final int XK_KP_0 = 0xFFB0;
+// public static final int XK_KP_1 = 0xFFB1;
+// public static final int XK_KP_2 = 0xFFB2;
+// public static final int XK_KP_3 = 0xFFB3;
+// public static final int XK_KP_4 = 0xFFB4;
+// public static final int XK_KP_5 = 0xFFB5;
+// public static final int XK_KP_6 = 0xFFB6;
+// public static final int XK_KP_7 = 0xFFB7;
+// public static final int XK_KP_8 = 0xFFB8;
+// public static final int XK_KP_9 = 0xFFB9;
+// public static final int XK_KP_Add = 0xFFAB;
+// public static final int XK_KP_Decimal = 0xFFAE;
+// public static final int XK_KP_Divide = 0xFFAF;
+// public static final int XK_KP_Enter = 0xFF8D;
+// public static final int XK_KP_Multiply = 0xFFAA;
+// public static final int XK_KP_Subtract = 0xFFAD;
+ public static final int XK_Left = 0xFF51;
+ public static final int XK_Page_Down = 0xFF56;
+ public static final int XK_Page_Up = 0xFF55;
+ public static final int XK_Right = 0xFF53;
+ public static final int XK_Return = 0xFF0D;
+ public static final int XK_Shift_L = 0xFFE1;
+ public static final int XK_Shift_R = 0xFFE2;
+ public static final int XK_Tab = 0xFF09;
+ public static final int XK_Up = 0xFF52;
+// public static final int XLookupBoth = 0x4;
+// public static final int XLookupChars = 0x2;
+// public static final int XLookupKeySym = 0x3;
+// public static final int XLookupNone = 0x1;
+ public static final int XmALIGNMENT_BEGINNING = 0x0;
+ public static final int XmALIGNMENT_CENTER = 0x1;
+ public static final int XmALIGNMENT_END = 0x2;
+ public static final int XmARROW_DOWN = 0x1;
+ public static final int XmARROW_LEFT = 0x2;
+ public static final int XmARROW_RIGHT = 0x3;
+ public static final int XmARROW_UP = 0x0;
+// public static final int XmARROWS_END = 0x0;
+// public static final int XmAS_NEEDED = 0x1;
+// public static final int XmATTACH_CENTER = 0x8;
+// public static final int XmATTACH_EAST = 0x3;
+ public static final int XmATTACH_FORM = 0x1;
+// public static final int XmATTACH_HOT = 0x9;
+// public static final int XmATTACH_NONE = 0x0;
+// public static final int XmATTACH_NORTH = 0x1;
+// public static final int XmATTACH_NORTH_EAST = 0x2;
+// public static final int XmATTACH_NORTH_WEST = 0x0;
+// public static final int XmATTACH_OPPOSITE_FORM = 0x2;
+// public static final int XmATTACH_OPPOSITE_WIDGET = 0x4;
+// public static final int XmATTACH_POSITION = 0x5;
+// public static final int XmATTACH_SELF = 0x6;
+// public static final int XmATTACH_SOUTH = 0x5;
+// public static final int XmATTACH_SOUTH_EAST = 0x4;
+// public static final int XmATTACH_SOUTH_WEST = 0x6;
+// public static final int XmATTACH_WEST = 0x7;
+// public static final int XmATTACH_WIDGET = 0x3;
+ public static final int XmBLEND_ALL = 0x0;
+ public static final int XmBROWSE_SELECT = 0x3;
+ public static final int XmCHARSET_TEXT = 0x0;
+ public static final int XmClipboardFail = 0x0;
+ public static final int XmClipboardSuccess = 0x1;
+ public static final int XmClipboardLocked = 0x4;
+ public static final int XmClipboardNoData = 0x6;
+ public static final int XmCOMBO_BOX = 0x0;
+ public static final int XmCONSTANT = 0x1;
+ public static final int XmCOPY_FAILED = 0x0;
+// public static final int XmCOPY_SUCCEEDED = 0x1;
+ public static final int XmCOPY_TRUNCATED = 0x2;
+// public static final int XmCR_ACTIVATE = 0xA;
+// public static final int XmCR_APPLY = 0x22;
+// public static final int XmCR_ARM = 0xB;
+// public static final int XmCR_BROWSE_SELECT = 0x1A;
+// public static final int XmCR_CANCEL = 0x20;
+// public static final int XmCR_CASCADING = 0x1E;
+// public static final int XmCR_CLIPBOARD_DATA_DELETE = 0x1D;
+// public static final int XmCR_CLIPBOARD_DATA_REQUEST = 0x1C;
+// public static final int XmCR_COMMAND_CHANGED = 0x25;
+// public static final int XmCR_COMMAND_ENTERED = 0x24;
+// public static final int XmCR_CREATE = 0x2B;
+ public static final int XmCR_DECREMENT = 0x4;
+// public static final int XmCR_DEFAULT_ACTION = 0x1B;
+// public static final int XmCR_DISARM = 0xC;
+ public static final int XmCR_DRAG = 0x9;
+// public static final int XmCR_DRAGDROP_FINISH = 0x7;
+// public static final int XmCR_DRAG_MOTION = 0x2;
+// public static final int XmCR_DROP_FINISH = 0x6;
+// public static final int XmCR_DROP_MESSAGE = 0x4;
+// public static final int XmCR_DROP_SITE_ENTER = 0x3;
+ public static final int XmCR_DROP_SITE_ENTER_MESSAGE = 0x2;
+// public static final int XmCR_DROP_SITE_LEAVE = 0x4;
+ public static final int XmCR_DROP_SITE_LEAVE_MESSAGE = 0x1;
+ public static final int XmCR_DROP_SITE_MOTION_MESSAGE = 0x3;
+// public static final int XmCR_DROP_START = 0x5;
+// public static final int XmCR_EXECUTE = 0x16;
+// public static final int XmCR_EXPOSE = 0x26;
+// public static final int XmCR_EXTENDED_SELECT = 0x19;
+// public static final int XmCR_FOCUS = 0x12;
+// public static final int XmCR_GAIN_PRIMARY = 0x29;
+// public static final int XmCR_HELP = 0x1;
+ public static final int XmCR_INCREMENT = 0x3;
+// public static final int XmCR_INPUT = 0x28;
+// public static final int XmCR_LOSE_PRIMARY = 0x2A;
+// public static final int XmCR_LOSING_FOCUS = 0x13;
+// public static final int XmCR_MAP = 0x10;
+// public static final int XmCR_MODIFYING_TEXT_VALUE = 0x14;
+// public static final int XmCR_MOVING_INSERT_CURSOR = 0x15;
+// public static final int XmCR_MULTIPLE_SELECT = 0x18;
+// public static final int XmCR_NO_MATCH = 0x23;
+// public static final int XmCR_NONE = 0x0;
+// public static final int XmCR_OBSCURED_TRAVERSAL = 0x2E;
+// public static final int XmCR_OK = 0x1F;
+ public static final int XmCR_OPERATION_CHANGED = 0x8;
+ public static final int XmCR_PAGE_DECREMENT = 0x6;
+ public static final int XmCR_PAGE_INCREMENT = 0x5;
+// public static final int XmCR_PROTOCOLS = 0x2F;
+// public static final int XmCR_RESIZE = 0x27;
+// public static final int XmCR_SINGLE_SELECT = 0x17;
+// public static final int XmCR_TEAR_OFF_ACTIVATE = 0x2C;
+// public static final int XmCR_TEAR_OFF_DEACTIVATE = 0x2D;
+ public static final int XmCR_TO_BOTTOM = 0x8;
+// public static final int XmCR_TOP_LEVEL_ENTER = 0x0;
+// public static final int XmCR_TOP_LEVEL_LEAVE = 0x1;
+ public static final int XmCR_TO_TOP = 0x7;
+// public static final int XmCR_UNMAP = 0x11;
+ public static final int XmCR_VALUE_CHANGED = 0x2;
+// public static final int XmCR_WMPROTOCOLS = 0x1A0A;
+// public static final int XmDESTROY = 0x0;
+ public static final int XmDIALOG_APPLICATION_MODAL = 0x1;
+ public static final int XmDIALOG_APPLY_BUTTON = 0x1;
+ public static final int XmDIALOG_CANCEL_BUTTON = 0x2;
+// public static final int XmDIALOG_COMMAND = 0x3;
+// public static final int XmDIALOG_COMMAND_TEXT = 0xD;
+// public static final int XmDIALOG_DEFAULT_BUTTON = 0x3;
+// public static final int XmDIALOG_DIR_LIST = 0xF;
+// public static final int XmDIALOG_DIR_LIST_LABEL = 0x10;
+// public static final int XmDIALOG_ERROR = 0x1;
+// public static final int XmDIALOG_FILE_LIST = 0x8;
+// public static final int XmDIALOG_FILE_LIST_LABEL = 0x9;
+// public static final int XmDIALOG_FILE_SELECTION = 0x4;
+ public static final int XmDIALOG_FILTER_LABEL = 0x5;
+ public static final int XmDIALOG_FILTER_TEXT = 0x6;
+ public static final int XmDIALOG_FULL_APPLICATION_MODAL = 0x2;
+ public static final int XmDIALOG_HELP_BUTTON = 0x7;
+// public static final int XmDIALOG_HISTORY_LIST = 0x8;
+// public static final int XmDIALOG_INFORMATION = 0x2;
+ public static final int XmDIALOG_LIST = 0x8;
+ public static final int XmDIALOG_LIST_LABEL = 0x9;
+// public static final int XmDIALOG_MESSAGE = 0x3;
+ public static final int XmDIALOG_MESSAGE_LABEL = 0xA;
+ public static final int XmDIALOG_MODELESS = 0x0;
+// public static final int XmDIALOG_NONE = 0x0;
+ public static final int XmDIALOG_OK_BUTTON = 0x4;
+ public static final int XmDIALOG_PRIMARY_APPLICATION_MODAL = 0x1;
+// public static final int XmDIALOG_PROMPT = 0x1;
+// public static final int XmDIALOG_PROMPT_LABEL = 0xB;
+// public static final int XmDIALOG_QUESTION = 0x4;
+// public static final int XmDIALOG_SELECTION = 0x2;
+ public static final int XmDIALOG_SELECTION_LABEL = 0xB;
+// public static final int XmDIALOG_SEPARATOR = 0xE;
+// public static final int XmDIALOG_SYMBOL_LABEL = 0xC;
+ public static final int XmDIALOG_SYSTEM_MODAL = 0x3;
+// public static final int XmDIALOG_TEMPLATE = 0x0;
+ public static final int XmDIALOG_TEXT = 0xD;
+// public static final int XmDIALOG_VALUE_TEXT = 0xD;
+// public static final int XmDIALOG_WARNING = 0x5;
+// public static final int XmDIALOG_WORK_AREA = 0x0;
+// public static final int XmDIALOG_WORKING = 0x6;
+ public static final int XmDO_NOTHING = 0x2;
+// public static final int XmDOUBLE_DASHED_LINE = 0x4;
+// public static final int XmDOUBLE_LINE = 0x2;
+ public static final int XmDRAG_DYNAMIC = 5;
+ public static final byte XmDROP_COPY = (1 << 1);
+ public static final int XmDROP_DOWN_COMBO_BOX = 0x1;
+ public static final int XmDROP_DOWN_LIST = 0x2;
+ public static final byte XmDROP_LINK = (1 << 2);
+ public static final byte XmDROP_MOVE = (1 << 0);
+ public static final byte XmDROP_NOOP = 0;
+ public static final int XmDROP_SITE_ACTIVE = 0;
+ public static final int XmDROP_SITE_INVALID = 2;
+ public static final int XmDROP_SITE_VALID = 3;
+ public static final byte XmDROP = 0;
+ public static final int XmEXTENDED_SELECT = 0x2;
+ public static final int XmFONT_IS_FONT = 0x0;
+ public static final int XmFONT_IS_FONTSET = 0x1;
+// public static final int XmFRAME_GENERIC_CHILD = 0x0;
+ public static final int XmFRAME_TITLE_CHILD = 0x2;
+// public static final int XmFRAME_WORKAREA_CHILD = 0x1;
+ public static final int XmHIGHLIGHT_NORMAL = 0x0;
+// public static final int XmHIGHLIGHT_SECONDARY_SELECTED = 0x2;
+// public static final int XmHIGHLIGHT_SELECTED = 0x1;
+ public static final int XmHORIZONTAL = 0x2;
+ public static final int XmLAST_POSITION = -1;
+ public static final int XmMAX_ON_BOTTOM = 0x1;
+// public static final int XmMAX_ON_LEFT = 0x2;
+ public static final int XmMAX_ON_RIGHT = 0x3;
+ public static final int XmMAX_ON_TOP = 0x0;
+ public static final int XmMERGE_REPLACE = 0x1;
+ public static final int XmMULTI_LINE_EDIT = 0x0;
+ public static final int XmMULTIPLE_SELECT = 0x1;
+ public static final int XmN_OF_MANY = 0x1;
+ public static final int XmNONE = 0x0;
+// public static final int XmNUMERIC = 0x3;
+
+ /* char */
+ public static final int XmNalignment = malloc ("alignment");
+ public static final int XmNarrowDirection = malloc ("arrowDirection");
+ public static final int XmNblendModel = malloc ("blendModel");
+ public static final int XmNbottomAttachment = malloc ("bottomAttachment");
+ public static final int XmNchildType = malloc ("childType");
+ public static final int XmNcomboBoxType = malloc ("comboBoxType");
+ public static final int XmNdialogStyle = malloc ("dialogStyle");
+ public static final int XmNcursorPositionVisible = malloc ("cursorPositionVisible");
+ public static final int XmNdeleteResponse = malloc ("deleteResponse");
+ public static final int XmNdragInitiatorProtocolStyle = malloc ("dragInitiatorProtocolStyle");
+ public static final int XmNdragReceiverProtocolStyle = malloc ("dragReceiverProtocolStyle");
+ public static final int XmNdragOperations = malloc ("dragOperations");
+ public static final int XmNeditable = malloc ("editable");
+ public static final int XmNiconic = malloc ("iconic");
+ public static final int XmNlabelType = malloc ("labelType");
+ public static final int XmNleftAttachment = malloc ("leftAttachment");
+ public static final int XmNlistSizePolicy = malloc ("listSizePolicy");
+ public static final int XmNindicatorOn = malloc ("indicatorOn");
+ public static final int XmNindicatorType = malloc ("indicatorType");
+ public static final int XmNnoResize = malloc ("noResize");
+ public static final int XmNorientation = malloc ("orientation");
+ public static final int XmNprocessingDirection = malloc ("processingDirection");
+ public static final int XmNrecomputeSize = malloc ("recomputeSize");
+ public static final int XmNpushButtonEnabled = malloc ("pushButtonEnabled");
+ public static final int XmNresizable = malloc ("resizable");
+ public static final int XmNresizePolicy = malloc ("resizePolicy");
+ public static final int XmNrightAttachment = malloc ("rightAttachment");
+ public static final int XmNscrollHorizontal = malloc ("scrollHorizontal");
+ public static final int XmNscrollVertical = malloc ("scrollVertical");
+ public static final int XmNselectionPolicy = malloc ("selectionPolicy");
+ public static final int XmNsensitive = malloc ("sensitive");
+ public static final int XmNseparatorType = malloc ("separatorType");
+ public static final int XmNset = malloc ("set");
+ public static final int XmNshadowType = malloc ("shadowType");
+ public static final int XmNtraversalOn = malloc ("traversalOn");
+ public static final int XmNtopAttachment = malloc ("topAttachment");
+ public static final int XmNverifyBell = malloc ("verifyBell");
+ public static final int XmNwordWrap = malloc ("wordWrap");
+ public static final int XmNnavigationType = malloc ("navigationType");
+
+ /* short */
+ public static final int XmNarrowSize = malloc ("arrowSize");
+ public static final int XmNarrowSpacing = malloc ("arrowSpacing");
+ public static final int XmNborderWidth = malloc ("borderWidth");
+ public static final int XmNheight = malloc ("height");
+ public static final int XmNhighlightThickness = malloc ("highlightThickness");
+ public static final int XmNlistMarginHeight = malloc ("listMarginHeight");
+ public static final int XmNlistMarginWidth = malloc ("listMarginWidth");
+ public static final int XmNlistSpacing = malloc ("listSpacing");
+ public static final int XmNmarginBottom = malloc ("marginBottom");
+ public static final int XmNmarginHeight = malloc ("marginHeight");
+ public static final int XmNmarginLeft = malloc ("marginLeft");
+ public static final int XmNmarginRight = malloc ("marginRight");
+ public static final int XmNmarginTop = malloc ("marginTop");
+ public static final int XmNmarginWidth = malloc ("marginWidth");
+ public static final int XmNpositionIndex = malloc ("positionIndex");
+ public static final int XmNrows = malloc ("rows");
+ public static final int XmNshadowThickness = malloc ("shadowThickness");
+ public static final int XmNshowAsDefault = malloc ("showAsDefault");
+ public static final int XmNwidth = malloc ("width");
+ public static final int XmNx = malloc ("x");
+ public static final int XmNy = malloc ("y");
+
+ /* int */
+ public static final int XmNaccelerator = malloc ("accelerator");
+ public static final int XmNacceleratorText = malloc ("acceleratorText");
+ public static final int XmNactivateCallback = malloc ("activateCallback");
+ public static final int XmNarmCallback = malloc ("armCallback");
+ public static final int XmNbackground = malloc ("background");
+ public static final int XmNborderColor = malloc ("borderColor");
+ public static final int XmNbottomShadowColor = malloc ("bottomShadowColor");
+ public static final int XmNbrowseSelectionCallback = malloc ("browseSelectionCallback");
+ public static final int XmNcancelCallback = malloc ("cancelCallback");
+ public static final int XmNcancelLabelString = malloc ("cancelLabelString");
+ public static final int XmNcascadingCallback = malloc ("cascadingCallback");
+ public static final int XmNchildren = malloc ("children");
+ public static final int XmNclientData = malloc ("clientData");
+ public static final int XmNcolormap = malloc ("colormap");
+ public static final int XmNconvertProc = malloc ("convertProc");
+ public static final int XmNdecrementCallback = malloc ("decrementCallback");
+ public static final int XmNdefaultActionCallback = malloc ("defaultActionCallback");
+ public static final int XmNdefaultButtonShadowThickness = malloc ("defaultButtonShadowThickness");
+ public static final int XmNdialogTitle = malloc ("dialogTitle");
+ public static final int XmNdirectory = malloc ("directory");
+ public static final int XmNdirSpec = malloc ("dirSpec");
+ public static final int XmNdirMask = malloc ("dirMask");
+ public static final int XmNdragCallback = malloc ("dragCallback");
+ public static final int XmNdragDropFinishCallback = malloc ("dragDropFinishCallback");
+ public static final int XmNdragProc = malloc ("dragProc");
+ public static final int XmNdropFinishCallback = malloc ("dropFinishCallback");
+ public static final int XmNdropProc = malloc("dropProc");
+ public static final int XmNeditMode = malloc ("editMode");
+ public static final int XmNexportTargets = malloc ("exportTargets");
+ public static final int XmNexposeCallback = malloc ("exposeCallback");
+ public static final int XmNextendedSelectionCallback = malloc ("extendedSelectionCallback");
+ public static final int XmNfilterLabelString = malloc ("filterLabelString");
+ public static final int XmNfont = malloc ("font");
+ public static final int XmNfontList = malloc ("fontList");
+ public static final int XmNfontType = malloc ("fontType");
+ public static final int XmNforeground = malloc ("foreground");
+ public static final int XmNhelpCallback = malloc ("helpCallback");
+ public static final int XmNhelpLabelString = malloc ("helpLabelString");
+ public static final int XmNhighlightColor = malloc ("highlightColor");
+ public static final int XmNhorizontalScrollBar = malloc ("horizontalScrollBar");
+ public static final int XmNiconMask = malloc ("iconMask");
+ public static final int XmNiconPixmap = malloc ("iconPixmap");
+ public static final int XmNincrement = malloc ("increment");
+ public static final int XmNincrementCallback = malloc ("incrementCallback");
+ public static final int XmNitemCount = malloc ("itemCount");
+ public static final int XmNitems = malloc ("items");
+ public static final int XmNlabelInsensitivePixmap = malloc ("labelInsensitivePixmap");
+ public static final int XmNlabelPixmap = malloc ("labelPixmap");
+ public static final int XmNlabelString = malloc ("labelString");
+ public static final int XmNlist = malloc ("list");
+ public static final int XmNmapCallback = malloc ("mapCallback");
+ public static final int XmNmappedWhenManaged = malloc ("mappedWhenManaged");
+ public static final int XmNmaximum = malloc ("maximum");
+ public static final int XmNmenuBar = malloc ("menuBar");
+ public static final int XmNmessageString = malloc ("messageString");
+ public static final int XmNminimum = malloc ("minimum");
+ public static final int XmNmodifyVerifyCallback = malloc ("modifyVerifyCallback");
+ public static final int XmNmwmDecorations = malloc ("mwmDecorations");
+ public static final int XmNmwmInputMode = malloc ("mwmInputMode");
+ public static final int XmNnumChildren = malloc ("numChildren");
+ public static final int XmNnumDropTransfers = malloc ("numDropTransfers");
+ public static final int XmNnumExportTargets = malloc ("numExportTargets");
+ public static final int XmNnumImportTargets = malloc("numImportTargets");
+ public static final int XmNmnemonic = malloc ("mnemonic");
+ public static final int XmNimportTargets = malloc("importTargets");
+ public static final int XmNokCallback = malloc ("okCallback");
+ public static final int XmNokLabelString = malloc ("okLabelString");
+ public static final int XmNoperationCursorIcon = malloc ("operationCursorIcon");
+ public static final int XmNselectionCallback = malloc ("selectionCallback");
+ public static final int XmNsourceCursorIcon = malloc ("sourceCursorIcon");
+ public static final int XmNstateCursorIcon = malloc ("stateCursorIcon");
+ public static final int XmNsubstitute = malloc ("substitute");
+ public static final int XmNpageDecrementCallback = malloc ("pageDecrementCallback");
+ public static final int XmNpageIncrement = malloc ("pageIncrement");
+ public static final int XmNpageIncrementCallback = malloc ("pageIncrementCallback");
+ public static final int XmNpattern = malloc ("pattern");
+ public static final int XmNrenderTable = malloc ("renderTable");
+ public static final int XmNscaleMultiple = malloc ("scaleMultiple");
+ public static final int XmNselectedItemCount = malloc ("selectedItemCount");
+ public static final int XmNselectedItems = malloc ("selectedItems");
+ public static final int XmNselectedPosition = malloc ("selectedPosition");
+ public static final int XmNselectionArrayCount = malloc ("selectionArrayCount");
+ public static final int XmNsliderSize = malloc ("sliderSize");
+ public static final int XmNsubMenuId = malloc ("subMenuId");
+ public static final int XmNtabList = malloc ("tabList");
+ public static final int XmNtextField = malloc ("textField");
+ public static final int XmNtitle = malloc ("title");
+ public static final int XmNtitleString = malloc ("titleString");
+ public static final int XmNtoBottomCallback = malloc ("toBottomCallback");
+ public static final int XmNtoTopCallback = malloc ("toTopCallback");
+// public static final int XmNtopCharacter = malloc ("topCharacter");
+ public static final int XmNtopItemPosition = malloc ("topItemPosition");
+ public static final int XmNtopShadowColor = malloc ("topShadowColor");
+ public static final int XmNtransferProc = malloc ("transferProc");
+ public static final int XmNtransferStatus = malloc ("transferStatus");
+ public static final int XmNtroughColor = malloc ("troughColor");
+ public static final int XmNunmapCallback = malloc ("unmapCallback");
+ public static final int XmNuserData = malloc ("userData");
+ public static final int XmNvalue = malloc ("value");
+ public static final int XmNvalueChangedCallback = malloc ("valueChangedCallback");
+ public static final int XmNverticalScrollBar = malloc ("verticalScrollBar");
+ public static final int XmNvisibleItemCount = malloc ("visibleItemCount");
+ public static final int XmNdropTransfers = malloc ("dropTransfers");
+ public static final int XmNshowArrows = malloc ("showArrows");
+
+/* Unknown */
+ public static final int XmNdropSiteActivity = malloc("dropSiteActivity");
+ public static final int XmNdropSiteOperations = malloc("dropSiteOperations");
+ public static final int XmNdropSiteType = malloc("dropSiteType");
+
+ public static final int XmNO_LINE = 0x0;
+ public static final int XmONE_OF_MANY = 0x2;
+ public static final int XmOUTPUT_ALL = 0x0;
+ public static final int XmPIXELS = 0x0;
+ public static final int XmPIXMAP = 0x1;
+ public static final int XmRELATIVE = 0x1;
+// public static final int XmRESIZE_ANY = 0x2;
+// public static final int XmRESIZE_GROW = 0x1;
+// public static final int XmRESIZE_IF_POSSIBLE = 0x2;
+ public static final int XmRESIZE_NONE = 0x0;
+ public static final int XmSHADOW_ETCHED_IN = 0x5;
+// public static final int XmSHADOW_ETCHED_IN_DASH = 0x7;
+ public static final int XmSHADOW_ETCHED_OUT = 0x6;
+// public static final int XmSHADOW_ETCHED_OUT_DASH = 0x8;
+ public static final int XmSHADOW_IN = 0x7;
+ public static final int XmSHADOW_OUT = 0x8;
+// public static final int XmSINGLE_DASHED_LINE = 0x3;
+// public static final int XmSINGLE_LINE = 0x1;
+ public static final int XmSINGLE_LINE_EDIT = 0x1;
+// public static final int XmSINGLE_SELECT = 0x0;
+// public static final int XmSPIN_NEXT = 0x3E;
+// public static final int XmSPIN_PRIOR = 0x3F;
+// public static final int XmSTATIC = 0x0;
+ public static final int XmSTRING = 0x2;
+ public static final int XmSTRING_COMPONENT_SEPARATOR = 0x4;
+ public static final int XmSTRING_COMPONENT_TAB = 0xC;
+ public static final int XmTAB_GROUP = 0x1;
+ public static final int XmTRANSFER_FAILURE = 0;
+ public static final int XmTRAVERSE_CURRENT = 0x0;
+// public static final int XmTRAVERSE_DOWN = 0x7;
+// public static final int XmTRAVERSE_HOME = 0x3;
+// public static final int XmTRAVERSE_LEFT = 0x8;
+ public static final int XmTRAVERSE_NEXT = 0x1;
+ public static final int XmTRAVERSE_NEXT_TAB_GROUP = 0x4;
+ public static final int XmTRAVERSE_PREV = 0x2;
+ public static final int XmTRAVERSE_PREV_TAB_GROUP = 0x5;
+// public static final int XmTRAVERSE_RIGHT = 0x9;
+// public static final int XmTRAVERSE_UP = 0x6;
+// public static final int XmUNMAP = 0x1;
+ public static final int XmUNSPECIFIED_PIXMAP = 0x2;
+ public static final int XmVARIABLE = 0x0;
+ public static final int XmVERTICAL = 0x1;
+// public static final int XtCWQueryOnly = 128;
+// public static final int XtGeometryAlmost = 0x2;
+// public static final int XtGeometryDone = 0x3;
+// public static final int XtGeometryNo = 0x1;
+// public static final int XtGeometryYes = 0x0;
+// public static final int XtGrabExclusive = 0x2;
+ public static final int XtGrabNone = 0x0;
+// public static final int XtGrabNonexclusive = 0x1;
+// public static final int XtIMAll = 0x7;
+ public static final int XtIMAlternateInput = 0x4;
+ public static final int XtIMTimer = 0x2;
+ public static final int XtIMXEvent = 0x1;
+ public static final int XYBitmap = 0;
+// public static final int XYPixmap = 1;
+// public static final int YSorted = 0x1;
+// public static final int YXBanded = 0x3;
+// public static final int YXSorted = 0x2;
+ public static final int ZPixmap = 2;
+
+ /* Unused X Structs */
+ /*
+ public class XPoint {
+ public short x, y;
+ public static final int sizeof = 4;
+ }
+ */
+
+ /* Unused Natives */
+ /*
+ public static final native int XBlackPixel (int display, int screenNum);
+ public static final native void XChangeActivePointerGrab (int display, int eventMask, int cursor, int time);
+ public static final native int XDefaultGC (int display, int screen_number);
+ public static final native void XNoOp (int display);
+ public static final native int XRootWindowOfScreen (int screen);
+ public static final native int XSendEvent (int display, int w, boolean propagate, int event_mask, XAnyEvent event);
+ public static final native int XmCreateCascadeButton (int parent, byte [] name, int [] arglist, int argcount);
+ public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
+ public static final native int XmCreateRowColumn (int parent, byte [] name, int [] arglist, int argcount);
+ public static final native int XmCreateScrolledWindow (int parent, byte [] name, int [] arglist, int argcount);
+ public static final native boolean XmDestroyPixmap (int screen, int pixmap);
+ public static final native int XmGetFocusWidget (int widget);
+ public static final native int XmGetPixmapByDepth (int screen, byte [] image_name, int foreground, int background, int depth);
+ public static final native void XmListAddItemsUnselected (int list, int xmStringTable, int item_count, int position);
+ public static final native void XmListDeleteItem (int list, int item);
+ public static final native void XmListDeselectItem (int list, int xmString);
+ public static final native void XmListSelectItem (int list, int xmString, boolean notify);
+ public static final native int XmPushButtonWidgetClass ();
+ public static final native void XmStringDrawUnderline (int display, int window, int fontlist, int xmString, int gc, int x, int y, int width, int align, int lay_dir, XRectangle clip, int xmStringUnderline);
+ public static final native int XmStringLineCount (int xmString);
+ public static final native boolean XmTextRemove (int widget);
+ public static final native int XtAppSetErrorHandler (int app_context, int handler);
+ public static final native int XtAppSetWarningHandler (int app_context, int handler);
+ public static final native void XtCallActionProc (int widget, byte [] action, XAnyEvent event, byte [] params, int num_params);
+ public static final native void XtCloseDisplay (int display);
+ public static final native int XtCreateWidget (byte [] name, int widgetClass, int parent, int [] argList, int argCount);
+ public static final native void XtRemoveCallback (int widget, int callback_name, int callback, int client_data);
+ public static final native void XtRemoveEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
+ public static final native int XtScreen (int widget);
+ */
+public static final native int OverrideShellWidgetClass ();
+public static final native int ShellWidgetClass ();
+public static final native int TopLevelShellWidgetClass ();
+public static final native int TransientShellWidgetClass ();
+public static final native int XAllocColor (int display, int colormap, XColor color);
+public static final native void XBell (int display, int ms);
+public static final native int XBitmapBitOrder (int display);
+public static final native int XBlackPixel (int display, int screenNum);
+public static final native int XChangeActivePointerGrab(int display, int event_mask, int cursor, int time);
+public static final native int XChangeGC (int display, int gc, int valuemask, XGCValues values);
+public static final native void XChangeWindowAttributes (int display, int window, int mask, XSetWindowAttributes attributes);
+public static final native boolean XCheckMaskEvent (int display, int mask, XAnyEvent event);
+public static final native boolean XCheckWindowEvent (int display, int window, int mask, XAnyEvent event);
+public static final native void XClearArea (int display, int window, int x, int y, int width, int height, boolean exposures);
+public static final native void XClipBox (int region, XRectangle rectangle);
+public static final native void XCopyArea (int display, int src, int dest, int gc, int src_x, int src_y, int width, int height, int dest_x, int dest_y);
+public static final native void XCopyPlane (int display, int src, int dest, int gc, int src_x, int src_y, int width, int height, int dest_x, int dest_y, int plane);
+public static final native int XCreateBitmapFromData (int display, int drawable, byte [] data, int width, int height);
+public static final native int XCreateFontCursor (int display, int shape);
+public static final native int XCreateGC (int display, int window, int mask, XGCValues values);
+public static final native int XCreateImage (int display, int visual, int depth, int format, int offset, int data, int width, int height, int bitmap_pad, int bytes_per_line);
+public static final native int XCreatePixmap (int display, int drawable, int width, int height, int depth);
+public static final native int XCreatePixmapCursor (int display, int source, int mask, XColor foreground_color, XColor background_color, int x, int y);
+public static final native int XCreateRegion ();
+public static final native int XDefaultColormap (int display, int screen_number);
+public static final native int XDefaultDepthOfScreen (int screen);
+public static final native int XDefaultRootWindow (int display);
+public static final native int XDefaultScreen (int display);
+public static final native int XDefaultScreenOfDisplay (int display);
+public static final native int XDefaultVisual (int display, int screen_number);
+public static final native void XDefineCursor (int display, int window, int cursor);
+public static final native int XDestroyImage(int ximage);
+public static final native void XDestroyRegion (int region);
+public static final native int XDisplayHeight (int display, int screen);
+public static final native int XDisplayHeightMM (int display, int screen);
+public static final native int XDisplayWidth (int display, int screen);
+public static final native int XDisplayWidthMM (int display, int screen);
+public static final native void XDrawArc (int display, int drawable, int gc, int x1, int y1, int x2, int y2, int a1, int a2);
+public static final native void XDrawLine (int display, int drawable, int gc, int x1, int y1, int x2, int y2);
+public static final native void XDrawLines (int display, int drawable, int gc, short[] xPoints, int nPoints, int mode);
+public static final native void XDrawRectangle (int display, int drawable, int gc, int x, int y, int width, int height);
+public static final native boolean XEmptyRegion (int region);
+public static final native boolean XEqualRegion (int region1, int region2);
+public static final native void XFillArc (int display, int drawable, int gc, int x1, int y1, int x2, int y2, int a1, int a2);
+public static final native int XFillPolygon (int display, int drawable, int gc, short[] xPoints, int nPoints, int mode, int style);
+public static final native void XFillRectangle (int display, int drawable, int gc, int x, int y, int width, int height);
+public static final native boolean XFilterEvent (XAnyEvent event, int window);
+public static final native void XFlush (int display);
+public static final native int XFontsOfFontSet (int fontSet, int[] fontStructs, int[] fontNames);
+public static final native int XFree (int address);
+public static final native int XFreeColors (int display, int colormap, int [] pixels, int npixels, int planes);
+public static final native void XFreeCursor (int display, int pixmap);
+public static final native void XFreeFontNames(int list);
+public static final native void XFreeGC (int display, int gc);
+public static final native void XFreePixmap (int display, int pixmap);
+public static final native int XGetGCValues (int display, int gc, int valuemask, XGCValues values);
+public static final native int XGetGeometry (int display, int drawable, int [] root_return, int [] x_return, int [] y_return, int [] width_return, int [] height_return, int [] border_width_return, int [] depth_return);
+public static final native int XGetImage (int display, int drawable, int x, int y, int width, int height, int plane_mask, int format);
+public static final native int XGetInputFocus (int display, int [] window, int [] revert);
+public static final native boolean XGetWindowAttributes (int display, int window, XWindowAttributes attributes);
+public static final native int XGrabPointer (
+ int display,
+ int grabWindow,
+ int ownerEvents,
+ int eventMask,
+ int pointerMode,
+ int keyboardMode,
+ int confineToWindow,
+ int cursor,
+ int time);
+public static final native int XInitThreads ();
+public static final native int XKeysymToString (int keysym);
+public static final native int XListFonts(int display, byte[] pattern, int maxnames, int[] actual_count_return);
+public static final native int XLookupString (XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final native int XLowerWindow (int display, int window);
+public static final native boolean XPointInRegion (int region, int x, int y);
+public static final native int XPutImage (int display, int drawable, int gc, int image, int srcX, int srcY, int destX, int destY, int width, int height);
+public static final native int XQueryColor (int display, int colormap, XColor color);
+public static final native int XQueryPointer (
+ int display,
+ int window,
+ int [] root,
+ int [] child,
+ int [] rootX,
+ int [] rootY,
+ int [] windowX,
+ int [] windowY,
+ int [] mask);
+public static final native int XQueryTree (int display, int window, int [] root_return, int [] parent_return, int [] children_return, int [] nChildren_return);
+public static final native int XRaiseWindow (int display, int window);
+public static final native int XReconfigureWMWindow (int display, int window, int screen, int valueMask, XWindowChanges values);
+public static final native int XRectInRegion (int region, int x, int y, int width, int height);
+public static final native void XSetBackground (int display, int gc, int background);
+public static final native void XSetClipMask (int display, int gc, int pixmap);
+public static final native void XSetClipRectangles (int display, int gc, int clip_x_origin, int clip_y_origin, XRectangle rectangles, int n, int ordering);
+public static final native int XSetDashes (int display, int gc, int dash_offset, byte[] dash_list, int n);
+public static final native int XSetErrorHandler (int handler);
+public static final native void XSetFillStyle (int display, int gc, int fill_style);
+public static final native int XSetFont (int display, int gc, int font);
+public static final native void XSetForeground (int display, int gc, int foreground);
+public static final native void XSetFunction (int display, int gc, int function);
+public static final native void XSetGraphicsExposures (int display, int gc, boolean graphics_exposures);
+public static final native int XSetInputFocus (int display, int window, int revert, int time);
+public static final native int XSetLineAttributes (int display, int gc, int lineWidth, int lineStyle, int capStyle, int joinStyle);
+public static final native void XSetRegion (int display, int gc, int region);
+public static final native void XSetStipple (int display, int gc, int pixmap);
+public static final native void XSetSubwindowMode (int display, int gc, int subwindow_mode);
+public static final native void XSetWindowBorderWidth (int display, int window, int width);
+public static final native void XSubtractRegion (int sra, int srb, int dr_return);
+public static final native void XSync (int display, boolean discard);
+public static final native int XSynchronize (int display, boolean onoff);
+public static final native void XUndefineCursor (int display, int window);
+public static final native int XUngrabPointer (int display, int time);
+public static final native void XUnionRectWithRegion (XRectangle rectangle, int src_region, int dest_region_return);
+public static final native void XUnionRegion (int sra, int srb, int dr_return);
+public static final native int XWhitePixel (int display, int screenNum);
+public static final native void XWithdrawWindow (int display, int window, int screen);
+public static final native void XmAddWMProtocolCallback (int shell, int protocol, int callback, int closure);
+public static final native void XmChangeColor (int widget, int pixel);
+public static final native int XmClipboardCopy(int display, int window, int item_id, byte[] format_name, byte[] buffer, int length, int private_id, int[] data_id);
+public static final native int XmClipboardEndCopy(int display, int window, int item_id);
+public static final native int XmClipboardStartCopy(int display, int window, int clip_label, int timestamp, int widget, int callback, int[] item_id);
+public static final native int XmClipboardInquireLength(int display, int widget, byte[] format_name, int[] length);
+public static final native int XmClipboardInquireFormat(int display, int window, int index, byte[] format_name_buf, int buffer_len, int[]copied_len);
+public static final native int XmClipboardInquireCount(int display, int window, int[] count, int[] max_format_name_length);
+public static final native int XmClipboardStartRetrieve(int display, int window, int timestamp);
+public static final native int XmClipboardRetrieve(int display, int window, byte[] format_name, byte[] buffer, int length, int[] num_bytes, int[] private_id);
+public static final native int XmClipboardEndRetrieve(int display, int window);
+public static final native void XmComboBoxAddItem(int widget, int xmString, int position, boolean unique);
+public static final native void XmComboBoxDeletePos(int widget, int position);
+public static final native void XmComboBoxSelectItem(int widget, int xmString);
+public static final native int XmCreateArrowButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateCascadeButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateComboBox(int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateDialogShell (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateDrawingArea (int parent, byte [] name, int [] arglist, int argcount);
+//public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateErrorDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateFileSelectionDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateForm (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateFrame (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateInformationDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateLabel (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateList (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateMainWindow (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateMenuBar (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateMessageDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreatePopupMenu (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreatePulldownMenu (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreatePushButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreatePushButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateQuestionDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateScale (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateScrollBar (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateScrolledList (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateScrolledText (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateSeparator (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateSeparatorGadget (int parent, byte [] name, int [] arglist, int argcount);
+//public static final native int XmCreateSimpleSpinBox (int parent, byte [] name, int [] arglist, int argcount);
+//public static final native int XmCreateSpinBox (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateTextField (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateToggleButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateToggleButtonGadget (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XmCreateWarningDialog (int parent, byte [] name, int [] arglist, int argcount);
+public static final native void XmDragCancel(int dragcontext);
+public static final native int XmDragStart(int widget, XAnyEvent event, int[] arglist, int argcount);
+public static final native void XmDropSiteRegister(int widget, int [] arglist, int argcount);
+public static final native void XmDropSiteUnregister(int widget);
+public static final native void XmDropSiteUpdate(int widget, int [] arglist, int argcount);
+public static final native void XmDropTransferAdd(int drop_transfer, int [] transfers, int num_transfers);
+public static final native int XmDropTransferStart(int widget, int [] arglist, int argcount);
+public static final native int XmFileSelectionBoxGetChild (int widget, int child);
+public static final native int XmFontListAppendEntry (int oldList, int entry);
+public static final native int XmFontListCopy (int fontlist);
+public static final native void XmFontListEntryFree (int[] entry);
+public static final native int XmFontListEntryGetFont (int entry, int[] type_return);
+public static final native int XmFontListEntryLoad (int display, byte [] fontName, int type, byte[] tag);
+public static final native void XmFontListFree (int list);
+public static final native void XmFontListFreeFontContext (int context);
+public static final native boolean XmFontListInitFontContext (int[] context,int fontList);
+public static final native int XmFontListNextEntry (int context);
+public static final native int XmGetAtomName (int display, int atom);
+public static final native int XmGetDragContext (int widget, int timestamp);
+public static final native int XmGetFocusWidget (int widget);
+public static final native int XmGetXmDisplay (int display);
+public static final native int XmImMbLookupString (int widget, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final native int XmInternAtom (int display, byte [] name, boolean only_if_exists);
+public static final native void XmListAddItemUnselected (int list, int xmString, int position);
+public static final native void XmListDeleteAllItems (int list);
+public static final native void XmListDeleteItemsPos (int list, int item_count, int position);
+public static final native void XmListDeletePos (int list, int position);
+public static final native void XmListDeletePositions (int list, int [] position_list, int position_count);
+public static final native void XmListDeselectAllItems (int list);
+public static final native void XmListDeselectPos (int list, int position);
+public static final native int XmListGetKbdItemPos (int list);
+public static final native boolean XmListGetSelectedPos (int list, int [] positions, int [] count);
+public static final native int XmListItemPos (int list, int xmString);
+public static final native boolean XmListPosSelected (int list, int position);
+public static final native void XmListReplaceItemsPosUnselected (int list, int [] new_items, int item_count, int position);
+public static final native void XmListSelectPos (int list, int position, boolean notify);
+public static final native boolean XmListSetKbdItemPos (int list, int position);
+public static final native void XmListSetPos (int list, int position);
+public static final native void XmListUpdateSelectedList (int list);
+public static final native void XmMainWindowSetAreas (int widget, int menu, int command, int hscroll, int vscroll, int wregion);
+public static final native int XmMenuShellWidgetClass ();
+public static final native int XmMessageBoxGetChild (int widget, int child);
+public static final native int XmParseMappingCreate (int [] argList, int argCount);
+public static final native void XmParseMappingFree (int parseMapping);
+public static final native void XmParseTableFree (int [] parseTable, int mappingCount);
+public static final native boolean XmProcessTraversal (int widget, int dir);
+public static final native int XmRenderTableAddRenditions(int oldTable, int[] renditions, int renditionCount, int mergeMode);
+public static final native void XmRenderTableFree(int renderTable);
+public static final native int XmRenditionCreate(int widget, byte[] tag, int[] argList, int argCount);
+public static final native void XmRenditionFree(int rendition);
+public static final native boolean XmStringCompare (int xmString1, int xmString2);
+public static final native int XmStringComponentCreate (int type, int length, byte[] value);
+public static final native int XmStringCreate (byte [] string, byte [] charset);
+public static final native int XmStringCreateLocalized (byte [] string);
+public static final native int XmStringCreateLtoR (byte [] string, byte [] charset);
+public static final native void XmStringDraw (int display, int window, int renderTable, int xmString, int gc, int x, int y, int width, int align, int lay_dir, XRectangle clip);
+public static final native void XmStringDrawImage (int display, int window, int renderTable, int xmString, int gc, int x, int y, int width, int align, int lay_dir, XRectangle clip);
+public static final native boolean XmStringEmpty (int s1);
+public static final native void XmStringFree (int xmString);
+public static final native boolean XmStringGetLtoR (int xmString, byte [] charset, int [] text);
+public static final native int XmStringGenerate(byte[] text, byte[] tag, int type, byte[] rendition);
+public static final native int XmStringHeight (int fontList, int xmString);
+public static final native int XmStringParseText (byte[] text, int textEnd, byte [] tag, int tagType, int [] parseTable, int parseCount, int callData);
+public static final native int XmStringWidth (int fontList, int xmString);
+public static final native int XmStringUnparse (int xmString, byte [] tag, int tagType, int outputType, int [] parseTable, int parseCount, int parseModel);
+public static final native int XmTabCreate(int value, byte units, byte offsetModel, byte alignment, byte[] decimal);
+public static final native void XmTabFree(int tab);
+public static final native void XmTabListFree(int tabList);
+public static final native int XmTabListInsertTabs(int oldList, int[] tabs, int tab_count, int position);
+public static final native void XmTextClearSelection (int widget, int time);
+public static final native boolean XmTextCopy (int widget, int time);
+public static final native boolean XmTextCut (int widget, int time);
+public static final native void XmTextDisableRedisplay (int widget);
+public static final native void XmTextEnableRedisplay (int widget);
+public static final native int XmTextGetInsertionPosition (int widget);
+public static final native int XmTextGetLastPosition (int widget);
+public static final native int XmTextGetMaxLength (int widget);
+public static final native int XmTextGetSelection (int widget);
+public static final native boolean XmTextGetSelectionPosition (int widget, int [] left, int [] right);
+public static final native int XmTextGetString (int widget);
+public static final native int XmTextGetSubstring (int widget, int start, int num_chars, int buffer_size, byte [] buffer);
+public static final native int XmTextGetSubstringWcs (int widget, int start, int num_chars, int buffer_size, char [] buffer);
+public static final native void XmTextInsert (int widget, int position, byte [] value);
+public static final native boolean XmTextPaste (int widget);
+public static final native boolean XmTextPosToXY (int widget, int position, short [] x, short [] y);
+public static final native void XmTextReplace (int widget, int from_pos, int to_pos, byte [] value);
+public static final native void XmTextScroll (int widget, int lines);
+public static final native void XmTextSetEditable (int widget, boolean editable);
+public static final native void XmTextSetHighlight (int widget, int left, int right, int mode);
+public static final native void XmTextSetInsertionPosition (int widget, int position);
+public static final native void XmTextSetMaxLength (int widget, int max_length);
+public static final native void XmTextSetSelection (int widget, int first, int last, int time);
+public static final native void XmTextSetString (int widget, byte [] value);
+public static final native void XmTextShowPosition (int widget, int position);
+public static final native void XmUpdateDisplay (int widget);
+public static final native boolean XmWidgetGetDisplayRect (int region, XRectangle rectangle);
+public static final native int XmbLookupString (int ic, XKeyEvent event, byte [] string, int size, int [] keysym, int [] status);
+public static final native void XtAddCallback (int widget, int callback_name, int callback, int client_data);
+public static final native void XtAddEventHandler (int widget, int event_mask, boolean nonmaskable, int proc, int client_data);
+public static final native void XtAddExposureToRegion (int event, int region);
+public static final native int XtAppAddTimeOut (int app_context, int interval, int proc, int client_data);
+public static final native int XtAppCreateShell (
+ byte [] appName,
+ byte [] appClass,
+ int widgetClass,
+ int display,
+ int [] argList,
+ int argCount);
+public static final native void XtAppNextEvent (int appContext, XAnyEvent event);
+public static final native boolean XtAppPeekEvent (int appContext, XAnyEvent event);
+public static final native int XtAppPending (int appContext);
+public static final native void XtAppProcessEvent (int appContext, int inputMask);
+public static final native int XtAppSetErrorHandler (int app_context, int msg_handler);
+public static final native int XtAppSetWarningHandler (int app_context, int msg_handler);
+public static final native int XtBuildEventMask (int widget);
+public static final native void XtCallActionProc (int widget, byte [] action, XAnyEvent event, int [] params, int num_params);
+public static final native int XtClass (int widget);
+public static final native void XtConfigureWidget (int widget, int x, int y, int width, int height, int borderWidth);
+public static final native int XtCreateApplicationContext ();
+public static final native int XtCreatePopupShell (byte [] name, int widgetClass, int parent, int [] argList, int argCount);
+public static final native void XtDestroyApplicationContext (int appContext);
+public static final native void XtDestroyWidget (int widget);
+public static final native boolean XtDispatchEvent (XAnyEvent event);
+public static final native int XtDisplay (int widget);
+public static final native int XtDisplayToApplicationContext (int display);
+public static final native void XtFree (int ptr);
+public static final native int XtGetMultiClickTime (int display);
+public static final native void XtGetValues (int widget, int [] argList, int numArgs);
+public static final native boolean XtIsManaged (int widget);
+public static final native boolean XtIsRealized (int widget);
+public static final native boolean XtIsSubclass (int widget, int widgetClass);
+public static final native boolean XtIsTopLevelShell (int widget);
+public static final native boolean XtIsWidget (int widget);
+public static final native int XtLastTimestampProcessed (int display);
+public static final native int XtMalloc (int size);
+public static final native void XtManageChild (int widget);
+public static final native void XtMapWidget (int widget);
+public static final native void XtMoveWidget (int widget, int x, int y);
+public static final native int XtOpenDisplay (
+ int xtAppContext,
+ byte [] displayName,
+ byte [] applicationName,
+ byte [] applicationClass,
+ int options,
+ int numOptions,
+ int [] argc,
+ int argv);
+public static final native void XtOverrideTranslations (int w, int translations);
+public static final native int XtParent (int widget);
+public static final native int XtParseTranslationTable (byte [] string);
+public static final native void XtPopdown (int widget);
+public static final native void XtPopup (int widget, int flags);
+public static final native int XtQueryGeometry (int widget, XtWidgetGeometry intended, XtWidgetGeometry preferred_return);
+public static final native void XtRealizeWidget (int widget);
+public static final native void XtRemoveTimeOut (int id);
+public static final native void XtResizeWidget (int widget, int width, int height, int borderWidth);
+public static final native void XtResizeWindow (int widget);
+public static final native int XtSetLanguageProc (int appContext, int languageProc, int pointer);
+public static final native void XtSetMappedWhenManaged (int widget, boolean flag);
+public static final native void XtSetValues (int widget, int [] argList, int numArgs);
+public static final native void XtToolkitInitialize ();
+public static final native void XtTranslateCoords (int widget, short x, short y, short [] root_x, short [] root_y);
+public static final native void XtUnmanageChild (int widget);
+public static final native void XtUnmapWidget (int widget);
+public static final native int XtWindow (int widget);
+public static final native int XtWindowToWidget (int display, int widget);
+static int malloc(String name) {
+ int length = name.length();
+ int ptr = OS.XtMalloc (length + 1);
+ char [] unicode = new char [length];
+ name.getChars (0, length, unicode, 0);
+ byte[] buffer = new byte [length + 1];
+ for (int i = 0; i < length; i++) {
+ buffer[i] = (byte) unicode[i];
+ }
+ OS.memmove (ptr, buffer, length + 1);
+ return ptr;
+}
+public static final native void memmove (int dest, XImage src, int count);
+public static final native void memmove (int dest, XmDragProcCallback src, int count);
+public static final native void memmove (int dest, XmTextBlockRec src, int count);
+public static final native void memmove (int dest, XmTextVerifyCallbackStruct src, int count);
+public static final native void memmove (int dest, byte [] src, int count);
+public static final native void memmove (int dest, int [] src, int count);
+public static final native void memmove (Visual dest, int src, int count);
+public static final native void memmove (XButtonEvent dest, int src, int count);
+public static final native void memmove (XCharStruct dest, int src, int count);
+public static final native void memmove (XConfigureEvent dest, int src, int count);
+public static final native void memmove (XCrossingEvent dest, int src, int count);
+public static final native void memmove (XExposeEvent dest, int src, int count);
+public static final native void memmove (XFocusChangeEvent dest, int src, int count);
+public static final native void memmove (XFontStruct dest, int src, int count);
+public static final native void memmove (XImage dest, int src, int count);
+public static final native void memmove (XKeyEvent dest, int src, int count);
+public static final native void memmove (XKeyEvent dest, XAnyEvent src, int count);
+public static final native void memmove (XMotionEvent dest, int src, int count);
+public static final native void memmove (XmAnyCallbackStruct dest, int src, int count);
+public static final native void memmove (XmDragProcCallback dest, int src, int count);
+public static final native void memmove (XmDropFinishCallback dest, int src, int count);
+public static final native void memmove (XmDropProcCallback dest, int src, int count);
+public static final native void memmove (XmTextBlockRec dest, int src, int count);
+public static final native void memmove (XmTextVerifyCallbackStruct dest, int src, int count);
+public static final native void memmove (byte [] dest, int src, int count);
+public static final native void memmove (int [] dest, int src, int count);
+public static final native int strlen (int string);
+public static final native int XpmReadFileToPixmap(int display, int drawable, byte[] fileName, int[] pixmap_return, int[] shapemask_return, int attributes);
+public static final native int XmCreateDrawnButton (int parent, byte [] name, int [] arglist, int argcount);
+public static final native int XCheckIfEvent (int display, XAnyEvent event_return, int predicate, int arg);
+public static final native boolean XtToolkitThreadInitialize ();
+public static final native int Call (int proc, int arg1, int arg2);
+public static final native int XSetIOErrorHandler (int handler);
+public static final native boolean XmTextFieldPaste (int widget);
+
+/*
+ * ======== Start of printing constants and functions ========
+ */
+ public static final byte XPJobAttr = 1;
+ public static final byte XPDocAttr = 2;
+ public static final byte XPPrinterAttr = 4;
+ public static final byte XPAttrMerge = 2;
+ public static final byte XPSpool = 1;
+ public static final int CopyFromParent = 0;
+
+public static final native int XpCreateContext(int display, byte [] printer_name);
+public static final native int XpGetPrinterList(int display, byte [] printer_name, int [] list_count);
+public static final native void XpFreePrinterList(int printer_list);
+public static final native int XpGetAttributes(int display, int print_context, byte type);
+public static final native void XpSetAttributes(int display, int print_context, byte type, byte [] pool, byte replacement_rule);
+public static final native int XpGetOneAttribute(int display, int print_context, byte type, byte [] attribute_name);
+public static final native void XpSetContext(int display, int print_context);
+public static final native int XpGetScreenOfContext(int display, int print_context);
+public static final native void XpDestroyContext(int display, int print_context);
+public static final native int XpGetPageDimensions(int display, int print_context, short [] width, short [] height, XRectangle reproducible_area);
+public static final native void XpStartJob(int display, byte save_data);
+public static final native void XpStartPage(int display, int window);
+public static final native void XpEndPage(int display);
+public static final native void XpEndJob(int display);
+public static final native void XpCancelJob(int display, boolean discard);
+public static final native int XpQueryVersion(int display, short[] major_version, short[] minor_version);
+public static final native int XDefaultGCOfScreen(int screen);
+public static final native int XDefaultColormapOfScreen(int screen);
+public static final native int XRootWindowOfScreen(int screen);
+public static final native int XScreenNumberOfScreen(int screen);
+public static final native int XCreateWindow(int display, int parent, int x, int y, int width, int height,
+ int border_width, int depth, int clazz, int visual, long value_mask, int attributes);
+public static final native void XDestroyWindow(int display, int w);
+
+/*
+ * ======== End of printing constants and functions ========
+ */
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/Visual.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/Visual.java
new file mode 100755
index 0000000000..7b23c27be8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/Visual.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class Visual {
+ public int ext_data;
+ public int visualid;
+ public int c_class;
+ public int red_mask, green_mask, blue_mask;
+ public int bits_per_rgb;
+ public int map_entries;
+ public static final int sizeof = 32;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XAnyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XAnyEvent.java
new file mode 100755
index 0000000000..dd733286ee
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XAnyEvent.java
@@ -0,0 +1,11 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XAnyEvent extends XEvent {
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+ public int pad10, pad11, pad12, pad13, pad14, pad15, pad16, pad17, pad18;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XButtonEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XButtonEvent.java
new file mode 100755
index 0000000000..b8b8cb3a6c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XButtonEvent.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XButtonEvent extends XInputEvent {
+ public int button; /* detail */
+ public int same_screen; /* same screen flag */
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCharStruct.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCharStruct.java
new file mode 100755
index 0000000000..bdec29c6db
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCharStruct.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XCharStruct {
+ public short lbearing;
+ public short rbearing;
+ public short width;
+ public short ascent;
+ public short descent;
+ public short attributes;
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XColor.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XColor.java
new file mode 100755
index 0000000000..5f38a015be
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XColor.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XColor {
+ public int pixel;
+ public short red, green, blue;
+ public byte flags;
+ public byte pad;
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java
new file mode 100755
index 0000000000..3842b9584e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XConfigureEvent.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XConfigureEvent extends XEvent {
+ public int x, y;
+ public int width, height;
+ public int border_width;
+ public int above;
+ public int override_redirect;
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+ public int pad10, pad11;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java
new file mode 100755
index 0000000000..14605f9f88
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XCrossingEvent.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XCrossingEvent extends XWindowEvent {
+ public int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ public int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear, NotifyNonlinearVirtual
+ */
+ public int same_screen; /* same screen flag */
+ public int focus; /* boolean focus */
+ public int state; /* key or button mask */
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XEvent.java
new file mode 100755
index 0000000000..11c539fdff
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XEvent.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class XEvent {
+ public int type;
+ public int serial;
+ public int send_event;
+ public int display;
+ public int window;
+ public static final int sizeof = 96;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XExposeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XExposeEvent.java
new file mode 100755
index 0000000000..d6a470345f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XExposeEvent.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XExposeEvent extends XEvent {
+ public int x, y;
+ public int width, height;
+ public int count;
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+ public int pad10, pad11, pad12, pad13;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java
new file mode 100755
index 0000000000..b0073ad986
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFocusChangeEvent.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XFocusChangeEvent extends XEvent {
+ public int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ public int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+ public int pad10, pad11, pad12, pad13, pad14, pad15, pad16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFontStruct.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFontStruct.java
new file mode 100755
index 0000000000..5062f111ab
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XFontStruct.java
@@ -0,0 +1,36 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XFontStruct {
+ public int ext_data;
+ public int fid;
+ public int direction;
+ public int min_char_or_byte2;
+ public int max_char_or_byte2;
+ public int min_byte1;
+ public int max_byte1;
+ public int all_chars_exist;
+ public int default_char;
+ public int n_properties;
+ public int properties;
+ public short min_bounds_lbearing;
+ public short min_bounds_rbearing;
+ public short min_bounds_width;
+ public short min_bounds_ascent;
+ public short min_bounds_descent;
+ public short min_bounds_attributes;
+ public short max_bounds_lbearing;
+ public short max_bounds_rbearing;
+ public short max_bounds_width;
+ public short max_bounds_ascent;
+ public short max_bounds_descent;
+ public short max_bounds_attributes;
+ public int per_char;
+ public int ascent;
+ public int descent;
+ public static final int sizeof = 80;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XGCValues.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XGCValues.java
new file mode 100755
index 0000000000..eebdef85d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XGCValues.java
@@ -0,0 +1,33 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XGCValues {
+ public int function; /* logical operation */
+ public int plane_mask;/* plane mask */
+ public int foreground;/* foreground pixel */
+ public int background;/* background pixel */
+ public int line_width; /* line width */
+ public int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ public int cap_style; /* CapNotLast, CapButt, CapRound, CapProjecting */
+ public int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ public int fill_style; /* FillSolid, FillTiled, FillStippled, FillOpaeueStippled */
+ public int fill_rule; /* EvenOddRule, WindingRule */
+ public int arc_mode; /* ArcChord, ArcPieSlice */
+ public int tile; /* tile pixmap for tiling operations */
+ public int stipple; /* stipple 1 plane pixmap for stipping */
+ public int ts_x_origin; /* offset for tile or stipple operations */
+ public int ts_y_origin;
+ public int font; /* default text font for text operations */
+ public int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ public int graphics_exposures;/* boolean, should exposures be generated */
+ public int clip_x_origin; /* origin for clipping */
+ public int clip_y_origin;
+ public int clip_mask; /* bitmap clipping; other calls for rects */
+ public int dash_offset; /* patterned/dashed line information */
+ public byte dashes;
+ public static final int sizeof = 92;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XImage.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XImage.java
new file mode 100755
index 0000000000..691df05be9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XImage.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XImage {
+ public int width, height;
+ public int xoffset, format;
+ public int data;
+ public int byte_order, bitmap_unit, bitmap_bit_order, bitmap_pad;
+ public int depth, bytes_per_line, bits_per_pixel;
+ public int red_mask, green_mask, blue_mask;
+ public int obdata;
+// struct funcs {
+ public int create_image;
+ public int destroy_image;
+ public int get_pixel;
+ public int put_pixel;
+ public int sub_image;
+ public int add_pixel;
+// } f;
+ public static final int sizeof = 88;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XInputEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XInputEvent.java
new file mode 100755
index 0000000000..fde28843f7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XInputEvent.java
@@ -0,0 +1,10 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class XInputEvent extends XWindowEvent {
+ public int state; /* key or button mask */
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XKeyEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XKeyEvent.java
new file mode 100755
index 0000000000..1541cfe711
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XKeyEvent.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XKeyEvent extends XInputEvent {
+ public int keycode; /* detail */
+ public int same_screen; /* same screen flag */
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XMotionEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XMotionEvent.java
new file mode 100755
index 0000000000..82428b47d4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XMotionEvent.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XMotionEvent extends XInputEvent {
+ public int is_hint; /* detail */
+ public int same_screen; /* same screen flag */
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XRectangle.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XRectangle.java
new file mode 100755
index 0000000000..b8feffa676
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XRectangle.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XRectangle {
+ public short x, y, width, height;
+ public static final int sizeof = 8;
+public String toString () {
+ return "XRectangle {" + x + ", " + y + ", " + width + ", " + height + "}";
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java
new file mode 100755
index 0000000000..5f4d79350e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XSetWindowAttributes.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XSetWindowAttributes {
+ public int background_pixmap; /* background or None or ParentRelative */
+ public int background_pixel; /* background pixel */
+ public int border_pixmap; /* border of the window */
+ public int border_pixel; /* border pixel value */
+ public int bit_gravity; /* one of bit gravity values */
+ public int win_gravity; /* one of the window gravity values */
+ public int backing_store; /* NotUseful, WhenMapped, Always */
+ public int backing_planes;/* planes to be preseved if possible */
+ public int backing_pixel;/* value to use in restoring planes */
+ public int save_under; /* should bits under be saved? (popups) */
+ public int event_mask; /* set of events that should be saved */
+ public int do_not_propagate_mask; /* set of events that should not propagate */
+ public int override_redirect; /* boolean value for override-redirect */
+ public int colormap; /* color map to be associated with window */
+ public int cursor; /* cursor to be displayed (or None) */
+ public static final int sizeof = 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java
new file mode 100755
index 0000000000..11d1443999
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowAttributes.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XWindowAttributes {
+ public int x, y; /* location of window */
+ public int width, height; /* width and height of window */
+ public int border_width; /* border width of window */
+ public int depth; /* depth of window */
+ public int visual; /* the associated visual structure */
+ public int root; /* root of screen containing window */
+ public int c_class; /* InputOutput, InputOnly*/
+ public int bit_gravity; /* one of bit gravity values */
+ public int win_gravity; /* one of the window gravity values */
+ public int backing_store; /* NotUseful, WhenMapped, Always */
+ public int backing_planes;/* planes to be preserved if possible */
+ public int backing_pixel;/* value to be used when restoring planes */
+ public int save_under; /* boolean, should bits under be saved? */
+ public int colormap; /* color map to be associated with window */
+ public int map_installed; /* boolean, is color map currently installed*/
+ public int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ public int all_event_masks; /* set of events all people have interest in*/
+ public int your_event_mask; /* my event mask */
+ public int do_not_propagate_mask; /* set of events that should not propagate */
+ public int override_redirect; /* boolean value for override-redirect */
+ public int screen; /* back pointer to correct screen */
+ public static final int sizeof = 92;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowChanges.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowChanges.java
new file mode 100755
index 0000000000..991383513c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowChanges.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XWindowChanges {
+ public int x, y;
+ public int width, height;
+ public int border_width;
+ public int sibling;
+ public int stack_mode;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowEvent.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowEvent.java
new file mode 100755
index 0000000000..5d229c0f57
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XWindowEvent.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public abstract class XWindowEvent extends XEvent {
+ public int root; /* root window that the event occured on */
+ public int subwindow; /* child window */
+ public int time; /* milliseconds */
+ public int x, y; /* pointer x, y coordinates in event window */
+ public int x_root, y_root; /* coordinates relative to root */
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java
new file mode 100755
index 0000000000..389e0d1fb1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmAnyCallbackStruct.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XmAnyCallbackStruct {
+ public int reason; // 0
+ public int event; // 4
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java
new file mode 100755
index 0000000000..6afd4717cd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDragProcCallback.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XmDragProcCallback {
+ public int reason; // the reason callback was called
+ public int event; // event structure that triggered callback
+ public int timeStamp; // timestamp of ;logical event
+ public int dragContext; // DragContext widget associated with operation
+ public short x; // x-coordinate of pointer
+ public short y; // y-coordinate of pointer
+ public byte dropSiteStatus; // valid or invalid
+ public byte operation; // current operation
+ public byte operations; // supported operations
+ public byte animate; // toolkit or receiver does animation
+
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java
new file mode 100755
index 0000000000..07586efac3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropFinishCallback.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XmDropFinishCallback {
+ public int reason; // the reason callback was called
+ public int event; // event structure that triggered callback
+ public int timeStamp; // time at which drop completed
+ public byte operation; // current operation
+ public byte operations; // supported operations
+ public byte dropSiteStatus; // valid, invalid or none
+ public byte dropAction; // drop, cancel, help or interrupt
+ public byte completionStatus; // success or failure
+
+ public static final int sizeof = 17;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java
new file mode 100755
index 0000000000..f8e95ff1d0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmDropProcCallback.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XmDropProcCallback {
+ public int reason; // the reason callback was called
+ public int event; // event structure that triggered callback
+ public int timeStamp; // timestamp of ;logical event
+ public int dragContext; // DragContext widget associated with operation
+ public short x; // x-coordinate of pointer
+ public short y; // y-coordinate of pointer
+ public byte dropSiteStatus; // valid or invalid
+ public byte operation; // current operation
+ public byte operations; // supported operations
+ public byte dropAction; // drop or help
+
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java
new file mode 100755
index 0000000000..c508f8f420
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextBlockRec.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XmTextBlockRec {
+ public int ptr; // 0
+ public int length; // 4
+ public int format; // 8
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java
new file mode 100755
index 0000000000..8d5203cfa2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XmTextVerifyCallbackStruct.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XmTextVerifyCallbackStruct extends XmAnyCallbackStruct {
+ public byte doit; // 8
+ public int currInsert; // 12
+ public int newInsert; // 16
+ public int startPos; // 20
+ public int endPos; // 24
+ public int text; // 28
+ public static final int sizeof = 32;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java
new file mode 100755
index 0000000000..661378fadc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/internal/motif/XtWidgetGeometry.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.motif;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class XtWidgetGeometry {
+ public int request_mode;
+ public int x, y;
+ public int width, height, border_width;
+ public int sibling;
+ public int stack_mode;
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
new file mode 100755
index 0000000000..b23dff6c03
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -0,0 +1,318 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class stores and manages child items of a tree item.
+ * It provides protocol to query the index of an item relative
+ * to the root and to retrieve items by index.
+ * The TreeItem class implements this protocol for general
+ * tree items.
+ * TreeRoots provides a special implementation that allows the
+ * Tree class to treat trees with one root and with multiple
+ * roots equally.
+ */
+abstract class AbstractTreeItem extends SelectableItem {
+ private Vector children;
+ private boolean isExpanded = false;
+ // number of children.
+ // includes all expanded items down to the leafs.
+ private int visibleItemCount = 0;
+
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver belongs to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+AbstractTreeItem(Tree parent, int swtStyle) {
+ super(parent, swtStyle);
+}
+/**
+ * Insert 'item' in the list of child items. Notify the
+ * parent about the new item.
+ * @param 'item' - the item that should be added to the
+ * receiver's children.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void add(TreeItem item, int index) {
+ Vector items = getChildren();
+ int visibleIndex = getVisibleIndex();
+
+ if (index < 0 || index > items.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (item.isRoot()) {
+ visibleIndex = index;
+ }
+ else
+ if (isExpanded == false) {
+ visibleIndex = -1;
+ }
+ if (visibleIndex != -1) {
+ if (index > 0) {
+ TreeItem previousChild = (TreeItem) getChildren().elementAt(index - 1);
+ visibleIndex = previousChild.getVisibleIndex() + previousChild.getVisibleItemCount() + 1;
+ }
+ else {
+ visibleIndex = getVisibleIndex() + 1;
+ }
+ }
+ getSelectableParent().addingItem(item, visibleIndex);
+ item.setIndex(index);
+ resetChildIndices(index, true);
+ items.insertElementAt(item, index);
+ if (isExpanded == true) {
+ visibleItemCount++;
+ calculateVisibleItemCountParent();
+ }
+ getSelectableParent().addedItem(item, visibleIndex);
+}
+/**
+ * Set whether the receiver is expanded or not.
+ * If the receiver is expanded its child items are visible.
+ * @param expanded -
+ * true=the receiver is expanded, making its child items visible.
+ * false=the receiver is collapsed, making its child items invisible
+ */
+void internalSetExpanded(boolean expanded) {
+ isExpanded = expanded;
+ calculateVisibleItemCount();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+abstract void calculateVisibleItemCount();
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+abstract void calculateVisibleItemCountParent();
+/**
+ * Deselect the receiver and all children
+ */
+void deselectAll() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ setSelected(false);
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.deselectAll();
+ }
+}
+/**
+ * Destroy all children of the receiver
+ */
+void disposeItem() {
+ Vector children = getChildren();
+ AbstractTreeItem child;
+ while (children.size() > 0) { // TreeItem objects are removed from vector during dispose
+ child = (AbstractTreeItem) children.firstElement();
+ child.dispose();
+ }
+ doDispose();
+ super.disposeItem();
+}
+/**
+ * Subclasses should free resources here
+ */
+void doDispose() {
+ setChildren(null);
+ visibleItemCount = 0;
+}
+/**
+ * Answer the Vector containing the child items of the receiver.
+ */
+Vector getChildren() {
+ if (children == null) {
+ children = new Vector(4);
+ }
+ return children;
+}
+/**
+ * Answer whether the receiver is expanded or not.
+ * If the receiver is expanded its children are visible.
+ * @return
+ * true - the receiver is expanded, making its children visible
+ * false - the receiver is collapsed, making its children invisible
+ */
+public boolean getExpanded() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return isExpanded;
+}
+/**
+ * Answer the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getChildren().size();
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the global index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+abstract int getVisibleIndex();
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+abstract int getVisibleIndex(int childIndex);
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ */
+abstract TreeItem getVisibleItem(int searchIndex);
+/**
+ * Answer the number of expanded children, direct and indirect.
+ */
+int getVisibleItemCount() {
+ return visibleItemCount;
+}
+/**
+ * Returns the expanded state. Circumvent widget/thread check
+ * for performance. For non-API callers only.
+ */
+boolean internalGetExpanded() {
+ return isExpanded;
+}
+/**
+ * Answer whether the receiver is a leaf item.
+ * An item is a leaf when it has no child items.
+ * @return
+ * true - receiver is a leaf item
+ * false - receiver is not a leaf item.
+ */
+boolean isLeaf() {
+ return (getChildren().size() == 0);
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it doesn't have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return false;
+}
+/**
+ * Remove 'child' from the receiver.
+ * Notify the parent widget only if it is not being disposed itself.
+ */
+void removeItem(SelectableItem child) {
+ Vector children = getChildren();
+ SelectableItemWidget parent = getSelectableParent();
+ int childIndex = children.indexOf(child);
+
+ if (childIndex != -1) {
+ if (((Tree) parent).isRemovingAll() == true) {
+ children.removeElementAt(childIndex); // just remove the item from the list if the whole tree is being disposed
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ }
+ else {
+ parent.removingItem(child);
+ children.removeElementAt(childIndex);
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ resetChildIndices(childIndex, false); // mark child index dirty
+ parent.removedItem(child);
+ }
+ }
+}
+/**
+ * Allow subclasses to reset any cached data.
+ * Called for all children of the receiver.
+ */
+void reset() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.reset();
+ }
+}
+/**
+ * Mark all child indices dirty starting with the child at
+ * 'startIndex'. This causes getIndex to recalculate the index.
+ * @param startIndex - index in the list of children at which
+ * and after which the indices are reset.
+ */
+void resetChildIndices(int startIndex, boolean addItem) {
+ Vector children = getChildren();
+ TreeItem child;
+ int increment = addItem ? 1 : 0;
+
+ for (int i = startIndex; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ child.setIndex(i + increment); // mark child index dirty
+ }
+}
+/**
+ * Select the receiver and all children.
+ * Return a Vector containing all the items that have been selected
+ * (and that have not been selected before).
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ if (isSelected() == false) {
+ selectedItems.addElement(this);
+ setSelected(true);
+ getSelectableParent().redrawSelection(this);
+ }
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+/**
+ * Set the Array containing the receiver's child items to 'children'.
+ */
+void setChildren(Vector children) {
+ this.children = children;
+}
+
+void setVisibleItemCount(int count) {
+ visibleItemCount = count;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
new file mode 100755
index 0000000000..93b8ec8dbc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java
@@ -0,0 +1,631 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+* The button class represents a selectable user interface object
+* that issues notificiation when pressed and released.
+*
+* <p>
+* <b>Styles</b><br>
+* <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE<br>
+* <br>
+* <b>Events</b><br>
+* <dd>Selection<br>
+*/
+
+/* Class Definition */
+public /*final*/ class Button extends Control {
+ Image image, bitmap, disabled;
+ static final byte [] ARM_AND_ACTIVATE;
+ static {
+ String name = "ArmAndActivate";
+ int length = name.length();
+ char [] unicode = new char [length];
+ name.getChars (0, length, unicode, 0);
+ byte [] buffer = new byte [length + 1];
+ for (int i = 0; i < length; i++) {
+ buffer[i] = (byte) unicode[i];
+ }
+ ARM_AND_ACTIVATE = buffer;
+ }
+/**
+* Creates a new instance of the widget.
+*/
+public Button (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
+ if ((style & SWT.PUSH) != 0) {
+ return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) {
+ return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
+ }
+ if ((style & SWT.ARROW) != 0) {
+ return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0);
+ }
+ return style;
+}
+void click () {
+ OS.XtCallActionProc (handle, ARM_AND_ACTIVATE, new XAnyEvent (), null, 0);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.ARROW) != 0) {
+ Display display = getDisplay ();
+ width += display.scrolledMarginX;
+ height += display.scrolledMarginY;
+ return new Point (width, height);
+ }
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ result.request_mode = OS.CWWidth | OS.CWHeight;
+ int [] argList2 = {OS.XmNrecomputeSize, 1};
+ OS.XtSetValues(handle, argList2, argList2.length / 2);
+ OS.XtQueryGeometry (handle, null, result);
+ int [] argList3 = {OS.XmNrecomputeSize, 0};
+ OS.XtSetValues(handle, argList3, argList3.length / 2);
+ width += result.width;
+ height += result.height;
+ /**
+ * Feature in Motif. If a button's labelType is XmSTRING but it
+ * has no label set into it yet, recomputing the size will
+ * not take into account the height of the font, as we would
+ * like it to. Take care of this case.
+ */
+ int [] argList = {OS.XmNlabelType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == OS.XmSTRING) {
+ int [] argList1 = {OS.XmNlabelString, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int xmString = argList1 [1];
+ if (OS.XmStringEmpty (xmString)) height += getFontHeight ();
+ }
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ int [] argList4 = new int [] {OS.XmNmarginLeft, 0, OS.XmNmarginRight, 0, OS.XmNmarginTop, 0, OS.XmNmarginBottom, 0};
+ OS.XtGetValues (handle, argList4, argList4.length / 2);
+ if (wHint != SWT.DEFAULT) width = wHint + argList4 [1] + argList4 [3] + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + argList4 [5] + argList4 [7] + (border * 2);
+ }
+ return new Point (width, height);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ int borderWidth = (style & SWT.BORDER) != 0 ? 1 : 0;
+
+ /* ARROW button */
+ if ((style & SWT.ARROW) != 0) {
+ int alignment = OS.XmARROW_UP;
+ if ((style & SWT.UP) != 0) alignment = OS.XmARROW_UP;
+ if ((style & SWT.DOWN) != 0) alignment = OS.XmARROW_DOWN;
+ if ((style & SWT.LEFT) != 0) alignment = OS.XmARROW_LEFT;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.XmARROW_RIGHT;
+ int [] argList = {
+ OS.XmNtraversalOn, 0,
+ OS.XmNarrowDirection, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateArrowButton (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.FLAT) != 0) {
+ int [] argList1 = {OS.XmNshadowThickness, 1};
+ OS.XtSetValues (handle, argList1, argList1.length / 2);
+ }
+ return;
+ }
+
+ /* Compute alignment */
+ int alignment = OS.XmALIGNMENT_BEGINNING;
+ if ((style & SWT.CENTER) != 0) alignment = OS.XmALIGNMENT_CENTER;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.XmALIGNMENT_END;
+
+ /* TOGGLE button */
+ if ((style & SWT.TOGGLE) != 0) {
+ /*
+ * Bug in Motif. When XmNindicatorOn is set to false,
+ * Motif doesn't reset the shadow thickness to give a
+ * push button look. The fix is to set the shadow
+ * thickness when ever this resource is changed.
+ */
+ int [] argList = {
+ OS.XmNrecomputeSize, 0,
+ OS.XmNindicatorOn, 0,
+ OS.XmNshadowThickness, (style & SWT.FLAT) != 0 ? 1 : 2,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateToggleButton (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* CHECK or RADIO button */
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ /*
+ * Bug in Motif. For some reason, a toggle button
+ * with XmNindicatorType XmONE_OF_MANY must have this
+ * value set at creation or the highlight color will
+ * not be correct. The fix is to set these values
+ * on create.
+ */
+ int indicatorType = OS.XmONE_OF_MANY;
+ if ((style & SWT.CHECK) != 0) indicatorType = OS.XmN_OF_MANY;
+ int [] argList = {
+ OS.XmNrecomputeSize, 0,
+ OS.XmNindicatorType, indicatorType,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateToggleButton (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* PUSH button */
+ int [] argList = {
+ OS.XmNrecomputeSize, 0,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreatePushButton (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & SWT.FLAT) != 0) {
+ int [] argList1 = {OS.XmNshadowThickness, 1};
+ OS.XtSetValues (handle, argList1, argList1.length / 2);
+ }
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ if ((style & SWT.PUSH) == 0) return;
+ if (getShell ().parent == null) return;
+ int [] argList = new int [] {OS.XmNdefaultButtonShadowThickness, 1};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+int defaultBackground () {
+ return getDisplay ().buttonBackground;
+}
+int defaultFont () {
+ return getDisplay ().buttonFont;
+}
+int defaultForeground () {
+ return getDisplay ().buttonForeground;
+}
+/**
+* Gets the alignment.
+* <p>
+* This method returns the aligment of the button.
+* If the button is an ARROW, the value indicates
+* the direction of the arrow.
+* <p>
+* LEFT, RIGHT, UP, DOWN - when the button is an ARROW button.<br>
+* LEFT, RIGHT, CENTER - when the button is any other style.
+*
+* @return the button alignment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) {
+ int [] argList = {OS.XmNarrowDirection, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int direction = argList [1];
+ if (direction == OS.XmARROW_UP) return SWT.UP;
+ if (direction == OS.XmARROW_DOWN) return SWT.DOWN;
+ if (direction == OS.XmARROW_LEFT) return SWT.LEFT;
+ if (direction == OS.XmARROW_RIGHT) return SWT.RIGHT;
+ return SWT.UP;
+ }
+ int [] argList = {OS.XmNalignment, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int alignment = argList [1];
+ if (alignment == OS.XmALIGNMENT_BEGINNING) return SWT.LEFT;
+ if (alignment == OS.XmALIGNMENT_CENTER) return SWT.CENTER;
+ if (alignment == OS.XmALIGNMENT_END)return SWT.RIGHT;
+ return SWT.CENTER;
+}
+boolean getDefault () {
+ if ((style & SWT.PUSH) == 0) return false;
+ int [] argList = {OS.XmNshowAsDefault, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets the widget image.
+* <p>
+* @return the widget image
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+String getNameText () {
+ return getText ();
+}
+/**
+* Gets the selection.
+* <p>
+* This method gets the widget selection state for a
+* widgets with the style CHECK, RADIO or TOGGLE. It
+* returns false for widgets that do not have one of
+* these styles.
+* true or false - for CHECK, RADIO or TOGGLE.
+* false - for all other widget styles
+*
+* @return the selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] argList = {OS.XmNset, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets the widget text.
+* <p>
+* This method returns the button label. The label may
+* include the mnemonic character but must not contain line
+* delimiters.
+*
+* @return the button text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) return "";
+ int [] argList = {OS.XmNlabelString, 0, OS.XmNmnemonic, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int xmString = argList [1], mnemonic = argList [3];
+ if (xmString == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
+ char [] result = null;
+ int address = OS.XmStringUnparse (
+ xmString,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address != 0) {
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ result = Converter.mbcsToWcs (null, buffer);
+ }
+ if (xmString != 0) OS.XmStringFree (xmString);
+ int count = 0;
+ if (mnemonic != 0) count++;
+ for (int i=0; i<result.length-1; i++)
+ if (result [i] == Mnemonic) count++;
+ char [] newResult = result;
+ if ((count != 0) || (mnemonic != 0)) {
+ newResult = new char [result.length + count];
+ int i = 0, j = 0;
+ while (i < result.length) {
+ if ((mnemonic != 0) && (result [i] == mnemonic)) {
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ mnemonic = 0;
+ }
+ if ((newResult [j++] = result [i++]) == Mnemonic)
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ }
+ }
+ return new String (newResult);
+}
+void hookEvents () {
+ super.hookEvents ();
+ int callback = OS.XmNactivateCallback;
+ int windowProc = getDisplay ().windowProc;
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) callback = OS.XmNvalueChangedCallback;
+ OS.XtAddCallback (handle, callback, windowProc, SWT.Selection);
+}
+boolean mnemonicHit () {
+ if (!setFocus ()) return false;
+ click ();
+ return true;
+}
+boolean mnemonicMatch (char key) {
+ char mnemonic = findMnemonic (getText ());
+ if (mnemonic == '\0') return false;
+ return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
+}
+int processFocusIn () {
+ super.processFocusIn ();
+ if ((style & SWT.PUSH) == 0) return 0;
+ getShell ().setDefaultButton (this, false);
+ return 0;
+}
+int processFocusOut () {
+ super.processFocusOut ();
+ if ((style & SWT.PUSH) == 0) return 0;
+ if (getDefault ()) {
+ getShell ().setDefaultButton (null, false);
+ }
+ return 0;
+}
+int processSelection (int callData) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) selectRadio ();
+ }
+ return super.processSelection (callData);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ int [] argList = {
+ OS.XmNlabelPixmap, OS.XmUNSPECIFIED_PIXMAP,
+ OS.XmNlabelInsensitivePixmap, OS.XmUNSPECIFIED_PIXMAP,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ if (bitmap != null) bitmap.dispose ();
+ if (disabled != null) disabled.dispose ();
+ image = bitmap = disabled = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+void selectRadio () {
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child && child instanceof Button) {
+ Button button = (Button) child;
+ if ((button.getStyle () & SWT.RADIO) != 0) {
+ if (button.getSelection ()) {
+ button.setSelection (false);
+ button.postEvent (SWT.Selection);
+ }
+ }
+ }
+ }
+ setSelection (true);
+}
+/**
+* Sets the alignment.
+* <p>
+* This method sets the aligment of the button.
+* If the button is an ARROW, the value indicated
+* the direction of the arrow.
+*
+* @param alignment the button alignment or the direction
+* of the arrow if the button is an ARROW
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) {
+ int [] argList = {OS.XmNarrowDirection, OS.XmARROW_UP};
+ if ((alignment & SWT.UP) != 0) argList [1] = OS.XmARROW_UP;
+ if ((alignment & SWT.DOWN) != 0) argList [1] = OS.XmARROW_DOWN;
+ if ((alignment & SWT.LEFT) != 0) argList [1] = OS.XmARROW_LEFT;
+ if ((alignment & SWT.RIGHT) != 0) argList [1] = OS.XmARROW_RIGHT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ return;
+ }
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) == 0) return;
+ int [] argList = {OS.XmNalignment, OS.XmALIGNMENT_BEGINNING};
+ if ((alignment & SWT.CENTER) != 0) argList [1] = OS.XmALIGNMENT_CENTER;
+ if ((alignment & SWT.RIGHT) != 0) argList [1] = OS.XmALIGNMENT_END;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ int [] argList = {OS.XmNlabelType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == OS.XmPIXMAP) setBitmap (image);
+}
+void setBitmap (Image image) {
+ int labelPixmap = OS.XmUNSPECIFIED_PIXMAP;
+ int labelInsensitivePixmap = OS.XmUNSPECIFIED_PIXMAP;
+ if (bitmap != null) bitmap.dispose ();
+ if (disabled != null) disabled.dispose ();
+ bitmap = disabled = null;
+ if (image != null) {
+ Display display = getDisplay ();
+ switch (image.type) {
+ case SWT.BITMAP:
+ labelPixmap = image.pixmap;
+ disabled = new Image (display, image, SWT.IMAGE_DISABLE);
+ labelInsensitivePixmap = disabled.pixmap;
+ break;
+ case SWT.ICON:
+ Rectangle rect = image.getBounds ();
+ bitmap = new Image (display, rect.width, rect.height);
+ GC gc = new GC (bitmap);
+ gc.setBackground (getBackground ());
+ gc.fillRectangle (rect);
+ gc.drawImage (image, 0, 0);
+ gc.dispose ();
+ labelPixmap = bitmap.pixmap;
+ disabled = new Image (display, bitmap, SWT.IMAGE_DISABLE);
+ labelInsensitivePixmap = disabled.pixmap;
+ break;
+ default:
+ error (SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ }
+ int [] argList = {
+ OS.XmNlabelType, OS.XmPIXMAP,
+ OS.XmNlabelPixmap, labelPixmap,
+ OS.XmNlabelInsensitivePixmap, labelInsensitivePixmap,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+void setDefault (boolean value) {
+ if ((style & SWT.PUSH) == 0) return;
+ if (getShell ().parent == null) return;
+ int [] argList = {OS.XmNshowAsDefault, (value ? 1 : 0)};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the widget image.
+* <p>
+* @param image the widget image (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBitmap (this.image = image);
+}
+/**
+* Sets the selection.
+* <p>
+* This method Sets the widget selection state for a
+* widgets with the style CHECK, RADIO or TOGGLE. It
+* returns false for widgets that do not have one of
+* these styles.
+*
+* @param selected the new selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] argList = {OS.XmNset, selected ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the widget text.
+* <p>
+* This method sets the button label. The label may include
+* the mnemonic character but must not contain line delimiters.
+*
+* @param string the desired label of the button
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.ARROW) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ int i=0, j=0, mnemonic=0;
+ while (i < text.length) {
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int xmString = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+ int [] argList = {
+ OS.XmNlabelType, OS.XmSTRING,
+ OS.XmNlabelString, xmString,
+ OS.XmNmnemonic, mnemonic,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ if (xmString != 0) OS.XmStringFree (xmString);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
new file mode 100755
index 0000000000..6a6d902ecd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Canvas.java
@@ -0,0 +1,212 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The canvas class implements a drawing area for
+* arbitrary graphics.
+*
+* Styles
+*
+* NO_BACKGROUND,
+* NO_FOCUS,
+* MERGE_EXPOSES,
+* RESIZE_REDRAW
+*
+* Events
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/* Class Definition */
+public class Canvas extends Composite {
+ Caret caret;
+
+Canvas () {
+ /* Do nothing */
+}
+/**
+* Create a Canvas.
+*
+* PARAMTERS
+*
+* parent a composite widget (cannot be null)
+* style the bitwise OR'ing of widget styles
+*
+* REMARKS
+*
+* This method creates a child widget using style bits
+* to select a particular look or set of properties.
+*
+**/
+public Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ fontList = defaultFont ();
+}
+/**
+* Get the current caret.
+*
+* REMARKS
+*
+* This method gets the current caret for the window.
+* The current caret is automatically hidden and shown
+* by the window when:
+*
+* - during expose and resize
+* - when focus is gained or lost
+* - when an the window is scrolled
+*
+**/
+public Caret getCaret () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return caret;
+}
+
+int processFocusIn () {
+ int result = super.processFocusIn ();
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+int processFocusOut () {
+ int result = super.processFocusOut ();
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+int processPaint (int callData) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ int result = super.processPaint (callData);
+ if (isFocus) caret.setFocus ();
+ return result;
+}
+
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.redrawWidget (x, y, width, height, all);
+ if (isFocus) caret.setFocus ();
+}
+
+void releaseWidget () {
+ if (caret != null) {
+ caret.releaseWidget ();
+ caret.releaseHandle ();
+ }
+ caret = null;
+ super.releaseWidget();
+}
+
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (width <= 0 || height <= 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+ if (!isVisible ()) return;
+
+ /* Hide the caret */
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+
+ /* Flush outstanding exposes */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return;
+ XAnyEvent xEvent = new XAnyEvent ();
+ OS.XSync (xDisplay, false); OS.XSync (xDisplay, false);
+ while (OS.XCheckWindowEvent (xDisplay, xWindow, OS.ExposureMask, xEvent)) {
+ OS.XtDispatchEvent (xEvent);
+ }
+
+ /* Scroll the window */
+ int xGC = OS.XCreateGC (xDisplay, xWindow, 0, null);
+ OS.XCopyArea (xDisplay, xWindow, xWindow, xGC, x, y, width, height, destX, destY);
+ OS.XFreeGC (xDisplay, xGC);
+ boolean disjoint = (destX + width < x) || (x + width < destX) || (destY + height < y) || (y + height < destY);
+ if (disjoint) {
+ OS.XClearArea (xDisplay, xWindow, x, y, width, height, true);
+ } else {
+ if (deltaX != 0) {
+ int newX = destX - deltaX;
+ if (deltaX < 0) newX = destX + width;
+ OS.XClearArea (xDisplay, xWindow, newX, y, Math.abs (deltaX), height, true);
+ }
+ if (deltaY != 0) {
+ int newY = destY - deltaY;
+ if (deltaY < 0) newY = destY + height;
+ OS.XClearArea (xDisplay, xWindow, x, newY, width, Math.abs (deltaY), true);
+ }
+ }
+
+ /* Show the caret */
+ if (isFocus) caret.setFocus ();
+}
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.setBounds (x, y, width, height);
+ if (isFocus) caret.setFocus ();
+}
+/**
+* Set the current caret.
+*
+* PARAMTERS
+*
+* caret - the new caret or null
+*
+* REMARKS
+*
+* This method sets the current caret for the window.
+* The current caret is automatically hidden and shown
+* by the window when:
+*
+* - during expose and resize
+* - when focus is gained or lost
+* - when an the window is scrolled
+*
+**/
+public void setCaret (Caret caret) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Caret newCaret = caret;
+ Caret oldCaret = this.caret;
+ this.caret = newCaret;
+ if (hasFocus ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) newCaret.setFocus ();
+ }
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.setLocation (x, y);
+ if (isFocus) caret.setFocus ();
+}
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ super.setSize (width, height);
+ if (isFocus) caret.setFocus ();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
new file mode 100755
index 0000000000..818e4d53cd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Caret.java
@@ -0,0 +1,402 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+* The caret class implements an i-beam that is
+* typically used as the insertion point for text.
+*/
+
+/* Class Definition */
+public /*final*/ class Caret extends Widget {
+ Canvas parent;
+ int x, y, width, height;
+ boolean moved, resized;
+ boolean isVisible, isShowing;
+ int blinkRate = 500;
+/**
+* Creates a new instance of the widget.
+*/
+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);
+ isVisible = true;
+ if (parent.getCaret () == null) {
+ parent.setCaret (this);
+ }
+}
+boolean drawCaret () {
+ if (parent == null) return false;
+ if (parent.isDisposed ()) return false;
+ int handle = parent.handle;
+ int window = OS.XtWindow (handle);
+ if (window == 0) return false;
+ int xDisplay = OS.XtDisplay (handle);
+ int gc = OS.XCreateGC (xDisplay, window, 0, null);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int foreground = argList [1];
+ int background = argList [3];
+ int color = foreground ^ background;
+ OS.XSetFunction (xDisplay, gc, OS.GXxor);
+ OS.XSetForeground (xDisplay, gc, color);
+ int nWidth = width;
+ if (nWidth <= 0) nWidth = 2;
+ OS.XFillRectangle (xDisplay, window, gc, x, y, nWidth, height);
+ OS.XFreeGC (xDisplay, gc);
+ return true;
+}
+/**
+* Gets the widget bounds.
+* <p>
+* @return a rectangle that is the widget bounds.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Rectangle (x, y, width, height);
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+* Gets the widget font.
+* <p>
+* @return the widget font
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Font getFont () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getFont ();
+}
+/**
+* Gets the widget location.
+* <p>
+* @return the widget location
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point (x, y);
+}
+/**
+* Gets the parent.
+* <p>
+* @return the parent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Canvas getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+/**
+* Gets the widget size.
+* <p>
+* @return the widget size
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point (width, height);
+}
+/**
+* Gets the visibility state.
+* <p>
+* If the parent is not visible or some other condition
+* makes the widget not visible, the widget can still be
+* considered visible even though it may not actually be
+* showing.
+*
+* @return visible the visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return isVisible;
+}
+boolean hideCaret () {
+ Display display = getDisplay ();
+ if (display.currentCaret != this) return false;
+ if (!isShowing) return true;
+ isShowing = false;
+ return drawCaret ();
+}
+/**
+* Gets the visibility status.
+* <p>
+* This method returns the visibility status of the
+* widget in the widget hierarchy. If the parent is not
+* visible or some other condition makes the widget not
+* visible, this method will return false.
+*
+* @return the actual visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+boolean isFocusCaret () {
+ Display display = getDisplay ();
+ return this == display.currentCaret;
+}
+void killFocus () {
+ Display display = getDisplay ();
+ if (display.currentCaret != this) return;
+ if (isVisible) hideCaret ();
+ display.setCurrentCaret (null);
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ Display display = getDisplay ();
+ if (display.currentCaret == this) {
+ if (isVisible) hideCaret ();
+ display.setCurrentCaret (null);
+ }
+ parent = null;
+}
+/**
+* Sets the widget bounds.
+* <p>
+* @param x the new x coordinate
+* @param y the new y coordinate
+* @param width the new widget width
+* @param height the new widget height
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean samePosition, sameExtent, showing;
+ samePosition = (this.x == x) && (this.y == y);
+ sameExtent = (this.width == width) && (this.height == height);
+ if ((samePosition) && (sameExtent)) return;
+ if (isShowing) hideCaret ();
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ if (sameExtent) {
+ moved = true;
+ if (isVisible ()) {
+ moved = false;
+ //IsDBLocale ifTrue: [
+ //widget == nil ifFalse: [widget updateCaret]].
+ }
+ } else {
+ resized = true;
+ if (isVisible ()) {
+ moved = false;
+ //IsDBLocale ifTrue: [
+ //widget == nil ifFalse: [widget updateCaret]].
+ resized = false;
+ }
+ }
+ if (isShowing) showCaret ();
+}
+/**
+* Set the widget bounds.
+*
+* @param rect the new bounding rectangle
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when rect is null
+*/
+public void setBounds (Rectangle rect) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+void setFocus () {
+ Display display = getDisplay ();
+ if (display.currentCaret == this) return;
+ display.setCurrentCaret (this);
+ if (isVisible) showCaret ();
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setFont (Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+/**
+* Sets the widget location.
+* <p>
+* @param x the new x position.
+* @param y the new y position.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height);
+}
+/**
+* Sets the widget location.
+* <p>
+* @param location the new location
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when location is null
+*/
+public void setLocation (Point location) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+/**
+* Sets the widget size.
+* <p>
+* @param x the new width
+* @param y the new height
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height);
+}
+/**
+* Sets the widget size.
+* <p>
+* @param size the widget size
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when size is null
+*/
+public void setSize (Point size) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+/**
+* Sets the visibility state.
+* <p>
+* If the parent is not visible or some other condition
+* makes the widget not visible, the widget can still be
+* considered visible even though it may not actually be
+* showing.
+*
+* @param visible the new visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (visible == isVisible) return;
+ if (isVisible = visible) {
+ showCaret ();
+ } else {
+ hideCaret ();
+ }
+}
+boolean showCaret () {
+ if (getDisplay ().currentCaret != this) return false;
+ if (isShowing) return true;
+ isShowing = true;
+ return drawCaret ();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
new file mode 100755
index 0000000000..a57ccd7cda
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ColorDialog.java
@@ -0,0 +1,525 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+
+/**
+ * A color dialog allows the user to select a color
+ * from all available colors in the current pallette
+ */
+public /*final*/ class ColorDialog extends Dialog {
+ private static final int DEPTH_4 = 0; // index for COLOR_SWATCH_EXTENTS
+ private static final int DEPTH_8 = 1; // index for COLOR_SWATCH_EXTENTS
+ private static final int COLOR_SWATCH_EXTENTS[] = {40, 10}; // extents of the squares drawn to display a
+ // color out of 4 bit and 8 bit color depth
+ private static final int COLOR_SWATCH_BORDER = 1; // border between each color pad
+
+ private Shell shell; // the dialog shell
+ private Canvas colorsCanvas;
+ private Label sampleLabel;
+ private Canvas sampleCanvas;
+ private Label selectionLabel;
+ private Canvas selectionCanvas;
+ private Button ok;
+ private Button cancel;
+
+ private boolean okSelected; // true if the dialog was hidden
+ // because the ok button was selected
+ private RGB dialogResult;
+ private int colorDepth; // color depth of the display
+ private int colorSwatchExtent; // the size of on square used
+ // to display one color
+ private Color colorGrid[][]; // the colors displayed in the dialog
+
+public ColorDialog(Shell parent) {
+ this(parent, SWT.NULL);
+}
+public ColorDialog(Shell parent, int style) {
+ super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+}
+
+void createChildren() {
+ Shell dialog = getDialogShell();
+ GridData gridData = new GridData();
+ GridLayout layout = new GridLayout();
+ final int ButtonHeight = 30;
+ final int ColorChooserWidth = COLOR_SWATCH_EXTENTS[DEPTH_8] * 32 - COLOR_SWATCH_BORDER; // extent of one color field multiplied with number of fields in a row
+ final int ColorChooserHeight = COLOR_SWATCH_EXTENTS[DEPTH_8] * 8 - COLOR_SWATCH_BORDER; // extent of one color field multiplied with number of rows
+
+ layout.numColumns = 3;
+ layout.marginWidth = 15;
+ layout.marginHeight = 15;
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 2;
+ dialog.setLayout(layout);
+
+ // row one
+ colorsCanvas = new Canvas(dialog, SWT.BORDER);
+ gridData.widthHint = ColorChooserWidth;
+ gridData.heightHint = ColorChooserHeight;
+ gridData.verticalSpan = 2;
+ gridData.horizontalSpan = 2;
+ colorsCanvas.setLayoutData(gridData);
+
+ // create ok and cancel buttons (row two and three)
+ createOkCancel();
+
+ // row three - empty row
+ Label fillLabel = new Label(dialog, SWT.NULL);
+ gridData = new GridData();
+ gridData.heightHint = 5;
+ gridData.horizontalSpan = layout.numColumns;
+ fillLabel.setLayoutData(gridData);
+
+ // row four - setup group box with sample text and canvas
+ createSampleGroup(ColorChooserWidth);
+ createSelectionGroup();
+}
+void createSampleGroup(int colorChooserWidth) {
+ Shell dialog = getDialogShell();
+ Group sampleGroup = new Group(dialog, SWT.NULL);
+ GridData gridData = new GridData();
+ GridLayout layout = new GridLayout();
+ int sampleGroupWidth;
+
+ sampleGroup.setText("Sample");
+ gridData.horizontalAlignment = GridData.FILL;
+ sampleGroup.setLayoutData(gridData);
+ sampleGroup.setLayout(layout);
+ sampleGroupWidth = (colorChooserWidth - layout.marginWidth * 4 - layout.horizontalSpacing * 4) / 2;
+
+ sampleLabel = new Label(sampleGroup, SWT.CENTER | SWT.BORDER);
+ sampleLabel.setAlignment(SWT.CENTER);
+ sampleLabel.setText("A Sample Text");
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.widthHint = sampleGroupWidth;
+ sampleLabel.setLayoutData(gridData);
+
+ sampleCanvas = new Canvas(sampleGroup, SWT.BORDER);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.heightHint = 15;
+ gridData.widthHint = sampleGroupWidth;
+ sampleCanvas.setLayoutData(gridData);
+}
+void createSelectionGroup() {
+ Shell dialog = getDialogShell();
+ Group selectionGroup = new Group(dialog, SWT.NULL);
+ GridData gridData = new GridData();
+ GridLayout layout = new GridLayout();
+
+ selectionGroup.setText("Selection");
+ gridData.horizontalAlignment = GridData.FILL;
+ selectionGroup.setLayoutData(gridData);
+ selectionGroup.setLayout(layout);
+
+ selectionLabel = new Label(selectionGroup, SWT.CENTER | SWT.BORDER);
+ selectionLabel.setAlignment(SWT.CENTER);
+ selectionLabel.setText("Current Selection");
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ selectionLabel.setLayoutData(gridData);
+
+ selectionCanvas = new Canvas(selectionGroup, SWT.BORDER);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.heightHint = 15;
+ selectionCanvas.setLayoutData(gridData);
+}
+void disposeColors() {
+ for (int row = 0; row < colorGrid.length; row++) {
+ for (int column = 0; column < colorGrid[row].length; column++) {
+ colorGrid[row][column].dispose();
+ }
+ }
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+void drawColor(int xIndex, int yIndex, Color color, GC gc) {
+ int colorSwatchExtent = getColorSwatchExtent();
+ int colorExtent = colorSwatchExtent - COLOR_SWATCH_BORDER;
+
+ gc.setBackground(color);
+ gc.fillRectangle(
+ xIndex * colorSwatchExtent, yIndex * colorSwatchExtent,
+ colorExtent, colorExtent);
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+Canvas getColorCanvas() {
+ return colorsCanvas;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+int getColorDepth() {
+ return colorDepth;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+Color [][] getColorGrid() {
+ return colorGrid;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+int getColorSwatchExtent() {
+ return colorSwatchExtent;
+}
+public RGB getRGB() {
+ return dialogResult;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+Canvas getSampleCanvas() {
+ return sampleCanvas;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+Label getSampleText() {
+ return sampleLabel;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+Canvas getSelectionCanvas() {
+ return selectionCanvas;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+Label getSelectionText() {
+ return selectionLabel;
+}
+void handleEvents(Event event) {
+ Color selectionColor;
+
+ if (event.type == SWT.Paint) {
+ paint(event);
+ }
+ else
+ if (event.type == SWT.MouseDown) {
+ mouseDown(event);
+ }
+ else
+ if (event.type == SWT.MouseMove) {
+ mouseMove(event);
+ }
+ else
+ if (event.type == SWT.Selection) {
+ if (event.widget == getOKButton()) {
+ setOkSelected(true);
+ getDialogShell().setVisible(false);
+ }
+ else
+ if (event.widget == getCancelButton()) {
+ setOkSelected(false);
+ getDialogShell().setVisible(false);
+ }
+ }
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+void initialize4BitColors() {
+ Display display = getDialogShell().getDisplay();
+
+ colorGrid[0][0] = new Color(display, 0, 0, 0);
+ colorGrid[0][1] = new Color(display, 255, 255, 255);
+ colorGrid[1][0] = new Color(display, 128, 128, 128);
+ colorGrid[1][1] = new Color(display, 192, 192, 192);
+
+ colorGrid[2][0] = new Color(display, 0, 0, 128);
+ colorGrid[2][1] = new Color(display, 0, 0, 255);
+ colorGrid[3][0] = new Color(display, 0, 128, 128);
+ colorGrid[3][1] = new Color(display, 0, 255, 255);
+
+ colorGrid[4][0] = new Color(display, 0, 128, 0);
+ colorGrid[4][1] = new Color(display, 0, 255, 0);
+ colorGrid[5][0] = new Color(display, 128, 128, 0);
+ colorGrid[5][1] = new Color(display, 255, 255, 0);
+
+ colorGrid[6][0] = new Color(display, 128, 0, 0);
+ colorGrid[6][1] = new Color(display, 255, 0, 0);
+ colorGrid[7][0] = new Color(display, 128, 0, 128);
+ colorGrid[7][1] = new Color(display, 255, 0, 255);
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+void initialize8BitColors() {
+ Display display = getDialogShell().getDisplay();
+ int numColumns = colorGrid.length;
+ int numRows = colorGrid[0].length;
+ int iterationStep = 51;
+ int row = 0;
+ int column = 0;
+ int red;
+ int green;
+ int blue;
+
+ for (red = 0; red <= 255; red += iterationStep) {
+ for (blue = 0; blue <= 255; blue += iterationStep) {
+ if (blue == iterationStep && column < 20) { // hack to evenly distribute 256 colors on 32 columns
+ blue += iterationStep;
+ }
+ for (green = 0; green <= 255; green += iterationStep) {
+ if (row == 2 || row == 5) { // hack to evenly distribute 256 colors on 8 rows
+ colorGrid[column][row++] = new Color(display, red, green - iterationStep / 2, blue);
+ }
+ if (row == numRows) {
+ row = 0;
+ column++;
+ }
+ colorGrid[column][row++] = new Color(display, red, green, blue);
+ }
+ }
+ }
+}
+void initializeWidgets() {
+ Display display = getDialogShell().getDisplay();
+ Color selectionColor;
+ RGB rgb = getRGB();
+
+ if (rgb != null) {
+ selectionColor = new Color(display, rgb);
+ getSelectionCanvas().setBackground(selectionColor);
+ getSelectionText().setBackground(selectionColor);
+ selectionColor.dispose();
+ }
+ setColorDepth(display.getDepth());
+}
+void installListeners() {
+ Canvas colorCanvas = getColorCanvas();
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+
+ getOKButton().addListener(SWT.Selection, listener);
+ getCancelButton().addListener(SWT.Selection, listener);
+ colorCanvas.addListener(SWT.Paint, listener);
+ colorCanvas.addListener(SWT.MouseDown, listener);
+ colorCanvas.addListener(SWT.MouseMove, listener);
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/19/99 7:13:21 PM)
+ */
+void mouseDown(Event event) {
+ int swatchExtent = getColorSwatchExtent();
+ Color colorGrid[][] = getColorGrid();
+ Color color = colorGrid[event.x / swatchExtent][event.y / swatchExtent];
+
+ getSelectionCanvas().setBackground(color);
+ getSelectionText().setBackground(color);
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/19/99 7:13:21 PM)
+ */
+void mouseMove(Event event) {
+ int swatchExtent = getColorSwatchExtent();
+ Color colorGrid[][] = getColorGrid();
+ Color color = colorGrid[event.x / swatchExtent][event.y / swatchExtent];
+
+ getSampleCanvas().setBackground(color);
+ getSampleText().setBackground(color);
+}
+public RGB open() {
+ Color selectionColor;
+ RGB dialogResult = null;
+ Shell dialog = new Shell(getParent(), getStyle() | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+
+ setDialogShell(dialog);
+ createChildren();
+ installListeners();
+ openModal();
+ if (isOkSelected() == true) {
+ selectionColor = getSelectionCanvas().getBackground();
+ dialogResult = new RGB(
+ selectionColor.getRed(),
+ selectionColor.getGreen(),
+ selectionColor.getBlue());
+ setRGB(dialogResult);
+ }
+ disposeColors();
+ // Fix for 1G5NLY7
+ if (dialog.isDisposed() == false) {
+ dialog.dispose();
+ }
+ return dialogResult;
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+void paint(Event event) {
+ Color colorGrid[][] = getColorGrid();
+
+ for (int column = 0; column < colorGrid.length; column++) {
+ for (int row = 0; row < colorGrid[0].length; row++) {
+ drawColor(column, row, colorGrid[column][row], event.gc);
+ }
+ }
+}
+/**
+ * Insert the method's description here.
+ * Creation date: (7/6/99 5:07:09 PM)
+ */
+void setColorDepth(int bits) {
+ colorDepth = bits;
+ if (bits == 4) {
+ colorSwatchExtent = COLOR_SWATCH_EXTENTS[DEPTH_4];
+ colorGrid = new Color[8][2];
+ initialize4BitColors();
+ }
+ else {
+ colorSwatchExtent = COLOR_SWATCH_EXTENTS[DEPTH_8];
+ colorGrid = new Color[32][8];
+ initialize8BitColors();
+ }
+}
+/**
+ *
+ */
+public void setRGB(RGB rgb) {
+ dialogResult = rgb;
+}
+/**
+ * Create the widgets of the dialog.
+ */
+void createOkCancel() {
+ Shell dialog = getDialogShell();
+ GridData gridData;
+
+ ok = new Button(dialog, SWT.PUSH);
+ ok.setText("OK");
+ dialog.setDefaultButton(ok);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.widthHint = 70;
+ ok.setLayoutData(gridData);
+
+ cancel = new Button(dialog, SWT.PUSH);
+ cancel.setText("Cancel");
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ cancel.setLayoutData(gridData);
+}
+/**
+ * Answer the cancel button
+ */
+Button getCancelButton() {
+ return cancel;
+}
+
+/**
+ * Answer the dialog shell.
+ */
+Shell getDialogShell() {
+ return shell;
+}
+/**
+ * Answer the ok button.
+ */
+Button getOKButton() {
+ return ok;
+}
+
+
+/**
+ * Insert the method's description here.
+ * Creation date: (08/05/99 12:34:43)
+ * @return boolean
+ */
+boolean isOkSelected() {
+ return okSelected;
+}
+/**
+ * Open the receiver and set its size to the size calculated by
+ * the layout manager.
+ */
+void openDialog() {
+ Shell dialog = getDialogShell();
+ Point pt;
+ Rectangle displayRect;
+ int widthLimit;
+
+ // Start everything off by setting the shell size to its computed size.
+ pt = dialog.computeSize(-1, -1, false);
+
+ // Ensure that the width of the shell fits the display.
+ displayRect = dialog.getDisplay().getBounds();
+ widthLimit = displayRect.width * 7 / 8;
+ if (pt.x > widthLimit) {
+ pt = dialog.computeSize (widthLimit, -1, false);
+ }
+ dialog.setBounds (0, 0, pt.x, pt.y);
+ dialog.setText(getText());
+ // Open the window.
+ dialog.open();
+}
+/**
+ * Initialize the widgets of the receiver, open the dialog
+ * and block the method until the dialog is closed by the user.
+ */
+void openModal() {
+ Shell dialog = getDialogShell();
+ Display display = dialog.getDisplay();
+
+ initializeWidgets();
+ setRGB(null);
+ openDialog();
+ while (dialog.isDisposed() == false && dialog.getVisible() == true) {
+ if (display.readAndDispatch() == false) {
+ display.sleep();
+ }
+ }
+}
+
+
+/**
+ * Insert the method's description here.
+ * Creation date: (08/05/99 12:34:43)
+ * @param newOkSelected boolean
+ */
+void setOkSelected(boolean newOkSelected) {
+ okSelected = newOkSelected;
+}
+/**
+ * Set the shell used as the dialog window.
+ */
+void setDialogShell(Shell shell) {
+ this.shell = shell;
+}
+
+
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
new file mode 100755
index 0000000000..7ff8aa18ec
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java
@@ -0,0 +1,1196 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The combo class represents a selectable user interface object
+* that combines a text field and a list and issues notificiation
+* when an item is selected from the list.
+*
+* Styles
+*
+* SIMPLE,
+* DROP_DOWN,
+* READ_ONLY,
+*
+* Events
+*
+* Selection
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/* Class Definition */
+public /*final*/ class Combo extends Composite {
+ public 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;
+ }
+
+/**
+* Creates a new instance of the widget.
+*/
+public Combo (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+* Adds an item.
+* <p>
+* The item is placed at the end of the list.
+* Indexing is zero based.
+*
+* This operation can fail when the item cannot
+* be added in the OS.
+*
+* @param string the new item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the operation fails in the OS
+*/
+public void add (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.XmComboBoxAddItem(handle, xmString, -1, false);
+ OS.XmStringFree (xmString);
+}
+/**
+* Adds an item at an index.
+* <p>
+* The item is placed at an index in the list.
+* Indexing is zero based.
+*
+* This operation will fail when the index is
+* out of range or the item cannot be added in
+* the OS.
+*
+* @param string the new item
+* @param index the index for the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the string is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the item cannot be added
+*/
+public void add (String string, int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+
+ /*
+ * Feature in Motif. When an index is out of range,
+ * the list widget adds the item at the end. This
+ * behavior is not wrong but it is unwanted. The
+ * fix is to check the range before adding the item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index <= argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.XmComboBoxAddItem(handle, xmString, index + 1, false);
+ OS.XmStringFree (xmString);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ /*
+ * 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);
+}
+/**
+* Clears the current selection.
+* <p>
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void clearSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmTextClearSelection (argList[1], OS.XtLastTimestampProcessed (xDisplay));
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {
+ OS.XmNlist, 0,
+ OS.XmNtextField, 0,
+ OS.XmNitemCount, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNshadowThickness, 0,
+ OS.XmNhighlightThickness, 0,
+ OS.XmNarrowSize, 0,
+ OS.XmNarrowSpacing, 0,
+ };
+ OS.XtGetValues(handle, argList, argList.length / 2);
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ result.request_mode = OS.CWWidth;
+ OS.XtQueryGeometry (argList[1], null, result);
+ int width = result.width, height = getTextHeight();
+ int[] argList2 = {OS.XmNmarginWidth, 0, OS.XmNshadowThickness, 0};
+ OS.XtGetValues(argList[3], argList2, argList2.length / 2);
+ if ((style & SWT.READ_ONLY) == 0) width += (2 * argList[7]);
+ if ((style & SWT.DROP_DOWN) != 0) {
+ width += argList[13] + argList[15];
+ } else {
+ int itemCount = (argList[5] == 0) ? 5 : argList[5];
+ height += (getItemHeight () * itemCount);
+ }
+ width += (2 * argList[9])
+ + (2 * argList[11])
+ + (2 * argList2[1])
+ + (2 * argList2[3]);
+ if (argList[5] == 0) width = DEFAULT_WIDTH;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ Rectangle rect = computeTrim (0, 0, width, height);
+ return new Point (rect.width, rect.height);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+
+ /*
+ * Feature in Motif. When items are added or removed
+ * from a combo, it may request and be granted, a new
+ * preferred size. This behavior is unwanted. The fix
+ * is to create a parent for the list that will disallow
+ * geometry requests.
+ */
+ formHandle = OS.XmCreateForm (parent.handle, null, null, 0);
+ if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int comboBoxType = OS.XmDROP_DOWN_COMBO_BOX;
+ if ((style & SWT.SIMPLE) != 0) {
+ comboBoxType = OS.XmCOMBO_BOX;
+ } else if ((style & SWT.READ_ONLY) != 0) {
+ comboBoxType = OS.XmDROP_DOWN_LIST;
+ }
+ int [] argList = {
+ OS.XmNcomboBoxType, comboBoxType,
+ OS.XmNtopAttachment, OS.XmATTACH_FORM,
+ OS.XmNbottomAttachment, OS.XmATTACH_FORM,
+ OS.XmNleftAttachment, OS.XmATTACH_FORM,
+ OS.XmNrightAttachment, OS.XmATTACH_FORM,
+ OS.XmNresizable, 0,
+ };
+ handle = OS.XmCreateComboBox (formHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+* Deselects an item.
+* <p>
+* If the item at an index is selected, it is
+* deselected. If the item at an index is not
+* selected, it remains deselected. Indices
+* that are out of range are ignored. Indexing
+* is zero based.
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselect (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index == -1) return;
+ int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+
+ if (OS.XmListPosSelected (argList[3], index + 1)) {
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (argList[1], new byte[1]);
+ OS.XmTextSetInsertionPosition (argList[1], 0);
+ display.setWarnings (warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+ }
+}
+/**
+* Deselects all items.
+* <p>
+*
+* If an item is selected, it is deselected.
+* If an item is not selected, it remains unselected.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (argList[1], new byte[1]);
+ OS.XmTextSetInsertionPosition (argList[1], 0);
+ display.setWarnings(warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+}
+
+
+/**
+* Gets an item at an 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
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public String getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitemCount, 0, OS.XmNitems, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ if (argList [3] == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int ptr = argList [3] + (index * 4);
+ int [] buffer1 = new int [1];
+ OS.memmove (buffer1, ptr, 4);
+ ptr = buffer1 [0];
+ int address = OS.XmStringUnparse (
+ ptr,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ return decodeString(new String (Converter.mbcsToWcs (null, buffer)));
+}
+/**
+* Gets the number of items.
+* <p>
+* This operation will fail if the number of
+* items could not be queried from the OS.
+*
+* @return the number of items in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_COUNT)
+* when the operation fails
+*/
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM_HEIGHT)
+* when the operation fails
+*/
+public int getItemHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] listHandleArgs = {OS.XmNlist, 0};
+ OS.XtGetValues (handle, listHandleArgs, listHandleArgs.length / 2);
+ int [] argList = {OS.XmNlistSpacing, 0, OS.XmNhighlightThickness, 0};
+ OS.XtGetValues (listHandleArgs[1], argList, argList.length / 2);
+ int spacing = argList [1], highlight = argList [3];
+ /* Result is from empirical analysis on Linux and AIX */
+ return getFontHeight () + spacing + (2 * highlight);
+}
+/**
+* Gets the items.
+* <p>
+* This operation will fail if the items cannot
+* be queried from the OS.
+*
+* @return the items in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public String [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int items = argList [1], itemCount = argList [3];
+ int [] buffer1 = new int [1];
+ String [] result = new String [itemCount];
+ for (int i = 0; i < itemCount; i++) {
+ OS.memmove (buffer1, items, 4);
+ int ptr = buffer1 [0];
+ int address = OS.XmStringUnparse (
+ ptr,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ result[i] = decodeString(new String (Converter.mbcsToWcs (null, buffer)));
+ items += 4;
+ }
+ return result;
+}
+/**
+* Gets the selection.
+* <p>
+* @return a point representing the selection start and end
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Point getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] start = new int [1], end = new int [1];
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmTextGetSelectionPosition (argList[1], start, end);
+ if (start [0] == end [0]) {
+ start [0] = end [0] = OS.XmTextGetInsertionPosition (argList[1]);
+ }
+ return new Point (start [0], end [0]);
+}
+/**
+* Gets the index of the selected item.
+* <p>
+* Indexing is zero based.
+* If no item is selected -1 is returned.
+*
+* @return the index of the selected item.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] argList = {OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+
+ int index = OS.XmListGetKbdItemPos (argList[1]);
+ if (OS.XmListPosSelected (argList[1], index)) return index - 1;
+ int [] count = new int [1], positions = new int [1];
+ if (!OS.XmListGetSelectedPos (argList[1], positions, count)) return -1;
+ if (count [0] == 0) return -1;
+ int address = positions [0];
+ int [] indices = new int [1];
+ OS.memmove (indices, address, 4);
+ OS.XtFree (address);
+ return indices [0] - 1;
+}
+/**
+* Gets the widget text.
+* <p>
+* If the widget has no text, an empty string is returned.
+*
+* @return the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+
+ int ptr = OS.XmTextGetString (argList[1]);
+ if (ptr == 0) return "";
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ OS.XtFree (ptr);
+ return decodeString(new String (Converter.mbcsToWcs (null, buffer)));
+}
+/**
+* Gets the height of the combo's text field.
+* <p>
+* The operation will fail if the height cannot
+* be queried from the OS.
+
+* @return the height of the combo's text field.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ERROR_CANNOT_GET_ITEM_HEIGHT)
+* when the operation fails
+*/
+public int getTextHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if ((style & SWT.DROP_DOWN) != 0) {
+ /*
+ * Bug in MOTIF. For some reason, XtQueryGeometry ()
+ * returns the wrong height when the combo is not realized.
+ * The fix is to force the combo to be realized by forcing
+ * the shell to be realized.
+ */
+ if (!OS.XtIsRealized (handle)) getShell ().realizeWidget ();
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ result.request_mode = OS.CWHeight;
+ OS.XtQueryGeometry (handle, null, result);
+ return result.height;
+ } else {
+ /* Calculate text field height. */
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int [] argList2 = {OS.XmNmarginHeight, 0};
+ OS.XtGetValues (argList[1], argList2, argList2.length / 2);
+ int height = getFontHeight ();
+ XRectangle rect = new XRectangle ();
+ OS.XmWidgetGetDisplayRect (argList[1], rect);
+ height += (rect.y * 2) + (2 * argList2[1]);
+
+ /* Add in combo box margins. */
+ int [] argList3 = {OS.XmNmarginHeight, 0, OS.XmNshadowThickness, 0, OS.XmNhighlightThickness, 0};
+ OS.XtGetValues(handle, argList3, argList3.length / 2);
+ height += (2 * argList3[1]) + (2 * argList3[3]) + (2 * argList3[5]);
+
+ return height;
+ }
+}
+/**
+* Gets the text limit.
+* <p>
+* @return the text limit
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getTextLimit () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return OS.XmTextGetMaxLength (argList[1]);
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNselectionCallback, windowProc, SWT.Selection);
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XtAddCallback (argList[1], OS.XmNactivateCallback, windowProc, SWT.DefaultSelection);
+ OS.XtAddCallback (argList[1], OS.XmNvalueChangedCallback, windowProc, SWT.Modify);
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) return -1;
+
+ int [] argList = {OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+
+ int index = OS.XmListItemPos (argList[1], xmString);
+ OS.XmStringFree (xmString);
+ return index - 1;
+}
+/**
+* Gets the index of an item.
+* <p>
+* The widget is searched starting at start including
+* the end position until an item is found that
+* is equal to the search itenm. If no item is
+* found, -1 is returned. Indexing is zero based.
+*
+* @param string the search item
+* @param index the starting position
+* @return the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (String string, int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int items = argList [1], itemCount = argList [3];
+ if (!((0 <= start) && (start < itemCount))) return -1;
+ byte [] buffer1 = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer1);
+ if (xmString == 0) return -1;
+ int index = start;
+ items += start * 4;
+ int [] buffer2 = new int [1];
+ while (index < itemCount) {
+ OS.memmove (buffer2, items, 4);
+ if (OS.XmStringCompare (buffer2 [0], xmString)) break;
+ items += 4; index++;
+ }
+ OS.XmStringFree (xmString);
+ if (index == itemCount) return -1;
+ return index;
+}
+/**
+* Removes an item at an index.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param index the index of the item
+* @return the selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ /*
+ * Feature in Motif. An index out of range handled
+ * correctly by the list widget but causes an unwanted
+ * Xm Warning. The fix is to check the range before
+ * deleting an item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ OS.XmComboBoxDeletePos (handle, index + 1);
+}
+/**
+* Removes a range of items.
+* <p>
+* Indexing is zero based. The range of items
+* is from the start index up to and including
+* the end index.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ /*
+ * Feature in Motif. An index out of range handled
+ * correctly by the list widget but causes an unwanted
+ * Xm Warning. The fix is to check the range before
+ * deleting an item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= start && start < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int newEnd = Math.min (end, argList [1] - 1);
+ for (int i = start; i <= newEnd; i++) {
+ OS.XmComboBoxDeletePos (handle, start + 1);
+ }
+ if (end >= argList [1]) error (SWT.ERROR_INVALID_RANGE);
+}
+void register () {
+ super.register ();
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ WidgetTable.put(argList[1], this);
+}
+/**
+* Removes an item.
+* <p>
+* This operation will fail when the item
+* could not be removed from the OS.
+*
+* @param string the search item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+
+ int [] argList = {OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int index = OS.XmListItemPos (argList[1], xmString);
+
+ OS.XmStringFree (xmString);
+ if (index == 0) error (SWT.ERROR_INVALID_ARGUMENT);
+ OS.XmComboBoxDeletePos (handle, index);
+}
+/**
+* Removes all items.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void removeAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (argList[1], new byte[1]);
+ OS.XmTextSetInsertionPosition (argList[1], 0);
+ display.setWarnings(warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+
+ for (int i = 0; i < argList[5]; i++) {
+ OS.XmComboBoxDeletePos(handle, 1);
+ }
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+/**
+* Selects an item.
+* <p>
+* If the item at an index is not selected, it is
+* selected. Indices that are out of
+* range are ignored. Indexing is zero based.
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void select (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index == -1) {
+ int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (argList[1], new byte[1]);
+ OS.XmTextSetInsertionPosition (argList[1], 0);
+ display.setWarnings (warnings);
+ OS.XmListDeselectAllItems (argList[3]);
+ } else {
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int [] argList2 = {OS.XmNselectedPosition, index};
+ OS.XtSetValues(handle, argList2, argList2.length / 2);
+ }
+}
+/**
+* Sets the widget bounds.
+*/
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ super.setBounds (x, y, width, newHeight);
+}
+/**
+* Sets the text of an item.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be changed in
+* the OS.
+*
+* @param index the index for the item
+* @param string the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+* @exception SWTError(ERROR_ITEM_NOT_MODIFIED)
+* when the operation fails
+*/
+public void setItem (int index, String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ int [] argList = {OS.XmNlist, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [3])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ boolean isSelected = OS.XmListPosSelected (argList[1], index + 1);
+ OS.XmListReplaceItemsPosUnselected (argList[1], new int [] {xmString}, 1, index + 1);
+ if (isSelected) OS.XmListSelectPos (argList[1], index + 1, false);
+ OS.XmStringFree (xmString);
+}
+/**
+* Sets all items.
+* <p>
+* @param items the array of items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the operation fails
+*/
+public void setItems (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ if (items.length == 0) {
+ removeAll();
+ return;
+ }
+
+ int index = 0;
+ int [] table = new int [items.length];
+ while (index < items.length) {
+ String string = items [index];
+ if (string == null) break;
+ byte [] buffer = Converter.wcsToMbcs (null, encodeString(string), true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) break;
+ table [index++] = xmString;
+ }
+ int ptr = OS.XtMalloc (index * 4);
+ OS.memmove (ptr, table, index * 4);
+ int [] argList = {OS.XmNitems, ptr, OS.XmNitemCount, index};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ for (int i=0; i<index; i++) OS.XmStringFree (table [i]);
+ OS.XtFree (ptr);
+ if (index < items.length) error (SWT.ERROR_ITEM_NOT_ADDED);
+}
+/**
+* Sets the new selection.
+* <p>
+* @param selection point representing the start and the end of the new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when selection is null
+*/
+public void setSelection (Point selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+
+ /* Clear the highlight before setting the selection. */
+ int position = OS.XmTextGetLastPosition (argList[1]);
+
+ /*
+ * Bug in MOTIF. XmTextSetSelection () fails to set the
+ * selection when the receiver is not realized. The fix
+ * is to force the receiver to be realized by forcing the
+ * shell to be realized. If the receiver is realized before
+ * the shell, MOTIF fails to draw the text widget and issues
+ * lots of X BadDrawable errors.
+ */
+ if (!OS.XtIsRealized (handle)) getShell ().realizeWidget ();
+
+ /* Set the selection. */
+ int xDisplay = OS.XtDisplay (argList[1]);
+ if (xDisplay == 0) return;
+ int nStart = Math.min (Math.max (Math.min (selection.x, selection.y), 0), position);
+ int nEnd = Math.min (Math.max (Math.max (selection.x, selection.y), 0), position);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetSelection (argList[1], nStart, nEnd, OS.XtLastTimestampProcessed (xDisplay));
+
+ /* Force the i-beam to follow the highlight/selection. */
+ OS.XmTextSetInsertionPosition (argList[1], nEnd);
+ display.setWarnings(warnings);
+}
+/**
+* Sets the widget size.
+*/
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight () : height;
+ super.setSize (width, newHeight);
+}
+/**
+* Sets the widget text
+* <p>
+* @param string the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ if ((style & SWT.READ_ONLY) == 0) {
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) return;
+ int [] argList = {OS.XmNtextField, 0, OS.XmNlist, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int index = OS.XmListItemPos (argList[3], xmString);
+ if (index > 0) {
+ /* The list contains the item. */
+ OS.XmComboBoxSelectItem(handle, xmString);
+ } else {
+ /* The list does not contain the item. */
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (argList[1], buffer);
+ OS.XmTextSetInsertionPosition (argList[1], 0);
+ display.setWarnings(warnings);
+ }
+ OS.XmStringFree (xmString);
+ /*
+ * Bug in Linux. When the widget is multi-line
+ * it does not send a Modify to notify the application
+ * that the text has changed. The fix is to send the event.
+ */
+ if (IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);
+ }
+}
+/**
+* Sets the text limit
+* <p>
+* @param limit new text limit
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_BE_ZERO)
+* when limit is 0
+*/
+public void setTextLimit (int limit) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmTextSetMaxLength (argList[1], limit);
+}
+
+void deregister () {
+ super.deregister ();
+ int [] argList = {OS.XmNtextField, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ WidgetTable.remove (argList[1]);
+}
+
+/**
+ * Bug in Motif.
+ * Empty strings in the combo will cause GPFs if a) they
+ * are the only items in the combo or b) if they are
+ * included in an array which is set as the value of the
+ * combo's items resource. To protect against these GPFs,
+ * make sure that no empty strings are added to the combo.
+ * The solution is to add a space to empty strings or
+ * strings which are all spaces. This space is removed
+ * when answering the text of items which are all spaces.
+ */
+String encodeString(String string) {
+ for (int i = 0; i < string.length(); i++) {
+ if (string.charAt(i) != ' ') {
+ return string;
+ }
+ }
+ return string + ' ';
+}
+/**
+ * Bug in Motif.
+ * Empty strings in the combo will cause GPFs if a) they
+ * are the only items in the combo or b) if they are
+ * included in an array which is set as the value of the
+ * combo's items resource. To protect against these GPFs,
+ * make sure that no empty strings are added to the combo.
+ * The solution is to add a space to empty strings or
+ * strings which include only spaces. A space is removed
+ * when answering the text of items which are all spaces.
+ */
+String decodeString(String string) {
+ if (string.length() == 0) return string;
+
+ for (int i = 0; i < string.length(); i++) {
+ if (string.charAt(i) != ' ') {
+ return string;
+ }
+ }
+ return string.substring(0, string.length() - 1);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
new file mode 100755
index 0000000000..5177c3bccd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
@@ -0,0 +1,439 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The composite class represents a user interface object
+* that contains other widgets.
+*
+* Styles
+*
+* H_SCROLL, V_SCROLL
+*
+* Events
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/* Class Definition */
+public class Composite extends Scrollable {
+ Layout layout;
+ int damagedRegion;
+
+Composite () {
+ /* Do nothing */
+}
+public Composite (Composite parent, int style) {
+ super (parent, style);
+}
+Control [] _getChildren () {
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int ptr = argList [1], count = argList [3];
+ if (count == 0 || ptr == 0) return new Control [0];
+ int [] handles = new int [count];
+ OS.memmove (handles, ptr, count * 4);
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ while (i < count) {
+ int handle = handles [i];
+ if (handle != 0) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget != null && widget != this) {
+ if (widget instanceof Control) {
+ children [j++] = (Control) widget;
+ }
+ }
+ }
+ i++;
+ }
+ if (i == j) return children;
+ Control [] newChildren = new Control [j];
+ System.arraycopy (children, 0, newChildren, 0, j);
+ return newChildren;
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size;
+ if (layout != null) {
+ if ((wHint == SWT.DEFAULT) || (hHint == SWT.DEFAULT)) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = new Point (wHint, hHint);
+ }
+ } else {
+ size = minimumSize ();
+ }
+ 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);
+}
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+void createHandle (int index) {
+ state |= HANDLE | CANVAS;
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
+ int border = (style & SWT.BORDER) != 0 ? 1 : 0;
+ int [] argList = {
+ OS.XmNborderWidth, border,
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1,
+ };
+ handle = OS.XmCreateDrawingArea (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+ OS.XtOverrideTranslations (handle, display.arrowTranslations);
+ } else {
+ createScrolledHandle (parent.handle);
+ }
+}
+void createScrolledHandle (int topHandle) {
+ scrolledHandle = OS.XmCreateMainWindow (topHandle, null, null, 0);
+ if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) != 0) {
+ int [] argList1 = {
+ OS.XmNmarginWidth, 3,
+ OS.XmNmarginHeight, 3,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNshadowType, OS.XmSHADOW_IN,
+ OS.XmNshadowThickness, 2,
+ };
+ formHandle = OS.XmCreateForm (scrolledHandle, null, argList1, argList1.length / 2);
+ if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int [] argList2 = {
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNtopAttachment, OS.XmATTACH_FORM,
+ OS.XmNbottomAttachment, OS.XmATTACH_FORM,
+ OS.XmNleftAttachment, OS.XmATTACH_FORM,
+ OS.XmNrightAttachment, OS.XmATTACH_FORM,
+ OS.XmNresizable, 0,
+ OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1,
+ };
+ handle = OS.XmCreateDrawingArea (formHandle, null, argList2, argList2.length / 2);
+ } else {
+ int [] argList = {
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNtraversalOn, (style & SWT.NO_FOCUS) != 0 ? 0 : 1,
+ };
+ handle = OS.XmCreateDrawingArea (scrolledHandle, null, argList, argList.length / 2);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ Display display = getDisplay ();
+ OS.XtOverrideTranslations (handle, display.tabTranslations);
+ OS.XtOverrideTranslations (handle, display.arrowTranslations);
+}
+int defaultBackground () {
+ return getDisplay ().compositeBackground;
+}
+int defaultForeground () {
+ return getDisplay ().compositeForeground;
+}
+public boolean forceFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Control [] children = _getChildren ();
+ int [] traversals = new int [children.length];
+ int [] argList = new int [] {OS.XmNtraversalOn, 0};
+ for (int i=0; i<children.length; i++) {
+ OS.XtGetValues (children [i].handle, argList, argList.length / 2);
+ traversals [i] = argList [1];
+ argList [1] = 0;
+ OS.XtSetValues (children [i].handle, argList, argList.length / 2);
+ }
+ boolean result = super.forceFocus ();
+ for (int i=0; i<children.length; i++) {
+ argList [1] = traversals [i];
+ OS.XtSetValues (children [i].handle, argList, argList.length / 2);
+ }
+ return result;
+}
+public Control [] getChildren () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return _getChildren ();
+}
+int getChildrenCount () {
+ // BOGUS - could count non-registered children or gadgets
+ int [] argList = {OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+public Layout getLayout () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return layout;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ if ((state & CANVAS) != 0) {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddEventHandler (handle, 0, true, windowProc, -1);
+ }
+}
+
+/**
+* Lays out the children.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void layout () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ layout (true);
+}
+public void layout (boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (layout == null) return;
+ int count = getChildrenCount ();
+ if (count == 0) return;
+ layout.layout (this, changed);
+}
+Point minimumSize () {
+ 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);
+}
+void moveAbove (int handle1, int handle2) {
+ if (handle1 == handle2) return;
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int ptr = argList [1], count = argList [3];
+ if (count == 0 || ptr == 0) return;
+ int [] handles = new int [count];
+ OS.memmove (handles, ptr, count * 4);
+ if (handle2 == 0) handle2 = handles [0];
+ int i = 0, index1 = -1, index2 = -1;
+ while (i < count) {
+ int handle = handles [i];
+ if (handle == handle1) index1 = i;
+ if (handle == handle2) index2 = i;
+ if (index1 != -1 && index2 != -1) break;
+ i++;
+ }
+ if (index1 == -1 || index2 == -1) return;
+ if (index1 == index2) return;
+ if (index1 < index2) {
+ System.arraycopy (handles, index1 + 1, handles, index1, index2 - index1 - 1);
+ handles [index2 - 1] = handle1;
+ } else {
+ System.arraycopy (handles, index2, handles, index2 + 1, index1 - index2);
+ handles [index2] = handle1;
+ }
+ OS.memmove (ptr, handles, count * 4);
+}
+void moveBelow (int handle1, int handle2) {
+ if (handle1 == handle2) return;
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int ptr = argList [1], count = argList [3];
+ if (count == 0 || ptr == 0) return;
+ int [] handles = new int [count];
+ OS.memmove (handles, ptr, count * 4);
+ if (handle2 == 0) handle2 = handles [count - 1];
+ int i = 0, index1 = -1, index2 = -1;
+ while (i < count) {
+ int handle = handles [i];
+ if (handle == handle1) index1 = i;
+ if (handle == handle2) index2 = i;
+ if (index1 != -1 && index2 != -1) break;
+ i++;
+ }
+ if (index1 == -1 || index2 == -1) return;
+ if (index1 == index2) return;
+ if (index1 < index2) {
+ System.arraycopy (handles, index1 + 1, handles, index1, index2 - index1);
+ handles [index2] = handle1;
+ } else {
+ System.arraycopy (handles, index2 + 1, handles, index2 + 2, index1 - index2 - 1);
+ handles [index2 + 1] = handle1;
+ }
+ OS.memmove (ptr, handles, count * 4);
+}
+
+int processNonMaskable (int callData) {
+ if ((state & CANVAS) != 0) {
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, callData, XExposeEvent.sizeof);
+ if (xEvent.type == OS.GraphicsExpose) processPaint (callData);
+ }
+ return 0;
+}
+int processPaint (int callData) {
+ if ((state & CANVAS) == 0) {
+ return super.processPaint (callData);
+ }
+ if (!hooks (SWT.Paint)) return 0;
+ if ((style & SWT.NO_MERGE_PAINTS) != 0) {
+ return super.processPaint (callData);
+ }
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, callData, XExposeEvent.sizeof);
+ int exposeCount = xEvent.count;
+ if (damagedRegion == 0 && exposeCount == 0) {
+ XAnyEvent event = new XAnyEvent ();
+ Display display = getDisplay ();
+ display.exposeCount = 0;
+ int checkExposeProc = display.checkExposeProc;
+ OS.XCheckIfEvent (xEvent.display, event, checkExposeProc, xEvent.window);
+ if (display.exposeCount == 0) return super.processPaint (callData);
+ exposeCount = display.exposeCount;
+ }
+ if (damagedRegion == 0) damagedRegion = OS.XCreateRegion ();
+ OS.XtAddExposureToRegion (callData, damagedRegion);
+ if (exposeCount != 0) return 0;
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return 0;
+ Event event = new Event ();
+ GC gc = event.gc = new GC (this);
+ OS.XSetRegion (xDisplay, gc.handle, damagedRegion);
+ XRectangle rect = new XRectangle ();
+ OS.XClipBox (damagedRegion, rect);
+ OS.XDestroyRegion (damagedRegion);
+ damagedRegion = 0;
+ event.time = OS.XtLastTimestampProcessed (xDisplay);
+ event.x = rect.x; event.y = rect.y;
+ event.width = rect.width; event.height = rect.height;
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ event.gc = null;
+ return 0;
+}
+
+void propagateChildren (boolean enabled) {
+ super.propagateChildren (enabled);
+ Control [] children = _getChildren ();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children [i];
+ if (child.getEnabled ()) {
+ child.propagateChildren (enabled);
+ }
+ }
+}
+void realizeChildren () {
+ super.realizeChildren ();
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ children [i].realizeChildren ();
+ }
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) == 0 && (style & SWT.NO_REDRAW_RESIZE) != 0) return;
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return;
+ int flags = 0;
+ XSetWindowAttributes attributes = new XSetWindowAttributes ();
+ if ((style & SWT.NO_BACKGROUND) != 0) {
+ flags |= OS.CWBackPixmap;
+ attributes.background_pixmap = OS.None;
+ }
+ if ((style & SWT.NO_REDRAW_RESIZE) == 0) {
+ flags |= OS.CWBitGravity;
+ attributes.bit_gravity = OS.ForgetGravity;
+ }
+ if (flags != 0) {
+ OS.XChangeWindowAttributes (xDisplay, xWindow, flags, attributes);
+ }
+ }
+}
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ super.redrawWidget (x, y, width, height, all);
+ if (!all) return;
+ Control [] children = _getChildren ();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children [i];
+ Point location = child.getClientLocation ();
+ child.redrawWidget (x - location.x, y - location.y, width, height, all);
+ }
+}
+void releaseChildren () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) {
+ child.releaseWidget ();
+ child.releaseHandle ();
+ }
+ }
+}
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+ if (damagedRegion != 0) OS.XDestroyRegion (damagedRegion);
+ damagedRegion = 0;
+}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) != 0) {
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return;
+ XSetWindowAttributes attributes = new XSetWindowAttributes ();
+ attributes.background_pixmap = OS.None;
+ OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWBackPixmap, attributes);
+ }
+ }
+}
+public void setBounds (int x, int y, int width, int height) {
+ super.setBounds (x, y, width, height);
+ if (layout != null) layout (false);
+}
+public void setLayout (Layout layout) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.layout = layout;
+}
+public void setSize (int width, int height) {
+ super.setSize (width, height);
+ if (layout != null) layout (false);
+}
+int traversalCode () {
+ if ((state & CANVAS) != 0 && hooks (SWT.KeyDown)) return 0;
+ return super.traversalCode ();
+}
+boolean traverseMnemonic (char key) {
+ if (super.traverseMnemonic (key)) return true;
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.traverseMnemonic (key)) return true;
+ }
+ return false;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
new file mode 100755
index 0000000000..c1a7ed8a6f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java
@@ -0,0 +1,1813 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The widget class is the abstract superclass of all
+* user interface objects. All widgets can be created,
+* disposed and support events.
+*
+* Styles
+*
+* BORDER
+* CLIP_CHILDREN, CLIP_SIBLINGS
+*
+* Events
+*
+* KeyDown, KeyUp,
+* MouseDown, MouseUp, MouseMove,
+* DoubleClick,
+* Paint,
+* Move, Resize,
+* FocusIn, FocusOut,
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/* Class Definition */
+public abstract class Control extends Widget implements Drawable {
+ Composite parent;
+ int fontList;
+ Menu menu;
+ String toolTipText;
+ Object layoutData;
+Control () {
+ /* Do nothing */
+}
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addFocusListener(FocusListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addKeyListener(KeyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addMouseListener(MouseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when listener is null</li>
+* </ul>
+*/
+public void addMouseTrackListener (MouseTrackListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addMouseMoveListener(MouseMoveListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener(SWT.MouseMove,typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addPaintListener(PaintListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener(SWT.Paint,typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when listener is null</li>
+* </ul>
+*/
+public void addTraverseListener (TraverseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Traverse,typedListener);
+}
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+/**
+* Computes the preferred size.
+* <p>
+* @param wHint the width hint (can be SWT.DEFAULT)
+* @param hHint the height hint (can be SWT.DEFAULT)
+* @param changed the changed hint (for layouts)
+* @return the preferred size of the widget.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = DEFAULT_WIDTH;
+ int 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 createWidget (int index) {
+ super.createWidget (index);
+ setZOrder ();
+ realizeChildren ();
+}
+int defaultBackground () {
+ return getDisplay ().defaultBackground;
+}
+int defaultFont () {
+ return getDisplay ().defaultFontList;
+}
+int defaultForeground () {
+ return getDisplay ().defaultForeground;
+}
+void enableHandle (boolean enabled, int widgetHandle) {
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (widgetHandle, argList, argList.length / 2);
+}
+void enableWidget (boolean enabled) {
+ enableHandle (enabled, handle);
+}
+char findMnemonic (String string) {
+ int index = 0;
+ int length = string.length ();
+ do {
+ while ((index < length) && (string.charAt (index) != Mnemonic)) index++;
+ if (++index >= length) return '\0';
+ if (string.charAt (index) != Mnemonic) return string.charAt (index);
+ index++;
+ } while (index < length);
+ return '\0';
+}
+int fontHandle () {
+ return handle;
+}
+public boolean forceFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Decorations shell = menuShell ();
+ shell.setSavedFocus (this);
+ shell.bringToTop ();
+ return OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
+}
+public Color getBackground () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return Color.motif_new (getDisplay (), getXColor (getBackgroundPixel ()));
+}
+int getBackgroundPixel () {
+ int [] argList = {OS.XmNbackground, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+public int getBorderWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ return argList [1];
+}
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ int borders = argList [9] * 2;
+ return new Rectangle ((short) argList [1], (short) argList [3], argList [5] + borders, argList [7] + borders);
+}
+Point getClientLocation () {
+ short [] handle_x = new short [1], handle_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) 0, (short) 0, handle_x, handle_y);
+ short [] topHandle_x = new short [1], topHandle_y = new short [1];
+ OS.XtTranslateCoords (parent.handle, (short) 0, (short) 0, topHandle_x, topHandle_y);
+ return new Point (handle_x [0] - topHandle_x [0], handle_y [0] - topHandle_y [0]);
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (topHandle (), argList, argList.length / 2);
+ return argList [1] != 0;
+}
+public Font getFont () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return Font.motif_new (getDisplay (), getFontList ());
+}
+
+int getFontAscent () {
+ int fontList = getFontList ();
+
+ /* Create a font context to iterate over each element in the font list */
+ int [] buffer = new int [1];
+ if (!OS.XmFontListInitFontContext (buffer, fontList)) {
+ error (SWT.ERROR_NO_HANDLES);
+ }
+ int context = buffer [0];
+
+ /* Values discovering during iteration */
+ int ascent = 0;
+ XFontStruct fontStruct = new XFontStruct ();
+ int fontListEntry;
+ int [] fontStructPtr = new int [1];
+ int [] fontNamePtr = new int [1];
+
+ /* Go through each entry in the font list. */
+ while ((fontListEntry = OS.XmFontListNextEntry (context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont (fontListEntry, buffer);
+ if (buffer [0] == 0) {
+ /* FontList contains a single font */
+ OS.memmove (fontStruct, fontPtr, XFontStruct.sizeof);
+ int fontAscent = Math.max (fontStruct.ascent, fontStruct.max_bounds_ascent);
+ if (fontAscent > ascent) ascent = fontAscent;
+ } else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet (fontPtr, fontStructPtr, fontNamePtr);
+ int [] fontStructs = new int [nFonts];
+ OS.memmove (fontStructs, fontStructPtr [0], nFonts * 4);
+
+ /* Go through each fontStruct in the font set */
+ for (int i=0; i<nFonts; i++) {
+ OS.memmove (fontStruct, fontStructs[i], XFontStruct.sizeof);
+ int fontAscent = Math.max (fontStruct.ascent, fontStruct.max_bounds_ascent);
+ if (fontAscent > ascent) ascent = fontAscent;
+ }
+ }
+ }
+
+ OS.XmFontListFreeFontContext (context);
+ return ascent;
+}
+
+int getFontHeight () {
+ int fontList = getFontList ();
+
+ /* Create a font context to iterate over each element in the font list */
+ int [] buffer = new int [1];
+ if (!OS.XmFontListInitFontContext (buffer, fontList)) {
+ error (SWT.ERROR_NO_HANDLES);
+ }
+ int context = buffer [0];
+
+ /* Values discovering during iteration */
+ int height = 0;
+ XFontStruct fontStruct = new XFontStruct ();
+ int fontListEntry;
+ int [] fontStructPtr = new int [1];
+ int [] fontNamePtr = new int [1];
+
+ /* Go through each entry in the font list. */
+ while ((fontListEntry = OS.XmFontListNextEntry (context)) != 0) {
+ int fontPtr = OS.XmFontListEntryGetFont (fontListEntry, buffer);
+ if (buffer [0] == 0) {
+ /* FontList contains a single font */
+ OS.memmove (fontStruct, fontPtr, XFontStruct.sizeof);
+ int fontAscent = Math.max (fontStruct.ascent, fontStruct.max_bounds_ascent);
+ int fontDescent = Math.max (fontStruct.descent, fontStruct.max_bounds_descent);
+ int fontHeight = fontAscent + fontDescent;
+ if (fontHeight > height) height = fontHeight;
+ } else {
+ /* FontList contains a fontSet */
+ int nFonts = OS.XFontsOfFontSet (fontPtr, fontStructPtr, fontNamePtr);
+ int [] fontStructs = new int [nFonts];
+ OS.memmove (fontStructs, fontStructPtr [0], nFonts * 4);
+
+ /* Go through each fontStruct in the font set */
+ for (int i=0; i<nFonts; i++) {
+ OS.memmove (fontStruct, fontStructs[i], XFontStruct.sizeof);
+ int fontAscent = Math.max (fontStruct.ascent, fontStruct.max_bounds_ascent);
+ int fontDescent = Math.max (fontStruct.descent, fontStruct.max_bounds_descent);
+ int fontHeight = fontAscent + fontDescent;
+ if (fontHeight > height) height = fontHeight;
+ }
+ }
+ }
+
+ OS.XmFontListFreeFontContext (context);
+ return height;
+}
+int getFontList () {
+ int fontHandle = fontHandle ();
+ int [] argList = {OS.XmNfontList, 0};
+ OS.XtGetValues (fontHandle, argList, argList.length / 2);
+ if (argList [1] != 0) return argList [1];
+ if (fontList == 0) fontList = defaultFont ();
+ return fontList;
+}
+public Color getForeground () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return Color.motif_new (getDisplay (), getXColor (getForegroundPixel ()));
+}
+int getForegroundPixel () {
+ int [] argList = {OS.XmNforeground, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+public Object getLayoutData () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return layoutData;
+}
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ return new Point ((short) argList [1], (short) argList [3]);
+}
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menu;
+}
+public Composite getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+}
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ int borders = argList [5] * 2;
+ return new Point (argList [1] + borders, argList [3] + borders);
+}
+/**
+* Gets the tool tip text.
+* <p>
+* @return the tool tip text.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNmappedWhenManaged, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+XColor getXColor (int pixel) {
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return null;
+ int [] argList = {OS.XmNcolormap, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int colormap = argList [1];
+ if (colormap == 0) return null;
+ XColor color = new XColor ();
+ color.pixel = pixel;
+ OS.XQueryColor (display, colormap, color);
+ return color;
+}
+boolean hasFocus () {
+ return this == getDisplay ().getFocusControl ();
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddEventHandler (handle, OS.KeyPressMask, false, windowProc, SWT.KeyDown);
+ OS.XtAddEventHandler (handle, OS.KeyReleaseMask, false, windowProc, SWT.KeyUp);
+ OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, SWT.MouseDown);
+ OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, SWT.MouseUp);
+ OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, SWT.MouseMove);
+ OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, SWT.MouseEnter);
+ OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit);
+ OS.XtAddEventHandler (handle, OS.ExposureMask, false, windowProc, SWT.Paint);
+ OS.XtAddEventHandler (handle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn);
+ OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, SWT.Help);
+}
+int inputContext () {
+ return getShell ().inputContext ();
+}
+public int internal_new_GC (GCData data) {
+ if (!OS.XtIsRealized (handle)) {
+ int xtParent = handle;
+ while ((OS.XtParent (xtParent) != 0) && !OS.XtIsSubclass (xtParent, OS.ShellWidgetClass ())) {
+ xtParent = OS.XtParent (xtParent);
+ }
+ OS.XtRealizeWidget (xtParent);
+ }
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int xGC = OS.XCreateGC (xDisplay, xWindow, 0, null);
+ if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.XSetGraphicsExposures (xDisplay, xGC, false);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNcolormap, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (data != null) {
+ data.device = getDisplay ();
+ data.display = xDisplay;
+ data.drawable = xWindow;
+ data.foreground = argList [1];
+ data.background = argList [3];
+ data.fontList = getFontList ();
+ data.colormap = argList [5];
+ }
+ return xGC;
+}
+public void internal_dispose_GC (int xGC, GCData data) {
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.XFreeGC (xDisplay, xGC);
+}
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+public boolean isFocusControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hasFocus ();
+}
+public boolean isReparentable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible () && parent.isVisible ();
+}
+void manageChildren () {
+ OS.XtSetMappedWhenManaged (handle, false);
+ OS.XtManageChild (handle);
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XtResizeWidget (handle, 1, 1, argList [1]);
+ OS.XtSetMappedWhenManaged (handle, true);
+}
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+boolean mnemonicHit () {
+ return false;
+}
+boolean mnemonicMatch (char key) {
+ return false;
+}
+public void moveAbove (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setZOrder (control, true);
+}
+public void moveBelow (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setZOrder (control, false);
+}
+/**
+* Packs the widget.
+* <p>
+* Packing a widget causes it to be resized to the
+* preferred size for the widget. For a composite,
+* this involves computing the preferred size from
+* the layout.
+*
+* @see Control#computeSize(int, int)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void pack () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ pack (true);
+}
+/**
+* Packs the widget.
+* <p>
+* Packing a widget causes it to be resized to the
+* preferred size for the widget. For a composite,
+* this involves computing the preferred size from
+* the layout.
+*
+* @param changed the changed hint (for layouts)
+*
+* @see Control#computeSize(int, int)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void pack (boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+int processDefaultSelection (int callData) {
+ postEvent (SWT.DefaultSelection);
+ return 0;
+}
+int processFocusIn () {
+ sendEvent (SWT.FocusIn);
+// IsDBLocale ifTrue: [self killImeFocus].
+ return 0;
+}
+int processFocusOut () {
+ sendEvent (SWT.FocusOut);
+// IsDBLocale ifTrue: [self killImeFocus].
+ return 0;
+}
+int processHelp (int callData) {
+ sendHelpEvent (callData);
+ return 0;
+}
+int processKeyDown (int callData) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, callData, XKeyEvent.sizeof);
+ sendKeyEvent (SWT.KeyDown, xEvent);
+ return 0;
+}
+int processKeyUp (int callData) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, callData, XKeyEvent.sizeof);
+ sendKeyEvent (SWT.KeyUp, xEvent);
+ return 0;
+}
+int processModify (int callData) {
+ sendEvent (SWT.Modify);
+ return 0;
+}
+int processMouseDown (int callData) {
+ getDisplay ().hideToolTip ();
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, callData, XButtonEvent.sizeof);
+ sendMouseEvent (SWT.MouseDown, xEvent.button, xEvent.state, xEvent);
+ if (xEvent.button == 2 && hooks (SWT.DragDetect)) {
+ sendEvent (SWT.DragDetect);
+ }
+ if (xEvent.button == 3 && menu != null) {
+ OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
+ menu.setVisible (true);
+ }
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay != 0) {
+ Display display = getDisplay ();
+ int clickTime = OS.XtGetMultiClickTime (xDisplay);
+ int lastTime = display.lastTime, eventTime = xEvent.time;
+ int lastButton = display.lastButton, eventButton = xEvent.button;
+ if (lastButton == eventButton && lastTime != 0 && Math.abs (lastTime - eventTime) <= clickTime) {
+ sendMouseEvent (SWT.MouseDoubleClick, eventButton, xEvent.state, xEvent);
+ }
+ if (eventTime == 0) eventTime = 1;
+ display.lastTime = eventTime;
+ display.lastButton = eventButton;
+ }
+ return 0;
+}
+int processMouseEnter (int callData) {
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, callData, XCrossingEvent.sizeof);
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+ if (xEvent.subwindow != 0) return 0;
+ Event event = new Event ();
+ event.x = xEvent.x;
+ event.y = xEvent.y;
+ postEvent (SWT.MouseEnter, event);
+ return 0;
+}
+int processMouseMove (int callData) {
+ Display display = getDisplay ();
+ display.addMouseHoverTimeOut (handle);
+ XMotionEvent xEvent = new XMotionEvent ();
+ OS.memmove (xEvent, callData, XMotionEvent.sizeof);
+ sendMouseEvent (SWT.MouseMove, 0, xEvent.state, xEvent);
+ return 0;
+}
+int processMouseExit (int callData) {
+ Display display = getDisplay ();
+ display.removeMouseHoverTimeOut ();
+ display.hideToolTip ();
+
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, callData, XCrossingEvent.sizeof);
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+ if (xEvent.subwindow != 0) return 0;
+ Event event = new Event ();
+ event.x = xEvent.x;
+ event.y = xEvent.y;
+ postEvent (SWT.MouseExit, event);
+ return 0;
+}
+int processMouseUp (int callData) {
+ getDisplay ().hideToolTip ();
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, callData, XButtonEvent.sizeof);
+ sendMouseEvent (SWT.MouseUp, xEvent.button, xEvent.state, xEvent);
+ return 0;
+}
+int processPaint (int callData) {
+ if (!hooks (SWT.Paint)) return 0;
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, callData, XExposeEvent.sizeof);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return 0;
+ Event event = new Event ();
+ event.count = xEvent.count;
+ event.time = OS.XtLastTimestampProcessed (xDisplay);
+ event.x = xEvent.x; event.y = xEvent.y;
+ event.width = xEvent.width; event.height = xEvent.height;
+ GC gc = event.gc = new GC (this);
+ XRectangle rect = new XRectangle ();
+ rect.x = (short) xEvent.x; rect.y = (short) xEvent.y;
+ rect.width = (short) xEvent.width; rect.height = (short) xEvent.height;
+ OS.XSetClipRectangles (xDisplay, gc.handle, 0, 0, rect, 1, OS.Unsorted);
+ sendEvent (SWT.Paint, event);
+ if (!gc.isDisposed ()) gc.dispose ();
+ event.gc = null;
+ return 0;
+}
+int processSelection (int callData) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+int processSetFocus (int callData) {
+
+ /* Get the focus change event */
+ XFocusChangeEvent xEvent = new XFocusChangeEvent ();
+ OS.memmove (xEvent, callData, XFocusChangeEvent.sizeof);
+
+ /* Ignore focus changes caused by grabbing and ungrabing. */
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+
+ /* Only process focus callbacks between windows. */
+ if (xEvent.detail != OS.NotifyAncestor &&
+ xEvent.detail != OS.NotifyInferior &&
+ xEvent.detail != OS.NotifyNonlinear) return 0;
+
+ /*
+ * Ignore focus change events when the window getting or losing
+ * focus is a menu. Because XmGetFocusWidget() does not answer
+ * the menu shell (it answers the menu parent), it is necessary
+ * to use XGetInputFocus() to get the real X focus window.
+ */
+ int xDisplay = xEvent.display;
+ if (xDisplay == 0) return 0;
+ int [] unused = new int [1], xWindow = new int [1];
+ OS.XGetInputFocus (xDisplay, xWindow, unused);
+ if (xWindow [0] != 0) {
+ int widget = OS.XtWindowToWidget (xDisplay, xWindow [0]);
+ if (widget != 0 && OS.XtClass (widget) == OS.XmMenuShellWidgetClass ()) return 0;
+ }
+
+ /* Process the focus change for the widget. */
+ if (xEvent.type == OS.FocusIn) {
+ int result = processFocusIn ();
+ int index = 0;
+ Shell shell = getShell ();
+ Control [] focusIn = getPath ();
+ Control lastFocus = shell.lastFocus;
+ if (lastFocus != null) {
+ if (!lastFocus.isDisposed ()) {
+ Control [] focusOut = lastFocus.getPath ();
+ int length = Math.min (focusIn.length, focusOut.length);
+ while (index < length) {
+ if (focusIn [index] != focusOut [index]) break;
+ index++;
+ }
+ for (int i=focusOut.length-1; i>=index; --i) {
+ focusOut [i].sendEvent (SWT.Deactivate);
+ }
+ }
+ shell.lastFocus = null;
+ }
+ for (int i=focusIn.length-1; i>=index; --i) {
+ focusIn [i].sendEvent (SWT.Activate);
+ }
+ return result;
+ }
+ if (xEvent.type == OS.FocusOut) {
+ int result = processFocusOut ();
+ Shell shell = getShell ();
+ shell.lastFocus = this;
+ Display display = getDisplay ();
+ Control focusControl = display.getFocusControl ();
+ if (focusControl == null || shell != focusControl.getShell ()) {
+ Control [] focusOut = getPath ();
+ for (int i=focusOut.length-1; i>=0; --i) {
+ focusOut [i].sendEvent (SWT.Deactivate);
+ }
+ shell.lastFocus = null;
+ }
+ return result;
+ }
+ return 0;
+}
+void propagateChildren (boolean enabled) {
+ propagateWidget (enabled);
+}
+void propagateHandle (boolean enabled, int widgetHandle) {
+ int xDisplay = OS.XtDisplay (widgetHandle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (widgetHandle);
+ if (xWindow == 0) return;
+ int event_mask = OS.XtBuildEventMask (widgetHandle);
+ int do_not_propagate_mask = OS.KeyPressMask | OS.KeyReleaseMask | OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask;
+ if (!enabled) {
+ event_mask &= ~do_not_propagate_mask;
+ do_not_propagate_mask = 0;
+ }
+ XSetWindowAttributes attributes = new XSetWindowAttributes ();
+ attributes.event_mask = event_mask;
+ attributes.do_not_propagate_mask = do_not_propagate_mask;
+ OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWDontPropagate | OS.CWEventMask, attributes);
+ int [] argList = {OS.XmNtraversalOn, enabled ? 1 : 0};
+ OS.XtSetValues (widgetHandle, argList, argList.length / 2);
+}
+void propagateWidget (boolean enabled) {
+ propagateHandle (enabled, handle);
+}
+void realizeChildren () {
+ if (!isEnabled ()) propagateWidget (false);
+}
+public void redraw () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ redrawWidget (0, 0, 0, 0, false);
+}
+public void redraw (int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (x == 0 && y == 0 && width == 0 && height == 0) return;
+ redrawWidget (x, y, width, height, all);
+}
+void redrawHandle (int x, int y, int width, int height, int widgetHandle) {
+ int display = OS.XtDisplay (widgetHandle);
+ if (display == 0) return;
+ int window = OS.XtWindow (widgetHandle);
+ if (window == 0) return;
+ int [] argList = {OS.XmNborderWidth, 0, OS.XmNborderColor, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ if (argList [1] != 0) {
+ /* Force the border to repaint by setting the color */
+ OS.XtSetValues (widgetHandle, argList, argList.length / 2);
+ }
+ OS.XClearArea (display, window, x, y, width, height, true);
+}
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ redrawHandle (x, y, width, height, handle);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ Display display = getDisplay ();
+ display.releaseToolTipHandle (handle);
+ toolTipText = null;
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+/*
+ "Release the IME."
+ self isMenu ifFalse: [
+ handle xtIsWidget ifTrue: [
+ handle xmImUnregister.
+
+ "Bug in X. On Solaris only, destroying the window that has IME focus causes
+ a segment fault. The fix is to set focus to the IME client window (typically
+ the shell) when the receiver is being destroyed. Destroying the shell window
+ does not have the problem. Note that this fix is not necessary on AIX."
+ (xIC := self inputContext) == nil ifFalse: [
+ (window := handle xtWindow) isNull ifFalse: [
+ xIC xGetICValues: XNFocusWindow with: (buffer := ByteArray new: 4) with: 0.
+ (buffer uint32At: 0) = window asInteger ifTrue: [
+ xIC xGetICValues: XNClientWindow with: (buffer := ByteArray new: 4) with: 0.
+ xIC
+ xUnsetICFocus;
+ xSetICValues: XNFocusWindow with: (buffer uint32At: 0) with: 0;
+ xSetICFocus]]]]].
+*/
+ parent = null;
+ layoutData = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeFocusListener(FocusListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeKeyListener(KeyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeMouseListener(MouseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeMouseMoveListener(MouseMoveListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.MouseMove, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when listener is null</li>
+* </ul>
+*/
+public void removeMouseTrackListener(MouseTrackListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removePaintListener(PaintListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Paint, listener);
+}/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when listener is null</li>
+* </ul>
+*/
+public void removeTraverseListener(TraverseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Traverse, listener);
+}
+void sendHelpEvent (int callData) {
+ Control control = this;
+ while (control != null) {
+ if (control.hooks (SWT.Help)) {
+ control.postEvent (SWT.Help);
+ return;
+ }
+ control = control.parent;
+ }
+}
+void sendKeyEvent (int type, XKeyEvent xEvent) {
+
+ /* Look up the keysym and character(s) */
+ byte [] buffer;
+ boolean isVirtual = false;
+ int [] keysym = new int [1], status = new int [1];
+ if (xEvent.keycode != 0) {
+ buffer = new byte [1];
+ isVirtual = OS.XLookupString (xEvent, buffer, buffer.length, keysym, status) == 0;
+ } else {
+ int size = 0;
+ buffer = new byte [2];
+ int xIC = inputContext ();
+ if (xIC == 0) {
+ size = OS.XmImMbLookupString (handle, xEvent, buffer, buffer.length, keysym, status);
+ if (status [0] == OS.XBufferOverflow) {
+ buffer = new byte [size];
+ size = OS.XmImMbLookupString (handle, xEvent, buffer, size, keysym, status);
+ }
+ } else {
+ size = OS.XmbLookupString (xIC, xEvent, buffer, buffer.length, keysym, status);
+ if (status [0] == OS.XBufferOverflow) {
+ buffer = new byte [size];
+ size = OS.XmbLookupString (xIC, xEvent, buffer, size, keysym, status);
+ }
+ }
+ if (size == 0) return;
+ }
+
+ /*
+ * Bug in MOTIF. On Solaris only, XK_F11 and XK_F12 are not
+ * translated correctly by XLookupString(). They are mapped
+ * to 0x1005FF10 and 0x1005FF11 respectively. The fix is to
+ * look for these values explicitly and correct them.
+ */
+ if (IsSunOS) {
+ if ((keysym [0] == 0x1005FF10) || (keysym [0] == 0x1005FF11)) {
+ if (keysym [0] == 0x1005FF10) keysym [0] = OS.XK_F11;
+ if (keysym [0] == 0x1005FF11) keysym [0] = OS.XK_F12;
+ }
+ }
+
+ /*
+ * Bug in MOTIF. On Solaris only, their is garbage in the
+ * high 16-bits for Keysyms such as XK_Down. Since Keysyms
+ * must be 16-bits to fit into a Character, mask away the
+ * high 16-bits on all platforms.
+ */
+ keysym [0] &= 0xFFFF;
+
+ /* Convert from MBCS to UNICODE and send the event */
+ char [] result = Converter.mbcsToWcs (null, buffer);
+ for (int i=0; i<result.length; i++) {
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.character = result [i];
+ if (isVirtual) event.keyCode = Display.translateKey (keysym [0]);
+ if ((xEvent.state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;
+ if ((xEvent.state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;
+ if ((xEvent.state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;
+ if ((xEvent.state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((xEvent.state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;
+ postEvent (type, event);
+ }
+}
+void sendMouseEvent (int type, int button, int mask, XWindowEvent xEvent) {
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.button = button;
+ event.x = xEvent.x; event.y = xEvent.y;
+ if ((mask & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;
+ if ((mask & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;
+ if ((mask & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;
+ if ((mask & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((mask & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((mask & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;
+ postEvent (type, event);
+}
+public void setBackground (Color color) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (color == null) {
+ setBackgroundPixel (defaultBackground ());
+ } else {
+ if (color.isDisposed ()) return;
+ setBackgroundPixel (color.handle.pixel);
+ }
+}
+void setBackgroundPixel (int pixel) {
+ int [] argList = {OS.XmNforeground, 0, OS.XmNhighlightColor, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XmChangeColor (handle, pixel);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Feature in Motif. Motif will not allow a window
+ * to have a zero width or zero height. The fix is
+ * to ensure these values are never zero.
+ */
+ int topHandle = topHandle ();
+ int [] argList = {
+ OS.XmNx, 0, /* 1 */
+ OS.XmNy, 0, /* 3 */
+ OS.XmNwidth, 0, /* 5 */
+ OS.XmNheight, 0, /* 7 */
+ OS.XmNborderWidth, 0, /* 9 */
+ };
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ int newWidth = Math.max (width - (argList [9] * 2), 1);
+ int newHeight = Math.max (height - (argList [9] * 2), 1);
+ boolean sameOrigin = (x == (short) argList [1]) && (y == (short) argList [3]);
+ boolean sameExtent = (newWidth == argList [5]) && (newHeight == argList [7]);
+ if (sameOrigin && sameExtent) return;
+ OS.XtConfigureWidget (topHandle, x, y, newWidth, newHeight, argList [9]);
+ if (!sameOrigin) sendEvent (SWT.Move);
+ if (!sameExtent) sendEvent (SWT.Resize);
+}
+public void setBounds (Rectangle rect) {
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+public void setCapture (boolean capture) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ if (capture) {
+ int window = OS.XtWindow (handle);
+ if (window == 0) return;
+ OS.XGrabPointer (
+ display,
+ window,
+ 0,
+ OS.ButtonPressMask | OS.ButtonReleaseMask | OS.PointerMotionMask,
+ OS.GrabModeAsync,
+ OS.GrabModeAsync,
+ OS.None,
+ OS.None,
+ OS.CurrentTime);
+ } else {
+ OS.XUngrabPointer (display, OS.CurrentTime);
+ }
+}
+public void setCursor (Cursor cursor) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ int window = OS.XtWindow (handle);
+ if (window == 0) {
+ if (OS.XtIsRealized (handle)) return;
+ Shell shell = this.getShell ();
+ shell.realizeWidget ();
+ window = OS.XtWindow (handle);
+ if (window == 0) return;
+ }
+ if (cursor == null) {
+ OS.XUndefineCursor (display, window);
+ } else {
+ int xCursor = cursor.handle;
+ OS.XDefineCursor (display, window, xCursor);
+ OS.XFlush (display);
+ }
+}
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ enableWidget (enabled);
+ if (!enabled || (isEnabled () && enabled)) {
+ propagateChildren (enabled);
+ }
+}
+public boolean setFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Decorations shell = menuShell ();
+ shell.setSavedFocus (this);
+ shell.bringToTop ();
+ return OS.XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT);
+}
+public void setFont (Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int fontList = 0;
+ if (font != null) fontList = font.handle;
+ if (fontList == 0) fontList = defaultFont ();
+ setFontList (fontList);
+}
+void setFontList (int fontList) {
+ this.fontList = fontList;
+
+ /*
+ * Feature in Motif. Setting the font in a widget
+ * can cause the widget to automatically resize in
+ * the OS. This behavior is unwanted. The fix is
+ * to force the widget to resize to original size
+ * after every font change.
+ */
+ int [] argList1 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+
+ /* Set the font list */
+ int fontHandle = fontHandle ();
+ int [] argList2 = {OS.XmNfontList, fontList};
+ OS.XtSetValues (fontHandle, argList2, argList2.length / 2);
+
+ /* Restore the widget size */
+ OS.XtSetValues (handle, argList1, argList1.length / 2);
+}
+public void setForeground (Color color) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (color == null) {
+ setForegroundPixel (defaultForeground ());
+ } else {
+ if (color.isDisposed ()) return;
+ setForegroundPixel (color.handle.pixel);
+ }
+}
+void setForegroundPixel (int pixel) {
+ int [] argList = {OS.XmNforeground, pixel};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return;
+ OS.XClearArea (xDisplay, xWindow, 0, 0, 0, 0, true);
+}
+void setGrabCursor (int cursor) {
+ /* | window attributes eventMask grabMask |
+ handle xtIsWidget ifFalse: [^self].
+ (window := handle xtWindow) isNull ifTrue: [^self].
+ attributes := OSXWindowAttributesPtr new.
+ XDisplay
+ xGetWindowAttributes: window
+ windowAttributesReturn: attributes.
+ grabMask := ((((((((((ButtonPressMask bitOr: ButtonReleaseMask) bitOr:
+ EnterWindowMask) bitOr: LeaveWindowMask) bitOr: PointerMotionMask) bitOr:
+ PointerMotionHintMask) bitOr: Button1MotionMask) bitOr: Button2MotionMask) bitOr:
+ Button3MotionMask) bitOr: Button4MotionMask) bitOr: Button5MotionMask) bitOr: ButtonMotionMask.
+ eventMask := attributes yourEventMask bitAnd: grabMask.
+ XDisplay xChangeActivePointerGrab: eventMask cursor: aCursor time: CurrentTime.
+ */
+}
+void setKeyState (Event event, XKeyEvent xEvent) {
+ if (xEvent.keycode != 0) {
+ event.time = xEvent.time;
+ byte [] buffer1 = new byte [1];
+ int [] keysym = new int [1], status = new int [1];
+ if (OS.XLookupString (xEvent, buffer1, buffer1.length, keysym, status) == 0) {
+ event.keyCode = Display.translateKey (keysym [0] & 0xFFFF);
+ } else {
+ event.character = (char) buffer1 [0];
+ }
+ if ((xEvent.state & OS.Mod1Mask) != 0) event.stateMask |= SWT.ALT;
+ if ((xEvent.state & OS.ShiftMask) != 0) event.stateMask |= SWT.SHIFT;
+ if ((xEvent.state & OS.ControlMask) != 0) event.stateMask |= SWT.CONTROL;
+ if ((xEvent.state & OS.Button1Mask) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((xEvent.state & OS.Button2Mask) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((xEvent.state & OS.Button3Mask) != 0) event.stateMask |= SWT.BUTTON3;
+ }
+}
+public void setLayoutData (Object layoutData) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.layoutData = layoutData;
+}
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ boolean sameOrigin = (x == (short) argList [1]) && (y == (short) argList [3]);
+ if (sameOrigin) return;
+ OS.XtMoveWidget (topHandle, x, y);
+ if (!sameOrigin) sendEvent (SWT.Move);
+}
+public void setLocation (Point location) {
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+/**
+* Sets the pop up menu.
+* <p>
+* Every window has a optional pop up menu that is
+* displayed when the user requests a popup menu for
+* the window. The sequence of key strokes/button
+* presses/button releases that is used to request
+* a pop up menu is platform specific.
+*
+* @param menu the new pop up menu
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_MENU_NOT_POP_UP)
+* when the menu is not a POP_UP
+* @exception SWTError(ERROR_NO_COMMON_PARENT)
+* when the menu is not in the same widget tree
+*/
+public void setMenu (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+}
+
+/**
+ * Changes the parent of the widget to be the one provided if
+ * the underlying operating system supports this feature.
+ * Answers true if the parent is successfully changed.
+ *
+ * @param parent Composite
+ * the new parent for the control.
+ * @return boolean
+ * true if parent is changed and false otherwise.
+ *
+ * @exception SWTError <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 boolean setParent (Composite parent) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Feature in Motif. Motif will not allow a window
+ * to have a zero width or zero height. The fix is
+ * to ensure these values are never zero.
+ */
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ int newWidth = Math.max (width - (argList [5] * 2), 1);
+ int newHeight = Math.max (height - (argList [5] * 2), 1);
+ boolean sameExtent = (newWidth == argList [1]) && (newHeight == argList [3]);
+ if (sameExtent) return;
+ OS.XtResizeWidget (topHandle, newWidth, newHeight, argList [5]);
+ if (!sameExtent) sendEvent (SWT.Resize);
+}
+public void setSize (Point size) {
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+/**
+* Sets the tool tip text.
+* <p>
+* @param string the new tool tip text (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
+}
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] argList = {OS.XmNmappedWhenManaged, 0};
+ OS.XtGetValues (topHandle, argList, argList.length / 2);
+ if ((argList [1] != 0) == visible) return;
+ OS.XtSetMappedWhenManaged (topHandle, visible);
+ sendEvent (visible ? SWT.Show : SWT.Hide);
+}
+void setZOrder () {
+ /*
+ * Feature in MOTIF. When a widget is created before the
+ * parent has been realized, the widget is created behind
+ * all siblings in the Z-order. When a widget is created
+ * after the parent parent has been realized, it is created
+ * in front of all siblings. This is not incorrect but is
+ * unexpected. The fix is to force all widgets to always
+ * be created behind their siblings.
+ */
+ int topHandle = topHandle ();
+ if (OS.XtIsRealized (topHandle)) {
+ int window = OS.XtWindow (topHandle);
+ if (window != 0) {
+ int display = OS.XtDisplay (topHandle);
+ if (display != 0) OS.XLowerWindow (display, window);
+ }
+ }
+}
+void setZOrder (Control control, boolean above) {
+ /*
+ * Feature in Xt. We cannot use XtMakeGeometryRequest() to
+ * restack widgets because this call can fail under certain
+ * conditions. For example, XtMakeGeometryRequest() answers
+ * XtGeometryNo when attempting to bring a child widget that
+ * is larger than the parent widget to the front. The fix
+ * is to use X calls instead.
+ */
+ int topHandle1 = topHandle ();
+ int display = OS.XtDisplay (topHandle1);
+ if (display == 0) return;
+ if (!OS.XtIsRealized (topHandle1)) {
+ Shell shell = this.getShell ();
+ shell.realizeWidget ();
+ }
+ int window1 = OS.XtWindow (topHandle1);
+ if (window1 == 0) return;
+ if (control == null) {
+ if (above) {
+ OS.XRaiseWindow (display, window1);
+ if (parent != null) parent.moveAbove (topHandle1, 0);
+ } else {
+ OS.XLowerWindow (display, window1);
+ if (parent != null) parent.moveBelow (topHandle1, 0);
+ }
+ return;
+ }
+ int topHandle2 = control.topHandle ();
+ if (display != OS.XtDisplay (topHandle2)) return;
+ if (!OS.XtIsRealized (topHandle2)) {
+ Shell shell = control.getShell ();
+ shell.realizeWidget ();
+ }
+ int window2 = OS.XtWindow (topHandle2);
+ if (window2 == 0) return;
+ XWindowChanges struct = new XWindowChanges ();
+ struct.sibling = window2;
+ struct.stack_mode = above ? OS.Above : OS.Below;
+ /*
+ * 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 ().
+ */
+ int screen = OS.XDefaultScreen (display);
+ int flags = OS.CWStackMode | OS.CWSibling;
+ OS.XReconfigureWMWindow (display, window1, screen, flags, struct);
+ if (above) {
+ if (parent != null) parent.moveAbove (topHandle1, topHandle2);
+ } else {
+ if (parent != null) parent.moveBelow (topHandle1, topHandle2);
+ }
+}
+public Point toControl (Point point) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) 0, (short) 0, root_x, root_y);
+ return new Point (point.x - root_x [0], point.y - root_y [0]);
+}
+public Point toDisplay (Point point) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) point.x, (short) point.y, root_x, root_y);
+ return new Point (root_x [0], root_y [0]);
+}
+boolean translateMnemonic (int aKey, XKeyEvent xEvent) {
+ if (xEvent.state != OS.Mod1Mask) {
+ if (xEvent.state != 0 || !(this instanceof Button)) {
+ return false;
+ }
+ }
+ Decorations shell = menuShell ();
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ char ch = mbcsToWcs ((char) aKey);
+ return ch != 0 && shell.traverseMnemonic (ch);
+}
+boolean translateTraversal (int key, XKeyEvent xEvent) {
+ int detail = 0;
+ switch (key) {
+ case OS.XK_Escape:
+ case OS.XK_Cancel:
+ Shell shell = getShell ();
+ if (shell.parent == null) return false;
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ case OS.XK_Return:
+ Button button = menuShell ().getDefaultButton ();
+ if (button == null || button.isDisposed ()) return false;
+ if (!button.isVisible () || !button.isEnabled ()) return false;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ case OS.XK_Tab:
+ detail = SWT.TRAVERSE_TAB_PREVIOUS;
+ boolean next = (xEvent.state & OS.ShiftMask) == 0;
+ if (next && ((xEvent.state & OS.ControlMask) != 0)) return false;
+ if (next) detail = SWT.TRAVERSE_TAB_NEXT;
+ break;
+ case OS.XK_Up:
+ case OS.XK_Left:
+ detail = SWT.TRAVERSE_ARROW_PREVIOUS;
+ break;
+ case OS.XK_Down:
+ case OS.XK_Right:
+ detail = SWT.TRAVERSE_ARROW_NEXT;
+ break;
+ default:
+ return false;
+ }
+ boolean doit = (detail & traversalCode ()) != 0;
+ if (hooks (SWT.Traverse)) {
+ Event event = new Event();
+ event.doit = doit;
+ event.detail = detail;
+ setKeyState (event, xEvent);
+ sendEvent (SWT.Traverse, event);
+ doit = event.doit;
+ detail = event.detail;
+ }
+ /*
+ * NOTE: The native widgets handle tab and arrow key traversal
+ * so it is not necessary to traverse these keys. A canvas widget
+ * has no native traversal by definition so it is necessary to
+ * traverse all keys.
+ */
+ if (doit) {
+ int flags = SWT.TRAVERSE_RETURN | SWT.TRAVERSE_ESCAPE;
+ if ((detail & flags) != 0 || (state & CANVAS) != 0) {
+ return traverse (detail);
+ }
+ }
+ return false;
+}
+int traversalCode () {
+ int code = SWT.TRAVERSE_ESCAPE | SWT.TRAVERSE_RETURN;
+ int [] argList = {OS.XmNnavigationType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == OS.XmNONE) {
+ code |= SWT.TRAVERSE_ARROW_NEXT | SWT.TRAVERSE_ARROW_PREVIOUS;
+ } else {
+ code |= SWT.TRAVERSE_TAB_NEXT | SWT.TRAVERSE_TAB_PREVIOUS;
+ }
+ return code;
+}
+boolean traverseMnemonic (char key) {
+ if (!isVisible () || !isEnabled ()) return false;
+ return mnemonicMatch (key) && mnemonicHit ();
+}
+/**
+* Traverse the widget.
+* <p>
+* @param traversal the type of traversal.
+* @return true if the traversal succeeded
+*
+* @exception SWTError <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 boolean traverse (int traversal) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (!isFocusControl () && !setFocus ()) return false;
+ switch (traversal) {
+ 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);
+ }
+ return false;
+}
+boolean traverseEscape () {
+ Shell shell = getShell ();
+ if (shell.parent == null) return false;
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ shell.close ();
+ return true;
+}
+boolean traverseGroup (boolean next) {
+ return OS.XmProcessTraversal (handle, next ? OS.XmTRAVERSE_NEXT_TAB_GROUP : OS.XmTRAVERSE_PREV_TAB_GROUP);
+}
+boolean traverseItem (boolean next) {
+ return OS.XmProcessTraversal (handle, next ? OS.XmTRAVERSE_NEXT : OS.XmTRAVERSE_PREV);
+}
+boolean traverseReturn () {
+ Button button = menuShell ().getDefaultButton ();
+ if (button == null || button.isDisposed ()) return false;
+ if (!button.isVisible () || !button.isEnabled ()) return false;
+ button.click ();
+ return true;
+}
+public void update () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ int window = OS.XtWindow (handle);
+ if (window == 0) return;
+ XAnyEvent event = new XAnyEvent ();
+ OS.XSync (display, false); OS.XSync (display, false);
+ while (OS.XCheckWindowEvent (display, window, OS.ExposureMask, event)) {
+ OS.XtDispatchEvent (event);
+ }
+}
+int processMouseHover (int id) {
+ Display display = getDisplay();
+ Event event = new Event();
+ Point local = toControl(display.getCursorLocation());
+ event.x = local.x; event.y = local.y;
+ postEvent (SWT.MouseHover, event);
+ display.showToolTip(handle, toolTipText);
+ return 0;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java
new file mode 100755
index 0000000000..236e238b8e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolBar.java
@@ -0,0 +1,544 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+public /*final*/ class CoolBar extends Composite {
+ Vector rows;
+ Cursor hoverCursor;
+ Cursor dragCursor;
+ static final int ROW_SPACING = 2;
+
+public CoolBar (Composite parent, int style) {
+ super (parent, style);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT) width = 0x7FFFFFFF;
+ if (hHint == SWT.DEFAULT) height = 0x7FFFFFFF;
+ Point extent = layout (width, false);
+ if (wHint != SWT.DEFAULT) extent.x = wHint;
+ if (hHint != SWT.DEFAULT) extent.y = hHint;
+ return extent;
+}
+public CoolItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index < 0) error (SWT.ERROR_INVALID_RANGE);
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ if (row.size() > index) {
+ return (CoolItem) row.elementAt(index);
+ } else {
+ index -= row.size();
+ }
+ }
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemCount = 0;
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ itemCount += row.size();
+ }
+ return itemCount;
+}
+public CoolItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ CoolItem [] result = new CoolItem [getItemCount()];
+ int index = 0;
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ for (int j = 0; j < row.size(); j++) {
+ result[index] = (CoolItem) row.elementAt(j);
+ index++;
+ }
+ }
+ return result;
+}
+int getRowHeight (int rowIndex) {
+ Vector row = (Vector) rows.elementAt(rowIndex);
+ int height = 0;
+ for (int i = 0; i < row.size(); i++) {
+ CoolItem item = (CoolItem) row.elementAt(i);
+ int itemHeight = item.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
+ height = Math.max(height, itemHeight);
+ }
+ return height;
+}
+int getRowIndex (CoolItem item) {
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem next = (CoolItem) row.elementAt(j);
+ if (next.equals(item)) return i;
+ }
+ }
+ return -1;
+}
+Vector getRow (CoolItem item) {
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem next = (CoolItem) row.elementAt(j);
+ if (next.equals(item)) return row;
+ }
+ }
+ return null;
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddEventHandler (handle, OS.ExposureMask, false, windowProc, SWT.Paint);
+}
+public int indexOf (CoolItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int answer = 0;
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem next = (CoolItem) row.elementAt(j);
+ if (next.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, Vector row, int x_root, int rowY) {
+ if (row.size() == 0) {
+ Point size = item.computeSize(SWT.DEFAULT, SWT.DEFAULT);
+ item.setBounds(0, rowY, getSize().x, size.y);
+ row.addElement(item);
+ return;
+ }
+
+ int x = x_root - toDisplay(new Point(0, 0)).x;
+
+ /* Find the insertion index and add the item. */
+ int index = 0;
+ for (int i = 0; i < row.size(); i++) {
+ CoolItem next = (CoolItem) row.elementAt(i);
+ if (x < next.getBounds().x) break;
+ index++;
+ }
+ row.insertElementAt(item, index);
+
+ /* Adjust the width of the item to the left. */
+ if (index > 0) {
+ CoolItem left = (CoolItem) row.elementAt(index - 1);
+ Rectangle leftBounds = left.getBounds();
+ int newWidth = x - leftBounds.x;
+ if (newWidth < CoolItem.MINIMUM_WIDTH) {
+ x += CoolItem.MINIMUM_WIDTH - newWidth;
+ newWidth = CoolItem.MINIMUM_WIDTH;
+ }
+ left.setBounds(leftBounds.x, leftBounds.y, newWidth, leftBounds.height);
+ }
+
+ /* Set the item's bounds. */
+ int width = 0;
+ if (index < row.size() - 1) {
+ CoolItem right = (CoolItem) row.elementAt(index + 1);
+ width = right.getBounds().x - x;
+ if (width < CoolItem.MINIMUM_WIDTH) {
+ moveRight(right, CoolItem.MINIMUM_WIDTH - width);
+ width = CoolItem.MINIMUM_WIDTH;
+ }
+ } else {
+ width = getBounds().width - x;
+ }
+ item.setBounds(x, rowY, width, item.getBounds().height);
+}
+void createItem (CoolItem item, int index) {
+ int itemCount = getItemCount();
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ item.createWidget (index);
+ item.id = itemCount;
+ if (index < itemCount) {
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ if (row.size() > index) {
+ row.insertElementAt(item, index);
+ return;
+ } else {
+ index -= row.size();
+ }
+ }
+ } else {
+ Vector lastRow = (Vector) rows.lastElement();
+ lastRow.addElement(item);
+ }
+}
+void createWidget (int index) {
+ rows = new Vector(5);
+ super.createWidget (index);
+ rows.addElement(new Vector(10));
+ hoverCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);
+ dragCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEALL);
+}
+void releaseWidget () {
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem item = (CoolItem) row.elementAt(j);
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ }
+ rows = null;
+ if (hoverCursor != null) hoverCursor.dispose();
+ if (dragCursor != null) dragCursor.dispose();
+ super.releaseWidget ();
+}
+void moveDown(CoolItem item, int x_root) {
+ int oldRowIndex = getRowIndex(item);
+ Vector oldRowItems = (Vector) rows.elementAt(oldRowIndex);
+ if (oldRowIndex == rows.size() - 1 && oldRowItems.size() == 1) {
+ /* This is the only item in the bottom row, don't move it. */
+ return;
+ }
+
+ int newRowIndex = (oldRowItems.size() == 1) ? oldRowIndex : oldRowIndex + 1;
+ removeItemFromRow(item, oldRowItems);
+
+ int newRowY = ROW_SPACING;
+ for (int i = 0; i < newRowIndex; i++) {
+ newRowY += getRowHeight(i) + ROW_SPACING;
+ }
+
+ if (newRowIndex == rows.size()) {
+ /* Create a new bottom row for the item. */
+ Vector newRow = new Vector(10);
+ insertItemIntoRow(item, newRow, x_root, newRowY);
+ rows.add(newRow);
+ adjustItemHeights(oldRowIndex);
+ return;
+ }
+
+ Vector newRowItems = (Vector) rows.elementAt(newRowIndex);
+ insertItemIntoRow(item, newRowItems, x_root, newRowY);
+ adjustItemHeights(oldRowIndex);
+}
+void moveLeft(CoolItem item, int pixels) {
+ Vector row = getRow(item);
+ int index = row.indexOf(item);
+ if (index == 0) return;
+ Rectangle bounds = item.getBounds();
+ int min = index * CoolItem.MINIMUM_WIDTH;
+ int x = Math.max(min, bounds.x - pixels);
+ CoolItem left = (CoolItem) row.elementAt(index - 1);
+ Rectangle leftBounds = left.getBounds();
+ if (leftBounds.x + CoolItem.MINIMUM_WIDTH >= x) {
+ int shift = leftBounds.x + CoolItem.MINIMUM_WIDTH - x;
+ moveLeft(left, shift);
+ leftBounds = left.getBounds();
+ }
+ int leftWidth = Math.max(CoolItem.MINIMUM_WIDTH, leftBounds.width - pixels);
+ left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+ int width = bounds.width + (bounds.x - x);
+ item.setBounds(x, bounds.y, width, bounds.height);
+}
+void moveRight(CoolItem item, int pixels) {
+ Vector row = getRow(item);
+ int index = row.indexOf(item);
+ if (index == 0) return;
+ Rectangle bounds = item.getBounds();
+ int minSpaceOnRight = (row.size() - index) * CoolItem.MINIMUM_WIDTH;
+ int max = getBounds().width - minSpaceOnRight;
+ int x = Math.min(max, bounds.x + pixels);
+ int width = 0;
+ if (index + 1 == row.size()) {
+ width = getBounds().width - x;
+ } else {
+ CoolItem right = (CoolItem) row.elementAt(index + 1);
+ Rectangle rightBounds = right.getBounds();
+ if (x + CoolItem.MINIMUM_WIDTH >= rightBounds.x) {
+ int shift = x + CoolItem.MINIMUM_WIDTH - rightBounds.x;
+ moveRight(right, shift);
+ rightBounds = right.getBounds();
+ }
+ width = rightBounds.x - x;
+ }
+ item.setBounds(x, bounds.y, width, bounds.height);
+ CoolItem left = (CoolItem) row.elementAt(index - 1);
+ Rectangle leftBounds = left.getBounds();
+ int leftWidth = x - leftBounds.x;
+ left.setBounds(leftBounds.x, leftBounds.y, leftWidth, leftBounds.height);
+}
+void moveUp(CoolItem item, int x_root) {
+ int oldRowIndex = getRowIndex(item);
+ Vector oldRowItems = (Vector) rows.elementAt(oldRowIndex);
+ if (oldRowIndex == 0 && oldRowItems.size() == 1) {
+ /* This is the only item in the top row, don't move it. */
+ return;
+ }
+
+ removeItemFromRow(item, oldRowItems);
+ int newRowIndex = oldRowIndex - 1;
+ int newRowY = ROW_SPACING;
+ for (int i = 0; i < newRowIndex; i++) {
+ newRowY += getRowHeight(i) + ROW_SPACING;
+ }
+
+ if (oldRowIndex == 0) {
+ /* Create a new top row for the item. */
+ Vector newRow = new Vector(10);
+ insertItemIntoRow(item, newRow, x_root, newRowY);
+ rows.add(0, newRow);
+ adjustItemHeights(0);
+ return;
+ }
+
+ Vector newRowItems = (Vector) rows.elementAt(newRowIndex);
+ insertItemIntoRow(item, newRowItems, x_root, newRowY);
+ adjustItemHeights(newRowIndex);
+}
+int processPaint (int callData) {
+ if (rows.size() == 0) return 0;
+ GC gc = new GC(this);
+ Display display = getDisplay();
+ int y = getRowHeight(0) + ROW_SPACING;
+ int stopX = getBounds().width;
+ Color shadowColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ Color highlightColor = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+ for (int i = 1; i < rows.size(); i++) {
+ gc.setForeground(shadowColor);
+ gc.drawLine(0, y, stopX, y);
+ gc.setForeground(highlightColor);
+ gc.drawLine(0, y + 1, stopX, y + 1);
+ y += getRowHeight(i) + ROW_SPACING;
+ }
+ gc.dispose();
+ return 0;
+}
+/**
+ * Remove the item from the row. Adjust the x and width values
+ * appropriately.
+ */
+void removeItemFromRow(CoolItem item, Vector row) {
+ int index = row.indexOf(item);
+ row.removeElementAt(index);
+ if (row.size() == 0) {
+ rows.removeElement(row);
+ return;
+ }
+ if (index == 0) {
+ CoolItem first = (CoolItem) row.elementAt(0);
+ Rectangle bounds = first.getBounds();
+ int width = bounds.x + bounds.width;
+ first.setBounds(0, bounds.y, width, bounds.height);
+ } else {
+ CoolItem previous = (CoolItem) row.elementAt(index - 1);
+ Rectangle bounds = previous.getBounds();
+ int width = bounds.width + item.getSize().x;
+ previous.setBounds(bounds.x, bounds.y, width, bounds.height);
+ }
+}
+/**
+ * Update the children to reflect a change in y values.
+ */
+void adjustItemHeights(int startIndex) {
+ int y = ROW_SPACING;
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ int rowHeight = getRowHeight(i);
+ if (i >= startIndex) {
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem child = (CoolItem) row.elementAt(j);
+ Rectangle bounds = child.getBounds();
+ if (bounds.y != y || bounds.height != rowHeight) {
+ child.setBounds(bounds.x, y, bounds.width, rowHeight);
+ if (bounds.height != rowHeight) child.redraw();
+ }
+ }
+ }
+ y += ROW_SPACING + rowHeight;
+ }
+ Point size = getSize();
+ if (size.y != y) super.setSize(size.x, y);
+}
+/**
+ * The row has been assigned a new width. Grow or
+ * shrink the row's items as necessary.
+ */
+void adjustItemWidths (Vector row, int width) {
+ CoolItem last = (CoolItem) row.lastElement();
+ Rectangle bounds = last.getBounds();
+ int rowWidth = bounds.x + bounds.width;
+ if (width == rowWidth) return;
+ if (width > rowWidth || width > bounds.x + CoolItem.MINIMUM_WIDTH) {
+ last.setBounds(bounds.x, bounds.y, width - bounds.x, bounds.height);
+ return;
+ }
+ /* Shifting the last item ensures that all hidden items
+ to its left are made visible as well.*/
+ last.setBounds(bounds.x, bounds.y, CoolItem.MINIMUM_WIDTH, bounds.height);
+ moveLeft(last, bounds.x - width + CoolItem.MINIMUM_WIDTH);
+}
+Point layout (int width, boolean resize) {
+ int y = ROW_SPACING, maxWidth = 0;
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ int x = 0, rowHeight = getRowHeight(i);
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem child = (CoolItem) row.elementAt(j);
+ int childWidth = child.getSize().x;
+ if (resize) child.setBounds(x, y, childWidth, rowHeight);
+ x += childWidth;
+ }
+ maxWidth = Math.max(maxWidth, x);
+ if (resize) adjustItemWidths(row, width);
+ y += ROW_SPACING + rowHeight;
+ }
+ return new Point(maxWidth, y);
+}
+void realizeChildren () {
+ super.realizeChildren ();
+ CoolItem[] items = getItems();
+ for (int i = 0; i < items.length; i++) {
+ int window = OS.XtWindow (items[i].handle);
+ if (window != 0) {
+ int display = OS.XtDisplay (items[i].handle);
+ if (display != 0) OS.XLowerWindow (display, window);
+ }
+ }
+ layout(getSize().x, true);
+}
+void relayout() {
+ Point size = layout(getSize().x, true);
+ super.setSize(size.x, size.y);
+}
+public void setBounds (int x, int y, int width, int height) {
+ super.setBounds (x, y, width, height);
+ layout(width, true);
+}
+public void setSize (int width, int height) {
+ super.setSize (width, height);
+ layout (width, true);
+}
+CoolItem getChild (int id) {
+ for (int i = 0; i < rows.size(); i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ for (int j = 0; j < row.size(); j++) {
+ CoolItem child = (CoolItem) row.elementAt(j);
+ if (child.id == id) return child;
+ }
+ }
+ return null;
+}
+public int[] getItemOrder () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ CoolItem[] items = getItems();
+ int[] ids = new int[items.length];
+ for (int i = 0; i < items.length; i++) {
+ ids[i] = items[i].id;
+ }
+ return ids;
+}
+void setItemOrder (int[] itemOrder) {
+ if (itemOrder == null) error(SWT.ERROR_NULL_ARGUMENT);
+ CoolItem[] items = getItems();
+ if (itemOrder.length != items.length) error(SWT.ERROR_INVALID_ARGUMENT);
+ Vector row = new Vector(items.length);
+ for (int i = 0; i < itemOrder.length; i++) {
+ CoolItem child = getChild(itemOrder[i]);
+ if (child == null) error(SWT.ERROR_INVALID_ARGUMENT);
+ row.addElement(child);
+ }
+ rows = new Vector(1);
+ rows.addElement(row);
+}
+public Point[] getItemSizes () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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++) {
+ Rectangle bounds = items[i].getBounds();
+ items[i].setBounds(bounds.x, bounds.y, sizes[i].x, sizes[i].y);
+ }
+}
+public int[] getWrapIndices () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int[] data = new int[rows.size() - 1];
+ int itemIndex = 0;
+ for (int i = 0; i < rows.size() - 1; i++) {
+ Vector row = (Vector) rows.elementAt(i);
+ itemIndex += row.size();
+ data[i] = itemIndex;
+ }
+ return data;
+}
+public void setWrapIndices (int[] data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (data == null) error(SWT.ERROR_NULL_ARGUMENT);
+ CoolItem[] items = getItems();
+ rows = new Vector(5);
+ int itemIndex = 0;
+ for (int i = 0; i < data.length; i++) {
+ int nextWrap = data[i];
+ Vector row = new Vector(10);
+ while (itemIndex < nextWrap) {
+ row.addElement(items[itemIndex]);
+ itemIndex++;
+ }
+ rows.addElement(row);
+ }
+ Vector row = new Vector(10);
+ while (itemIndex < items.length) {
+ row.addElement(items[itemIndex]);
+ itemIndex++;
+ }
+ rows.addElement(row);
+ relayout();
+}
+public void setItemLayout (int[] itemOrder, int[] wrapIndices, Point[] sizes) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setItemOrder(itemOrder);
+ setWrapIndices(wrapIndices);
+ setItemSizes(sizes);
+ relayout();
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java
new file mode 100755
index 0000000000..5340a39911
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/CoolItem.java
@@ -0,0 +1,296 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.motif.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public /*final*/ class CoolItem extends Item {
+ Control control;
+ CoolBar parent;
+ boolean dragging;
+ int mouseXOffset;
+ int preferredWidth = -1;
+ int preferredHeight = -1;
+ int id;
+
+ static final int MARGIN_WIDTH = 4;
+ static final int MARGIN_HEIGHT = 2;
+ static final int DEFAULT_HEIGHT = (2 * MARGIN_HEIGHT) + 28;
+ static final int GRABBER_WIDTH = 2;
+ static final int MINIMUM_WIDTH = (2 * MARGIN_WIDTH) + GRABBER_WIDTH;
+
+public CoolItem (CoolBar parent, int style) {
+ super(parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+public CoolItem (CoolBar parent, int style, int index) {
+ super(parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+public Point computeSize (int wHint, int hHint) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (preferredWidth > -1) return new Point(preferredWidth, preferredHeight);
+ int width = MINIMUM_WIDTH;
+ int height = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) width = wHint + MINIMUM_WIDTH + MARGIN_WIDTH;
+ if (hHint != SWT.DEFAULT) height = hHint + (2 + MARGIN_HEIGHT);
+ return new Point (width, height);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ int [] argList = {
+ OS.XmNwidth, MINIMUM_WIDTH,
+ OS.XmNheight, DEFAULT_HEIGHT,
+ OS.XmNpositionIndex, index,
+ OS.XmNtraversalOn, 0,
+ };
+ handle = OS.XmCreateDrawingArea(parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return new Rectangle ((short) argList [1], (short) argList [3], argList [5], argList [7]);
+}
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+Rectangle getGrabberArea () {
+ int [] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return new Rectangle(0, 0, MINIMUM_WIDTH, argList[1]);
+}
+public CoolBar getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+Point getSize () {
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return new Point (argList [1], argList [3]);
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddEventHandler (handle, OS.ExposureMask, false, windowProc, SWT.Paint);
+ OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, SWT.MouseDown);
+ OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, SWT.MouseUp);
+ OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, SWT.MouseMove);
+ OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit);
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+int processMouseDown (int callData) {
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, callData, XButtonEvent.sizeof);
+ if (getGrabberArea().contains(xEvent.x, xEvent.y)) {
+ dragging = true;
+ mouseXOffset = xEvent.x;
+ parent.setCursor(parent.dragCursor);
+ }
+ return 0;
+}
+int processMouseExit (int callData) {
+ if (!dragging) parent.setCursor(null);
+ return 0;
+}
+int processMouseMove (int callData) {
+ XMotionEvent xEvent = new XMotionEvent ();
+ OS.memmove (xEvent, callData, XMotionEvent.sizeof);
+ if (dragging) {
+ int [] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int left_root = xEvent.x_root - mouseXOffset;
+ if (xEvent.y < 0) {
+ parent.moveUp(this, left_root);
+ return 0;
+ }
+ if (xEvent.y > argList[1]){
+ parent.moveDown(this, left_root);
+ return 0;
+ }
+ int delta = Math.abs(xEvent.x - mouseXOffset);
+ if (xEvent.x < mouseXOffset) {
+ parent.moveLeft(this, delta);
+ return 0;
+ }
+ if (xEvent.x > mouseXOffset) {
+ parent.moveRight(this, delta);
+ return 0;
+ }
+ return 0;
+ }
+ if (getGrabberArea().contains(xEvent.x, xEvent.y)) {
+ parent.setCursor(parent.hoverCursor);
+ } else {
+ parent.setCursor(null);
+ }
+ return 0;
+}
+int processMouseUp (int callData) {
+ dragging = false;
+ parent.setCursor(parent.hoverCursor);
+ return 0;
+}
+int processPaint (int callData) {
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return 0;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return 0;
+ int xGC = OS.XCreateGC (xDisplay, xWindow, 0, null);
+
+ Display display = getDisplay();
+ int shadowPixel = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW).handle.pixel;
+ int highlightPixel = display.getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW).handle.pixel;
+ int lightShadowPixel = display.getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW).handle.pixel;
+
+ int[] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int height = argList[1];
+ int grabberHeight = height - (2 * MARGIN_HEIGHT);
+
+ /* Draw separator. */
+ OS.XSetForeground(xDisplay, xGC, shadowPixel);
+ OS.XDrawLine (xDisplay, xWindow, xGC, 0, 0, 0, height);
+ OS.XSetForeground(xDisplay, xGC, highlightPixel);
+ OS.XDrawLine (xDisplay, xWindow, xGC, 1, 0, 1, height);
+
+ /* Draw grabber. */
+ OS.XSetForeground(xDisplay, xGC, highlightPixel);
+ OS.XSetBackground(xDisplay, xGC, lightShadowPixel);
+ OS.XFillRectangle(xDisplay, xWindow, xGC, MARGIN_WIDTH, MARGIN_HEIGHT, GRABBER_WIDTH, grabberHeight);
+ OS.XSetForeground(xDisplay, xGC, shadowPixel);
+ int right = MARGIN_WIDTH + GRABBER_WIDTH;
+ int bottom = MARGIN_HEIGHT + grabberHeight;
+ OS.XDrawLine (xDisplay, xWindow, xGC, right, MARGIN_HEIGHT, right, bottom);
+ OS.XDrawLine (xDisplay, xWindow, xGC, MARGIN_WIDTH, bottom, right, bottom);
+
+ OS.XFreeGC(xDisplay, xGC);
+ return 0;
+}
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ Control oldControl = this.control;
+ if (oldControl != null) oldControl.setVisible(false);
+ this.control = control;
+ if (control != null && !control.isDisposed ()) {
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int controlY = ((short) argList[3]) + MARGIN_HEIGHT;
+ control.setBounds (
+ ((short) argList [1]) + MINIMUM_WIDTH,
+ controlY,
+ argList [5] - MINIMUM_WIDTH - MARGIN_WIDTH,
+ argList [7] - (2 * MARGIN_HEIGHT));
+
+ if (OS.XtIsRealized (handle)) {
+ int window = OS.XtWindow (handle);
+ if (window == 0) return;
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ OS.XLowerWindow (display, window);
+ }
+ control.setVisible(true);
+ }
+}
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ width = Math.max (width, MINIMUM_WIDTH);
+ height = Math.max (height, DEFAULT_HEIGHT);
+ OS.XtResizeWidget (handle, width, height, 0);
+ if (control != null) {
+ int controlWidth = width - MINIMUM_WIDTH - MARGIN_WIDTH;
+ int controlHeight = height - (2 * MARGIN_HEIGHT);
+ control.setSize(controlWidth, controlHeight);
+ }
+ parent.relayout();
+}
+int getControlOffset(int height) {
+ return ((height - control.getSize().y - (2 * MARGIN_HEIGHT)) / 2) + MARGIN_HEIGHT;
+}
+void redraw() {
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ int window = OS.XtWindow (handle);
+ if (window == 0) return;
+ OS.XClearArea (display, window, 0, 0, 0, 0, true);
+}
+void setLocation (int x, int y) {
+ OS.XtMoveWidget (handle, x, y);
+ if (control != null) {
+ int [] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int controlY = y + getControlOffset(argList[1]);
+ control.setLocation(x + MINIMUM_WIDTH, controlY);
+ }
+}
+public void setSize (Point size) {
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+void setBounds (int x, int y, int width, int height) {
+ /*
+ * Feature in Motif. Motif will not allow a window
+ * to have a zero width or zero height. The fix is
+ * to ensure these values are never zero.
+ */
+ int newWidth = Math.max (width, 1), newHeight = Math.max (height, 1);
+ OS.XtConfigureWidget (handle, x, y, newWidth, newHeight, 0);
+ if (control != null) {
+ int controlY = y + getControlOffset(newHeight);
+ control.setBounds(
+ x + MINIMUM_WIDTH,
+ controlY,
+ newWidth - MINIMUM_WIDTH - MARGIN_WIDTH,
+ control.getSize().y);
+ }
+}
+public Point getPreferredSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point(preferredWidth, preferredHeight);
+}
+public void setPreferredSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ preferredWidth = Math.max (width, MINIMUM_WIDTH);
+ preferredHeight = Math.max (height, DEFAULT_HEIGHT);
+ OS.XtResizeWidget (handle, preferredWidth, preferredHeight, 0);
+ if (control != null) {
+ int controlWidth = preferredWidth - MINIMUM_WIDTH - MARGIN_WIDTH;
+ int controlHeight = preferredHeight - (2 * MARGIN_HEIGHT);
+ control.setSize(controlWidth, controlHeight);
+ }
+}
+public void setPreferredSize (Point size) {
+ setPreferredSize(size.x, size.y);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
new file mode 100755
index 0000000000..27a9612f8a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Decorations.java
@@ -0,0 +1,324 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The decorations class implements a widget that
+* looks and behaves like a shell, but has the same
+* properties as a child widget.
+*
+* Styles
+*
+* NO_TRIM,
+* BORDER, RESIZE,
+* TITLE, MENU, MIN, MAX
+*
+* Events
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/* Class Definition */
+public class Decorations extends Canvas {
+ String label;
+ Image image;
+ int dialogHandle;
+ boolean minimized, maximized;
+ Menu menuBar;
+ Menu [] menus;
+ Control savedFocus;
+ Button defaultButton, saveDefault;
+Decorations () {
+ /* Do nothing */
+}
+/**
+* Creates a new instance of the widget.
+*/
+public Decorations (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+void add (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;
+}
+void bringToTop () {
+ /*
+ * Feature in X. Calling XSetInputFocus() when the
+ * widget is not viewable causes an X bad match error.
+ * The fix is to call XSetInputFocus() when the widget
+ * is viewable.
+ */
+ if (minimized) return;
+ if (!isVisible ()) return;
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ int window = OS.XtWindow (handle);
+ if (window == 0) return;
+ OS.XSetInputFocus (display, window, OS.RevertToParent, OS.CurrentTime);
+}
+static int checkStyle (int style) {
+ 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);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle trim = super.computeTrim (x, y, width, height);
+ if (menuBar != null) {
+ XtWidgetGeometry request = new XtWidgetGeometry ();
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ request.request_mode = OS.CWWidth;
+ request.width = trim.width;
+ OS.XtQueryGeometry (menuBar.handle, request, result);
+ trim.height += result.height;
+ }
+ return trim;
+}
+void createHandle (int index) {
+ state |= HANDLE | CANVAS;
+ createScrolledHandle (parent.handle);
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ label = "";
+}
+int dialogHandle () {
+ if (dialogHandle != 0) return dialogHandle;
+ return dialogHandle = OS.XmCreateDialogShell (handle, null, null, 0);
+}
+public Button getDefaultButton () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return defaultButton;
+}
+/**
+* Gets the image.
+* <p>
+* @return the image
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+public boolean getMaximized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return maximized;
+}
+public Menu getMenuBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menuBar;
+}
+public boolean getMinimized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return minimized;
+}
+String getNameText () {
+ return getText ();
+}
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return label;
+}
+Decorations menuShell () {
+ return this;
+}
+void propagateWidget (boolean enabled) {
+ super.propagateWidget (enabled);
+ int [] argList = {OS.XmNmenuBar, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ if (argList [1] != 0) propagateHandle (enabled, argList [1]);
+}
+void releaseHandle () {
+ super.releaseHandle ();
+ dialogHandle = 0;
+}
+void releaseWidget () {
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null && !menu.isDisposed ()) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ }
+ }
+ menuBar = null;
+ menus = null;
+ super.releaseWidget ();
+ defaultButton = saveDefault = null;
+ label = null;
+}
+void remove (Menu menu) {
+ if (menus == null) return;
+ for (int i=0; i<menus.length; i++) {
+ if (menus [i] == menu) {
+ menus [i] = null;
+ return;
+ }
+ }
+}
+public void setDefaultButton (Button button) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setDefaultButton (button, true);
+}
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) return;
+ } else {
+ if ((button.style & SWT.PUSH) == 0) return;
+ if (button == defaultButton) return;
+ }
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
+ }
+ if ((defaultButton = button) == null) defaultButton = saveDefault;
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
+ }
+ if (save || saveDefault == null) saveDefault = defaultButton;
+ if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
+}
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int pixmap = 0, mask = 0;
+ if (image != null) {
+ switch (image.type) {
+ case SWT.BITMAP:
+ pixmap = image.pixmap;
+ break;
+ case SWT.ICON:
+ pixmap = image.pixmap;
+ mask = image.mask;
+ break;
+ default:
+ error (SWT.ERROR_INVALID_IMAGE);
+ }
+ }
+ this.image = image;
+ int [] argList = {
+ OS.XmNiconPixmap, pixmap,
+ OS.XmNiconMask, mask,
+ };
+ int topHandle = topHandle ();
+ OS.XtSetValues (topHandle, argList, argList.length / 2);
+}
+public void setMaximized (boolean maximized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.maximized = maximized;
+}
+public void setMenuBar (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+ }
+
+ /* Ensure the new menu bar is correctly enabled */
+ if (menuBar != null) {
+ if (!isEnabled () && menuBar.getEnabled ()) {
+ propagateHandle (true, menuBar.handle);
+ }
+ }
+ if (menu != null) {
+ if (!isEnabled ()) {
+ propagateHandle (false, menu.handle);
+ }
+ }
+
+ /*
+ * Bug in Motif. When a XmMainWindowSetAreas () is used
+ * to replace an existing menu, both menus must be managed
+ * before the call to XmMainWindowSetAreas () or the new
+ * menu will not be layed out properly.
+ */
+ int newHandle = (menu != null) ? menu.handle : 0;
+ int oldHandle = (menuBar != null) ? menuBar.handle : 0;
+ menuBar = menu;
+ int hHandle = (horizontalBar != null) ? horizontalBar.handle : 0;
+ int vHandle = (verticalBar != null) ? verticalBar.handle : 0;
+ if (newHandle != 0) {
+ OS.XtSetMappedWhenManaged (newHandle, false);
+ OS.XtManageChild (newHandle);
+ }
+ int clientHandle = (formHandle != 0) ? formHandle : handle;
+ OS.XmMainWindowSetAreas (scrolledHandle, newHandle, 0, hHandle, vHandle, clientHandle);
+ if (oldHandle != 0) OS.XtUnmanageChild (oldHandle);
+ if (newHandle != 0) {
+ OS.XtSetMappedWhenManaged (newHandle, true);
+ }
+
+ /*
+ * Bug in Motif. When a menu bar is removed after the
+ * main window has been realized, the main window does
+ * not layout the new menu bar or the work window.
+ * The fix is to force a layout by temporarily resizing
+ * the main window.
+ */
+ if (newHandle == 0 && OS.XtIsRealized (scrolledHandle)) {
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ OS.XtResizeWidget (scrolledHandle, argList [1] + 1, argList [3], argList [5]);
+ OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]);
+ }
+}
+public void setMinimized (boolean minimized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.minimized = minimized;
+}
+void setSavedFocus (Control control) {
+ if (this == control) return;
+ savedFocus = control;
+}
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ label = string;
+}
+public void setVisible (boolean visible) {
+ super.setVisible (visible);
+ if (!visible) return;
+ if (savedFocus != null && !savedFocus.isDisposed ()) {
+ savedFocus.setFocus ();
+ }
+ savedFocus = null;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java
new file mode 100755
index 0000000000..28048caa14
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -0,0 +1,220 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/**
+* A DirectoryDialog allows the user to navigate
+* the file and select a directory.
+*/
+
+/* Class Definition */
+public /*final*/ class DirectoryDialog extends Dialog {
+ String filterPath = "";
+ boolean cancel = true;
+ String message = "";
+public DirectoryDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+}
+int activate (int widget, int client, int call) {
+ cancel = client == OS.XmDIALOG_CANCEL_BUTTON;
+ OS.XtUnmanageChild (widget);
+ return 0;
+}
+public String getFilterPath () {
+ return filterPath;
+}
+public String getMessage () {
+ return message;
+}
+public String open () {
+
+ /* Get the parent */
+ boolean destroyContext;
+ Display appContext = Display.getCurrent ();
+ if (destroyContext = (appContext == null)) appContext = new Display ();
+ int display = appContext.xDisplay;
+ int parentHandle = appContext.shellHandle;
+ if ((parent != null) && (parent.getDisplay () == appContext))
+ parentHandle = parent.shellHandle;
+ /* Compute the dialog title */
+ /*
+ * Feature in Motif. It is not possible to set a shell
+ * title to an empty string. The fix is to set the title
+ * to be a single space.
+ */
+ String string = title;
+ if (string.length () == 0) string = " ";
+ byte [] buffer1 = Converter.wcsToMbcs (null, string, true);
+ int xmStringPtr1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Compute the filter */
+ byte [] buffer2 = Converter.wcsToMbcs (null, "*", true);
+ int xmStringPtr2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ /* Compute the filter path */
+ if (filterPath == null) filterPath = "";
+ byte [] buffer3 = Converter.wcsToMbcs (null, filterPath, true);
+ int xmStringPtr3 = OS.XmStringParseText (
+ buffer3,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ byte [] buffer7 = Converter.wcsToMbcs (null, "Selection", true);
+ int xmStringPtr4 = OS.XmStringParseText (
+ buffer7,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /* Create the dialog */
+ int [] argList1 = {
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNdialogStyle, OS.XmDIALOG_PRIMARY_APPLICATION_MODAL,
+ OS.XmNwidth, OS.XDisplayWidth (display, OS.XDefaultScreen (display)) * 4 / 9,
+ OS.XmNdialogTitle, xmStringPtr1,
+ OS.XmNpattern, xmStringPtr2,
+ OS.XmNdirectory, xmStringPtr3,
+ OS.XmNfilterLabelString, xmStringPtr4
+ };
+ /*
+ * Feature in Linux. For some reason, the XmCreateFileSelectionDialog()
+ * will not accept NULL for the widget name. This works fine on the other
+ * Motif platforms and in the other XmCreate calls on Linux. The fix is
+ * to pass in a NULL terminated string, not a NULL pointer.
+ */
+ byte [] name = new byte [] {0};
+ int dialog = OS.XmCreateFileSelectionDialog (parentHandle, name, argList1, argList1.length / 2);
+ int child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_HELP_BUTTON);
+ if (child != 0) OS.XtUnmanageChild (child);
+ child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST);
+ if (child != 0) {
+ int parent2 = OS.XtParent(child);
+ if (parent2 !=0) OS.XtUnmanageChild (parent2);
+ }
+ child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_LIST_LABEL);
+ if (child != 0) OS.XtUnmanageChild (child);
+ child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_TEXT);
+ if (child != 0) OS.XtUnmanageChild (child);
+ child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_SELECTION_LABEL);
+ if (child != 0) OS.XtUnmanageChild (child);
+ OS.XmStringFree (xmStringPtr1);
+ OS.XmStringFree (xmStringPtr2);
+ OS.XmStringFree (xmStringPtr3);
+ OS.XmStringFree (xmStringPtr4);
+
+ // Add label widget for message text.
+ byte [] buffer4 = Converter.wcsToMbcs (null, message, true);
+ int [] parseTable = Display.getDefault ().parseTable;
+ int xmString1 = OS.XmStringParseText (
+ buffer4,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ parseTable,
+ parseTable.length,
+ 0);
+ int [] argList = {
+ OS.XmNlabelType, OS.XmSTRING,
+ OS.XmNlabelString, xmString1
+ };
+ int textArea = OS.XmCreateLabel(dialog, name, argList, argList.length/2);
+ OS.XtManageChild(textArea);
+
+ /* Hook the callbacks. */
+ Callback callback = new Callback (this, "activate", 3);
+ int address = callback.getAddress ();
+ OS.XtAddCallback (dialog, OS.XmNokCallback, address, OS.XmDIALOG_OK_BUTTON);
+ OS.XtAddCallback (dialog, OS.XmNcancelCallback, address, OS.XmDIALOG_CANCEL_BUTTON);
+
+ /* Open the dialog and dispatch events. */
+ cancel = true;
+ OS.XtManageChild (dialog);
+
+//BOGUS - should be a pure OS message loop (no SWT AppContext)
+ while (OS.XtIsRealized (dialog) && OS.XtIsManaged (dialog))
+ if (!appContext.readAndDispatch ()) appContext.sleep ();
+
+ /* Set the new path, file name and filter. */
+ String directoryPath="";
+ if (!cancel) {
+ int [] argList2 = {OS.XmNdirMask, 0};
+ OS.XtGetValues (dialog, argList2, argList2.length / 2);
+ int xmString3 = argList2 [1];
+ int ptr = OS.XmStringUnparse (
+ xmString3,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (ptr != 0) {
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ OS.XtFree (ptr);
+ directoryPath = new String (Converter.mbcsToWcs (null, buffer));
+ }
+ OS.XmStringFree (xmString3);
+ int length = directoryPath.length ();
+ if (length != 0) {
+ if (directoryPath.charAt (length -1) == '/') {
+ directoryPath = directoryPath.substring (0, length - 1);
+ } else {
+ if (length > 1 && directoryPath.charAt (length - 2) == '/' && directoryPath.charAt (length - 1) == '*') {
+ directoryPath = directoryPath.substring (0, length - 2);
+ }
+ }
+ }
+ }
+
+ /* Destroy the dialog and update the display. */
+ if (OS.XtIsRealized (dialog)) OS.XtDestroyWidget (dialog);
+ if (destroyContext) appContext.dispose ();
+ callback.dispose ();
+
+// (shell == nil or: [shell isDestroyed not]) ifTrue: [dialog xtDestroyWidget].
+// OSWidget updateDisplay.
+// entryPoint unbind.
+
+ if (cancel) return null;
+ return directoryPath;
+}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+public void setMessage (String string) {
+ message = string;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
new file mode 100755
index 0000000000..a842c12ea9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
@@ -0,0 +1,1401 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* A display is the class used to represent a group of widgets
+* that are all running in a single thread. Display's implement
+* event dispatching and a synchronous/asynchronous communication
+* mechanism to allow widgets in this thread to be accessed from
+* another thread.
+*
+* A typical application will use multiple threads, but only
+* one display, and therefore only one thread that can directly
+* access widgets. Other threads are typically used to compute
+* a value and communuicate the result to the widget thread.
+* Often, the widget thread will present a user interface that
+* allows the user to cancel or restart a computation. When a
+* computation is performed in the widget thread, events for
+* that thread are not dispatch because the widget thread is
+* doing the compuation, not dispatching the events. In this
+* case, widgets in the thread will not redraw and will not be
+* selectable by the user. On some platforms, the entire user
+* interface for every running program becomes locked. For
+* this reason, it is advisable to run only short computations
+* in the widget thread.
+*
+*
+**/
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Display extends Device {
+
+ /* Motif Only Public Fields */
+ public XAnyEvent xEvent = new XAnyEvent ();
+
+ /* Windows, Events and Callbacks */
+ Callback windowCallback;
+ int windowProc, shellHandle;
+ static boolean XtInitialized;
+ static String APP_NAME = "SWT";
+ byte [] displayName, appName, appClass;
+ Event [] eventQueue;
+
+ /* Default Fonts, Colors, Insets, Widths and Heights. */
+ int defaultFont, defaultFontList;
+ int listFont, textFont, buttonFont, labelFont;
+ int dialogBackground, dialogForeground;
+ int buttonBackground, buttonForeground, buttonShadowThickness;
+ int compositeBackground, compositeForeground;
+ int compositeTopShadow, compositeBottomShadow, compositeBorder;
+ int listBackground, listForeground, textBackground, textForeground;
+ int labelBackground, labelForeground, scrollBarBackground, scrollBarForeground;
+ int scrolledInsetX, scrolledInsetY, scrolledMarginX, scrolledMarginY;
+ int defaultBackground, defaultForeground;
+ int textHighlightThickness;
+
+ /* System Colors */
+ XColor COLOR_WIDGET_DARK_SHADOW, COLOR_WIDGET_NORMAL_SHADOW, COLOR_WIDGET_LIGHT_SHADOW;
+ XColor COLOR_WIDGET_HIGHLIGHT_SHADOW, COLOR_WIDGET_BACKGROUND, COLOR_WIDGET_BORDER;
+ XColor COLOR_LIST_FOREGROUND, COLOR_LIST_BACKGROUND, COLOR_LIST_SELECTION, COLOR_LIST_SELECTION_TEXT;
+ Color COLOR_INFO_BACKGROUND;
+
+ /* 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;
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread = Thread.currentThread ();
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timerIDs;
+ Runnable [] timerList;
+ Callback timerCallback;
+ int timerProc;
+
+ /* Key Mappings. */
+ static int [] [] KeyTable = {
+
+ /* Keyboard and Mouse Masks */
+ {OS.XK_Alt_L, SWT.ALT},
+ {OS.XK_Alt_R, SWT.ALT},
+ {OS.XK_Shift_L, SWT.SHIFT},
+ {OS.XK_Shift_R, SWT.SHIFT},
+ {OS.XK_Control_L, SWT.CONTROL},
+ {OS.XK_Control_R, SWT.CONTROL},
+
+// {OS.VK_LBUTTON, SWT.BUTTON1},
+// {OS.VK_MBUTTON, SWT.BUTTON3},
+// {OS.VK_RBUTTON, SWT.BUTTON2},
+
+ /* Non-Numeric Keypad Constants */
+ {OS.XK_Up, SWT.ARROW_UP},
+ {OS.XK_Down, SWT.ARROW_DOWN},
+ {OS.XK_Left, SWT.ARROW_LEFT},
+ {OS.XK_Right, SWT.ARROW_RIGHT},
+ {OS.XK_Page_Up, SWT.PAGE_UP},
+ {OS.XK_Page_Down, SWT.PAGE_DOWN},
+ {OS.XK_Home, SWT.HOME},
+ {OS.XK_End, SWT.END},
+ {OS.XK_Insert, SWT.INSERT},
+// {OS.XK_Delete, SWT.DELETE},
+
+ /* Functions Keys */
+ {OS.XK_F1, SWT.F1},
+ {OS.XK_F2, SWT.F2},
+ {OS.XK_F3, SWT.F3},
+ {OS.XK_F4, SWT.F4},
+ {OS.XK_F5, SWT.F5},
+ {OS.XK_F6, SWT.F6},
+ {OS.XK_F7, SWT.F7},
+ {OS.XK_F8, SWT.F8},
+ {OS.XK_F9, SWT.F9},
+ {OS.XK_F10, SWT.F10},
+ {OS.XK_F11, SWT.F11},
+ {OS.XK_F12, SWT.F12},
+
+ /* Numeric Keypad Constants */
+ /*
+ {OS.XK_KP_Add, SWT.KP_PLUS},
+ {OS.XK_KP_Subtract, SWT.KP_MINUS},
+ {OS.XK_KP_Multiply, SWT.KP_TIMES},
+ {OS.XK_KP_Divide, SWT.KP_DIVIDE},
+ {OS.XK_KP_Decimal, SWT.KP_PERIOD},
+ {OS.XK_KP_Enter, SWT.KP_ENTER},
+ {OS.XK_KP_0, SWT.KP_0},
+ {OS.XK_KP_1, SWT.KP_1},
+ {OS.XK_KP_2, SWT.KP_2},
+ {OS.XK_KP_3, SWT.KP_3},
+ {OS.XK_KP_4, SWT.KP_4},
+ {OS.XK_KP_5, SWT.KP_5},
+ {OS.XK_KP_6, SWT.KP_6},
+ {OS.XK_KP_7, SWT.KP_7},
+ {OS.XK_KP_8, SWT.KP_8},
+ {OS.XK_KP_9, SWT.KP_9},
+ */
+ };
+
+ /* Multiple Displays. */
+ static Display Default;
+ static Display [] Displays = new Display [4];
+
+ /* Double Click */
+ int lastTime, lastButton;
+
+ /* Current caret */
+ Caret currentCaret;
+ Callback caretCallback;
+ int caretID, caretProc;
+
+ /* Workaround for GP when disposing a display */
+ static boolean DisplayDisposed;
+
+ /* Package name */
+ static final String PACKAGE_NAME;
+ static {
+ String name = Display.class.getName ();
+ int index = name.lastIndexOf ('.');
+ PACKAGE_NAME = name.substring (0, index + 1);
+ }
+
+ /* Mouse Hover */
+ Callback mouseHoverCallback;
+ int mouseHoverID, mouseHoverProc;
+ int mouseHoverHandle, toolTipHandle;
+
+ /* Parse Tables */
+ int [] parseTable;
+ int crPointer, tabPointer;
+
+ /* Xt Translations */
+ int arrowTranslations, tabTranslations;
+
+ /* Check Expose Proc */
+ Callback checkExposeCallback;
+ int checkExposeProc;
+ int exposeCount;
+
+ /* Sleeping */
+ int sleepID;
+ Callback sleepCallback;
+ int sleepProc;
+
+ /* Display Data */
+ Object data;
+ String [] keys;
+ Object [] values;
+
+public Display () {
+ this (null);
+}
+public Display (DeviceData data) {
+ super (checkNull (data));
+}
+static DeviceData checkNull (DeviceData data) {
+ if (data == null) data = new DeviceData ();
+ if (data.application_name == null) {
+ data.application_name = APP_NAME;
+ }
+ if (data.application_class == null) {
+ data.application_class = APP_NAME;
+ }
+ return data;
+}
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+void addMouseHoverTimeOut (int handle) {
+ if (mouseHoverID != 0) OS.XtRemoveTimeOut (mouseHoverID);
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ mouseHoverID = OS.XtAppAddTimeOut (xtContext, 400, mouseHoverProc, handle);
+ mouseHoverHandle = handle;
+}
+public void asyncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.asyncExec (runnable);
+}
+public void beep () {
+ checkDevice ();
+ OS.XBell (xDisplay, 100);
+ OS.XFlush (xDisplay);
+}
+int caretProc (int clientData, int id) {
+ caretID = 0;
+ if (currentCaret == null) return 0;
+ if (currentCaret.blinkCaret ()) {
+ int blinkRate = currentCaret.blinkRate;
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ caretID = OS.XtAppAddTimeOut (xtContext, blinkRate, caretProc, 0);
+ } else {
+ currentCaret = null;
+ }
+ return 0;
+}
+int checkExposeProc (int display, int event, int window) {
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, event, XExposeEvent.sizeof);
+ if (xEvent.window == window) {
+ if (xEvent.type == OS.Expose || xEvent.type == OS.GraphicsExpose) {
+ exposeCount++;
+ }
+ }
+ return 0;
+}
+synchronized void checkDisplay () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+protected void checkSubclass () {
+ if (!Display.isValidClass (getClass ())) {
+ error (SWT.ERROR_INVALID_SUBCLASS);
+ }
+}
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay ();
+ createDisplay (data);
+ register ();
+ if (Default == null) Default = this;
+}
+void createDisplay (DeviceData data) {
+
+ /* Initialize X and Xt */
+ synchronized (Display.class) {
+ if (!XtInitialized) {
+ OS.XInitThreads ();
+ OS.XtToolkitThreadInitialize ();
+ OS.XtToolkitInitialize ();
+
+ /* Bug in XpExtention. If XInitThreads is called before
+ * any Xp functions then XpCheckExtInit hangs. The workaround
+ * is to create the printer display before calling XInitThreads.
+ */
+// int xtContext = OS.XtCreateApplicationContext ();
+// byte[] buffer = Converter.wcsToMbcs ( null, Device.XDefaultPrintServer, true );
+// xPrinter = OS.XtOpenDisplay (xtContext, buffer, null, null, 0, 0, new int [] {0}, 0);
+// if (xPrinter != 0) {
+// OS.XpQueryVersion (xPrinter, new short [1], new short [1]);
+// }
+// //OS.XInitThreads ();
+ }
+ XtInitialized = true;
+ }
+
+ /* Create the AppContext */
+ int [] argc = new int [] {0};
+ int xtContext = OS.XtCreateApplicationContext ();
+ OS.XtSetLanguageProc (xtContext, 0, 0);
+
+ /* Compute the display name, application name and class */
+ String display_name = null;
+ String application_name = APP_NAME;
+ String application_class = APP_NAME;
+ if (data != null) {
+ if (data.display_name != null) display_name = data.display_name;
+ if (data.application_name != null) application_name = data.application_name;
+ if (data.application_class != null) application_class = data.application_class;
+ }
+ if (display_name != null) displayName = Converter.wcsToMbcs (null, display_name, true);
+ if (application_name != null) appName = Converter.wcsToMbcs (null, application_name, true);
+ if (application_class != null) appClass = Converter.wcsToMbcs (null, application_class, true);
+
+ /* Create the XDisplay */
+ xDisplay = OS.XtOpenDisplay (xtContext, displayName, appName, appClass, 0, 0, argc, 0);
+ DisplayDisposed = false;
+}
+synchronized void deregister () {
+ for (int i=0; i<Displays.length; i++) {
+ if (this == Displays [i]) Displays [i] = null;
+ }
+}
+protected void destroy () {
+ if (this == Default) Default = null;
+ deregister ();
+ destroyDisplay ();
+}
+void destroyDisplay () {
+ /*
+ * Destroy AppContext (this destroys the display)
+ */
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ OS.XtDestroyApplicationContext (xtContext);
+ DisplayDisposed = true;
+}
+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;
+}
+void error (int code) {
+ SWT.error(code);
+}
+boolean filterEvent (XAnyEvent event) {
+
+ /* Check the event and find the widget */
+ if (event.type != OS.KeyPress) return false;
+ if (OS.XFilterEvent(event, OS.None)) return true;
+ XKeyEvent keyEvent = new XKeyEvent ();
+
+ /* Move the any event into the key event */
+ OS.memmove (keyEvent, event, XAnyEvent.sizeof);
+ if (keyEvent.keycode == 0) return false;
+ int xWindow = keyEvent.window;
+ if (xWindow == 0) return false;
+ int handle = OS.XtWindowToWidget (xDisplay, xWindow);
+ if (handle == 0) return false;
+ handle = OS.XmGetFocusWidget (handle);
+ if (handle == 0) return false;
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return false;
+ if (!(widget instanceof Control)) return false;
+ Control control = (Control) widget;
+
+ /* Get the unaffected character and keysym */
+ int oldState = keyEvent.state;
+ keyEvent.state = 0;
+ byte [] buffer1 = new byte [4];
+ int [] buffer2 = new int [1];
+ int key = 0;
+ if (OS.XLookupString (keyEvent, buffer1, 1, buffer2, null) != 0) {
+ key = buffer1 [0] & 0xFF;
+ }
+ int keysym = buffer2 [0] & 0xFFFF;
+ keyEvent.state = oldState;
+
+ /* Check for a mnemonic key */
+ if (key != 0) {
+ if (control.translateMnemonic (key, keyEvent)) return true;
+ }
+
+ /* Check for a traversal key */
+ if (keysym == 0) return false;
+ if (keysym == OS.XK_Escape || keysym == OS.XK_Cancel ||
+ keysym == OS.XK_Tab || keysym == OS.XK_Return ||
+ keysym == OS.XK_Up || keysym == OS.XK_Down ||
+ keysym == OS.XK_Left || keysym == OS.XK_Right) {
+ if (control.translateTraversal (keysym, keyEvent)) return true;
+ }
+
+ /* Answer false because the event was not processed */
+ return false;
+}
+public Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+public Shell getActiveShell () {
+ checkDevice ();
+ Control control = getFocusControl ();
+ if (control == null) return null;
+ return control.getShell ();
+}
+public static synchronized Display getCurrent () {
+ return findDisplay (Thread.currentThread ());
+}
+public static synchronized Display findDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ Display display = Displays [i];
+ if (display != null && display.thread == thread) {
+ return display;
+ }
+ }
+ return null;
+}
+public Control getCursorControl () {
+ checkDevice ();
+ int [] unused = new int [1], buffer = new int [1];
+ int xWindow, xParent = OS.XDefaultRootWindow (xDisplay);
+ do {
+ if (OS.XQueryPointer (
+ xDisplay, xParent, unused, buffer,
+ unused, unused, unused, unused, unused) == 0) return null;
+ if ((xWindow = buffer [0]) != 0) xParent = xWindow;
+ } while (xWindow != 0);
+ int handle = OS.XtWindowToWidget (xDisplay, xParent);
+ if (handle == 0) return null;
+ do {
+ Widget widget = WidgetTable.get (handle);
+ if (widget != null && widget instanceof Control) {
+ Control control = (Control) widget;
+ if (control.getEnabled ()) return control;
+ }
+ } while ((handle = OS.XtParent (handle)) != 0);
+ return null;
+}
+public Point getCursorLocation () {
+ checkDevice ();
+ int window = OS.XDefaultRootWindow (xDisplay);
+ int [] rootX = new int [1];
+ int [] rootY = new int [1];
+ int [] unused = new int [1];
+ OS.XQueryPointer(xDisplay, window, unused, unused, rootX, rootY, unused, unused, unused);
+ return new Point (rootX [0], rootY [0]);
+}
+public static synchronized Display getDefault () {
+ if (Default == null) Default = new Display ();
+ return Default;
+}
+public Object getData (String key) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (keys == null) return null;
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) return values [i];
+ }
+ return null;
+}
+public Object getData () {
+ checkDevice ();
+ return data;
+}
+public int getDoubleClickTime () {
+ checkDevice ();
+ return OS.XtGetMultiClickTime (xDisplay);
+}
+public Control getFocusControl () {
+ checkDevice ();
+ int [] buffer1 = new int [1], buffer2 = new int [1];
+ OS.XGetInputFocus (xDisplay, buffer1, buffer2);
+ int xWindow = buffer1 [0];
+ if (xWindow == 0) return null;
+ int handle = OS.XtWindowToWidget (xDisplay, xWindow);
+ if (handle == 0) return null;
+ handle = OS.XmGetFocusWidget (handle);
+ if (handle == 0) return null;
+ do {
+ Widget widget = WidgetTable.get (handle);
+ if (widget != null && widget instanceof Control) {
+ Control window = (Control) widget;
+ if (window.getEnabled ()) return window;
+ }
+ } while ((handle = OS.XtParent (handle)) != 0);
+ return null;
+}
+public int getIconDepth () {
+ return getDepth ();
+}
+public Shell [] getShells () {
+ checkDevice ();
+ /*
+ * NOTE: Need to check that the shells that belong
+ * to another display have not been disposed by the
+ * other display's thread as the shells list is being
+ * processed.
+ */
+ int count = 0;
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ count++;
+ }
+ }
+ if (count == shells.length) return shells;
+ int index = 0;
+ Shell [] result = new Shell [count];
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ result [index++] = shell;
+ }
+ }
+ return result;
+}
+/**
+ * Returns the thread that has invoked <code>syncExec</code>
+ * or <code>asyncExec</code>, or null if no such runnable is
+ * currently being invoked by the user-interface thread.
+ *
+ * @return the receiver's sync/async-interface thread
+ */
+public Thread getSyncThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return synchronizer.syncThread;
+}
+/**
+* Get a system color
+*
+* RETURNS
+*
+* A color that corresponds to a system color.
+*
+* REMARKS
+*
+* This method returns the color corresponding to a
+* system color constant. All system color constants
+* begin with the prefix COLOR_.
+*
+**/
+public Color getSystemColor (int id) {
+ checkDevice ();
+ XColor xColor = null;
+ switch (id) {
+ case SWT.COLOR_INFO_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
+ case SWT.COLOR_INFO_BACKGROUND: return COLOR_INFO_BACKGROUND;
+ case SWT.COLOR_TITLE_FOREGROUND: return super.getSystemColor (SWT.COLOR_WHITE);
+ case SWT.COLOR_TITLE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_BLUE);
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_BLUE);
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: return super.getSystemColor (SWT.COLOR_BLACK);
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: return super.getSystemColor (SWT.COLOR_DARK_GRAY);
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: return super.getSystemColor (SWT.COLOR_GRAY);
+ case SWT.COLOR_WIDGET_DARK_SHADOW: xColor = COLOR_WIDGET_DARK_SHADOW; break;
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: xColor = COLOR_WIDGET_NORMAL_SHADOW; break;
+ case SWT.COLOR_WIDGET_LIGHT_SHADOW: xColor = COLOR_WIDGET_LIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: xColor = COLOR_WIDGET_HIGHLIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_BACKGROUND: xColor = COLOR_WIDGET_BACKGROUND; break;
+ case SWT.COLOR_WIDGET_FOREGROUND:
+ case SWT.COLOR_WIDGET_BORDER: xColor = COLOR_WIDGET_BORDER; break;
+ case SWT.COLOR_LIST_FOREGROUND: xColor = COLOR_LIST_FOREGROUND; break;
+ case SWT.COLOR_LIST_BACKGROUND: xColor = COLOR_LIST_BACKGROUND; break;
+ case SWT.COLOR_LIST_SELECTION: xColor = COLOR_LIST_SELECTION; break;
+ case SWT.COLOR_LIST_SELECTION_TEXT: xColor = COLOR_LIST_SELECTION_TEXT; break;
+ default:
+ return super.getSystemColor (id);
+ }
+ if (xColor == null) return super.getSystemColor (SWT.COLOR_BLACK);
+ return Color.motif_new (this, xColor);
+}
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.motif_new (this, defaultFontList);
+}
+public Thread getThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+}
+void hideToolTip () {
+ if (toolTipHandle != 0) {
+ int shellHandle = OS.XtParent(toolTipHandle);
+ OS.XtDestroyWidget(shellHandle);
+ }
+ toolTipHandle = 0;
+}
+protected void init () {
+ super.init ();
+ initializeDisplay ();
+ initializeButton ();
+ initializeComposite ();
+ initializeDialog ();
+ initializeLabel ();
+ initializeList ();
+ initializeScrollBar ();
+ initializeText ();
+ initializeSystemColors ();
+ initializeDefaults ();
+ initializeParseTable ();
+ initializeTranslations ();
+}
+void initializeButton () {
+
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+
+ /* Get the push button information */
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreatePushButton (shellHandle, null, null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {
+ OS.XmNforeground, 0, /* 1 */
+ OS.XmNbackground, 0, /* 3 */
+ OS.XmNshadowThickness, 0, /* 5 */
+ OS.XmNfontList, 0, /* 7 */
+ };
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ buttonForeground = argList [1]; buttonBackground = argList [3];
+ buttonShadowThickness = argList [5];
+ /**
+ * Feature in Motif. Querying the font list from the widget and
+ * then destroying the shell (and the widget) could cause the
+ * font list to be freed as well. The fix is to make a copy of
+ * the font list, then to free it when the display is disposed.
+ */
+ buttonFont = OS.XmFontListCopy (argList [7]);
+ OS.XtDestroyWidget (shellHandle);
+}
+void initializeComposite () {
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ int shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ int scrolledHandle = OS.XmCreateMainWindow (shellHandle, null, null, 0);
+ int [] argList1 = {OS.XmNorientation, OS.XmHORIZONTAL};
+ int hScrollHandle = OS.XmCreateScrollBar (scrolledHandle, null, argList1, argList1.length / 2);
+ OS.XtManageChild (hScrollHandle);
+ int [] argList2 = {OS.XmNorientation, OS.XmVERTICAL};
+ int vScrollHandle = OS.XmCreateScrollBar (scrolledHandle, null, argList2, argList2.length / 2);
+ OS.XtManageChild (vScrollHandle);
+ OS.XtManageChild (scrolledHandle);
+ int [] argList5 = {
+ OS.XmNmarginWidth, 3,
+ OS.XmNmarginHeight, 3,
+ };
+ int formHandle = OS.XmCreateForm (scrolledHandle, null, argList5, argList5.length / 2);
+ OS.XtManageChild (formHandle);
+ int [] argList6 = {
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNtopAttachment, OS.XmATTACH_FORM,
+ OS.XmNbottomAttachment, OS.XmATTACH_FORM,
+ OS.XmNleftAttachment, OS.XmATTACH_FORM,
+ OS.XmNrightAttachment, OS.XmATTACH_FORM,
+ };
+ int widgetHandle = OS.XmCreateDrawingArea (formHandle, null, argList6, argList6.length / 2);
+ OS.XtManageChild (widgetHandle);
+ OS.XmMainWindowSetAreas (scrolledHandle, 0, 0, hScrollHandle, vScrollHandle, formHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ int screen = OS.XDefaultScreen (xDisplay);
+ OS.XtResizeWidget (shellHandle, OS.XDisplayWidth (xDisplay, screen), OS.XDisplayHeight (xDisplay, screen), 0);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList3 = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (scrolledHandle, argList3, argList3.length / 2);
+ int [] argList8 = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (formHandle, argList8, argList8.length / 2);
+ int [] argList4 = {
+ OS.XmNx, 0, /* 1 */
+ OS.XmNy, 0, /* 3 */
+ OS.XmNwidth, 0, /* 5 */
+ OS.XmNheight, 0, /* 7 */
+ OS.XmNforeground, 0, /* 9 */
+ OS.XmNbackground, 0, /* 11 */
+ OS.XmNtopShadowColor, 0, /* 13 */
+ OS.XmNbottomShadowColor, 0, /* 15 */
+ OS.XmNborderColor, 0, /* 17 */
+ };
+ OS.XtGetValues (widgetHandle, argList4, argList4.length / 2);
+ scrolledInsetX = argList4 [1] + argList8 [1];
+ scrolledInsetY = argList4 [3] + argList8 [3];
+ scrolledMarginX = argList3 [1] - argList8 [1] - argList4 [1] - argList4 [5];
+ scrolledMarginY = argList3 [3] - argList8 [3] - argList4 [3] - argList4 [7];
+ compositeForeground = argList4 [9]; compositeBackground = argList4 [11];
+ compositeTopShadow = argList4 [13]; compositeBottomShadow = argList4 [15];
+ compositeBorder = argList4 [17];
+ OS.XtDestroyWidget (shellHandle);
+}
+void initializeDefaults () {
+ defaultFontList = labelFont;
+ defaultForeground = compositeForeground;
+ defaultBackground = compositeBackground;
+
+ /**
+ * Initialize the default font id to the first
+ * font in the default font list
+ */
+ int [] buffer = new int [1];
+ if (!OS.XmFontListInitFontContext (buffer, defaultFontList)) {
+ return;
+ }
+ int context = buffer [0];
+ XFontStruct fontStruct = new XFontStruct ();
+ int [] fontStructPtr = new int [1];
+ int [] fontNamePtr = new int [1];
+
+ /* Take the first entry from the font list */
+ int fontListEntry = OS.XmFontListNextEntry (context);
+ int fontPtr = OS.XmFontListEntryGetFont (fontListEntry, buffer);
+ if (buffer [0] == 0) {
+ /* FontList contains a single font */
+ OS.memmove (fontStruct, fontPtr, XFontStruct.sizeof);
+ defaultFont = fontStruct.fid;
+ } else {
+ /* FontList contains a fontSet */
+ /* Take the first font in the font set */
+ int nFonts = OS.XFontsOfFontSet (fontPtr, fontStructPtr, fontNamePtr);
+ if (nFonts > 0) {
+ int [] fontStructs = new int [1];
+ OS.memmove (fontStructs, fontStructPtr [0], 4);
+ OS.memmove (fontStruct, fontStructs [0], XFontStruct.sizeof);
+ defaultFont = fontStruct.fid;
+ }
+ }
+ OS.XmFontListFreeFontContext (context);
+}
+void initializeDialog () {
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreateDialogShell (shellHandle, null, null, 0);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ dialogForeground = argList [1]; dialogBackground = argList [3];
+ OS.XtDestroyWidget (shellHandle);
+}
+void initializeDisplay () {
+
+ /* Create the callbacks */
+ windowCallback = new Callback (this, "windowProc", 4);
+ windowProc = windowCallback.getAddress ();
+ if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ timerCallback = new Callback (this, "timerProc", 2);
+ timerProc = timerCallback.getAddress ();
+ if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ caretCallback = new Callback (this, "caretProc", 2);
+ caretProc = caretCallback.getAddress ();
+ if (caretProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ mouseHoverCallback = new Callback (this, "mouseHoverProc", 2);
+ mouseHoverProc = mouseHoverCallback.getAddress ();
+ if (mouseHoverProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ checkExposeCallback = new Callback (this, "checkExposeProc", 3);
+ checkExposeProc = checkExposeCallback.getAddress ();
+ if (checkExposeProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ sleepCallback = new Callback (this, "sleepProc", 2);
+ sleepProc = sleepCallback.getAddress ();
+ if (sleepProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ /*
+ * Use dynamic Drag and Drop Protocol styles.
+ * Preregistered protocol is not supported.
+ */
+ int xmDisplay = OS.XmGetXmDisplay (xDisplay);
+ int [] args = new int [] {
+ OS.XmNdragInitiatorProtocolStyle, OS.XmDRAG_DYNAMIC,
+ OS.XmNdragReceiverProtocolStyle, OS.XmDRAG_DYNAMIC,
+ };
+ OS.XtSetValues (xmDisplay, args, args.length / 2);
+
+ /* Create the hidden Override shell parent */
+ int xScreen = OS.XDefaultScreen (xDisplay);
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtResizeWidget (shellHandle, OS.XDisplayWidth (xDisplay, xScreen), OS.XDisplayHeight (xDisplay, xScreen), 0);
+ OS.XtRealizeWidget (shellHandle);
+
+ /*
+ * Bug in MOTIF. For some reason, calls to XmGetPixmap ()
+ * and XmGetPixmapByDepth fail to find the pixmap unless at
+ * least one message box has been created. The fix is to
+ * create and destroy a message box.
+ */
+// int dialog = OS.XmCreateInformationDialog (shellHandle, null, null, 0);
+// OS.XtDestroyWidget (dialog);
+}
+void initializeLabel () {
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreateLabel (shellHandle, null, null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ labelForeground = argList [1]; labelBackground = argList [3];
+ /**
+ * Feature in Motif. Querying the font list from the widget and
+ * then destroying the shell (and the widget) could cause the
+ * font list to be freed as well. The fix is to make a copy of
+ * the font list, then to free it when the display is disposed.
+ */
+ labelFont = OS.XmFontListCopy (argList [5]);
+ OS.XtDestroyWidget (shellHandle);
+}
+void initializeList () {
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreateScrolledList (shellHandle, null, null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ listForeground = argList [1];
+ listBackground = argList [3];
+ /**
+ * Feature in Motif. Querying the font list from the widget and
+ * then destroying the shell (and the widget) could cause the
+ * font list to be freed as well. The fix is to make a copy of
+ * the font list, then to free it when the display is disposed.
+ */
+ listFont = OS.XmFontListCopy (argList [5]);
+ OS.XtDestroyWidget (shellHandle);
+}
+void initializeParseTable () {
+ byte[] tabBuffer = {(byte) '\t', 0};
+ tabPointer = OS.XtMalloc (tabBuffer.length);
+ OS.memmove (tabPointer, tabBuffer, tabBuffer.length);
+ int tabString = OS.XmStringComponentCreate(OS.XmSTRING_COMPONENT_TAB, 0, null);
+ int [] argList = {
+ OS.XmNpattern, tabPointer,
+ OS.XmNsubstitute, tabString,
+ };
+ int tabMapping = OS.XmParseMappingCreate(argList, argList.length / 2);
+ OS.XmStringFree(tabString);
+
+ byte[] crBuffer = {(byte) '\n', 0};
+ crPointer = OS.XtMalloc (crBuffer.length);
+ OS.memmove (crPointer, crBuffer, crBuffer.length);
+ int crString = OS.XmStringComponentCreate(OS.XmSTRING_COMPONENT_SEPARATOR, 0, null);
+ argList = new int[] {
+ OS.XmNpattern, crPointer,
+ OS.XmNsubstitute, crString,
+ };
+ int crMapping = OS.XmParseMappingCreate(argList, argList.length / 2);
+ OS.XmStringFree(crString);
+
+ parseTable = new int[2];
+ parseTable[0] = tabMapping;
+ parseTable[1] = crMapping;
+}
+void initializeScrollBar () {
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreateScrollBar (shellHandle, null, null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ scrollBarForeground = argList [1]; scrollBarBackground = argList [3];
+ OS.XtDestroyWidget (shellHandle);
+}
+void initializeSystemColors () {
+ int [] argList = {OS.XmNcolormap, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ int colormap = argList [1];
+
+ COLOR_WIDGET_DARK_SHADOW = new XColor();
+ COLOR_WIDGET_DARK_SHADOW.pixel = compositeBottomShadow;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_DARK_SHADOW);
+
+ COLOR_WIDGET_NORMAL_SHADOW = new XColor();
+ COLOR_WIDGET_NORMAL_SHADOW.pixel = compositeBottomShadow;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_NORMAL_SHADOW);
+
+ COLOR_WIDGET_LIGHT_SHADOW = new XColor();
+ COLOR_WIDGET_LIGHT_SHADOW.pixel = compositeTopShadow;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_LIGHT_SHADOW);
+
+ COLOR_WIDGET_HIGHLIGHT_SHADOW = new XColor();
+ COLOR_WIDGET_HIGHLIGHT_SHADOW.pixel = compositeTopShadow;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_HIGHLIGHT_SHADOW);
+
+ COLOR_WIDGET_BACKGROUND = new XColor();
+ COLOR_WIDGET_BACKGROUND.pixel = compositeBackground;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_BACKGROUND);
+
+ COLOR_WIDGET_BORDER = new XColor();
+ COLOR_WIDGET_BORDER.pixel = compositeBorder;
+ OS.XQueryColor (xDisplay, colormap, COLOR_WIDGET_BORDER);
+
+ COLOR_LIST_FOREGROUND = new XColor();
+ COLOR_LIST_FOREGROUND.pixel = listForeground;
+ OS.XQueryColor (xDisplay, colormap, COLOR_LIST_FOREGROUND);
+
+ COLOR_LIST_BACKGROUND = new XColor();
+ COLOR_LIST_BACKGROUND.pixel = listBackground;
+ OS.XQueryColor (xDisplay, colormap, COLOR_LIST_BACKGROUND);
+
+ COLOR_LIST_SELECTION = new XColor();
+ COLOR_LIST_SELECTION.pixel = listForeground;
+ OS.XQueryColor (xDisplay, colormap, COLOR_LIST_SELECTION);
+
+ COLOR_LIST_SELECTION_TEXT = new XColor();
+ COLOR_LIST_SELECTION_TEXT.pixel = listBackground;
+ OS.XQueryColor (xDisplay, colormap, COLOR_LIST_SELECTION_TEXT);
+
+ COLOR_INFO_BACKGROUND = new Color (this, 0xFF, 0xFF, 0xE1);
+}
+void initializeText () {
+ int shellHandle, widgetHandle;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (appName, appClass, widgetClass, xDisplay, null, 0);
+ widgetHandle = OS.XmCreateScrolledText (shellHandle, null, null, 0);
+ OS.XtManageChild (widgetHandle);
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ OS.XtRealizeWidget (shellHandle);
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0, OS.XmNfontList, 0, OS.XmNhighlightThickness, 0};
+ OS.XtGetValues (widgetHandle, argList, argList.length / 2);
+ textForeground = argList [1]; textBackground = argList [3];
+ textHighlightThickness = argList[7];
+ /**
+ * Feature in Motif. Querying the font list from the widget and
+ * then destroying the shell (and the widget) could cause the
+ * font list to be freed as well. The fix is to make a copy of
+ * the font list, then to free it when the display is disposed.
+ */
+ textFont = OS.XmFontListCopy (argList [5]);
+ OS.XtDestroyWidget (shellHandle);
+
+}
+void initializeTranslations () {
+ byte [] buffer1 = Converter.wcsToMbcs (null, "<Key>osfUp:\n<Key>osfDown:\n<Key>osfLeft:\n<Key>osfRight:\0");
+ arrowTranslations = OS.XtParseTranslationTable (buffer1);
+ byte [] buffer2 = Converter.wcsToMbcs (null, "~Meta ~Alt <Key>Tab:\nShift ~Meta ~Alt <Key>Tab:\0");
+ tabTranslations = OS.XtParseTranslationTable (buffer2);
+// byte [] buffer3 = Converter.wcsToMbcs (null, "<Btn2Down>\0");
+// overrideDragTranslations = OS.XtParseTranslationTable (buffer3);
+}
+public int internal_new_GC (GCData data) {
+ int xDrawable = OS.XDefaultRootWindow (xDisplay);
+ int xGC = OS.XCreateGC (xDisplay, xDrawable, 0, null);
+ if (xGC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ OS.XSetSubwindowMode (xDisplay, xGC, OS.IncludeInferiors);
+ if (data != null) {
+ data.device = this;
+ data.display = xDisplay;
+ data.drawable = xDrawable;
+ data.fontList = defaultFontList;
+ data.colormap = OS.XDefaultColormap (xDisplay, OS.XDefaultScreen (xDisplay));
+ }
+ return xGC;
+}
+public void internal_dispose_GC (int gc, GCData data) {
+ OS.XFreeGC(xDisplay, gc);
+}
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+static boolean isValidClass (Class clazz) {
+ String name = clazz.getName ();
+ int index = name.lastIndexOf ('.');
+ return name.substring (0, index + 1).equals (PACKAGE_NAME);
+}
+int mouseHoverProc (int handle, int id) {
+ mouseHoverID = mouseHoverHandle = 0;
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.processMouseHover(id);
+}
+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;
+}
+public boolean readAndDispatch () {
+ checkDevice ();
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ int status = OS.XtAppPending (xtContext);
+ if (status != 0) {
+ if ((status & OS.XtIMTimer) != 0) {
+ OS.XtAppProcessEvent (xtContext, OS.XtIMTimer);
+ runAsyncMessages ();
+ }
+ if ((status & OS.XtIMAlternateInput) != 0) {
+ OS.XtAppProcessEvent (xtContext, OS.XtIMAlternateInput);
+ }
+ if ((status & OS.XtIMXEvent) != 0) {
+ OS.XtAppNextEvent (xtContext, xEvent);
+ if (filterEvent (xEvent)) return false;
+ OS.XtDispatchEvent (xEvent);
+ }
+ runDeferredEvents ();
+ return true;
+ }
+ return runAsyncMessages ();
+}
+synchronized void register () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] == null) {
+ Displays [i] = this;
+ return;
+ }
+ }
+ Display [] newDisplays = new Display [Displays.length + 4];
+ System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+ newDisplays [Displays.length] = this;
+ Displays = newDisplays;
+}
+protected void release () {
+ super.release ();
+
+ /* Release shells */
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ if (this == shell.getDisplay ()) shell.dispose ();
+ }
+ }
+ while (readAndDispatch ()) {};
+
+ /* Run dispose list */
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+
+ /* Release synchronizer */
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+ releaseDisplay ();
+}
+void releaseDisplay () {
+ /* Dispose the caret callback */
+ if (caretID != 0) OS.XtRemoveTimeOut (caretID);
+ caretID = caretProc = 0;
+ caretCallback.dispose ();
+ caretCallback = null;
+
+ /* Dispose the timer callback */
+ if (timerIDs != null) {
+ for (int i=0; i<=timerIDs.length; i++) {
+ OS.XtRemoveTimeOut (timerIDs [i]);
+ }
+ }
+ timerIDs = null;
+ timerList = null;
+ timerProc = 0;
+ timerCallback.dispose ();
+ timerCallback = null;
+
+ /* Dispose the mouse hover callback */
+ if (mouseHoverID != 0) OS.XtRemoveTimeOut (mouseHoverID);
+ mouseHoverID = mouseHoverProc = mouseHoverHandle = toolTipHandle = 0;
+ mouseHoverCallback.dispose ();
+ mouseHoverCallback = null;
+
+ /* Dispose the sleep callback */
+ if (sleepID != 0) OS.XtRemoveTimeOut (sleepID);
+ sleepID = sleepProc = 0;
+ sleepCallback.dispose ();
+ sleepCallback = null;
+
+ /* Dispose window and expose callbacks */
+ windowCallback.dispose (); windowCallback = null;
+ checkExposeCallback.dispose (); checkExposeCallback = null;
+ checkExposeProc = 0;
+
+ /* Free the font lists */
+ if (buttonFont != 0) OS.XmFontListFree (buttonFont);
+ if (labelFont != 0) OS.XmFontListFree (labelFont);
+ if (textFont != 0) OS.XmFontListFree (textFont);
+ if (listFont != 0) OS.XmFontListFree (listFont);
+ listFont = textFont = labelFont = buttonFont = 0;
+ defaultFontList = defaultFont = 0;
+
+ /* Free the parse table */
+ OS.XtFree(tabPointer);
+ OS.XtFree(crPointer);
+ OS.XmParseTableFree(parseTable, parseTable.length);
+ parseTable = null;
+
+ /* Free the translations (no documentation describes how to do this) */
+ //OS.XtFree (arrowTranslations);
+ //OS.XtFree (tabTranslations);
+
+ /* Destroy the hidden Override shell parent */
+ if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+ shellHandle = 0;
+
+ /* Release references */
+ thread = null;
+ xEvent = null;
+ buttonBackground = buttonForeground = 0;
+ defaultBackground = defaultForeground = 0;
+ 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 = null;
+ COLOR_INFO_BACKGROUND = null;
+}
+void releaseToolTipHandle (int handle) {
+ if (mouseHoverHandle == handle) removeMouseHoverTimeOut ();
+ if (toolTipHandle != 0) {
+ int shellHandle = OS.XtParent(toolTipHandle);
+ int shellParent = OS.XtParent(shellHandle);
+ if (handle == shellParent) {
+ toolTipHandle = 0;
+ }
+ }
+}
+void removeMouseHoverTimeOut () {
+ if (mouseHoverID != 0) OS.XtRemoveTimeOut (mouseHoverID);
+ mouseHoverID = mouseHoverHandle = 0;
+}
+boolean runAsyncMessages () {
+ return synchronizer.runAsyncMessages ();
+}
+boolean runDeferredEvents () {
+ /*
+ * Run deferred events. This code is always
+ * called in the Display's thread so it must
+ * be re-enterant 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.notifyListeners (event.type, 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;
+}
+public static void setAppName (String name) {
+ APP_NAME = name;
+}
+void setCurrentCaret (Caret caret) {
+ if (caretID != 0) OS.XtRemoveTimeOut (caretID);
+ caretID = 0;
+ currentCaret = caret;
+ if (currentCaret != null) {
+ int blinkRate = currentCaret.blinkRate;
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ caretID = OS.XtAppAddTimeOut (xtContext, blinkRate, caretProc, 0);
+ }
+}
+public void setData (String key, Object value) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* 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;
+}
+public void setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+public void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+void showToolTip (int handle, String toolTipText) {
+ if (toolTipText == null || toolTipText.length() == 0 || toolTipHandle != 0) {
+ return;
+ }
+
+ /* Create the tooltip widgets. */
+ int widgetClass = OS.OverrideShellWidgetClass ();
+ int [] argList = {OS.XmNmwmDecorations, 0, OS.XmNborderWidth, 1};
+ int shellHandle = OS.XtCreatePopupShell (null, widgetClass, handle, argList, argList.length / 2);
+ toolTipHandle = OS.XmCreateLabel(shellHandle, null, null, 0);
+
+ /* Set the tooltip foreground and background. */
+ Color infoForeground = getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ Color infoBackground = getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ int foregroundPixel = (infoForeground == null) ? defaultForeground : infoForeground.handle.pixel;
+ int backgroundPixel = (infoBackground == null) ? defaultBackground : infoBackground.handle.pixel;
+ int [] argList2 = {OS.XmNforeground, foregroundPixel, OS.XmNbackground, backgroundPixel};
+ OS.XtSetValues (toolTipHandle, argList2, argList2.length / 2);
+ OS.XtManageChild(toolTipHandle);
+
+ /* Set the tooltip label string. */
+ byte [] buffer = Converter.wcsToMbcs (null, toolTipText, true);
+ int xmString = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ int [] argList3 = {OS.XmNlabelString, xmString};
+ OS.XtSetValues (toolTipHandle, argList3, argList3.length / 2);
+ if (xmString != 0) OS.XmStringFree (xmString);
+
+ /* Position and popup the tooltip. */
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ int [] rootX = new int [1], rootY = new int [1], unused = new int [1];
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, rootX, rootY, unused, unused, unused);
+
+ /*
+ * Feature in X. There is no way to query the size of a cursor.
+ * The fix is to use the default cursor size which is 16x16.
+ */
+ int x = rootX [0] + 16, y = rootY [0] + 16;
+ OS.XtMoveWidget (shellHandle, x, y);
+ OS.XtPopup (shellHandle, OS.XtGrabNone);
+}
+public boolean sleep () {
+ checkDevice ();
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ /*
+ * Bug in Motif. For some reason, when a time out
+ * is added from another thread while the display
+ * thread inside of a call-in, it fails to wake up
+ * the display event thread. The fix is to limit
+ * the maximum time spent waiting for an event.
+ */
+ sleepID = OS.XtAppAddTimeOut (xtContext, 50, sleepProc, 0);
+ boolean result = OS.XtAppPeekEvent (xtContext, xEvent);
+ if (sleepID != 0) OS.XtRemoveTimeOut (sleepID);
+ sleepID = 0;
+ return result;
+}
+int sleepProc (int index, int id) {
+ sleepID = 0;
+ return 0;
+}
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+public void timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (timerList == null) timerList = new Runnable [4];
+ if (timerIDs == null) timerIDs = new int [4];
+ int 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 xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ int timerID = OS.XtAppAddTimeOut (xtContext, milliseconds, timerProc, index);
+ if (timerID != 0) {
+ timerIDs [index] = timerID;
+ timerList [index] = runnable;
+ }
+}
+int timerProc (int index, int id) {
+ if (timerList == null) return 0;
+ if (0 <= index && index < timerList.length) {
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ timerIDs [index] = 0;
+ if (runnable != null) runnable.run ();
+ }
+ return 0;
+}
+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;
+}
+public void update () {
+ checkDevice ();
+ XAnyEvent event = new XAnyEvent ();
+ int mask = OS.ExposureMask | OS.ResizeRedirectMask |
+ OS.StructureNotifyMask | OS.SubstructureNotifyMask |
+ OS.SubstructureRedirectMask;
+ OS.XSync (xDisplay, false); OS.XSync (xDisplay, false);
+ while (OS.XCheckMaskEvent (xDisplay, mask, event)) OS.XtDispatchEvent (event);
+}
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ if (OS.XtAppPending (xtContext) == 0) OS.XtAppAddTimeOut (xtContext, 0, 0, 0);
+}
+int windowProc (int handle, int clientData, int callData, int unused) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.processEvent (clientData, callData);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java
new file mode 100755
index 0000000000..0b7a79abb5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FileDialog.java
@@ -0,0 +1,254 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * SWT - The Simple Widget Toolkit,
+ * (c) Copyright IBM Corp 1998, 1999.
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+
+/**
+ * A file dialog allows the user to navigate the file
+ * system and select a file name or type in a new name.
+ * The file name is not verified for correctness.
+ *
+ */
+public /*final*/ class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String filterPath = "";
+ String fullPath = "";
+ String fileName = "";
+ boolean cancel = true;
+ static final String FILTER = "*";
+
+public FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+}
+int activate (int widget, int client, int call) {
+ cancel = client == OS.XmDIALOG_CANCEL_BUTTON;
+ OS.XtUnmanageChild (widget);
+ return 0;
+}
+public String getFileName () {
+ return fileName;
+}
+public String [] getFileNames () {
+ return new String [] {fileName};
+}
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+public String [] getFilterNames () {
+ return filterNames;
+}
+public String getFilterPath () {
+ return filterPath;
+}
+public String open () {
+
+ /* Get the parent */
+ boolean destroyContext;
+ Display appContext = Display.getCurrent ();
+ if (destroyContext = (appContext == null)) appContext = new Display ();
+ int display = appContext.xDisplay;
+ int parentHandle = appContext.shellHandle;
+ if ((parent != null) && (parent.getDisplay () == appContext))
+ parentHandle = parent.shellHandle;
+
+ /* Compute the dialog title */
+ /*
+ * Feature in Motif. It is not possible to set a shell
+ * title to an empty string. The fix is to set the title
+ * to be a single space.
+ */
+ String string = title;
+ if (string.length () == 0) string = " ";
+ byte [] buffer1 = Converter.wcsToMbcs (null, string, true);
+ int xmStringPtr1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ /* Compute the filter */
+ String mask = FILTER;
+ if (filterExtensions == null) filterExtensions = new String [0];
+ if (filterNames == null) filterNames = new String [0];
+ if (filterExtensions.length != 0) {
+ /* Motif does not support multiple filters, so ignore them
+ * if there are more than one, or if there is a ; separator.
+ */
+ if (filterExtensions.length == 1) {
+ String filter = filterExtensions [0];
+ if (filter.indexOf (';', 0) == -1) mask = filter;
+ }
+ }
+ byte [] buffer2 = Converter.wcsToMbcs (null, mask, true);
+ int xmStringPtr2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ /* Compute the filter path */
+ if (filterPath == null) filterPath = "";
+ byte [] buffer3 = Converter.wcsToMbcs (null, filterPath, true);
+ int xmStringPtr3 = OS.XmStringParseText (
+ buffer3,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+
+ /* Create the dialog */
+ int [] argList1 = {
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNdialogStyle, OS.XmDIALOG_PRIMARY_APPLICATION_MODAL,
+ OS.XmNwidth, OS.XDisplayWidth (display, OS.XDefaultScreen (display)) * 4 / 9,
+ OS.XmNdialogTitle, xmStringPtr1,
+ OS.XmNpattern, xmStringPtr2,
+ OS.XmNdirectory, xmStringPtr3,
+ };
+ /*
+ * Feature in Linux. For some reason, the XmCreateFileSelectionDialog()
+ * will not accept NULL for the widget name. This works fine on the other
+ * Motif platforms and in the other XmCreate calls on Linux. The fix is
+ * to pass in a NULL terminated string, not a NULL pointer.
+ */
+ byte [] name = new byte [] {0};
+ int dialog = OS.XmCreateFileSelectionDialog (parentHandle, name, argList1, argList1.length / 2);
+ int child = OS.XmFileSelectionBoxGetChild (dialog, OS.XmDIALOG_HELP_BUTTON);
+ if (child != 0) OS.XtUnmanageChild (child);
+ OS.XmStringFree (xmStringPtr1);
+ OS.XmStringFree (xmStringPtr2);
+ OS.XmStringFree (xmStringPtr3);
+/*
+ string := OSWidget xmStringAt: XmNdirectory handle: dialog.
+ OSWidget xmStringAt: XmNdirSpec put: string, fileName handle: dialog.
+
+ "Select the matching file in the list and scroll to show it."
+ child := dialog xmFileSelectionBoxGetChild: XmDIALOGLIST.
+ child isNull ifFalse: [
+ string := OSWidget xmStringAt: XmNdirSpec handle: dialog.
+ string := PlatformConverter wcsToMbcs: 0 buffer: string.
+ xmString := OSXmString xmStringCreateLocalized: string asPSZ.
+ child
+ xmListSelectItem: xmString notify: false;
+ xmListSetItem: xmString.
+ xmString xmStringFree.
+
+ "Bug in Solaris. For some reason, the horizontal scroll bar in the dialog
+ list refuses to be displayed. This stops the dialog list from scrolling
+ horizontally and displaying the file names. This does not happen on other
+ Motif platforms. The fix is to force the horizontal scroll bar to be displayed
+ by explicitly setting the scroll bar display policy."
+ OSWidget resourceAt: XmNscrollBarDisplayPolicy put: XmSTATIC handle: child].
+*/
+
+ /* Hook the callbacks. */
+ Callback callback = new Callback (this, "activate", 3);
+ int address = callback.getAddress ();
+ OS.XtAddCallback (dialog, OS.XmNokCallback, address, OS.XmDIALOG_OK_BUTTON);
+ OS.XtAddCallback (dialog, OS.XmNcancelCallback, address, OS.XmDIALOG_CANCEL_BUTTON);
+
+ /* Open the dialog and dispatch events. */
+ cancel = true;
+/*
+ shell == nil ifFalse: [
+ shell minimized ifTrue: [shell minimized: false]].
+*/
+ OS.XtManageChild (dialog);
+
+//BOGUS - should be a pure OS message loop (no SWT AppContext)
+ while (OS.XtIsRealized (dialog) && OS.XtIsManaged (dialog))
+ if (!appContext.readAndDispatch ()) appContext.sleep ();
+
+ /* Set the new path, file name and filter. */
+ fullPath = "";
+ if (!cancel) {
+ filterPath = fullPath = "";
+ int [] argList2 = {OS.XmNdirectory, 0, OS.XmNdirSpec, 0};
+ OS.XtGetValues (dialog, argList2, argList2.length / 2);
+ int xmString3 = argList2 [1];
+ int ptr = OS.XmStringUnparse (
+ xmString3,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (ptr != 0) {
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ OS.XtFree (ptr);
+ filterPath = new String (Converter.mbcsToWcs (null, buffer));
+ }
+ OS.XmStringFree (xmString3);
+ int xmString4 = argList2 [3];
+ ptr = OS.XmStringUnparse (
+ xmString4,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (ptr != 0) {
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ OS.XtFree (ptr);
+ fullPath = new String (Converter.mbcsToWcs (null, buffer));
+ }
+ OS.XmStringFree (xmString4);
+ int length = filterPath.length ();
+ if ((length != 0) && (filterPath.charAt (length - 1) == '/')) {
+ filterPath = filterPath.substring (0, length - 1);
+ int index = fullPath.length () - 1;
+ while ((index >= 0) && (fullPath.charAt (index) != '/')) --index;
+ fileName = fullPath.substring (index, fullPath.length ());
+ }
+ }
+
+ /* Destroy the dialog and update the display. */
+ if (OS.XtIsRealized (dialog)) OS.XtDestroyWidget (dialog);
+ if (destroyContext) appContext.dispose ();
+ callback.dispose ();
+
+// (shell == nil or: [shell isDestroyed not]) ifTrue: [dialog xtDestroyWidget].
+// OSWidget updateDisplay.
+// entryPoint unbind.
+
+ if (cancel) return null;
+ return fullPath;
+}
+public void setFileName (String string) {
+ fileName = string;
+}
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
new file mode 100755
index 0000000000..cbc3f4532a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontDialog.java
@@ -0,0 +1,870 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * SWT - The Simple Widget Toolkit,
+ * (c) Copyright IBM Corp 1998, 1999.
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.layout.*;
+import java.text.*;
+import java.util.*;
+
+/**
+ * A FontDialog allows the user to select a font
+ * from all available fonts in the system.
+ */
+public /*final*/ class FontDialog extends Dialog {
+ private static final String TEXT_SAMPLE = "AaBbYyZz";
+ private static final String TEXT_FONT_NOT_LOADED = "Could not load selected font"; // text used in place of sample text when the selected font could not be loaded
+
+ private Shell shell; // the dialog shell
+ private Combo characterSet;
+ private Combo faceName;
+ private Combo fontSize;
+ private Combo fontStyle;
+ private Combo extendedStyle;
+ private Label sampleLabel;
+ private Button ok;
+ private Button cancel;
+
+ private boolean okSelected; // true if the dialog was hidden
+ // because the ok button was selected
+ private FontData dialogResult;
+ private Hashtable characterSets = new Hashtable(); // maps character sets to a hashtable
+ // that maps the fonts in that
+ // character set to FontStyles objects
+ private FontData initialSelection; // can be set by the programmer and
+ private Font sampleFont; // the sample font for the font data selected by the user.
+ // Used to correctly clean up allocated fonts
+ // will be used to initialize the font
+ // combo boxes when the dialog is opened
+/**
+ * Create a new instance of the receiver with 'parent' as
+ * its parent shell.
+ * @param parent - the parent shell. May be null
+ */
+public FontDialog(Shell parent) {
+ this(parent, SWT.NULL);
+}
+/**
+ * Create a new instance of the receiver with 'parent' as
+ * its parent shell using 'style' as the widget style.
+ * @param parent - the parent shell. May be null
+ * @param style - style bits used to create the receiver.
+ * See class definition for details
+ */
+public FontDialog(Shell parent, int style) {
+ super(parent, style | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+}
+/**
+ * Add the fonts found in 'fonts' to the list of fonts.
+ * Fonts are stored by character set and face name. For each character
+ * set/face name combination there is one FontExtStyles object that
+ * captures the different extended styles and the sizes and styles
+ * available for that extended style.
+ */
+void addFonts(FontData fonts[]) {
+ FontData font;
+ String faceName;
+ String characterSet;
+ Hashtable characterSets = getFonts();
+ Hashtable faceNames;
+ FontExtStyles fontExtStyles;
+
+ for (int i = 0; i < fonts.length; i++) {
+ font = fonts[i];
+ characterSet = getTranslatedCharSet(font);
+ faceNames = (Hashtable) characterSets.get(characterSet);
+ faceName = getTranslatedFaceName(font);
+ if (faceNames == null) {
+ faceNames = new Hashtable();
+ characterSets.put(characterSet, faceNames);
+ }
+ fontExtStyles = (FontExtStyles) faceNames.get(faceName);
+ if (fontExtStyles == null) {
+ fontExtStyles = new FontExtStyles(font.getName()); // use original face name for FontExtStyles
+ faceNames.put(faceName, fontExtStyles);
+ }
+ fontExtStyles.add(font);
+ }
+ setFonts(characterSets);
+}
+/**
+ * Create the widgets of the dialog.
+ */
+void createChildren() {
+ Shell dialog = getDialogShell();
+ Label characterSetLabel = new Label(dialog, SWT.NULL);
+ Label faceNameLabel = new Label(dialog, SWT.NULL);
+ Label extendedStyleLabel = new Label(dialog, SWT.NULL);
+ Label fontSizeLabel;
+ Label fontStyleLabel;
+ Label fillLabel;
+ Group sampleGroup;
+ GridData gridData;
+ GridLayout layout = new GridLayout();
+ final int ColumnOneWidth = 200;
+ final int ColumnTwoWidth = 150;
+ final int ColumnThreeWidth = 100;
+
+ layout.numColumns = 4;
+ layout.marginWidth = 15;
+ layout.marginHeight = 15;
+ layout.horizontalSpacing = 10;
+ layout.verticalSpacing = 2;
+ dialog.setLayout(layout);
+
+ // row one
+ characterSetLabel.setText("Character set:");
+ faceNameLabel.setText("Font:");
+ extendedStyleLabel.setText("Extended style:");
+
+ new Label(dialog, SWT.NULL);
+
+ // row two
+ characterSet = new Combo(dialog, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData();
+ gridData.widthHint = ColumnOneWidth;
+ gridData.heightHint = 150;
+ gridData.verticalSpan = 2;
+ characterSet.setData(new Integer(-1));
+ characterSet.setLayoutData(gridData);
+
+ faceName = new Combo(dialog, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData();
+ gridData.widthHint = ColumnTwoWidth;
+ gridData.heightHint = 150;
+ gridData.verticalSpan = 2;
+ gridData.verticalAlignment = GridData.FILL;
+ faceName.setData(new Integer(-1));
+ faceName.setLayoutData(gridData);
+
+ extendedStyle = new Combo(dialog, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData();
+ gridData.widthHint = ColumnThreeWidth;
+ gridData.heightHint = 150;
+ gridData.verticalSpan = 2;
+ gridData.verticalAlignment = GridData.FILL;
+ extendedStyle.setData(new Integer(-1));
+ extendedStyle.setLayoutData(gridData);
+
+ // create ok and cancel buttons (row two and three)
+ createOkCancel();
+
+ // row four
+ createEmptyRow();
+
+ // row five
+ fontSizeLabel = new Label(dialog, SWT.NULL);
+ fontSizeLabel.setText("Size:");
+ fontStyleLabel = new Label(dialog, SWT.NULL);
+ fontStyleLabel.setText("Style:");
+
+ fillLabel = new Label(dialog, SWT.NULL);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ fillLabel.setLayoutData(gridData);
+
+ // row six
+ fontSize = new Combo(dialog, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.heightHint = 110;
+ fontSize.setData(new Integer(-1));
+ fontSize.setLayoutData(gridData);
+
+ fontStyle = new Combo(dialog, SWT.SIMPLE | SWT.V_SCROLL);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.FILL;
+ fontStyle.setData(new Integer(-1));
+ fontStyle.setLayoutData(gridData);
+
+ fillLabel = new Label(dialog, SWT.NULL);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ fillLabel.setLayoutData(gridData);
+
+ // row seven
+ createEmptyRow();
+
+ // row eight
+ sampleGroup = new Group(dialog, SWT.NULL);
+ sampleGroup.setText("Sample");
+ gridData = new GridData();
+ gridData.heightHint = 70;
+ gridData.horizontalSpan = 3;
+ gridData.horizontalAlignment = GridData.FILL;
+ sampleGroup.setLayoutData(gridData);
+
+ // setup group box with sample text
+ layout = new GridLayout();
+ layout.marginWidth = 10;
+ layout.marginHeight = 10;
+ sampleGroup.setLayout(layout);
+
+ sampleLabel = new Label(sampleGroup, SWT.CENTER);
+ sampleLabel.setText(TEXT_SAMPLE);
+ gridData = new GridData();
+ gridData.grabExcessHorizontalSpace = true;
+ gridData.grabExcessVerticalSpace = true;
+ gridData.verticalAlignment = GridData.FILL;
+ gridData.horizontalAlignment = GridData.FILL;
+ sampleLabel.setLayoutData(gridData);
+
+ dialog.setSize(445, 410);
+}
+/**
+ * Answer the combo used to display all available character sets.
+ */
+Combo getCharacterSetCombo() {
+ return characterSet;
+}
+/**
+ * Answer the combo used to display all extended styles of
+ * the selected font.
+ */
+Combo getExtStyleCombo() {
+ return extendedStyle;
+}
+/**
+ * Answer the combo used to display the face names of the
+ * fonts in the selected character set.
+ */
+Combo getFaceNameCombo() {
+ return faceName;
+}
+/**
+ * Answer the FontData for the selected font.
+ * Answer null if no font was selected and the dialog was cancelled.
+ */
+public FontData getFontData() {
+ return dialogResult;
+}
+/**
+ * Answer the collection of fonts that are displayed by the
+ * receiver.
+ * See the class definition for an explanation of the structure
+ * of the returned Hashtable.
+ */
+Hashtable getFonts() {
+ return characterSets;
+}
+/**
+ * Return the sample font created from the selected font metrics.
+ * This font is set into the sampleLabel.
+ */
+Font getSampleFont() {
+ return sampleFont;
+}
+/**
+ * Answer the label used to display a sample of the selected font.
+ */
+Label getSampleLabel() {
+ return sampleLabel;
+}
+/**
+ * Answer the selected character set in the format used to load
+ * fonts.
+ */
+String getSelectedCharSet() {
+ String translatedCharSet = getCharacterSetCombo().getText();
+ String platformCharSet;
+ int characterSetIndex = translatedCharSet.indexOf("(");
+
+ if (characterSetIndex == -1) {
+ platformCharSet = translatedCharSet;
+ }
+ else {
+ platformCharSet = translatedCharSet.substring(
+ characterSetIndex + 1, translatedCharSet.length()-1);
+ }
+ return platformCharSet;
+}
+/**
+ * Answer the selected face name in the format used to load
+ * fonts.
+ */
+String getSelectedFaceName() {
+ String translatedFaceName = getFaceNameCombo().getText();
+ String platformFaceName;
+ int foundryIndex = translatedFaceName.indexOf("(");
+
+ if (foundryIndex == -1) { // if this is true, the face name is not selected from the list
+ platformFaceName = translatedFaceName;
+ }
+ else {
+ platformFaceName = translatedFaceName.substring(
+ 0, translatedFaceName.indexOf(" ("));
+ }
+ return platformFaceName;
+}
+/**
+ * Answer the selected font foundry in the format used to load
+ * fonts.
+ */
+String getSelectedFoundry() {
+ String translatedFaceName = getFaceNameCombo().getText();
+ String foundry = new String();
+ int foundryIndex = translatedFaceName.indexOf("(");
+
+ if (foundryIndex != -1) {
+ foundry = translatedFaceName.substring(
+ foundryIndex + 1, translatedFaceName.length()-1);
+ }
+ return foundry;
+}
+/**
+ * Answer a FontData object that can be used to load the selected
+ * font.
+ */
+FontData getSelectionFontData() {
+ String fontSize = getSizeCombo().getText();
+ String style = getStyleCombo().getText();
+ String extStyle = getExtStyleCombo().getText();
+ int styleBits = SWT.NULL;
+ Integer fontSizeInt = null;
+ FontData fontData;
+
+ if (style.indexOf(FontExtStyles.BOLD) != -1) {
+ styleBits |= SWT.BOLD;
+ }
+ if (style.indexOf(FontExtStyles.ITALIC) != -1) {
+ styleBits |= SWT.ITALIC;
+ }
+ try {
+ fontSizeInt = Integer.valueOf(fontSize);
+ }
+ catch (NumberFormatException exception) {}
+ if (fontSizeInt != null) {
+ fontData = new FontData(
+ getSelectedFaceName(),
+ fontSizeInt.intValue(),
+ styleBits);
+ }
+ else {
+ fontData = new FontData();
+ fontData.setName(getSelectedFaceName());
+ fontData.setStyle(styleBits);
+ }
+ if (extStyle.length() > 0) {
+ fontData.addStyle = extStyle;
+ }
+ fontData.characterSetRegistry = getSelectedCharSet();
+ fontData.foundry = getSelectedFoundry();
+ return fontData;
+}
+/**
+ * Answer the combo box used to display the available sizes of
+ * the selected font.
+ */
+Combo getSizeCombo() {
+ return fontSize;
+}
+/**
+ * Answer the combo box used to display the available styles of
+ * the selected font.
+ */
+Combo getStyleCombo() {
+ return fontStyle;
+}
+/**
+ * Answer the character set found in 'fontData' prefixed
+ * with a string explaining the character set.
+ */
+String getTranslatedCharSet(FontData fontData) {
+ String characterSet = fontData.characterSetRegistry;
+ String translatedCharSet = null;
+
+ if (characterSet.startsWith("iso8859") == true) {
+ translatedCharSet = "Western";
+ }
+ else
+ if (characterSet.startsWith("iso646") == true) {
+ translatedCharSet = "ASCII";
+ }
+ else
+ if (characterSet.startsWith("ucs") == true) {
+ translatedCharSet = "Unicode";
+ }
+ else
+ if (characterSet.startsWith("jis") == true) {
+ translatedCharSet = "Japanese";
+ }
+ else
+ if (characterSet.startsWith("gb") == true) {
+ translatedCharSet = "Simplified Chinese";
+ }
+ else
+ if (characterSet.startsWith("cns") == true) {
+ translatedCharSet = "Traditional Chinese";
+ }
+ else
+ if (characterSet.startsWith("ks") == true) {
+ translatedCharSet = "Korean";
+ }
+ if (translatedCharSet != null) {
+ translatedCharSet += " (" + characterSet + ')';
+ }
+ else {
+ translatedCharSet = characterSet;
+ }
+ return translatedCharSet;
+}
+/**
+ * Answer the face name as specified in FontData.familyName followed by
+ * the foundry set in parantheses if available.
+ * We display the face name first so that the list box sorts the fonts by
+ * face name, not by foundry. Users generally want to select fonts based
+ * on the face name and not by foundry. Once they've found the desired
+ * face name in the list they can compare the font variations from
+ * different foundries if available.
+ */
+String getTranslatedFaceName(FontData fontData) {
+ StringBuffer faceNameBuffer;
+
+ if (fontData.foundry != null && fontData.foundry.length() > 0) {
+ faceNameBuffer = new StringBuffer(fontData.fontFamily);
+ faceNameBuffer.append(" (");
+ faceNameBuffer.append(fontData.foundry);
+ faceNameBuffer.append(')');
+ }
+ else {
+ faceNameBuffer = new StringBuffer(fontData.getName());
+ }
+ return faceNameBuffer.toString();
+}
+/**
+ * Handle the events the receiver is listening to.
+ * Combo selections cause the downstream combos to be initialized
+ * with font data and the sample text to be updated.
+ */
+void handleEvents(Event event) {
+ int oldSelectionIndex;
+ int newSelectionIndex;
+
+ if (event.widget instanceof Combo) {
+ oldSelectionIndex = ((Integer) event.widget.getData()).intValue();
+ newSelectionIndex = ((Combo) event.widget).getSelectionIndex();
+ // work around broken getSelectionIndex
+ newSelectionIndex = ((Combo) event.widget).indexOf(((Combo) event.widget).getText());
+ event.widget.setData(new Integer(newSelectionIndex));
+ if (newSelectionIndex != oldSelectionIndex) {
+ if (event.widget == getCharacterSetCombo()) {
+ initFaceNameCombo();
+ }
+ else
+ if (event.widget == getFaceNameCombo()) {
+ initExtStyleCombo();
+ }
+ else
+ if (event.widget == getExtStyleCombo()) {
+ initFontDataCombos();
+ }
+ }
+ updateSample();
+ }
+ else
+ if (event.widget == getOKButton()) {
+ setOkSelected(true);
+ getDialogShell().setVisible(false);
+ }
+ else
+ if (event.widget == getCancelButton()) {
+ setOkSelected(false);
+ getDialogShell().setVisible(false);
+ }
+}
+/**
+ * Initialize the extended styles combo with the extended styles
+ * available for the selected font.
+ * Downstream combos are initialized as well (style and size).
+ */
+void initExtStyleCombo() {
+ String characterSet = getCharacterSetCombo().getText();
+ String faceName = getFaceNameCombo().getText();
+ Hashtable faceNames = (Hashtable) getFonts().get(characterSet);
+ FontExtStyles fontExtStyles = (FontExtStyles) faceNames.get(faceName);
+ Combo extStyleCombo = getExtStyleCombo();
+
+ setItemsSorted(extStyleCombo, fontExtStyles.getExtStyles());
+ extStyleCombo.select(0);
+ initFontDataCombos();
+}
+/**
+ * Initialize the face name combo box with all font names
+ * available in the selected character set.
+ * Downstream combos are initialized as well (extended style).
+ */
+void initFaceNameCombo() {
+ Hashtable faceNames = (Hashtable) getFonts().get(getCharacterSetCombo().getText());
+ Combo faceNameCombo = getFaceNameCombo();
+
+ faceNameCombo.removeAll();
+ setItemsSorted(faceNameCombo, faceNames);
+// faceNameCombo.select(0);
+// initExtStyleCombo();
+}
+/**
+ * Initialize the styles and size combos with the styles and sizes
+ * the selected font is available in.
+ */
+void initFontDataCombos() {
+ String characterSet = getCharacterSetCombo().getText();
+ String faceName = getFaceNameCombo().getText();
+ Hashtable faceNames = (Hashtable) getFonts().get(characterSet);
+ FontExtStyles fontStyles = (FontExtStyles) faceNames.get(faceName);
+
+ initSizeCombo(fontStyles);
+ initStyleCombo(fontStyles);
+}
+/**
+ * Initialize the size combo with the sizes the selected font
+ * is available in.
+ * If the selected font is scalable a selection of preset sizes
+ * is used.
+ */
+void initSizeCombo(FontExtStyles fontExtStyles) {
+ Vector sizes = null;
+ Integer size;
+ Combo sizeCombo = getSizeCombo();
+ String sizeStrings[] = {"8", "10", "11", "12", "14", "16", "18", "22", "24", "26"};
+ int selectionIndex = -1;
+ final int SelectionSize = 14;
+
+ sizeCombo.removeAll();
+ if (fontExtStyles.isScalable() == true) {
+ sizeCombo.setItems(sizeStrings);
+ selectionIndex = 4;
+ }
+ else {
+ sizes = fontExtStyles.getSizes(getExtStyleCombo().getText());
+ for (int i = 0; i < sizes.size(); i++) {
+ size = (Integer) sizes.elementAt(i);
+ sizeCombo.add(size.toString());
+ if (size.intValue() >= SelectionSize && selectionIndex == -1) {
+ selectionIndex = i;
+ }
+ }
+ }
+ if (selectionIndex == -1) {
+ selectionIndex = sizes.size() - 1; // select largest height if there's no font
+ // size that is at least as high as SelectionSize
+ }
+ sizeCombo.select(selectionIndex);
+}
+/**
+ * Initialize the styles combo with the styles the selected font
+ * is available in.
+ */
+void initStyleCombo(FontExtStyles fontExtStyles) {
+ Vector styleVector = fontExtStyles.getStyles(getExtStyleCombo().getText());
+ Enumeration styleEnum = styleVector.elements();
+ Combo styleCombo = getStyleCombo();
+ int selectionIndex = styleVector.indexOf(FontExtStyles.MEDIUM);
+ String style;
+
+ styleCombo.removeAll();
+ while (styleEnum.hasMoreElements() == true) {
+ style = (String) styleEnum.nextElement();
+ styleCombo.add(style);
+ }
+ if (selectionIndex == -1) {
+ selectionIndex = 0;
+ }
+ styleCombo.select(selectionIndex);
+}
+
+/**
+ * Initialize the widgets of the receiver with the data of
+ * all installed fonts.
+ * If the user specified a default font preselect that font in
+ * the combo boxes.
+ */
+void initializeWidgets() {
+ Combo characterSetCombo = getCharacterSetCombo();
+ Display display = getDialogShell().getDisplay();
+ FontData initialFontData = getFontData();
+ Font initialFont;
+
+ addFonts(display.getFontList(null, false)); // get all fonts availabe on the current display
+ addFonts(display.getFontList(null, true));
+ setItemsSorted(characterSetCombo, getFonts());
+
+ if (initialFontData != null) {
+ initialFont = new Font(display, initialFontData); // verify that the initial font data is a valid font
+ setFontCombos(initialFont.getFontData()[0]);
+ initialFont.dispose();
+ updateSample();
+ }
+}
+/**
+ * Register the receiver to receive events.
+ */
+void installListeners() {
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+
+ getOKButton().addListener(SWT.Selection, listener);
+ getCancelButton().addListener(SWT.Selection, listener);
+ getCharacterSetCombo().addListener(SWT.Selection, listener);
+ getFaceNameCombo().addListener(SWT.Selection, listener);
+ getSizeCombo().addListener(SWT.Selection, listener);
+ getStyleCombo().addListener(SWT.Selection, listener);
+ getExtStyleCombo().addListener(SWT.Selection, listener);
+}
+/**
+ * Initialize the widgets of the receiver, open the dialog
+ * and block the method until the dialog is closed by the user.
+ */
+public FontData open() {
+ FontData dialogResult = null;
+ Font sampleFont;
+ Shell dialog = new Shell(getParent(), getStyle() | SWT.TITLE | SWT.BORDER | SWT.APPLICATION_MODAL);
+
+ setDialogShell(dialog);
+ createChildren();
+ installListeners();
+ openModal();
+ if (isOkSelected() == true) {
+ dialogResult = getSelectionFontData();
+ setFontData(dialogResult);
+ }
+ // Fix for 1FRTJZV
+ sampleFont = getSampleFont();
+ if (sampleFont != null) {
+ sampleFont.dispose();
+ }
+ // Fix for 1G5NLY7
+ if (dialog.isDisposed() == false) {
+ dialog.dispose();
+ }
+ return dialogResult;
+}
+/**
+ * Initialize the combo boxes with the data of the preselected
+ * font specified by the user.
+ */
+void setFontCombos(FontData fontData) {
+ String characterSet = getTranslatedCharSet(fontData);
+ String faceName = getTranslatedFaceName(fontData);
+ Hashtable faceNames = (Hashtable) getFonts().get(characterSet);
+ FontExtStyles fontStyles = (FontExtStyles) faceNames.get(faceName);
+ String value;
+
+ getCharacterSetCombo().setText(characterSet);
+ initFaceNameCombo();
+
+ getFaceNameCombo().setText(faceName);
+ initExtStyleCombo();
+
+ getExtStyleCombo().setText(fontData.addStyle);
+ initSizeCombo(fontStyles);
+
+ value = Integer.toString(fontData.getHeight());
+ getSizeCombo().setText(value);
+ initStyleCombo(fontStyles);
+
+ value = FontExtStyles.getStyleString(fontData.getStyle());
+ getStyleCombo().setText(value);
+}
+/**
+ * Set the preselected font of the receiver to 'fontData'.
+ */
+public void setFontData(FontData fontData) {
+ dialogResult = fontData;
+}
+/**
+ * Set the fonts that are displayed by the receiver to 'fonts'.
+ */
+void setFonts(Hashtable fonts) {
+ characterSets = fonts;
+}
+/**
+ * Set the contents of 'combo' to the keys of 'items'.
+ * Keys are sorted in ascending order first and have to be Strings.
+ */
+void setItemsSorted(Combo combo, Hashtable items) {
+ Enumeration itemKeys = items.keys();
+ String item;
+ String sortedItems[] = new String[items.size()];
+ int index = 0;
+
+ while (itemKeys.hasMoreElements() == true) {
+ sortedItems[index++] = (String) itemKeys.nextElement();
+ }
+ sort(sortedItems);
+ combo.setItems(sortedItems);
+}
+/**
+ * Set the sample font created from the selected font metrics
+ * to 'newSampleFont'.
+ * This font is set into the sampleLabel.
+ */
+void setSampleFont(Font newSampleFont) {
+ // only dispose fonts we created. See 1FRTK1M for details.
+ if (sampleFont != null) {
+ sampleFont.dispose();
+ }
+ sampleFont = newSampleFont;
+ getSampleLabel().setFont(sampleFont);
+}
+/**
+ * Sort 'items' in ascending order.
+ */
+void sort(String items[]) {
+ Collator collator = Collator.getInstance();
+
+ /* 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 (collator.compare(items[j], items[j+gap]) > 0) {
+ String swap = items[j];
+ items[j] = items[j+gap];
+ items[j+gap] = swap;
+ }
+ }
+ }
+ }
+}
+/**
+ * Set the font of the sample text to the selected font.
+ * Display an error in place of the sample text if the selected
+ * font could not be loaded.
+ */
+void updateSample() {
+ Display display = getDialogShell().getDisplay();
+ FontData selectionFontData = getSelectionFontData();
+ Font sampleFont;
+
+ // sampleFont may not be the same as the one specified in selectionFontData.
+ // This happens when selectionFontData specifies a font alias. In that case,
+ // Font loads the real font. See 1FG3UWX for details.
+ sampleFont = new Font(display, selectionFontData);
+ setSampleFont(sampleFont);
+}
+/**
+ * Fill one row in the grid layout with empty widgets.
+ * Used to achieve a bigger vertical spacing between separate
+ * groups of widgets (ie. new rows of Text/Combo combinations).
+ */
+void createEmptyRow() {
+ Shell dialog = getDialogShell();
+ Label fillLabel = new Label(dialog, SWT.NULL);
+ GridData gridData = new GridData();
+
+ gridData.heightHint = 5;
+ gridData.horizontalSpan = ((GridLayout) dialog.getLayout()).numColumns;
+ fillLabel.setLayoutData(gridData);
+}
+/**
+ * Create the widgets of the dialog.
+ */
+void createOkCancel() {
+ Shell dialog = getDialogShell();
+ GridData gridData;
+
+ ok = new Button(dialog, SWT.PUSH);
+ ok.setText("OK");
+ dialog.setDefaultButton(ok);
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.widthHint = 70;
+ ok.setLayoutData(gridData);
+
+ cancel = new Button(dialog, SWT.PUSH);
+ cancel.setText("Cancel");
+ gridData = new GridData();
+ gridData.horizontalAlignment = GridData.FILL;
+ gridData.verticalAlignment = GridData.BEGINNING;
+ cancel.setLayoutData(gridData);
+}
+/**
+ * Answer the cancel button
+ */
+Button getCancelButton() {
+ return cancel;
+}
+
+/**
+ * Answer the dialog shell.
+ */
+Shell getDialogShell() {
+ return shell;
+}
+/**
+ * Answer the ok button.
+ */
+Button getOKButton() {
+ return ok;
+}
+
+/**
+ * Insert the method's description here.
+ * Creation date: (08/05/99 12:34:43)
+ * @return boolean
+ */
+boolean isOkSelected() {
+ return okSelected;
+}
+/**
+ * Open the receiver and set its size to the size calculated by
+ * the layout manager.
+ */
+void openDialog() {
+ Shell dialog = getDialogShell();
+ Point pt;
+ Rectangle displayRect;
+ int widthLimit;
+
+ // Start everything off by setting the shell size to its computed size.
+ pt = dialog.computeSize(-1, -1, false);
+
+ // Ensure that the width of the shell fits the display.
+ displayRect = dialog.getDisplay().getBounds();
+ widthLimit = displayRect.width * 7 / 8;
+ if (pt.x > widthLimit) {
+ pt = dialog.computeSize (widthLimit, -1, false);
+ }
+ dialog.setBounds (0, 0, pt.x, pt.y);
+ dialog.setText(getText());
+ // Open the window.
+ dialog.open();
+}
+/**
+ * Initialize the widgets of the receiver, open the dialog
+ * and block the method until the dialog is closed by the user.
+ */
+void openModal() {
+ Shell dialog = getDialogShell();
+ Display display = dialog.getDisplay();
+
+ initializeWidgets();
+ setFontData(null);
+ openDialog();
+ while (dialog.isDisposed() == false && dialog.getVisible() == true) {
+ if (display.readAndDispatch() == false) {
+ display.sleep();
+ }
+ }
+}
+/**
+ * Set whether the dialog was closed by selecting the ok button.
+ */
+void setOkSelected(boolean newOkSelected) {
+ okSelected = newOkSelected;
+}
+/**
+ * Set the shell used as the dialog window.
+ */
+void setDialogShell(Shell shell) {
+ this.shell = shell;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyle.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyle.java
new file mode 100755
index 0000000000..aa9305d0c9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyle.java
@@ -0,0 +1,91 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * SWT - The Simple Widget Toolkit,
+ * (c) Copyright IBM Corp 1998, 1999.
+ */
+
+import java.util.*;
+
+/**
+ * This class stores the sizes and styles for a font extended style.
+ * A font on X can have different styles and sizes depending on the
+ * extended style of a font.
+ */
+class FontExtStyle {
+ private Vector sizes;
+ private Vector styles;
+/**
+ * Create a new instance of the receiver
+ */
+FontExtStyle() {
+ sizes = new Vector();
+ styles = new Vector();
+}
+/**
+ * Add size to the existing sizes of the receiver.
+ * Insert in ascending sort order.
+ */
+void addSize(int size) {
+ Vector sizes = getSizes();
+ Integer sizeInteger;
+ Integer newSizeInteger = new Integer(size);
+
+ if (sizes.contains(newSizeInteger) == false) {
+ for (int i = 0; i < sizes.size(); i++) {
+ sizeInteger = (Integer) sizes.elementAt(i);
+ if (sizeInteger.intValue() > size) {
+ sizes.insertElementAt(newSizeInteger, i);
+ return;
+ }
+ }
+ sizes.addElement(newSizeInteger);
+ }
+}
+/**
+ * Add the 'style' to the list of styles.
+ * Styles are sorted in the order "medium", "medium italic", "bold",
+ * "bold italic"
+ * @param style - the font style. Can be "medium", "medium italic",
+ * "bold", "bold italic"
+ */
+void addStyle(String style) {
+ Vector styles = getStyles();
+ String existingStyle;
+
+ if (styles.contains(style) == true) {
+ return;
+ }
+ // "medium" always goes to top of list
+ if (style.equals(FontExtStyles.MEDIUM) == true) {
+ styles.insertElementAt(style, 0);
+ }
+ else {
+ // order is: "medium" "medium italic" "bold" "bold italic"
+ for (int i = 0; i < styles.size(); i++) {
+ existingStyle = (String) styles.elementAt(i);
+ if (existingStyle.startsWith(FontExtStyles.BOLD) == true &&
+ (style.startsWith(FontExtStyles.MEDIUM) == true ||
+ style.equals(FontExtStyles.BOLD) == true)) {
+ styles.insertElementAt(style, i);
+ return;
+ }
+ }
+ styles.addElement(style);
+ }
+}
+/**
+ * Answer the sizes that are available for the existing font.
+ * Vector is empty if the font is scalable.
+ */
+Vector getSizes() {
+ return sizes;
+}
+/**
+ * Answer the styles that are available for this extended style.
+ */
+Vector getStyles() {
+ return styles;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyles.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyles.java
new file mode 100755
index 0000000000..30fa605f6f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/FontExtStyles.java
@@ -0,0 +1,133 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * SWT - The Simple Widget Toolkit,
+ * (c) Copyright IBM Corp 1998, 1999.
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/**
+ * This class stores the extended styles that are available for a
+ * font as well as the sizes and styles that are available for each
+ * extended styles.
+ */
+class FontExtStyles {
+ final static String MEDIUM = "medium";
+ final static String BOLD = "bold";
+ final static String ITALIC = "italic";
+
+ private String faceName;
+ private boolean isScalable = false;
+ private Hashtable extStyles = new Hashtable(); // keys are extended styles,
+ // values a Vector with the
+ // corresponding sizes or null
+ // if the font is scalable
+/**
+ * Create a new instance of the receiver for the font with the
+ * name 'faceName'.
+ */
+FontExtStyles(String faceName) {
+ this.faceName = faceName;
+}
+/**
+ * Add the extended style, style and size data of 'fontData'
+ * to the receiver.
+ * The face name in 'fontData' has to match the face name of
+ * the receiver.
+ */
+void add(FontData fontData) {
+ Hashtable extStyles = getExtStyles();
+ FontExtStyle extStyle;
+ Integer height;
+ String style;
+
+ if (fontData.getName().equals(getFaceName()) == false) {
+ return;
+ }
+ extStyle = (FontExtStyle) extStyles.get(fontData.addStyle);
+ if (extStyle == null) {
+ extStyle = new FontExtStyle();
+ extStyles.put(fontData.addStyle, extStyle);
+ }
+ if (fontData.getHeight() == 0) {
+ setScalable(true);
+ }
+ else { // add the font size if the font is not scalable
+ extStyle.addSize(fontData.getHeight());
+ }
+ // add the style
+ style = getStyleString(fontData.getStyle());
+ extStyle.addStyle(style);
+}
+/**
+ * Answer the extended styles stored by the receiver.
+ * See the class definition for an explanation of the returned
+ * data structure.
+ */
+Hashtable getExtStyles() {
+ return extStyles;
+}
+/**
+ * Answer the face name of the receiver.
+ * The extended styles are stored for this face name.
+ */
+String getFaceName() {
+ return faceName;
+}
+/**
+ * Answer the font sizes of the receiver for the extended style
+ * identified by 'extStyle'.
+ * @return the font sizes of the receiver for the extended style
+ * identified by 'extStyle'.
+ * Empty collection if isScalable() answers true.
+ */
+Vector getSizes(String extStyle) {
+ return ((FontExtStyle) getExtStyles().get(extStyle)).getSizes();
+}
+/**
+ * Answer the string displayed for 'style'
+ * @param style - the font style. Can be SWT.BOLD, SWT.ITALIC
+ * or both combined with logical OR.
+ */
+static String getStyleString(int style) {
+ String styleString;
+
+ if ((style & SWT.BOLD) != 0) {
+ styleString = BOLD;
+ }
+ else {
+ styleString = MEDIUM;
+ }
+ if ((style & SWT.ITALIC) != 0) {
+ styleString += ' ' + ITALIC;
+ }
+ return styleString;
+}
+/**
+ * Answer the font styles of the receiver for the extended style
+ * identified by 'extStyle'.
+ */
+Vector getStyles(String extStyle) {
+ return ((FontExtStyle) getExtStyles().get(extStyle)).getStyles();
+}
+/**
+ * Answer whether the receiver is scalable or not.
+ * @return true=receiver is scalable. false=receiver is not
+ * scalable. It stores all available font sizes.
+ */
+boolean isScalable() {
+ return isScalable;
+}
+/**
+ * Set whether the receiveris scalable..
+ * @param newIsScalable - true=receiver is scalable.
+ * false=receiver is not scalable. It stores all available font sizes.
+ */
+void setScalable(boolean newIsScalable) {
+ isScalable = newIsScalable;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
new file mode 100755
index 0000000000..f68d4fc4d0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Group.java
@@ -0,0 +1,246 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+
+/**
+* The group class implements an etched border with that
+* is typically used to group radio buttons. A group can
+* have an optional label.
+* <p>
+* <b>Styles</b><br>
+* <dd>SHADOW_IN, SHADOW_OUT,<br>
+* <dd>SHADOW_ETCHED_IN, SHADOW_ETCHED_OUT<br>
+* <br>
+*/
+
+/* Class Definition */
+public /*final*/ class Group extends Composite {
+ int labelHandle;
+/**
+* Creates a new instance of the widget.
+*/
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+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 Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int trimX, trimY, trimWidth, trimHeight;
+ int [] argList = {
+ OS.XmNwidth, 0,
+ OS.XmNheight, 0,
+ OS.XmNshadowThickness, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int thickness = argList [5];
+ int marginWidth = argList [7];
+ int marginHeight = argList [9];
+ trimX = x - marginWidth + thickness;
+ trimY = y - marginHeight + thickness;
+ trimWidth = width + ((marginWidth + thickness) * 2);
+ trimHeight = height + ((marginHeight + thickness) * 2);
+ if (OS.XtIsManaged (labelHandle)) {
+ int [] argList2 = {OS.XmNy, 0, OS.XmNheight, 0};
+ OS.XtGetValues (labelHandle, argList2, argList2.length / 2);
+ int labelHeight = ((short) argList2 [1]) + argList2 [3];
+ trimY = y - labelHeight;
+ trimHeight = height + labelHeight + (marginHeight + thickness);
+ }
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+
+ /*
+ * Feature in Motif. When a widget is managed or unmanaged,
+ * it may request and be granted, a new size in the OS. This
+ * behavior is unwanted. The fix is to create a parent for
+ * the list that will disallow geometry requests.
+ */
+ int border = (style & SWT.BORDER) != 0 ? 1 : 0;
+ int [] argList1 = {OS.XmNborderWidth, border};
+ formHandle = OS.XmCreateForm (parent.handle, null, argList1, argList1.length / 2);
+ if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int [] argList2 = {
+ OS.XmNshadowType, shadowType (),
+ OS.XmNtopAttachment, OS.XmATTACH_FORM,
+ OS.XmNbottomAttachment, OS.XmATTACH_FORM,
+ OS.XmNleftAttachment, OS.XmATTACH_FORM,
+ OS.XmNrightAttachment, OS.XmATTACH_FORM,
+ OS.XmNresizable, 0,
+ };
+ handle = OS.XmCreateFrame (formHandle, null, argList2, argList2.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int [] argList3 = {OS.XmNchildType, OS.XmFRAME_TITLE_CHILD};
+ labelHandle = OS.XmCreateLabel (handle, null, argList3, argList3.length / 2);
+ if (labelHandle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ /*
+ * Bug in Motif. For some reason, if a form has not been realized,
+ * calling XtResizeWidget () on the form does not lay out properly.
+ * The fix is to force the widget to be realized by forcing the shell
+ * to be realized.
+ */
+ getShell ().realizeWidget ();
+}
+void enableWidget (boolean enabled) {
+ super.enableWidget (enabled);
+ enableHandle (enabled, labelHandle);
+}
+int fontHandle () {
+ return labelHandle;
+}
+/**
+* Gets the client area.
+*/
+public Rectangle getClientArea () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {
+ OS.XmNwidth, 0,
+ OS.XmNheight, 0,
+ OS.XmNshadowThickness, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int thickness = argList [5];
+ int marginWidth = argList [7];
+ int marginHeight = argList [9];
+ int x = marginWidth + thickness;
+ int y = marginHeight + thickness;
+ int width = argList [1] - ((marginWidth + thickness) * 2) - 1;
+ int height = argList [3] - ((marginHeight + thickness) * 2) - 1;
+ if (OS.XtIsManaged (labelHandle)) {
+ int [] argList2 = {OS.XmNy, 0, OS.XmNheight, 0};
+ OS.XtGetValues (labelHandle, argList2, argList2.length / 2);
+ y = ((short) argList2 [1]) + argList2 [3];
+ height = argList [3] - y - (marginHeight + thickness) - 1;
+ }
+ return new Rectangle (x, y, width, height);
+}
+/**
+* Gets the widget text.
+* <p>
+* @return the text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNlabelString, 0};
+ OS.XtGetValues (labelHandle, argList, 1);
+ int xmString = argList [1];
+ int address = OS.XmStringUnparse (
+ xmString,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address == 0) return "";
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ OS.XmStringFree (xmString);
+ return new String (Converter.mbcsToWcs (null, buffer));
+}
+boolean mnemonicHit () {
+ return setFocus ();
+}
+boolean mnemonicMatch (char key) {
+ char mnemonic = findMnemonic (getText ());
+ if (mnemonic == '\0') return false;
+ return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
+}
+void propagateWidget (boolean enabled) {
+ super.propagateWidget (enabled);
+ propagateHandle (enabled, labelHandle);
+}
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ super.redrawWidget (x, y, width, height, all);
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) x, (short) y, root_x, root_y);
+ short [] label_x = new short [1], label_y = new short [1];
+ OS.XtTranslateCoords (labelHandle, (short) 0, (short) 0, label_x, label_y);
+ redrawHandle (root_x [0] - label_x [0], root_y [0] - label_y [0], width, height, labelHandle);
+}
+void releaseHandle () {
+ super.releaseHandle ();
+ labelHandle = 0;
+}
+/**
+* Sets the widget text.
+* <p>
+* @param string the string
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ int [] argList = {OS.XmNlabelString, xmString};
+ OS.XtSetValues (labelHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmString);
+ if (string.length () == 0) {
+ OS.XtUnmanageChild (labelHandle);
+ } else {
+ OS.XtManageChild (labelHandle);
+ }
+}
+int shadowType () {
+ if ((style & SWT.SHADOW_IN) != 0) return OS.XmSHADOW_IN;
+ if ((style & SWT.SHADOW_OUT) != 0) return OS.XmSHADOW_OUT;
+ if ((style & SWT.SHADOW_ETCHED_IN) != 0) return OS.XmSHADOW_ETCHED_IN;
+ if ((style & SWT.SHADOW_ETCHED_OUT) != 0) return OS.XmSHADOW_ETCHED_OUT;
+ return OS.XmSHADOW_ETCHED_IN;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java
new file mode 100755
index 0000000000..0c2e37f0b6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Header.java
@@ -0,0 +1,336 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * A header draws one or more header items. Each item may have a text
+ * label. Each item is identified by an index and can be resized.
+ */
+class Header extends Canvas {
+ private static final int DEFAULT_WIDTH = 64; // used in computeSize if width could not be calculated
+ private static final int DEFAULT_HEIGHT = 64; // used in computeSize if height could not be calculated
+ private static final int VERTICAL_MARGIN = 4; // space added to the height of the header label
+ private static final int TEXT_Y_OFFSET = 2; // space between the header label and the lower header boundary
+ private static final int DEFAULT_ITEM_WIDTH = 9; // default width of a header item
+ private static final int TEXT_MARGIN = 6; // space in front and behind header text
+ private static final int SHADOW_WIDTH = 2; // width of the right side header shadow
+/**
+ * Create a Header widget as a child of 'parent'.
+ * @param parent - the parent of the new instance
+ */
+Header(Table parent) {
+ super(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_FOCUS);
+
+ addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event event) {paint(event);}
+ });
+ setHeaderHeight();
+}
+/**
+ * Answer the size of the receiver needed to display all items.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = 0;
+ int height = 0;
+
+ for (int i = 0; i < getItemCount(); i++) {
+ width += getBounds(i).width;
+ if (height == 0) {
+ height = getBounds(i).height;
+ }
+ }
+ 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);
+}
+/**
+ * Draw the bright shadow on the upper and left sides of a header item.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawHighlightShadow(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+ Color oldForeground = getForeground();
+
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ // draw top horizontal line
+ gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y);
+ // draw left vertical line
+ gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw the dark shadow on the lower and right side of a header item.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawLowlightShadows(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+ Point bottomShadowStart = new Point(bounds.x + 1, bounds.height - 2);
+ Point bottomShadowStop = new Point(bottomShadowStart.x + bounds.width - 2, bottomShadowStart.y);
+ Point rightShadowStart = null;
+ Point rightShadowStop = null;
+ Display display = getDisplay();
+ Color oldForeground = getForeground();
+
+ // light inner shadow
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ gc.drawLine(
+ bottomShadowStart.x, bottomShadowStart.y,
+ bottomShadowStop.x, bottomShadowStop.y);
+ if(itemIndex != TableColumn.FILL) {
+ rightShadowStart = new Point(bounds.x + bounds.width - 2, bounds.y + 1);
+ rightShadowStop = new Point(rightShadowStart.x, bounds.height - 2);
+ gc.drawLine(
+ rightShadowStart.x, rightShadowStart.y,
+ rightShadowStop.x, rightShadowStop.y);
+ }
+ // dark outer shadow
+ bottomShadowStart.x--;
+ bottomShadowStart.y++;
+ bottomShadowStop.y++;
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
+ gc.drawLine(
+ bottomShadowStart.x, bottomShadowStart.y,
+ bottomShadowStop.x, bottomShadowStop.y);
+ if(itemIndex != TableColumn.FILL) {
+ rightShadowStart.x++;
+ rightShadowStart.y--;
+ rightShadowStop.y++;
+ rightShadowStop.x++;
+ gc.drawLine(
+ rightShadowStart.x, rightShadowStart.y,
+ rightShadowStop.x, rightShadowStop.y);
+ }
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw the item text of the item identified by 'itemIndex'.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawText(GC gc, int itemIndex) {
+ String label = getText(gc, itemIndex);
+ Point textExtent;
+ Rectangle bounds = getBounds(itemIndex);
+ int yPosition;
+ int xPosition = 0;
+ int alignment;
+
+ if (label != null) {
+ alignment = ((Table) getParent()).internalGetColumn(itemIndex).getAlignment();
+ textExtent = gc.stringExtent(label);
+ yPosition = bounds.height - textExtent.y - TEXT_Y_OFFSET;
+
+ if ((alignment & SWT.CENTER) != 0) {
+ xPosition = (bounds.width - textExtent.x) / 2;
+ }
+ else
+ if ((alignment & SWT.RIGHT) != 0) {
+ xPosition = bounds.width - textExtent.x - TEXT_MARGIN;
+ }
+ xPosition = Math.max(TEXT_MARGIN, xPosition);
+ xPosition += bounds.x;
+ gc.drawString(label, xPosition, yPosition);
+ }
+}
+/**
+ * Answer the bounding rectangle of the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the item whose bounding rectangle
+ * should be returned.
+ * @return the bouding rectangle of the item identified by 'itemIndex'.
+ */
+Rectangle getBounds(int itemIndex) {
+ Rectangle bounds = null;
+ int itemCount = getItemCount();
+ Table parent = (Table) getParent();
+
+ if (itemIndex >= 0 && itemIndex < itemCount) {
+ bounds = parent.internalGetColumn(itemIndex).getBounds();
+ bounds.y = 0;
+ bounds.height = getBounds().height;
+ }
+ else
+ if (itemIndex == TableColumn.FILL) {
+ if (itemCount > 0) {
+ bounds = parent.internalGetColumn(itemCount - 1).getBounds();
+ bounds.x += bounds.width;
+ }
+ else {
+ bounds = new Rectangle(0, 0, 0, 0);
+ }
+ bounds.width = Math.max(0, getBounds().width - bounds.x);
+ bounds.y = 0;
+ bounds.height = getBounds().height;
+ }
+ return bounds;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+int getItemCount() {
+ return ((Table) getParent()).internalGetColumnCount();
+}
+/**
+ * Answer the maximum label width that fits into the item identified by
+ * 'itemIndex'.
+ */
+int getMaxLabelWidth(int itemIndex) {
+ return getBounds(itemIndex).width - 2 * TEXT_MARGIN;
+}
+/**
+ * Answer the width required to display the complete label of the header
+ * item at position 'index'.
+ * @param index - position of the header item whose preferred width should
+ * be returned.
+ */
+int getPreferredWidth(int index) {
+ Table parent = (Table) getParent();
+ String text = getText(index);
+ int headerWidth = 0;
+
+ if (text != null) {
+ headerWidth = parent.getTextWidth(text) + 2 * TEXT_MARGIN + 1;
+ }
+ return headerWidth;
+}
+/**
+ * Answer the label of the item identified by 'itemIndex'.
+ */
+String getText(int itemIndex) {
+ String itemLabel = null;
+
+ if (itemIndex >= 0 && itemIndex < getItemCount()) {
+ itemLabel = ((Table) getParent()).internalGetColumn(itemIndex).getText();
+ }
+ return itemLabel;
+}
+/**
+ * Answer the text that is going to be drawn in the header item
+ * identified by 'itemIndex'. This may be truncated to fit the item
+ * width.
+ * @param gc - GC to use for measuring the label width.
+ * @param itemIndex - specifies the item whose label should be returned.
+ */
+String getText(GC gc, int itemIndex) {
+ String label = getText(itemIndex);
+ int maxWidth;
+
+ if (label != null) {
+ maxWidth = getMaxLabelWidth(itemIndex);
+ label = ((Table) getParent()).trimItemText(label, maxWidth, gc);
+ }
+ return label;
+}
+/**
+ * Draw the header item identified by 'itemIndex'.
+ * @param gc - GC to draw on
+ * @param itemIndex - item that should be drawn
+ */
+void paint(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+
+ // draw header background
+ gc.fillRectangle(bounds.x, bounds.y + 1, bounds.width, bounds.height - 3);
+ if (itemIndex != TableColumn.FILL) {
+ drawText(gc, itemIndex);
+ }
+ drawHighlightShadow(gc, itemIndex);
+ drawLowlightShadows(gc, itemIndex);
+}
+/**
+ * Draw all header items.
+ * @param event - Paint event triggering the drawing operation.
+ */
+void paint(Event event) {
+ int labelCount = getItemCount();
+
+ for (int i = 0; i < labelCount; i++) {
+ paint(event.gc, i);
+ }
+ paint(event.gc, TableColumn.FILL); // paint empty fill item behind last item
+}
+/**
+ * Redraw the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the header item that should be redrawn
+ */
+void redraw(int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+
+ if (bounds != null) {
+ redraw(bounds.x, 0, bounds.width, bounds.height, false);
+ }
+}
+
+/**
+ * Set a new font. Recalculate the header height and redraw the header.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ super.setFont(font);
+ setHeaderHeight();
+ redraw();
+}
+/**
+ * Calculate and store the height of the receiver.
+ */
+void setHeaderHeight() {
+ GC gc = new GC(this);
+ Rectangle bounds = getBounds();
+
+ bounds.height = gc.stringExtent("aString").y + VERTICAL_MARGIN;
+ setBounds(bounds);
+ gc.dispose();
+}
+/**
+ * The width of the header item at position 'itemIndex' is about to change.
+ * Adjust the width of the header. Scroll and redraw all header items
+ * starting behind the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the item after which the redraw
+ * should begin.
+ * @param widthDiff - the width change of the item.
+ * > 0 = item width increased. < 0 = item width decreased
+ */
+void widthChange(int itemIndex, int widthDiff) {
+ Rectangle bounds = getBounds(itemIndex);
+ Rectangle headerBounds = getBounds();
+
+ if (bounds != null) {
+ if (itemIndex != TableColumn.FILL) { // ignore the fill column header item - there's nothing to redraw anyway
+ scroll(
+ bounds.x + bounds.width + widthDiff, 0, // destination x, y
+ bounds.x + bounds.width, 0, // source x, y
+ headerBounds.width + widthDiff, headerBounds.height, false);
+ redraw(bounds.x, 0, bounds.width, bounds.height, false);
+ }
+ }
+ headerBounds.width += widthDiff;
+ setBounds(headerBounds);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
new file mode 100755
index 0000000000..0bb0d5548a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Label.java
@@ -0,0 +1,408 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+* A label is a non-selectable user interface object
+* that represents displays a static value.
+*
+* <b>Styles</b><br>
+* <dd>SEPARATOR, HORIZONTAL, VERTICAL, SHADOW_IN, SHADOW_OUT<br>
+*/
+
+/* Class Definition */
+public /*final*/ class Label extends Control {
+ Image image, bitmap, disabled;
+/**
+* Creates a new instance of the widget.
+*/
+public Label (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ if ((style & SWT.SEPARATOR) != 0) return style;
+ return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.SEPARATOR) != 0) {
+ 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);
+ }
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ result.request_mode = OS.CWWidth | OS.CWHeight;
+ int [] argList2 = {OS.XmNrecomputeSize, 1};
+ OS.XtSetValues(handle, argList2, argList2.length / 2);
+ OS.XtQueryGeometry (handle, null, result);
+ int [] argList3 = {OS.XmNrecomputeSize, 0};
+ OS.XtSetValues(handle, argList3, argList3.length / 2);
+ width += result.width;
+ height += result.height;
+ /**
+ * Feature in Motif. If a button's labelType is XmSTRING but it
+ * has no label set into it yet, recomputing the size will
+ * not take into account the height of the font, as we would
+ * like it to. Take care of this case.
+ */
+ int [] argList = {OS.XmNlabelType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == OS.XmSTRING) {
+ int [] argList1 = {OS.XmNlabelString, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int xmString = argList1 [1];
+ if (OS.XmStringEmpty (xmString)) {
+ height += getFontHeight ();
+ width = 0;
+ }
+ }
+ 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;
+ int borderWidth = (style & SWT.BORDER) != 0 ? 1 : 0;
+ if ((style & SWT.SEPARATOR) != 0) {
+ int separatorType = separatorType ();
+ int orientation = (style & SWT.HORIZONTAL) != 0 ? OS.XmHORIZONTAL : OS.XmVERTICAL;
+ int [] argList = {
+ OS.XmNborderWidth, borderWidth,
+ OS.XmNorientation, orientation,
+ OS.XmNseparatorType, separatorType,
+ };
+ handle = OS.XmCreateSeparator (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ int alignment = OS.XmALIGNMENT_BEGINNING;
+ if ((style & SWT.CENTER) != 0) alignment = OS.XmALIGNMENT_CENTER;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.XmALIGNMENT_END;
+ int [] argList = {
+ OS.XmNrecomputeSize, 0,
+ OS.XmNalignment, alignment,
+ OS.XmNborderWidth, borderWidth,
+ };
+ handle = OS.XmCreateLabel (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+int defaultBackground () {
+ return getDisplay ().labelBackground;
+}
+int defaultFont () {
+ return getDisplay ().labelFont;
+}
+int defaultForeground () {
+ return getDisplay ().labelForeground;
+}
+/**
+* Gets the alignment.
+* <p>
+* @return the alignment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return SWT.LEFT;
+ int [] argList = {OS.XmNalignment, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int alignment = argList [1];
+ if (alignment == OS.XmALIGNMENT_BEGINNING) return SWT.LEFT;
+ if (alignment == OS.XmALIGNMENT_CENTER) return SWT.CENTER;
+ if (alignment == OS.XmALIGNMENT_END)return SWT.RIGHT;
+ return SWT.LEFT;
+}
+/**
+* Gets the widget image.
+* <p>
+* @return the widget image
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+String getNameText () {
+ return getText ();
+}
+/**
+* Gets the widget text.
+* <p>
+* @return the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return "";
+ int [] argList = {OS.XmNlabelString, 0, OS.XmNmnemonic, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int xmString = argList [1], mnemonic = argList [3];
+ if (xmString == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
+ char [] result = null;
+ int [] parseTable = getDisplay ().parseTable;
+ int address = OS.XmStringUnparse (
+ xmString,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ parseTable,
+ parseTable.length,
+ OS.XmOUTPUT_ALL);
+ if (address != 0) {
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ result = Converter.mbcsToWcs (null, buffer);
+ }
+ if (xmString != 0) OS.XmStringFree (xmString);
+ int count = 0;
+ if (mnemonic != 0) count++;
+ for (int i=0; i<result.length-1; i++)
+ if (result [i] == Mnemonic) count++;
+ char [] newResult = result;
+ if ((count != 0) || (mnemonic != 0)) {
+ newResult = new char [result.length + count];
+ int i = 0, j = 0;
+ while (i < result.length) {
+ if ((mnemonic != 0) && (result [i] == mnemonic)) {
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ mnemonic = 0;
+ }
+ if ((newResult [j++] = result [i++]) == Mnemonic)
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ }
+ }
+ return new String (newResult);
+}
+boolean getWrap () {
+ return false;
+}
+boolean mnemonicHit () {
+ 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 true;
+ }
+ control = control.parent;
+ }
+ return false;
+}
+boolean mnemonicMatch (char key) {
+ char mnemonic = findMnemonic (getText ());
+ if (mnemonic == '\0') return false;
+ return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
+}
+void propagateHandle (boolean enabled, int widgetHandle) {
+ super.propagateHandle (enabled, widgetHandle);
+ /*
+ * Labels never participate in focus traversal when
+ * either enabled or disabled.
+ */
+ if (enabled) {
+ int [] argList = {OS.XmNtraversalOn, 0};
+ OS.XtSetValues (widgetHandle, argList, argList.length / 2);
+ }
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ int [] argList = {
+ OS.XmNlabelPixmap, OS.XmUNSPECIFIED_PIXMAP,
+ OS.XmNlabelInsensitivePixmap, OS.XmUNSPECIFIED_PIXMAP,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ if (bitmap != null) bitmap.dispose ();
+ if (disabled != null) disabled.dispose ();
+ image = bitmap = disabled = null;
+}
+int separatorType () {
+ if ((style & (SWT.SHADOW_IN)) != 0) return OS.XmSHADOW_ETCHED_IN;
+ if ((style & (SWT.SHADOW_OUT)) != 0) return OS.XmSHADOW_ETCHED_OUT;
+ return OS.XmSHADOW_ETCHED_IN;
+}
+/**
+* Sets the alignment.
+* <p>
+* @param aligment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int [] argList = {OS.XmNalignment, OS.XmALIGNMENT_BEGINNING};
+ if ((alignment & SWT.CENTER) != 0) argList [1] = OS.XmALIGNMENT_CENTER;
+ if ((alignment & SWT.RIGHT) != 0) argList [1] = OS.XmALIGNMENT_END;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ int [] argList = {OS.XmNlabelType, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == OS.XmPIXMAP) setBitmap (image);
+}
+void setBitmap (Image image) {
+ int labelPixmap = OS.XmUNSPECIFIED_PIXMAP;
+ int labelInsensitivePixmap = OS.XmUNSPECIFIED_PIXMAP;
+ if (bitmap != null) bitmap.dispose ();
+ if (disabled != null) disabled.dispose ();
+ bitmap = disabled = null;
+ if (image != null) {
+ Display display = getDisplay ();
+ switch (image.type) {
+ case SWT.BITMAP:
+ labelPixmap = image.pixmap;
+ disabled = new Image (display, image, SWT.IMAGE_DISABLE);
+ labelInsensitivePixmap = disabled.pixmap;
+ break;
+ case SWT.ICON:
+ Rectangle rect = image.getBounds ();
+ bitmap = new Image (display, rect.width, rect.height);
+ GC gc = new GC (bitmap);
+ gc.setBackground (getBackground ());
+ gc.fillRectangle (rect);
+ gc.drawImage (image, 0, 0);
+ gc.dispose ();
+ labelPixmap = bitmap.pixmap;
+ disabled = new Image (display, bitmap, SWT.IMAGE_DISABLE);
+ labelInsensitivePixmap = disabled.pixmap;
+ break;
+ default:
+ error (SWT.ERROR_NOT_IMPLEMENTED);
+ }
+ }
+ int [] argList = {
+ OS.XmNlabelType, OS.XmPIXMAP,
+ OS.XmNlabelPixmap, labelPixmap,
+ OS.XmNlabelInsensitivePixmap, labelInsensitivePixmap,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the widget image.
+* <p>
+* @param image the widget image (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBitmap (this.image = image);
+}
+/**
+* Set the widget text.
+*
+* PARAMETERS
+*
+* string - the new label for the widget
+*
+* REMARKS
+*
+* This method sets the widget label. The label may include
+* the mnemonic characters and line delimiters.
+*
+**/
+/**
+* Sets the widget text.
+* <p>
+* @param string the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ int i=0, j=0, mnemonic=0;
+ while (i < text.length) {
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int [] parseTable = getDisplay ().parseTable;
+ int xmString = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ parseTable,
+ parseTable.length,
+ 0);
+ if (xmString == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+ int [] argList = {
+ OS.XmNlabelType, OS.XmSTRING,
+ OS.XmNlabelString, xmString,
+ OS.XmNmnemonic, mnemonic,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ if (xmString != 0) OS.XmStringFree (xmString);
+}
+void setWrap (boolean wrap) {
+ // NOT DONE
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
new file mode 100755
index 0000000000..9d77400dc8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java
@@ -0,0 +1,1584 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+
+/**
+* The list class represents a selectable user interface object
+* that display a list of items and issues notificiation when an
+* item is selected from the list. A list may be single or multi
+* select.
+* <p>
+* <b>Styles</b><br>
+* <dd>SINGLE, MULTI,<br>
+* <dd>H_SCROLL, V_SCROLL<br>
+* <br>
+* <b>Events</b><br>
+* <dd>Selection<br>
+* <dd>DoubleSelection<br>
+*/
+
+/* Class Definition */
+public /*final*/ class List extends Scrollable {
+ int rows, columns;
+/**
+* Creates a new instance of the widget.
+*/
+public List (Composite parent, int style) {
+ /**
+ * Feature in Motif. It is not possible to create
+ * scrolled list that will never show the vertical
+ * scroll bar. Therefore, not matter what style
+ * bits are specified, set the V_SCROLL bits to
+ * match the widget Motif creates.
+ */
+ super (parent, checkStyle (style | SWT.V_SCROLL));
+}
+/**
+* Adds an item.
+* <p>
+* The item is placed at the end of the list.
+* Indexing is zero based.
+*
+* This operation can fail when the item cannot
+* be added in the OS.
+*
+* @param string the new item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the operation fails in the OS
+*/
+public void add (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.XmListAddItemUnselected (handle, xmString, 0);
+ OS.XmStringFree (xmString);
+}
+/**
+* Adds an item at an index.
+* <p>
+* The item is placed at an index in the list.
+* Indexing is zero based.
+*
+* This operation will fail when the index is
+* out of range or the item cannot be added in
+* the OS.
+*
+* @param string the new item
+* @param index the index for the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the string is null
+* @exception SWTError(ERROR_ITEM_NOT_ADDED)
+* when the item cannot be added
+*/
+public void add (String string, int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ /*
+ * Feature in Motif. When an index is out of range,
+ * the list widget adds the item at the end. This
+ * behavior is not wrong but it is unwanted. The
+ * fix is to check the range before adding the item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index <= argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.XmListAddItemUnselected (handle, xmString, index + 1);
+ OS.XmStringFree (xmString);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ XtWidgetGeometry result = new XtWidgetGeometry ();
+ result.request_mode = OS.CWWidth;
+ OS.XtQueryGeometry (handle, null, result);
+ int width = result.width, height = 0;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ if (hHint == SWT.DEFAULT || wHint == SWT.DEFAULT) {
+ int count = rows;
+ if (count == 0) {
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ count = argList [1];
+ }
+ if (hHint == SWT.DEFAULT) {
+ if (count == 0) {
+ height = DEFAULT_HEIGHT;
+ } else {
+ height = getItemHeight () * count;
+ }
+ }
+ if (wHint == SWT.DEFAULT && count == 0) {
+ width = DEFAULT_WIDTH;
+ }
+ }
+ Rectangle rect = computeTrim (0, 0, width, height);
+ return new Point (rect.width, rect.height);
+}
+/**
+* Computes the trim.
+*/
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Display display = getDisplay ();
+ int border = getBorderWidth ();
+ int trimX = x - border;
+ int trimY = y - border;
+ int trimWidth = width + (border * 2);
+ int trimHeight = height + (border * 2);
+ if (horizontalBar != null) {
+ int [] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (horizontalBar.handle, argList, argList.length / 2);
+ /**
+ * Motif adds four pixels between the bottom of the
+ * list and the horizontal scroll bar. Add those now.
+ */
+ trimHeight += argList [1] + 4;
+ trimY -= display.scrolledInsetY;
+ if (verticalBar != null) {
+ trimX -= display.scrolledInsetX;
+ }
+ }
+ if (verticalBar != null) {
+ int [] argList = {OS.XmNwidth, 0};
+ OS.XtGetValues (verticalBar.handle, argList, argList.length / 2);
+ trimWidth += argList [1];
+ trimX -= display.scrolledInsetX;
+ if (horizontalBar != null) {
+ trimY -= display.scrolledInsetY;
+ }
+ }
+ int [] argList = {
+ OS.XmNhighlightThickness, 0, /* 1 */
+ OS.XmNshadowThickness, 0, /* 3 */
+ OS.XmNlistMarginWidth, 0, /* 5 */
+ OS.XmNlistMarginHeight, 0 /* 7 */
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int thickness = argList [1] + (argList [3] * 2);
+ trimWidth += thickness + argList [5] + 1;
+ trimHeight += thickness + argList [7] + 1;
+ trimX -= argList [1] + argList [3] + argList [5];
+ trimY -= argList [1] + argList [3] + argList [7];
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+void createHandle (int index) {
+ state |= HANDLE;
+
+ /*
+ * Feature in Motif. When items are added or removed
+ * from a list, it may request and be granted, a new
+ * preferred size. This behavior is unwanted. The fix
+ * is to create a parent for the list that will disallow
+ * geometry requests.
+ */
+ formHandle = OS.XmCreateForm (parent.handle, null, null, 0);
+ if (formHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ int selectionPolicy = OS.XmBROWSE_SELECT, listSizePolicy = OS.XmCONSTANT;
+ if ((style & SWT.MULTI) != 0) {
+ selectionPolicy = OS.XmEXTENDED_SELECT;
+ if ((style & SWT.SIMPLE) != 0) selectionPolicy = OS.XmMULTIPLE_SELECT;
+ }
+ if ((style & SWT.H_SCROLL) == 0) listSizePolicy = OS.XmVARIABLE;
+ int [] argList = {
+ OS.XmNlistSizePolicy, listSizePolicy,
+ OS.XmNselectionPolicy, selectionPolicy,
+ OS.XmNtopAttachment, OS.XmATTACH_FORM,
+ OS.XmNbottomAttachment, OS.XmATTACH_FORM,
+ OS.XmNleftAttachment, OS.XmATTACH_FORM,
+ OS.XmNrightAttachment, OS.XmATTACH_FORM,
+ OS.XmNresizable, 0,
+// OS.XmNmatchBehavior, OS.XmNONE,
+ };
+ if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) {
+ handle = OS.XmCreateList (formHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ handle = OS.XmCreateScrolledList (formHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ scrolledHandle = OS.XtParent (handle);
+ }
+}
+ScrollBar createScrollBar (int type) {
+ return createStandardBar (type);
+}
+int defaultBackground () {
+ return getDisplay ().listBackground;
+}
+int defaultFont () {
+ return getDisplay ().listFont;
+}
+int defaultForeground () {
+ return getDisplay ().listForeground;
+}
+/**
+* Deselects an item.
+* <p>
+* If the item at an index is selected, it is
+* deselected. If the item at an index is not
+* selected, it remains deselected. Indices
+* that are out of range are ignored. Indexing
+* is zero based.
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselect (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Note: We rely on the fact that XmListDeselectPos ()
+ * fails silently when the indices are out of range.
+ */
+ if (index != -1) OS.XmListDeselectPos (handle, index + 1);
+}
+/**
+* Deselects a range of items.
+* <p>
+* If the item at an index is selected, it is
+* deselected. If the item at an index is not
+* selected, it remains deselected. Indices
+* that are out of range are ignored.
+*
+* Indexing is zero based. The range of items
+* is from the start index up to and including
+* the end index.
+
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselect (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ /*
+ * Note: We rely on the fact that XmListDeselectPos ()
+ * fails silently when the indices are out of range.
+ */
+ for (int i=start; i<=end; i++) {
+ int index = i + 1;
+ if (index != 0) OS.XmListDeselectPos (handle, index);
+ }
+}
+/**
+* Deselects items.
+* <p>
+* If the item at an index is selected, it is
+* deselected. If the item at an index is not
+* selected, it remains deselected. Indices
+* that are out of range are ignored. Indexing
+* is zero based.
+*
+* @param indices the indices of the items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the indices are null
+*/
+public void deselect (int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ /*
+ * Note: We rely on the fact that XmListDeselectPos ()
+ * fails silently when the indices are out of range.
+ */
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i] + 1;
+ if (index != 0) OS.XmListDeselectPos (handle, index);
+ }
+}
+/**
+* Deselects all items.
+* <p>
+*
+* If an item is selected, it is deselected.
+* If an item is not selected, it remains unselected.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void deselectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.XmListDeselectAllItems (handle);
+}
+public int getFocusIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.XmListGetKbdItemPos (handle) - 1;
+}
+/**
+* Gets an item at an 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
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public String getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitemCount, 0, OS.XmNitems, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ if (argList [3] == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int ptr = argList [3] + (index * 4);
+ int [] buffer1 = new int [1];
+ OS.memmove (buffer1, ptr, 4);
+ ptr = buffer1 [0];
+ int address = OS.XmStringUnparse (
+ ptr,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ return new String (Converter.mbcsToWcs (null, buffer));
+}
+/**
+* Gets the number of items.
+* <p>
+* This operation will fail if the number of
+* items could not be queried from the OS.
+*
+* @return the number of items in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_COUNT)
+* when the operation fails
+*/
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM_HEIGHT)
+* when the operation fails
+*/
+public int getItemHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {
+ OS.XmNlistSpacing, 0,
+ OS.XmNhighlightThickness, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int spacing = argList [1], highlight = argList [3];
+
+ /* Result is from empirical analysis on Linux and AIX */
+ return getFontHeight () + spacing + highlight + 1;
+}
+/**
+* Gets the items.
+* <p>
+* This operation will fail if the items cannot
+* be queried from the OS.
+*
+* @return the items in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public String [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int items = argList [1], itemCount = argList [3];
+ int [] buffer1 = new int [1];
+ String [] result = new String [itemCount];
+ for (int i=0; i<itemCount; i++) {
+ OS.memmove (buffer1, items, 4);
+ int ptr = buffer1 [0];
+ int address = OS.XmStringUnparse (
+ ptr,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ result[i] = new String (Converter.mbcsToWcs (null, buffer));
+ items += 4;
+ }
+ return result;
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+* @exception SWTError(ERROR_CANNOT_GET_SELECTION)
+* when the operation fails
+*/
+public String [] getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNselectedItems, 0, OS.XmNselectedItemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int items = argList [1], itemCount = argList [3];
+ int [] buffer1 = new int [1];
+ String [] result = new String [itemCount];
+ for (int i=0; i<itemCount; i++) {
+ OS.memmove (buffer1, items, 4);
+ int ptr = buffer1 [0];
+ int address = OS.XmStringUnparse (
+ ptr,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ result[i] = new String (Converter.mbcsToWcs (null, buffer));
+ items += 4;
+ }
+ 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_COUNT)
+* when the operation fails
+*/
+public int getSelectionCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNselectedItemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the index of the selected item.
+* <p>
+* Indexing is zero based.
+*
+* When the list is single-select, the index of
+* the selected item is returned or -1 if no item
+* is selected.
+*
+* When the list is multi-select, the index of
+* a selected item that contains the focus
+* rectangle or the index of the first selected
+* item is return. If no item is selected, -1
+* is returned.
+*
+* This operation will fail if the selected
+* index cannot be queried from the OS.
+*
+* @return the index of the selected item.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_SELECTION)
+* when the operation fails
+*/
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = OS.XmListGetKbdItemPos (handle);
+ if (OS.XmListPosSelected (handle, index)) return index - 1;
+ int [] count = new int [1], positions = new int [1];
+ if (!OS.XmListGetSelectedPos (handle, positions, count)) return -1;
+ if (count [0] == 0) return -1;
+ int address = positions [0];
+ int [] indices = new int [1];
+ OS.memmove (indices, address, 4);
+ OS.XtFree (address);
+ return indices [0] - 1;
+}
+/**
+* Gets the indices of the selected items.
+* <p>
+* Indexing is zero based.
+*
+* If no item is selected, an array is returned.
+*
+* This operation will fail if the selected
+* indices cannot be queried from the OS.
+*
+* @return the indices of the selected items.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_SELECTION)
+* when the operation fails
+*/
+public int [] getSelectionIndices () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] count = new int [1], positions = new int [1];
+ OS.XmListGetSelectedPos (handle, positions, count);
+ int [] result = new int [count [0]];
+ OS.memmove (result, positions [0], count [0] * 4);
+ if (positions [0] != 0) OS.XtFree (positions [0]);
+ for (int i=0; i<result.length; i++) --result [i];
+ return result;
+}
+/**
+* Gets the top index.
+* <p>
+* The top index is the index of the item that
+* is currently at the top of the widget. The
+* top index changes when the widget is scrolled.
+* Indexing is zero based.
+*
+* @return the index of the top item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getTopIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNtopItemPosition, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] - 1;
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNbrowseSelectionCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNextendedSelectionCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNdefaultActionCallback, windowProc, SWT.DefaultSelection);
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) return -1;
+ int index = OS.XmListItemPos (handle, xmString);
+ OS.XmStringFree (xmString);
+ return index - 1;
+}
+/**
+* Gets the index of an item.
+* <p>
+* The list is searched starting at and including
+* the start position until an item is found that
+* is equal to the search itenm. If no item is
+* found, -1 is returned. Indexing is zero based.
+*
+* @param string the search item
+* @param index the starting position
+* @return the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (String string, int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] argList = {OS.XmNitems, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int items = argList [1], itemCount = argList [3];
+ if (!((0 <= start) && (start < itemCount))) return -1;
+ byte [] buffer1 = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer1);
+ if (xmString == 0) return -1;
+ int index = start;
+ items += start * 4;
+ int [] buffer2 = new int [1];
+ while (index < itemCount) {
+ OS.memmove (buffer2, items, 4);
+ if (OS.XmStringCompare (buffer2 [0], xmString)) break;
+ items += 4; index++;
+ }
+ OS.XmStringFree (xmString);
+ if (index == itemCount) return -1;
+ return index;
+}
+/**
+* Determines if an item is selected.
+* <p>
+* Indexing is zero based.
+*
+* @param index the index of the item
+* @return the selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean isSelected (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index == -1) return false;
+ return OS.XmListPosSelected (handle, index + 1);
+}
+/**
+* Removes an item at an index.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param index the index of the item
+* @return the selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ /*
+ * Feature in Motif. An index out of range handled
+ * correctly by the list widget but causes an unwanted
+ * Xm Warning. The fix is to check the range before
+ * deleting an item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ OS.XmListDeletePos (handle, index + 1);
+}
+/**
+* Removes a range of items.
+* <p>
+* Indexing is zero based. The range of items
+* is from the start index up to and including
+* the end index.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ int count = end - start + 1;
+ /*
+ * Feature in Motif. An index out of range handled
+ * correctly by the list widget but causes an unwanted
+ * Xm Warning. The fix is to check the range before
+ * deleting an item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= start && start < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ OS.XmListDeleteItemsPos (handle, count, start + 1);
+ if (end >= argList [1]) error (SWT.ERROR_INVALID_RANGE);
+}
+/**
+* Removes an item.
+* <p>
+* This operation will fail when the item
+* could not be removed from the OS.
+*
+* @param string the search item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ int index = OS.XmListItemPos (handle, xmString);
+ OS.XmStringFree (xmString);
+ if (index == 0) error (SWT.ERROR_INVALID_ARGUMENT);
+ OS.XmListDeletePos (handle, index);
+}
+/**
+* Removes items.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be removed from
+* the OS.
+*
+* @param indices the indices of the items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the indices are null
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void remove (int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ /*
+ * Feature in Motif. An index out of range handled
+ * correctly by the list widget but causes an unwanted
+ * Xm Warning. The fix is to check the range before
+ * deleting an item.
+ */
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int length = 0, count = argList [1];
+ int [] newIndices = new int [indices.length];
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (!(0 <= index && index < count)) break;
+ newIndices [length++] = index + 1;
+ }
+ OS.XmListDeletePositions (handle, newIndices, length);
+ if (length < indices.length) error (SWT.ERROR_INVALID_RANGE);
+}
+/**
+* Removes all items.
+* <p>
+* This operation will fail when an item
+* could not be removed in the OS.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_ITEM_NOT_REMOVED)
+* when the operation fails
+*/
+public void removeAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.XmListDeselectAllItems (handle);
+ OS.XmListDeleteAllItems (handle);
+ /*
+ * Bug in AIX. When all list items are deleted
+ * from a scrolled list that is currently showing a
+ * horizontal scroll bar, the horizontal scroll bar
+ * is hidden, but the list does not grow to take up
+ * the space once occupied by the bar. The fix is
+ * of force a resize of the list.
+ */
+ if ((style & SWT.H_SCROLL) != 0) OS.XtResizeWindow (handle);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+/**
+* Selects an item.
+* <p>
+* If the item at an index is not selected, it is
+* selected. If the item at an index is selected,
+* it remains selected. Indices that are out of
+* range are ignored. Indexing is zero based.
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void select (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index == -1) return;
+ if (OS.XmListPosSelected (handle, index + 1)) return;
+ /*
+ * Feature in MOTIF. The X/MOTIF 1.2 spec says that XmListSelectPos ()
+ * in a XmEXTENDED_SELECT list widget will add the index to the selected
+ * indices. The observed behavior does not match the spec. The fix is
+ * to temporarily switch the XmNselectionPolicy to XmMULTIPLE_SELECT
+ * and then switch it back because XmListSelectPost () works as specified
+ * for XmMULTIPLE_SELECT list widgets.
+ */
+ int [] argList = {OS.XmNselectionPolicy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int oldPolicy = argList [1];
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmMULTIPLE_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ /*
+ * Note: We rely on the fact that XmListSelectPos ()
+ * fails silently when the indices are out of range.
+ */
+ OS.XmListSelectPos (handle, index + 1, false);
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmEXTENDED_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+}
+/**
+* Selects a range of items.
+* <p>
+* If the item at an index is not selected, it is
+* selected. If the item at an index is selected,
+* it remains selected. Indices that are out of
+* range are ignored.
+*
+* Indexing is zero based. The range of items
+* is from the start index up to and including
+* the end index.
+*
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void select (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int index = Math.min (argList[1] - 1, end) + 1;
+ if (index != 0 && index >= start) OS.XmListSelectPos (handle, index, false);
+ return;
+ }
+ /*
+ * Feature in MOTIF. The X/MOTIF 1.2 spec says that XmListSelectPos ()
+ * in a XmEXTENDED_SELECT list widget will add the index to the selected
+ * indices. The observed behavior does not match the spec. The fix is
+ * to temporarily switch the XmNselectionPolicy to XmMULTIPLE_SELECT
+ * and then switch it back because XmListSelectPos () works as specified
+ * for XmMULTIPLE_SELECT list widgets.
+ */
+ int [] argList = {OS.XmNselectionPolicy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int oldPolicy = argList [1];
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmMULTIPLE_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ /*
+ * Note: We rely on the fact that XmListSelectPos ()
+ * fails silently when the indices are out of range.
+ */
+ for (int i=start; i<=end; i++) {
+ int index = i + 1;
+ if ((index != 0) && !OS.XmListPosSelected (handle, index)) {
+ OS.XmListSelectPos (handle, index, false);
+ }
+ }
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmEXTENDED_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+}
+/**
+* Selects items.
+* <p>
+* If the item at an index is not selected, it is
+* selected. If the item at an index is selected,
+* it remains selected. Indices that are out of
+* range are ignored. Indexing is zero based.
+*
+* @param indices the indices of the items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when the indices are null
+*/
+public void select (int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SINGLE) != 0) {
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int count = argList [1];
+ for (int i = 0; i < indices.length; i++) {
+ int index = indices [i];
+ if (0 <= index && index < count) {
+ select (index);
+ return;
+ }
+ }
+ return;
+ }
+ /*
+ * Feature in MOTIF. The X/MOTIF 1.2 spec says that XmListSelectPos ()
+ * in a XmEXTENDED_SELECT list widget will add the index to the selected
+ * indices. The observed behavior does not match the spec. The fix is
+ * to temporarily switch the XmNselectionPolicy to XmMULTIPLE_SELECT
+ * and then switch it back because XmListSelectPos () works as specified
+ * for XmMULTIPLE_SELECT list widgets.
+ */
+ int [] argList = {OS.XmNselectionPolicy, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int oldPolicy = argList [1];
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmMULTIPLE_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ /*
+ * Note: We rely on the fact that XmListSelectPos ()
+ * fails silently when the indices are out of range.
+ */
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i] + 1;
+ if ((index != 0) && !OS.XmListPosSelected (handle, index)) {
+ OS.XmListSelectPos (handle, index, false);
+ }
+ }
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmEXTENDED_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+}
+void select (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] table = new int [items.length];
+ for (int i=0; i<items.length; i++) {
+ String string = items [i];
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ table [i] = xmString;
+ }
+ int ptr = OS.XtMalloc (items.length * 4);
+ OS.memmove (ptr, table, items.length * 4);
+ int [] argList = {OS.XmNselectedItems, ptr, OS.XmNselectedItemCount, table.length};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ for (int i=0; i<table.length; i++) OS.XmStringFree (table [i]);
+ OS.XtFree (ptr);
+ OS.XmListUpdateSelectedList (handle);
+}
+/**
+* Selects all items.
+* <p>
+* If an item is not selected, it is selected.
+* If an item is selected, it remains selected.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void selectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return;
+ /*
+ * Feature in MOTIF. The X/MOTIF 1.2 spec says that XmListSelectPos ()
+ * in a XmEXTENDED_SELECT list widget will add the index to the selected
+ * indices. The observed behavior does not match the spec. The fix is
+ * to temporarily switch the XmNselectionPolicy to XmMULTIPLE_SELECT
+ * and then switch it back because XmListSelectPos () works as specified
+ * for XmMULTIPLE_SELECT list widgets.
+ */
+ int [] argList = {OS.XmNselectionPolicy, 0, OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int oldPolicy = argList [1];
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmMULTIPLE_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ for (int i=0; i<argList[3]; i++) {
+ int index = i + 1;
+ if (!OS.XmListPosSelected (handle, index)) {
+ OS.XmListSelectPos (handle, index, false);
+ }
+ }
+ if (oldPolicy == OS.XmEXTENDED_SELECT) {
+ argList [1] = OS.XmEXTENDED_SELECT;
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+}
+/**
+* Sets the bounds.
+*/
+public void setBounds (int x, int y, int width, int height) {
+ super.setBounds (x, y, width, height);
+ /*
+ * Bug in AIX. When the receiver has a vertical scroll bar
+ * that is currently not visible and no horizontal scroll bar
+ * and is resized to be smaller in both the width and height
+ * and goes from the state where the width of the longest item
+ * is smaller than the width of the list to the state where the
+ * width of the longest item is longer than the width of the
+ * list, the list hides the vertical scroll bar and leaves a
+ * blank space where it should be. This often happens when a
+ * shell containing a list that matches the above criteria is
+ * maximized and then restored. This is just one of a number
+ * of repeatable cases where the scrolled window hides the
+ * scroll bars but does not resize the list. The fix is to
+ * detect these cases and force the scroll bars to be layed
+ * out properly by growing and then shrinking the scrolled
+ * window.
+ */
+// fixHScroll := hScroll ~~ nil and: [
+// hScroll isVisible not and: [
+// height ~~ (self dimensionAt: XmNheight)]].
+// fixVScroll := vScroll ~~ nil and: [
+// vScroll isVisible not and: [
+// width ~~ (self dimensionAt: XmNwidth)]].
+// (fixHScroll or: [fixVScroll]) ifFalse: [^self].
+
+ /* Grow and shrink the scrolled window by one pixel */
+ if (scrolledHandle == 0) return;
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ OS.XtResizeWidget (scrolledHandle, argList [1] + 1, argList [3], argList [5]);
+ OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]);
+}
+void setFocusIndex (int index) {
+ OS.XmListSetKbdItemPos (handle, index + 1);
+}
+/**
+* Sets the text of an item.
+* <p>
+* Indexing is zero based.
+*
+* This operation will fail when the index is out
+* of range or an item could not be changed in
+* the OS.
+*
+* @param index the index for the item
+* @param string the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+* @exception SWTError(ERROR_ITEM_NOT_MODIFIED)
+* when the operation fails
+*/
+public void setItem (int index, String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ int [] argList = {OS.XmNitemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (!(0 <= index && index < argList [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ boolean isSelected = OS.XmListPosSelected (handle, index + 1);
+ OS.XmListReplaceItemsPosUnselected (handle, new int [] {xmString}, 1, index + 1);
+ if (isSelected) OS.XmListSelectPos (handle, index + 1, false);
+ OS.XmStringFree (xmString);
+}
+/**
+* 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 items the array of items
+*
+* This operation will fail when an item is null
+* or could not be added in the OS.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+*/
+public void setItems (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ /*
+ * Bug in AIX. When all list items are replaced
+ * in a scrolled list that is currently showing a
+ * horizontal scroll bar, the horizontal scroll bar
+ * is hidden, but the list does not grow to take up
+ * the space once occupied by the bar. The fix is
+ * of force the horizontal bar to be recomputed by
+ * removing all items and resizing the list.
+ */
+ OS.XmListSetPos (handle, 0);
+ OS.XmListDeselectAllItems (handle);
+ if ((style & SWT.H_SCROLL) != 0) {
+ OS.XmListDeleteAllItems (handle);
+ }
+ int index = 0;
+ int [] table = new int [items.length];
+ while (index < items.length) {
+ String string = items [index];
+ if (string == null) break;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString == 0) break;
+ table [index++] = xmString;
+ }
+ int ptr = OS.XtMalloc (index * 4);
+ OS.memmove (ptr, table, index * 4);
+ int [] argList = {OS.XmNitems, ptr, OS.XmNitemCount, index};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ for (int i=0; i<index; i++) OS.XmStringFree (table [i]);
+ OS.XtFree (ptr);
+ /*
+ * Bug in Motif. Resize the list to work around
+ * the horizontal scroll bar display bug described
+ * above.
+ */
+ if ((style & SWT.H_SCROLL) != 0) {
+ OS.XtResizeWindow (handle);
+ }
+ if (index < items.length) error (SWT.ERROR_ITEM_NOT_ADDED);
+}
+/**
+* Sets the selection.
+* <p>
+* The previous selection is cleared
+* before new items are selected.
+*
+* @see List#deselectAll()
+* @see List#select(int)
+*
+* @param index the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int index) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+}
+/**
+* Sets the selection.
+* <p>
+* The previous selection is cleared
+* before new items are selected.
+*
+* @see List#deselectAll()
+* @see List#select(int, int)
+*
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int start, int end) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+/**
+* Sets the selection.
+* <p>
+* The previous selection is cleared
+* before new items are selected.
+*
+* @see List#deselectAll()
+* @see List#select(int [])
+*
+* @param indices the indices of the items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection(int[] indices) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (indices);
+}
+/**
+* Sets the selection.
+* <p>
+* The previous selection is cleared
+* before new items are selected.
+*
+* @see List#deselectAll()
+* @see List#select(int [])
+*
+* @param items the array of items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when items is null
+*/
+public void setSelection (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SINGLE) != 0) {
+ for (int i=items.length-1; i>=0; --i) {
+ String string = items [i];
+ if (string != null) {
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString != 0) {
+ int index = OS.XmListItemPos (handle, xmString);
+ if (index != 0) OS.XmListSelectPos (handle, index, false);
+ OS.XmStringFree (xmString);
+ if ((index != 0) && OS.XmListPosSelected (handle, index)) return;
+ }
+ }
+ }
+ OS.XmListDeselectAllItems (handle);
+ return;
+ }
+ OS.XmListDeselectAllItems (handle);
+ int length = 0;
+ int [] table = new int [items.length];
+ for (int i=0; i<items.length; i++) {
+ String string = items [i];
+ if (string != null) {
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmString = OS.XmStringCreateLocalized (buffer);
+ if (xmString != 0) table [length++] = xmString;
+ }
+ }
+ int ptr = OS.XtMalloc (length * 4);
+ OS.memmove (ptr, table, length * 4);
+ int [] argList = {OS.XmNselectedItems, ptr, OS.XmNselectedItemCount, length};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ for (int i=0; i<length; i++) OS.XmStringFree (table [i]);
+ OS.XtFree (ptr);
+ OS.XmListUpdateSelectedList (handle);
+}
+/**
+* Sets the size.
+*/
+public void setSize (int width, int height) {
+ super.setSize (width, height);
+ /*
+ * Bug in AIX. When the receiver has a vertical scroll bar
+ * that is currently not visible and no horizontal scroll bar
+ * and is resized to be smaller in both the width and height
+ * and goes from the state where the width of the longest item
+ * is smaller than the width of the list to the state where the
+ * width of the longest item is longer than the width of the
+ * list, the list hides the vertical scroll bar and leaves a
+ * blank space where it should be. This often happens when a
+ * shell containing a list that matches the above criteria is
+ * maximized and then restored. This is just one of a number
+ * of repeatable cases where the scrolled window hides the
+ * scroll bars but does not resize the list. The fix is to
+ * detect these cases and force the scroll bars to be layed
+ * out properly by growing and then shrinking the scrolled
+ * window.
+ */
+// fixHScroll := hScroll ~~ nil and: [
+// hScroll isVisible not and: [
+// height ~~ (self dimensionAt: XmNheight)]].
+// fixVScroll := vScroll ~~ nil and: [
+// vScroll isVisible not and: [
+// width ~~ (self dimensionAt: XmNwidth)]].
+// (fixHScroll or: [fixVScroll]) ifFalse: [^self].
+
+ /* Grow and shrink the scrolled window by one pixel */
+ if (scrolledHandle == 0) return;
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ OS.XtResizeWidget (scrolledHandle, argList [1] + 1, argList [3], argList [5]);
+ OS.XtResizeWidget (scrolledHandle, argList [1], argList [3], argList [5]);
+}
+/**
+* Sets the top index.
+* <p>
+* The top index is the index of the item that
+* is currently at the top of the widget. The
+* top index changes when the widget is scrolled.
+* Indexing starts from zero.
+*
+* @param index the new top index
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setTopIndex (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNitemCount, 0, OS.XmNvisibleItemCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int newIndex = Math.max (1, Math.min (index + 1, argList [1]));
+ int lastIndex = Math.max (1, argList [1] - argList [3] + 1);
+ if (newIndex > lastIndex) newIndex = lastIndex;
+ OS.XmListSetPos (handle, newIndex);
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void showSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] buffer = new int [1], positions = new int [1];
+ if (!OS.XmListGetSelectedPos (handle, positions, buffer)) return;
+ if (buffer [0] == 0) return;
+ int address = positions [0];
+ int [] indices = new int [1];
+ OS.memmove (indices, address, 4);
+ OS.XtFree (address);
+ int index = indices [0];
+ int [] argList = {
+ OS.XmNtopItemPosition, 0,
+ OS.XmNvisibleItemCount, 0,
+ OS.XmNitemCount, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int topIndex = argList [1], visibleCount = argList [3], count = argList [5];
+ int bottomIndex = Math.min (topIndex + visibleCount - 1, count);
+ if ((topIndex <= index) && (index <= bottomIndex)) return;
+ int lastIndex = Math.max (1, count - visibleCount + 1);
+ int newTop = Math.min (Math.max (index - (visibleCount / 2), 1), lastIndex);
+ OS.XmListSetPos (handle, newTop);
+}
+int topHandle () {
+ /*
+ * Normally, when a composite has both a form handle
+ * and a scrolled handle, the scrolled handle is the
+ * parent of the form handle. In the case of a list,
+ * both handles are present but the form handle is
+ * parent of the scrolled handle and therefore is
+ * the top handle of the list.
+ */
+ return formHandle;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
new file mode 100755
index 0000000000..31a4ce5f15
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Menu.java
@@ -0,0 +1,648 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+* A menu is a user interface object contains selectable
+* menu items.
+* <p>
+* <b>Styles</b><br>
+* <dd>BAR, DROP_DOWN, POP_UP<br>
+*/
+
+/* Class Definition */
+public /*final*/ class Menu extends Widget {
+ boolean hasLocation;
+ MenuItem cascade, defaultItem;
+ Decorations parent;
+/**
+* Creates a new instance of the widget.
+*/
+public Menu (Control parent) {
+ this (checkNull(parent).getShell (), SWT.POP_UP);
+}
+/**
+* Creates a new instance of the widget.
+*/
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+/**
+* Creates a new instance of the widget.
+*/
+public Menu (Menu parentMenu) {
+ this (checkNull(parentMenu).parent, SWT.DROP_DOWN);
+}
+/**
+* Creates a new instance of the widget.
+*/
+public Menu (MenuItem parentItem) {
+ this (checkNull(parentItem).parent);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addMenuListener(MenuListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener(SWT.Hide,typedListener);
+ addListener(SWT.Show,typedListener);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.POP_UP, SWT.BAR, SWT.DROP_DOWN, 0, 0, 0);
+}
+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;
+}
+void createHandle (int index) {
+ state |= HANDLE;
+
+ /*
+ * Bug in Motif. For some reason, creating a menu after any application context
+ * and shell have been destroyed will segment fault unless a new application
+ * context and shell have been created in the current thread. The fix is to
+ * detect this case and create and destroy a temporary application context and
+ * shell.
+ */
+ int xDisplay = 0, shellHandle = 0;
+ if (Display.DisplayDisposed) {
+ int [] argc = new int [] {0};
+ int xtContext = OS.XtCreateApplicationContext ();
+ xDisplay = OS.XtOpenDisplay (xtContext, null, null, null, 0, 0, argc, 0);
+ shellHandle = OS.XtAppCreateShell (null, null, OS.TopLevelShellWidgetClass (), xDisplay, null, 0);
+ }
+
+ /* BAR menu */
+ if ((style & SWT.BAR) != 0) {
+ int parentHandle = parent.scrolledHandle;
+ handle = OS.XmCreateMenuBar (parentHandle, null, null, 0);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* POPUP and PULLDOWN menus */
+
+ /*
+ * Bug in Motif. When an existing popup menu is destroyed just
+ * before creating a new popup menu and the new menu is managed,
+ * the cursor changes to the menu cursor but the new menu is not
+ * displayed. Also, Motif fails to show a popup menu when the
+ * mouse is released. Both problems stem from the fact that the
+ * popup menu is in the widget tree of a visible shell. The fix
+ * is to create all popup menus as children of a hidden dialog
+ * shell. Menus created this way are automatically destroyed
+ * when the shell is destroyed.
+ */
+ if ((style & SWT.POP_UP) != 0) {
+ int parentHandle = parent.dialogHandle ();
+ handle = OS.XmCreatePopupMenu (parentHandle, new byte [1], null, 0);
+ } else {
+ /*
+ * Bug in Linux. For some reason, when the parent of the pulldown
+ * menu is not the main window handle, XtDestroyWidget() occasionally
+ * segment faults when the shell is destroyed. The fix is to ensure
+ * that the parent is the main window.
+ */
+ int parentHandle = parent.scrolledHandle;
+ handle = OS.XmCreatePulldownMenu (parentHandle, new byte [1], null, 0);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+
+ /* Workaround for bug in Motif */
+ if (Display.DisplayDisposed) {
+ if (shellHandle != 0) OS.XtDestroyWidget (shellHandle);
+ if (xDisplay != 0) {
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ OS.XtDestroyApplicationContext (xtContext);
+ }
+ }
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ parent.add (this);
+}
+/**
+* Gets the default item.
+* <p>
+*
+* @return the default menu item.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public MenuItem getDefaultItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return defaultItem;
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ Decorations parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+* Gets the enabled state.
+* <p>
+* @return the enabled flag
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets an item at an 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
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_CANNOT_GET_ITEM)
+* when the operation fails
+*/
+public MenuItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ int [] handles = new int [argList [3]];
+ OS.memmove (handles, argList [1], argList[3] * 4);
+ int i = 0, count = 0;
+ while (i < argList [3]) {
+ if (OS.XtIsManaged (handles [i])) {
+ if (index == count) break;
+ count++;
+ }
+ i++;
+ }
+ if (index != count) error (SWT.ERROR_INVALID_RANGE);
+ Widget widget = WidgetTable.get (handles [i]);
+ if (!(widget instanceof MenuItem)) error (SWT.ERROR_CANNOT_GET_ITEM);
+ return (MenuItem) widget;
+}
+/**
+* Gets the number of items.
+* <p>
+* @return the number of items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [1] == 0 || argList [3] == 0) return 0;
+ int [] handles = new int [argList [3]];
+ OS.memmove (handles, argList [1], argList [3] * 4);
+ int count = 0;
+ for (int i=0; i<argList [3]; i++) {
+ if (OS.XtIsManaged (handles [i])) count++;
+ }
+ return count;
+}
+/**
+* Gets the items.
+* <p>
+* @return items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public MenuItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int ptr = argList [1], count = argList [3];
+ if (count == 0 || ptr == 0) return new MenuItem [0];
+ int [] handles = new int [count];
+ OS.memmove (handles, ptr, count * 4);
+ MenuItem [] items = new MenuItem [count];
+ int i = 0, j = 0;
+ while (i < count) {
+ Widget item = WidgetTable.get (handles [i]);
+ if (item != null) items [j++] = (MenuItem) item;
+ i++;
+ }
+ if (i == j) return items;
+ MenuItem [] newItems = new MenuItem [j];
+ System.arraycopy (items, 0, newItems, 0, j);
+ return newItems;
+}
+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;
+}
+/**
+* Gets the parent.
+* <p>
+* @return the parent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Decorations getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+/**
+* Gets the parent item.
+* <p>
+* @return the parent item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public MenuItem getParentItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return cascade;
+}
+/**
+* Gets the parent menu.
+* <p>
+* @return the parent menu
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Menu getParentMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (cascade != null) return cascade.parent;
+ return null;
+}
+/**
+* Gets the shell.
+* <p>
+* @return the shell
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
+/**
+* Gets the visibility state.
+* <p>
+* If the parent is not visible or some other condition
+* makes the widget not visible, the widget can still be
+* considered visible even though it may not actually be
+* showing.
+*
+* @return visible the visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.XtIsManaged (handle);
+}
+void hookEvents () {
+ int windowProc = parent.getShell ().getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, SWT.Help);
+ OS.XtAddCallback (handle, OS.XmNmapCallback, windowProc, SWT.Show);
+ OS.XtAddCallback (handle, OS.XmNunmapCallback, windowProc, SWT.Hide);
+}
+/**
+* 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 item the search item
+* @return the index of the item
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public int indexOf (MenuItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int [] handles = new int [argList [3]];
+ OS.memmove (handles, argList [1], handles.length * 4);
+ int index = 0;
+ for (int i=0; i<handles.length; i++) {
+ if (OS.XtIsManaged (handles [i])) {
+ if (handles [i] == item.handle) return index;
+ index++;
+ }
+ }
+ return -1;
+}
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+/**
+* Gets the visibility status.
+* <p>
+* This method returns the visibility status of the
+* widget in the widget hierarchy. If the parent is not
+* visible or some other condition makes the widget not
+* visible, this method will return false.
+*
+* @return the actual visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible ();
+}
+int processHelp (int callData) {
+ sendHelpEvent (callData);
+ return 0;
+}
+int processHide (int callData) {
+ sendEvent (SWT.Hide);
+ return 0;
+}
+int processShow (int callData) {
+ /*
+ * SWT.Selection events are posted to allow stepping
+ * in the VA/Java debugger. SWT.Show events are
+ * sent to ensure that application event handler
+ * code runs before the menu is displayed. This
+ * means that SWT.Show events would normally occur
+ * before SWT.Selection events. While this is not
+ * strictly incorrect, applications often use the
+ * SWT.Selection event to update the state of menu
+ * items and would like the ordering of events to
+ * be the other way around.
+ *
+ * The fix is to run the deferred events before
+ * the menu is shown. This means that stepping
+ * through a selection event that was caused by
+ * a popup menu will fail in VA/Java.
+ */
+ Display display = getDisplay ();
+ display.runDeferredEvents ();
+ sendEvent (SWT.Show);
+ return 0;
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (cascade != null) cascade.setMenu (null);
+ if (((style & SWT.BAR) != 0) && (this == parent.menuBar)) parent.setMenuBar (null);
+}
+void releaseWidget () {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ super.releaseWidget ();
+ if (parent != null) parent.remove (this);
+ parent = null;
+ cascade = defaultItem = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeMenuListener(MenuListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Hide, listener);
+ eventTable.unhook(SWT.Show, listener);
+}
+void sendHelpEvent (int callData) {
+ if (hooks (SWT.Help)) {
+ postEvent (SWT.Help);
+ return;
+ }
+ parent.sendHelpEvent (callData);
+}
+/**
+* Sets the default item.
+* <p>
+* @param item the default menu item (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setDefaultItem (MenuItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ defaultItem = item;
+}
+/**
+* Sets the enabled state.
+* <p>
+* @param enabled the new value of the enabled flag
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ int [] argList = {OS.XmNx, x, OS.XmNy, y};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ hasLocation = true;
+}
+/**
+* Sets the visibility state.
+* <p>
+* If the parent is not visible or some other condition
+* makes the widget not visible, the widget can still be
+* considered visible even though it may not actually be
+* showing.
+*
+* @param visible the new visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.BAR | SWT.DROP_DOWN)) != 0) return;
+ if (visible) {
+ if (!hasLocation) {
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ if (xWindow == 0) return;
+ int [] unused = new int [1];
+ int [] rootX = new int [1], rootY = new int [1];
+ if (OS.XQueryPointer (
+ xDisplay, xWindow, unused, unused,
+ rootX, rootY,
+ unused, unused, unused) == 0) return;
+ int [] argList = {OS.XmNx, rootX [0], OS.XmNy, rootY [0]};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+ OS.XtManageChild (handle);
+ } else {
+ OS.XtUnmanageChild (handle);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
new file mode 100755
index 0000000000..23ff61753d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MenuItem.java
@@ -0,0 +1,705 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+* A menu item is a selectable user interface object
+* that issues notificiation when pressed and released.
+*
+* <p>
+* <b>Styles</b><br>
+* <dd>CASCADE, CHECK, PUSH, RADIO, SEPARATOR<br>
+* <b>Events</b><br>
+* <dd>Selection<br>
+*/
+
+/* Class Definition */
+public /*final*/ class MenuItem extends Item {
+ int accelerator;
+ Menu parent, menu;
+/**
+* Creates a new instance of the widget.
+*/
+public MenuItem (Menu parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (OS.XmLAST_POSITION);
+}
+/**
+* Creates a new instance of the widget.
+*/
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ if (index == OS.XmLAST_POSITION) error (SWT.ERROR_INVALID_RANGE);
+ createWidget (index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addArmListener (ArmListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Arm, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+ int parentHandle = parent.handle;
+ int [] argList1 = {OS.XmNchildren, 0, OS.XmNnumChildren, 0};
+ OS.XtGetValues (parentHandle, argList1, argList1.length / 2);
+ if (index != OS.XmLAST_POSITION && argList1 [1] != 0) {
+ int [] handles = new int [argList1 [3]];
+ OS.memmove (handles, argList1 [1], argList1 [3] * 4);
+ int i = 0, count = 0;
+ while (i < argList1 [3]) {
+ if (OS.XtIsManaged (handles [i])) {
+ if (index == count) break;
+ count++;
+ }
+ i++;
+ }
+ if (index != count) error (SWT.ERROR_INVALID_RANGE);
+ index = i;
+ }
+ if ((style & SWT.SEPARATOR) != 0) {
+ int [] argList = {
+ OS.XmNorientation, (parent.style & SWT.BAR) != 0 ? OS.XmVERTICAL : OS.XmHORIZONTAL,
+ OS.XmNpositionIndex, index,
+ };
+ handle = OS.XmCreateSeparatorGadget (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ int [] argList = {OS.XmNpositionIndex, index};
+ if ((style & SWT.PUSH) != 0) {
+ handle = OS.XmCreatePushButtonGadget (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ handle = OS.XmCreateToggleButtonGadget (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ handle = OS.XmCreateCascadeButtonGadget (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+void destroyWidget () {
+ /*
+ * Feature in Motif. When a popup menu item
+ * is destroyed, the menu does not recompute
+ * the menu size until the next time the menu
+ * is managed. This means that the user can
+ * watch the menu get updated as new items are
+ * added and old ones deleted. The fix is to
+ * unmanaged the item before destroying it to
+ * force the menu to recompute the menu size.
+ */
+ OS.XtUnmanageChild (handle);
+ super.destroyWidget ();
+}
+/**
+* Gets the accelerator.
+* <p>
+* This method gets the widget accelerator. An accelerator
+* is the bit-wise OR of zero or more modifier masks and a key.
+* Examples: SWT.CONTROL | SWT.SHIFT | 'T', SWT.ALT | SWT.F2.
+*
+* @param accelerator the accelerator
+*
+* @return the accelerator
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getAccelerator () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return accelerator;
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ Menu parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+* Gets the enabled state.
+* <p>
+* A disabled widget is typically not selectable from
+* the user interface and draws with an inactive or
+* grayed look.
+*
+* @return a boolean that is the enabled state of the widget.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets the menu.
+* <p>
+* For a cascade menu item, the menu is a pulldown menu
+* that is displayed when the user selects the cascade item.
+* For a window, the menu is always a popup menu, that is
+* displayed when the user requests a popup menu for the
+* window. The sequence of key strokes or button presses
+* that requests a menu is platform specific.
+*
+* @return the menu
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menu;
+}
+String getNameText () {
+ if ((style & SWT.SEPARATOR) != 0) return "|";
+ return super.getNameText ();
+}
+/**
+* Gets the parent.
+* <p>
+* @return the parent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Menu getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+/**
+* Gets the selection state.
+* <p>
+* This method gets the widget selection state for a
+* widgets with the style CHECK or RADIO. It
+* returns false for widgets that do not have one of
+* these styles.
+* true or false - for CHECK or RADIO.
+* false - for all other widget styles
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+ int [] argList = {OS.XmNset, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Get the button text.
+*
+* RETURNS
+*
+* A String that is the label of the button.
+*
+* REMARKS
+*
+* This method returns the button label. The label may
+* include the mnemonic character but must not contain line
+* delimiters.
+*
+**/
+String getText2 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) return "";
+ int [] argList = {OS.XmNlabelString, 0, OS.XmNmnemonic, 0, OS.XmNacceleratorText, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int xmString1 = argList [1], mnemonic = argList [3], xmString2 = argList [5];
+ if (xmString1 == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
+ char [] result = null;
+ int address = OS.XmStringUnparse (
+ xmString1,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address != 0) {
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ result = Converter.mbcsToWcs (null, buffer);
+ }
+ String accelText = "";
+ if (xmString1 != 0) OS.XmStringFree (xmString1);
+ if (xmString2 != 0) {
+ address = OS.XmStringUnparse (
+ xmString2,
+ null,
+ OS.XmCHARSET_TEXT,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ OS.XmOUTPUT_ALL);
+ if (address != 0) {
+ int length = OS.strlen (address);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, address, length);
+ OS.XtFree (address);
+ accelText = '\t' + new String (Converter.mbcsToWcs (null, buffer));
+ }
+ }
+ if (xmString2 != 0) OS.XmStringFree (xmString2);
+ if (result == null) return accelText;
+ int count = 0;
+ if (mnemonic != 0) count++;
+ for (int i=0; i<result.length-1; i++)
+ if (result [i] == Mnemonic) count++;
+ char [] newResult = result;
+ if ((count != 0) || (mnemonic != 0)) {
+ newResult = new char [result.length + count];
+ int i = 0, j = 0;
+ while (i < result.length) {
+ if ((mnemonic != 0) && (result [i] == mnemonic)) {
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ mnemonic = 0;
+ }
+ if ((newResult [j++] = result [i++]) == Mnemonic)
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ }
+ }
+ return new String (newResult) + accelText;
+}
+void hookEvents () {
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = parent.getShell ().getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNhelpCallback, windowProc, SWT.Help);
+ if ((style & SWT.CASCADE) != 0) {
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, SWT.Arm);
+ OS.XtAddCallback (handle, OS.XmNcascadingCallback, windowProc, SWT.Arm);
+ } else {
+ OS.XtAddCallback (handle, OS.XmNarmCallback, windowProc, SWT.Arm);
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection);
+ } else {
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, SWT.Selection);
+ }
+}
+/**
+* Gets the enabled state.
+* <p>
+* This method gets the enabled state of the widget
+* in the widget hierarchy. When an ancestor of the
+* widget is disabled, the enabled state of the widget
+* in the widget hierarchy is disabled regardless of
+* the actual enabled state of the widget.
+*
+* @param enabled a boolean that is the enabled state.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean isEnabled () {
+ return getEnabled ();
+}
+String keysymName (int keysym) {
+ if (keysym == 8) return "BackSpace";
+ if (keysym == 13) return "Return";
+ if (keysym == 27) return "Escape";
+ if (keysym == 127) return "Delete";
+ if (33 <= keysym && keysym <= 126) {
+ return new String (new char [] {(char) keysym});
+ }
+ /**
+ * Note that XKeysymToString returns a value in a static
+ * area which must not be modified or freed.
+ */
+ int ptr = OS.XKeysymToString (keysym);
+ if (ptr == 0) return "";
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, buffer.length);
+ return new String (Converter.mbcsToWcs (null, buffer));
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+int processArm (int callData) {
+ postEvent (SWT.Arm);
+ return 0;
+}
+int processHelp (int callData) {
+ if (hooks (SWT.Help)) {
+ postEvent (SWT.Help);
+ return 0;
+ }
+ parent.sendHelpEvent (callData);
+ return 0;
+}
+int processSelection (int callData) {
+ postEvent (SWT.Selection);
+ return 0;
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+}
+void releaseWidget () {
+ if (menu != null && !menu.isDisposed()) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ menu = null;
+ super.releaseWidget ();
+ accelerator = 0;
+ if (this == parent.defaultItem) {
+ parent.defaultItem = null;
+ }
+ parent = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeArmListener (ArmListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Arm, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+/**
+* Sets the accelerator.
+*/
+public void setAccelerator (int accelerator) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.accelerator = accelerator;
+ int ptr = 0;
+ if (accelerator != 0) {
+ String ctrl, alt, shift;
+ ctrl = alt = shift = "";
+ if ((accelerator & SWT.ALT) != 0) alt = "Meta ";
+ if ((accelerator & SWT.SHIFT) != 0) shift = "Shift ";
+ if ((accelerator & SWT.CTRL) != 0) ctrl = "Ctrl ";
+ int keysym = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CTRL);
+ int newKey = Display.untranslateKey (keysym);
+ if (newKey != 0) {
+ keysym = newKey;
+ } else {
+ keysym = wcsToMbcs ((char) keysym);
+ }
+ String key = "<Key>" + keysymName (keysym);
+ byte [] buffer = Converter.wcsToMbcs (null, ctrl + alt + shift + key, true);
+ ptr = OS.XtMalloc (buffer.length);
+ if (ptr != 0) OS.memmove (ptr, buffer, buffer.length);
+ }
+ int [] argList = {OS.XmNaccelerator, ptr};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ if (ptr != 0) OS.XtFree (ptr);
+}
+/**
+* Sets the enabled state.
+* <p>
+* A disabled widget is typically not selectable from
+* the user interface and draws with an inactive or
+* grayed look.
+*
+* @param enabled the new value of the enabled flag
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the menu.
+* <p>
+* For a cascade menu item, the menu is a pulldown menu
+* that is displayed when the user selects the cascade item.
+* For a window, the menu is always a popup menu, that is
+* displayed when the user requests a popup menu for the
+* window. The sequence of key strokes or button presses
+* that requests a menu is platform specific.
+*
+* @param menu the menu
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMenu (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /* 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;
+ if (oldMenu != null) oldMenu.cascade = null;
+ this.menu = menu;
+ int menuHandle = 0;
+
+ /* Set the new menu in the OS */
+ if (menu != null) {
+ menu.cascade = this;
+ menuHandle = menu.handle;
+ }
+ int [] argList = {OS.XmNsubMenuId, menuHandle};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the selection state.
+* <p>
+* This method sets the widget selection state for a
+* widgets with the style CHECK or RADIO. It
+* returns false for widgets that do not have one of
+* these styles.
+*
+* @param selected the new selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ int [] argList = {OS.XmNset, selected ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the widget text.
+* <p>
+* @param string the widget text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ if ((style & (SWT.ARROW | SWT.SEPARATOR)) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ boolean accel = false;
+ int i=0, j=0, mnemonic=0;
+ while (i < text.length) {
+ if (text [i] == '\t') {accel = true; break;};
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ byte [] buffer2;
+ if (accel && ++i < text.length) {
+ char [] accelText = new char [text.length - i];
+ System.arraycopy (text, i, accelText, 0, accelText.length);
+ buffer2 = Converter.wcsToMbcs (null, accelText, true);
+ } else {
+ buffer2 = new byte [1];
+ }
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ if (xmString2 == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ if (xmString1 == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+ int [] argList = {
+ OS.XmNlabelType, OS.XmSTRING,
+ OS.XmNlabelString, xmString1,
+ OS.XmNmnemonic, mnemonic,
+ OS.XmNacceleratorText, xmString2,
+ };
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ if (xmString1 != 0) OS.XmStringFree (xmString1);
+ if (xmString2 != 0) OS.XmStringFree (xmString2);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
new file mode 100755
index 0000000000..2f06dd4927
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/MessageBox.java
@@ -0,0 +1,319 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* A message box is used to inform or warn the
+* the user that a particular situation has occurred.
+*
+* Styles
+*
+* ICON_ERROR, ICON_INFORMATION, ICON_QUESTION, ICON_WARNING, ICON_WORKING,
+* OK, OK_CANCEL, YES_NO, YES_NO_CANCEL
+*
+* Events
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/* Class Definition */
+public /*final*/ class MessageBox extends Dialog {
+ int button;
+ String message = "";
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+public MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+}
+int activate (int widget, int client, int call) {
+ OS.XtUnmanageChild (widget);
+ button = client;
+ return 0;
+}
+static int checkStyle (int style) {
+ if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) == 0) style |= SWT.APPLICATION_MODAL;
+ 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;
+}
+int createHandle (int parentHandle, int [] argList) {
+ if ((style & SWT.ICON_ERROR) != 0) return OS.XmCreateErrorDialog (parentHandle, null, argList, argList.length / 2);
+ if ((style & SWT.ICON_INFORMATION) != 0) return OS.XmCreateInformationDialog (parentHandle, null, argList, argList.length / 2);
+ if ((style & SWT.ICON_QUESTION) != 0) return OS.XmCreateQuestionDialog (parentHandle, null, argList, argList.length / 2);
+ if ((style & SWT.ICON_WARNING) != 0) return OS.XmCreateWarningDialog (parentHandle, null, argList, argList.length / 2);
+ return OS.XmCreateMessageDialog (parentHandle, null, argList, argList.length / 2);
+}
+public String getMessage () {
+ return message;
+}
+public int open () {
+
+ /* Create the dialog.*/
+ boolean destroyContext;
+ Display appContext = Display.getCurrent ();
+ if (destroyContext = (appContext == null)) appContext = new Display ();
+ int display = appContext.xDisplay;
+ int parentHandle = appContext.shellHandle;
+ if (parent != null && parent.getDisplay () == appContext)
+ parentHandle = parent.shellHandle;
+
+ /* Compute the dialog title */
+ /*
+ * Feature in Motif. It is not possible to set a shell
+ * title to an empty string. The fix is to set the title
+ * to be a single space.
+ */
+ String string = title;
+ if (string.length () == 0) string = " ";
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int xmStringPtr = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ /*
+ * Feature in Motif. The modal values are only hints
+ * to the window manager. For example Enlightenment treats all modes
+ * as SWT.APPLICATION_MODAL. The generic Motif
+ * Window Manager honours all modes.
+ */
+ int dialogStyle = OS.XmDIALOG_MODELESS;
+ if ((style & SWT.PRIMARY_MODAL) != 0) dialogStyle = OS.XmDIALOG_PRIMARY_APPLICATION_MODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) dialogStyle = OS.XmDIALOG_FULL_APPLICATION_MODAL;
+ if ((style & SWT.SYSTEM_MODAL) != 0) dialogStyle = OS.XmDIALOG_SYSTEM_MODAL;
+ if (parent != null && dialogStyle == OS.XmDIALOG_MODELESS) {
+ dialogStyle = OS.XmDIALOG_PRIMARY_APPLICATION_MODAL;
+ }
+ int [] argList = {
+ OS.XmNnoResize, 1,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ OS.XmNdialogStyle, dialogStyle,
+ OS.XmNdialogTitle, xmStringPtr,
+ };
+ int dialog = createHandle (parentHandle, argList);
+ OS.XmStringFree (xmStringPtr);
+ setMessage (dialog);
+ setButtons (dialog);
+
+ /* Hook the callbacks. */
+ Callback callback = new Callback (this, "activate", 3);
+ int address = callback.getAddress ();
+ OS.XtAddCallback (dialog, OS.XmNokCallback, address, OS.XmDIALOG_OK_BUTTON);
+ OS.XtAddCallback (dialog, OS.XmNcancelCallback, address, OS.XmDIALOG_CANCEL_BUTTON);
+ OS.XtAddCallback (dialog, OS.XmNhelpCallback, address, OS.XmDIALOG_HELP_BUTTON);
+
+ /* Open the dialog and dispatch events. */
+/*
+ shell == nil ifFalse: [
+ shell minimized ifTrue: [shell minimized: false]].
+*/
+ OS.XtManageChild (dialog);
+
+//BOGUS - should be a pure OS message loop (no SWT AppContext)
+ while (OS.XtIsRealized (dialog) && OS.XtIsManaged (dialog))
+ if (!appContext.readAndDispatch()) appContext.sleep ();
+
+ /* Destroy the dialog and update the display. */
+ if (OS.XtIsRealized (dialog)) OS.XtDestroyWidget (dialog);
+ if (destroyContext) appContext.dispose ();
+ callback.dispose ();
+
+// (shell == nil or: [shell isDestroyed not]) ifTrue: [dialog xtDestroyWidget].
+// OSWidget updateDisplay.
+// entryPoint unbind.
+
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) {
+ if (button == OS.XmDIALOG_OK_BUTTON) return SWT.YES;
+ if (button == OS.XmDIALOG_CANCEL_BUTTON) return SWT.NO;
+ return SWT.CANCEL;
+ };
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
+ return (button == OS.XmDIALOG_OK_BUTTON) ? SWT.YES : SWT.NO;
+ }
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
+ return (button == OS.XmDIALOG_OK_BUTTON) ? SWT.OK : SWT.CANCEL;
+ }
+ if ((style & SWT.OK) == SWT.OK) return SWT.OK;
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
+ return (button == OS.XmDIALOG_OK_BUTTON) ? SWT.RETRY : SWT.CANCEL;
+ }
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
+ if (button == OS.XmDIALOG_OK_BUTTON) return SWT.ABORT;
+ if (button == OS.XmDIALOG_CANCEL_BUTTON) return SWT.RETRY;
+ return SWT.IGNORE;
+ }
+ return SWT.CANCEL;
+}
+void setButtons (int dialogHandle) {
+
+ /* Get the button children */
+ int ok = OS.XmMessageBoxGetChild (dialogHandle, OS.XmDIALOG_OK_BUTTON);
+ int cancel = OS.XmMessageBoxGetChild (dialogHandle, OS.XmDIALOG_CANCEL_BUTTON);
+ int help = OS.XmMessageBoxGetChild (dialogHandle, OS.XmDIALOG_HELP_BUTTON);
+ OS.XtUnmanageChild (help);
+
+ /* Set the button labels */
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) return;
+ if ((style & SWT.OK) == SWT.OK) {
+ OS.XtUnmanageChild (cancel);
+ return;
+ }
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) {
+ OS.XtManageChild (help);
+ byte [] buffer1 = Converter.wcsToMbcs (null, "Yes", true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ byte [] buffer2 = Converter.wcsToMbcs (null, "No", true);
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ byte [] buffer3 = Converter.wcsToMbcs (null, "Cancel", true);
+ int xmString3 = OS.XmStringParseText (
+ buffer3,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ int [] argList = {OS.XmNokLabelString, xmString1, OS.XmNcancelLabelString, xmString2, OS.XmNhelpLabelString, xmString3};
+ OS.XtSetValues (dialogHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmString1); OS.XmStringFree (xmString2); OS.XmStringFree (xmString3);
+ return;
+ }
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
+ byte [] buffer1 = Converter.wcsToMbcs (null, "Yes", true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ byte [] buffer2 = Converter.wcsToMbcs (null, "No", true);
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ int [] argList = {OS.XmNokLabelString, xmString1, OS.XmNcancelLabelString, xmString2};
+ OS.XtSetValues (dialogHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmString1); OS.XmStringFree (xmString2);
+ return;
+ }
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
+ byte [] buffer1 = Converter.wcsToMbcs (null, "Retry", true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ byte [] buffer2 = Converter.wcsToMbcs (null, "Cancel", true);
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ int [] argList = {OS.XmNokLabelString, xmString1, OS.XmNcancelLabelString, xmString2};
+ OS.XtSetValues (dialogHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmString1); OS.XmStringFree (xmString2);
+ return;
+ }
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
+ OS.XtManageChild (help);
+ byte [] buffer1 = Converter.wcsToMbcs (null, "Abort", true);
+ int xmString1 = OS.XmStringParseText (
+ buffer1,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ byte [] buffer2 = Converter.wcsToMbcs (null, "Retry", true);
+ int xmString2 = OS.XmStringParseText (
+ buffer2,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ byte [] buffer3 = Converter.wcsToMbcs (null, "Ignore", true);
+ int xmString3 = OS.XmStringParseText (
+ buffer3,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ int [] argList = {OS.XmNokLabelString, xmString1, OS.XmNcancelLabelString, xmString2, OS.XmNhelpLabelString, xmString3};
+ OS.XtSetValues (dialogHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmString1); OS.XmStringFree (xmString2); OS.XmStringFree (xmString3);
+ return;
+ }
+}
+void setMessage (int dialogHandle) {
+ String text = message;
+ int label = OS.XmMessageBoxGetChild (dialogHandle, OS.XmDIALOG_MESSAGE_LABEL);
+ if (label != 0) {
+// (fontList := OSWidget resourceAt: XmNfontList handle: widget) == 0 ifFalse: [
+// text := OSWidget wrapText: message font: fontList width: DisplayWidth * 3 // 5]].
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int [] parseTable = Display.getDefault ().parseTable;
+ int xmStringPtr = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ parseTable,
+ parseTable.length,
+ 0);
+ int [] argList = {OS.XmNmessageString, xmStringPtr};
+ OS.XtSetValues (dialogHandle, argList, argList.length / 2);
+ OS.XmStringFree (xmStringPtr);
+}
+public void setMessage (String string) {
+ message = string;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
new file mode 100755
index 0000000000..eb1a6cdbec
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ProgressBar.java
@@ -0,0 +1,262 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+* A progress bar is an unselectable user interface object
+* that is used to display progress in the form of a bar graph.
+*
+* <b>Styles</b><br>
+* <dd>HORIZONTAL, VERTICAL<br>
+*/
+
+/* Class Definition */
+public /*final*/ class ProgressBar extends Control {
+/**
+* Creates a new instance of the widget.
+*/
+public ProgressBar (Composite parent, int style) {
+ /**
+ * Feature in Motif. If you set the progress bar's value to 0,
+ * the thumb does not disappear. In order to make this happen,
+ * we hide the widget when the value is set to zero by changing
+ * its colors to render it invisible, which means that it
+ * would not visible unless a border is present. The fix is to
+ * always ensure that there is a border, which will be drawn
+ * even when the value is 0.
+ */
+ super (parent, checkStyle (style | SWT.BORDER));
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ Display display = getDisplay ();
+ int hScroll = display.scrolledMarginX;
+ int vScroll = display.scrolledMarginY;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += hScroll * 10;
+ height += vScroll;
+ } else {
+ width += hScroll;
+ height += vScroll * 10;
+ }
+ 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;
+ int backgroundPixel = defaultBackground ();
+ int [] argList1 = {
+ OS.XmNshowArrows, 0,
+ OS.XmNsliderSize, 1,
+ OS.XmNtraversalOn, 0,
+ OS.XmNtroughColor, backgroundPixel,
+ OS.XmNtopShadowColor, backgroundPixel,
+ OS.XmNbottomShadowColor, backgroundPixel,
+ OS.XmNshadowThickness, 1,
+ OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
+ OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
+ OS.XmNprocessingDirection, ((style & SWT.H_SCROLL) != 0) ? OS.XmMAX_ON_RIGHT : OS.XmMAX_ON_TOP,
+ };
+ handle = OS.XmCreateScrollBar (parent.handle, null, argList1, argList1.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+* Gets the maximum.
+* <p>
+* @return maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the minimum.
+* <p>
+* @return minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the selection.
+* <p>
+* @return the selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {
+ OS.XmNminimum, 0,
+ OS.XmNsliderSize, 0,
+ OS.XmNbackground, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int minimum = argList [1];
+ int sliderSize = argList [3];
+ int backGround = argList [5];
+ if (sliderSize == 1 && backGround == defaultBackground()) sliderSize = 0;
+ return minimum + sliderSize;
+}
+void realizeChildren () {
+ super.realizeChildren ();
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return;
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int event_mask = OS.XtBuildEventMask (handle);
+ XSetWindowAttributes attributes = new XSetWindowAttributes ();
+ attributes.event_mask = event_mask & ~OS.ButtonPressMask;
+ OS.XChangeWindowAttributes (xDisplay, xWindow, OS.CWEventMask, attributes);
+}
+/**
+* Sets the maximum.
+* <p>
+* @param maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {OS.XmNmaximum, value, OS.XmNvalue, 0};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the minimum
+* <p>
+* @param minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {
+ OS.XmNminimum, 0,
+ OS.XmNmaximum, 0,
+ OS.XmNsliderSize, 0,
+ OS.XmNvalue, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int minimum = argList [1];
+ int maximum = argList [3];
+ int sliderSize = argList [5];
+
+ if (value >= maximum) return;
+ int selection = sliderSize + minimum;
+ if (value > selection) selection = value;
+ argList [1] = value;
+ argList [7] = value;
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+ setThumb(selection - value);
+}
+/**
+* Sets the selection.
+* <p>
+* @param value new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {
+ OS.XmNminimum, 0,
+ OS.XmNmaximum, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int minimum = argList [1];
+ int maximum = argList [3];
+
+ int selection = value;
+ if (selection < minimum) selection = minimum;
+ if (selection > maximum) selection = maximum;
+ setThumb(selection - minimum);
+}
+void setThumb (int sliderSize) {
+ Display display = getDisplay ();
+ int backgroundPixel = defaultBackground ();
+ int [] argList1 = new int [] {OS.XmNbackground, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ if (sliderSize == 0) {
+ if (argList1 [1] != backgroundPixel) {
+ OS.XmChangeColor (handle, backgroundPixel);
+ }
+ } else {
+ if (argList1 [1] != display.listForeground) {
+ OS.XmChangeColor (handle, display.listForeground);
+ }
+ }
+ int [] argList2 = new int [] {
+ OS.XmNsliderSize, (sliderSize == 0) ? 1 : sliderSize,
+ OS.XmNtroughColor, backgroundPixel,
+ OS.XmNtopShadowColor, backgroundPixel,
+ OS.XmNbottomShadowColor, backgroundPixel,
+ };
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ display.setWarnings (warnings);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
new file mode 100755
index 0000000000..66fcca5ba0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
@@ -0,0 +1,227 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+* A sash is a selectable user interface object
+* that allows the user to drag a rubber banded
+* outline of the sash within the parent window.
+*
+* <p>
+* <b>Styles</b><br>
+* <dd>HORIZONTAL,VERTICAL<br>
+*/
+
+/* Class Definition */
+public /*final*/ class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+ int cursor;
+/**
+* Creates a new instance of the widget.
+*/
+public Sash (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+ int border = (style & SWT.BORDER) != 0 ? 1 : 0;
+ int [] argList = {
+ OS.XmNborderWidth, border,
+ OS.XmNmarginWidth, 0,
+ OS.XmNmarginHeight, 0,
+ OS.XmNresizePolicy, OS.XmRESIZE_NONE,
+ };
+ handle = OS.XmCreateDrawingArea (parent.handle, null, argList, argList.length / 2);
+}
+void drawBand (int x, int y, int width, int height) {
+ int display = OS.XtDisplay (parent.handle);
+ if (display == 0) return;
+ int window = OS.XtWindow (parent.handle);
+ if (window == 0) return;
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
+ OS.XtGetValues (parent.handle, argList, argList.length / 2);
+ int color = argList [1] ^ argList [3];
+ byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
+ int stipplePixmap = OS.XCreateBitmapFromData (display, window, bits, 8, 8);
+ int gc = OS.XCreateGC (display, window, 0, null);
+ OS.XSetForeground (display, gc, color);
+ OS.XSetStipple (display, gc, stipplePixmap);
+ OS.XSetSubwindowMode (display, gc, OS.IncludeInferiors);
+ OS.XSetFillStyle (display, gc, OS.FillStippled);
+ OS.XSetFunction (display, gc, OS.GXxor);
+ OS.XFillRectangle (display, window, gc, x, y, width, height);
+ OS.XFreePixmap (display, stipplePixmap);
+ OS.XFreeGC (display, gc);
+}
+int processMouseDown (int callData) {
+ super.processMouseDown (callData);
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, callData, XButtonEvent.sizeof);
+ if (xEvent.button != 1) return 0;
+ startX = xEvent.x; startY = xEvent.y;
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int border = argList [9], width = argList [5] + (border * 2), height = argList [7] + (border * 2);
+ lastX = ((short) argList [1]) - border; lastY = ((short) argList [3]) - border;
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ event.time = xEvent.time;
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ sendEvent (SWT.Selection, event);
+ if (event.doit) {
+ dragging = true;
+ OS.XmUpdateDisplay (handle);
+ drawBand (lastX = event.x, lastY = event.y, width, height);
+ }
+ return 0;
+}
+int processMouseMove (int callData) {
+ super.processMouseMove (callData);
+ XMotionEvent xEvent = new XMotionEvent ();
+ OS.memmove (xEvent, callData, XMotionEvent.sizeof);
+ if (!dragging || (xEvent.state & OS.Button1Mask) == 0) return 0;
+ int [] argList1 = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList1, argList1.length / 2);
+ int border = argList1 [9], x = ((short) argList1 [1]) - border, y = ((short) argList1 [3]) - border;
+ int width = argList1 [5] + (border * 2), height = argList1 [7] + (border * 2);
+ int [] argList2 = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (parent.handle, argList2, argList2.length / 2);
+ int parentBorder = argList2 [5];
+ int parentWidth = argList2 [1] + (parentBorder * 2);
+ int parentHeight = argList2 [3] + (parentBorder * 2);
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, xEvent.x + x - startX - parentBorder), parentWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, xEvent.y + y - startY - parentBorder), parentHeight - height);
+ }
+ if (newX == lastX && newY == lastY) return 0;
+ drawBand (lastX, lastY, width, height);
+ Event event = new Event ();
+ event.detail = SWT.DRAG;
+ event.time = xEvent.time;
+ event.x = newX; event.y = newY;
+ event.width = width; event.height = height;
+ sendEvent (SWT.Selection, event);
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ OS.XmUpdateDisplay (handle);
+ drawBand (lastX, lastY, width, height);
+ }
+ return 0;
+}
+int processMouseUp (int callData) {
+ super.processMouseUp (callData);
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, callData, XButtonEvent.sizeof);
+ if (xEvent.button != 1) return 0;
+ if (!dragging) return 0;
+ dragging = false;
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int border = argList [5];
+ int width = argList [1] + (border * 2), height = argList [3] + (border * 2);
+ Event event = new Event ();
+ event.time = xEvent.time;
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ drawBand (lastX, lastY, width, height);
+ sendEvent (SWT.Selection, event);
+ return 0;
+}
+void realizeChildren () {
+ super.realizeChildren ();
+ int window = OS.XtWindow (handle);
+ if (window == 0) return;
+ int display = OS.XtDisplay (handle);
+ if (display == 0) return;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ cursor = OS.XCreateFontCursor (display, OS.XC_sb_v_double_arrow);
+ } else {
+ cursor = OS.XCreateFontCursor (display, OS.XC_sb_h_double_arrow);
+ }
+ OS.XDefineCursor (display, window, cursor);
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ if (cursor != 0) {
+ int display = OS.XtDisplay (handle);
+ if (display != 0) OS.XFreeCursor (display, cursor);
+ }
+ cursor = 0;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
new file mode 100755
index 0000000000..583ba89eba
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scale.java
@@ -0,0 +1,300 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+* A scale is a selectable user interface object
+* that represents a range of continuous numeric values.
+*
+* <p>
+* <b>Styles</b><br>
+* <dd>HORIZONTAL,VERTICAL<br>
+* <br>
+* <b>Events</b><br>
+* <dd>Selection<br
+*/
+
+/* Class Definition */
+public /*final*/ class Scale extends Control {
+/**
+* Creates a new instance of the widget.
+*/
+public Scale (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ Display display = getDisplay ();
+ int hScroll = display.scrolledMarginX;
+ int vScroll = display.scrolledMarginY;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += hScroll * 10;
+ height += vScroll;
+ } else {
+ width += hScroll;
+ height += vScroll * 10;
+ }
+ 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;
+ int [] argList = {
+ OS.XmNtitleString, 0,
+ OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
+ OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
+ OS.XmNprocessingDirection, ((style & SWT.H_SCROLL) != 0) ? OS.XmMAX_ON_RIGHT : OS.XmMAX_ON_BOTTOM,
+ };
+ handle = OS.XmCreateScale (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+* Gets the increment.
+* <p>
+* @return the increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 1;
+}
+/**
+* Gets the maximum.
+* <p>
+* @return the maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the minimum.
+* <p>
+* @return the minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the page increment.
+* <p>
+* @return the page increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNscaleMultiple, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the selection.
+* <p>
+* @return the selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNvalue, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+/**
+* Sets the increment value.
+* <p>
+* @param increment the new increment value
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setIncrement (int increment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+/**
+* Sets the maximum.
+* <p>
+* @param maximum the new maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {OS.XmNmaximum, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the minimum.
+* <p>
+* @param minimum the new minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {OS.XmNminimum, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the page increment.
+* <p>
+* @param pageIncrement the new page increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setPageIncrement (int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (pageIncrement < 1) return;
+ int [] argList = {OS.XmNscaleMultiple, pageIncrement};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the selection.
+* <p>
+* @param selection the new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ int [] argList = {OS.XmNvalue, selection};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
new file mode 100755
index 0000000000..1ef0f41558
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ScrollBar.java
@@ -0,0 +1,558 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+* A scroll bar is a selectable user interface object
+* that represents a range of continuous numeric values.
+* Typically these values are used to represent lines of
+* text in a list or text widget.
+*
+* <p>
+* <b>Styles</b><br>
+* <dd>HORIZONTAL, VERTICAL<br>
+* <br>
+* <b>Events</b><br>
+* <dd>Selection<br>
+*/
+
+/* Class Definition */
+public /*final*/ class ScrollBar extends Widget {
+ Scrollable parent;
+ScrollBar () {
+ /* Do Nothing */
+}
+ScrollBar (Scrollable parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+ int [] argList = {
+ OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
+ OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
+ };
+ handle = OS.XmCreateScrollBar (parent.scrolledHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ Scrollable parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+* Gets the enabled state.
+* <p>
+* @return the enabled flag
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets the increment.
+* <p>
+* @return the increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNincrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the maximum.
+* <p>
+* @return the maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the minimum.
+* <p>
+* @return the minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the page increment.
+* <p>
+* @return the page increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNpageIncrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the parent.
+* <p>
+* @return the parent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Scrollable getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+/**
+* Gets the selection.
+* <p>
+* @return the selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNvalue, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the scroll bar size.
+* <p>
+* @return the scroll bar size
+*
+* @exception SWTError <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 Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int borders = argList [5] * 2;
+ return new Point (argList [1] + borders, argList [3] + borders);
+}
+/**
+* Gets the thumb.
+* <p>
+* @return the thumb value
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getThumb () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsliderSize, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the visibility state.
+* <p>
+* If the parent is not visible or some other condition
+* makes the widget not visible, the widget can still be
+* considered visible even though it may not actually be
+* showing.
+*
+* @return visible the visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.XtIsManaged (handle);
+}
+void hookEvents () {
+ int windowProc = parent.getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, SWT.Selection);
+}
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+/**
+* Gets the visibility status.
+* <p>
+* This method returns the visibility status of the
+* widget in the widget hierarchy. If the parent is not
+* visible or some other condition makes the widget not
+* visible, this method will return false.
+*
+* @return the actual visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible () && parent.isVisible ();
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+int processSelection (int callData) {
+ XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
+ OS.memmove (struct, callData, XmAnyCallbackStruct.sizeof);
+ Event event = new Event ();
+ switch (struct.reason) {
+ case OS.XmCR_DRAG: event.detail = SWT.DRAG; break;
+ /*
+ * Do not set the detail field to SWT.DRAG
+ * to indicate that the dragging has ended.
+ */
+// case OS.XmCR_VALUE_CHANGED: break;
+ case OS.XmCR_TO_TOP: event.detail = SWT.HOME; break;
+ case OS.XmCR_TO_BOTTOM: event.detail = SWT.END; break;
+ case OS.XmCR_DECREMENT: event.detail = SWT.ARROW_UP; break;
+ case OS.XmCR_INCREMENT: event.detail = SWT.ARROW_DOWN; break;
+ case OS.XmCR_PAGE_DECREMENT: event.detail = SWT.PAGE_UP; break;
+ case OS.XmCR_PAGE_INCREMENT: event.detail = SWT.PAGE_DOWN; break;
+ }
+ sendEvent (SWT.Selection, event);
+ return 0;
+}
+void releaseChild () {
+ super.releaseChild ();
+ if (parent.horizontalBar == this) parent.horizontalBar = null;
+ if (parent.verticalBar == this) parent.verticalBar = null;
+}
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+/**
+* Sets the enabled state.
+* <p>
+* @param enabled the new value of the enabled flag
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the increment.
+* <p>
+* @param value the new increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ int [] argList = {OS.XmNincrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the maximum.
+* <p>
+* @param value the new maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {OS.XmNmaximum, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the minimum.
+* <p>
+* @param value the new minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {
+ OS.XmNminimum, 0,
+ OS.XmNmaximum, 0,
+ OS.XmNsliderSize, 0,
+ };
+ /*
+ * Feature in Motif. For some reason, when minimium
+ * is set to be greater than or equal to maximum, Motif
+ * does not set the minimum. Instead, the value is
+ * changed and the minimum stays the same. This behavior
+ * differs from setting the maximum where the slider size
+ * is always decreased to make room for the new maximum.
+ * The fix is to decrease the slider to make room for
+ * the new minimum.
+ */
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [3] - value - argList [5] < 0) {
+ argList [5] = argList [3] - value;
+ }
+ argList [1] = value;
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the page increment.
+* <p>
+* @param value the new page increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ int [] argList = {OS.XmNpageIncrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the selection.
+* <p>
+* @param value the new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ int [] argList = {OS.XmNvalue, selection};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the thumb.
+* <p>
+* @param value the new thumb value
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ int [] argList = {OS.XmNsliderSize, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] argList = {
+ OS.XmNvalue, selection,
+ OS.XmNminimum, minimum,
+ OS.XmNmaximum, maximum,
+ OS.XmNsliderSize, thumb,
+ OS.XmNincrement, increment,
+ OS.XmNpageIncrement, pageIncrement,
+ };
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the visibility state.
+* <p>
+* If the parent is not visible or some other condition
+* makes the widget not visible, the widget can still be
+* considered visible even though it may not actually be
+* showing.
+*
+* @param visible the new visibility state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Feature in Motif. Hiding or showing a scroll bar
+ * can cause the widget to automatically resize in
+ * the OS. This behavior is unwanted. The fix is
+ * to force the widget to resize to original size.
+ */
+ int scrolledHandle = parent.scrolledHandle;
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+
+ /* Hide or show the scroll bar */
+ if (visible) {
+ OS.XtManageChild (handle);
+ } else {
+ OS.XtUnmanageChild (handle);
+ }
+
+ /* Restore the size */
+ OS.XtSetValues (scrolledHandle, argList, argList.length / 2);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
new file mode 100755
index 0000000000..7915cca806
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Scrollable.java
@@ -0,0 +1,217 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public abstract class Scrollable extends Control {
+ int scrolledHandle, formHandle;
+ ScrollBar horizontalBar, verticalBar;
+Scrollable () {
+ /* Do nothing */
+}
+public Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int trimX = x - border, trimY = y - border;
+ int trimWidth = width + (border * 2), trimHeight = height + (border * 2);
+ boolean hasHBar = (horizontalBar != null) && (horizontalBar.getVisible ());
+ boolean hasVBar = (verticalBar != null) && (verticalBar.getVisible ());
+ if (hasHBar) {
+ Display display = getDisplay ();
+ trimY -= display.scrolledInsetY;
+ trimHeight += display.scrolledInsetY + display.scrolledMarginY;
+ if (!hasVBar) {
+ trimX -= display.scrolledInsetX;
+ trimWidth += display.scrolledInsetX * 2;
+ trimHeight -= display.scrolledInsetY * 2;
+ }
+ }
+ if (hasVBar) {
+ Display display = getDisplay ();
+ trimX -= display.scrolledInsetX;
+ trimWidth += display.scrolledInsetX + display.scrolledMarginX;
+ if (!hasHBar) {
+ trimY -= display.scrolledInsetY;
+ trimHeight += display.scrolledInsetY * 2;
+ trimWidth -= display.scrolledInsetX * 2;
+ }
+ }
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+ScrollBar createScrollBar (int type) {
+ return new ScrollBar (this, type);
+}
+ScrollBar createStandardBar (int style) {
+ if (scrolledHandle == 0) return null;
+ ScrollBar bar = new ScrollBar ();
+ bar.parent = this;
+ bar.style = style;
+ bar.state |= HANDLE;
+ int [] argList = {OS.XmNhorizontalScrollBar, 0, OS.XmNverticalScrollBar, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ if (style == SWT.H_SCROLL) bar.handle = argList [1];
+ if (style == SWT.V_SCROLL) bar.handle = argList [3];
+ 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 (formHandle != 0) WidgetTable.remove (formHandle);
+ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
+}
+void enableWidget (boolean enabled) {
+ super.enableWidget (enabled);
+ if (formHandle != 0) enableHandle (enabled, formHandle);
+ if (scrolledHandle != 0) {
+ enableHandle (enabled, scrolledHandle);
+ int [] argList = {
+ OS.XmNhorizontalScrollBar, 0,
+ OS.XmNverticalScrollBar, 0,
+ };
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ if (argList [1] != 0) enableHandle (enabled, argList [1]);
+ if (argList [3] != 0) enableHandle (enabled, argList [3]);
+ }
+}
+public Rectangle getClientArea () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return new Rectangle (0, 0, argList [1], argList [3]);
+}
+public ScrollBar getHorizontalBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return horizontalBar;
+}
+public ScrollBar getVerticalBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return verticalBar;
+}
+void manageChildren () {
+ if (scrolledHandle != 0) {
+ OS.XtSetMappedWhenManaged (scrolledHandle, false);
+ OS.XtManageChild (scrolledHandle);
+ }
+ if (formHandle != 0) {
+ OS.XtSetMappedWhenManaged (formHandle, false);
+ OS.XtManageChild (formHandle);
+ }
+ super.manageChildren ();
+ if (formHandle != 0) {
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (formHandle, argList, argList.length / 2);
+ OS.XtResizeWidget (formHandle, 1, 1, argList [1]);
+ OS.XtSetMappedWhenManaged (formHandle, true);
+ }
+ if (scrolledHandle != 0) {
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ OS.XtResizeWidget (scrolledHandle, 1, 1, argList [1]);
+ OS.XtSetMappedWhenManaged (scrolledHandle, true);
+ }
+}
+void propagateWidget (boolean enabled) {
+ super.propagateWidget (enabled);
+ if (formHandle != 0) propagateHandle (enabled, formHandle);
+ if (scrolledHandle != 0) {
+ propagateHandle (enabled, scrolledHandle);
+ int [] argList = {
+ OS.XmNhorizontalScrollBar, 0,
+ OS.XmNverticalScrollBar, 0,
+ };
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ if (argList [1] != 0) propagateHandle (enabled, argList [1]);
+ if (argList [3] != 0) propagateHandle (enabled, argList [3]);
+ }
+}
+void redrawWidget (int x, int y, int width, int height, boolean all) {
+ super.redrawWidget (x, y, width, height, all);
+ /*
+ * Uncomment this code to force the window trimmings to redraw.
+ */
+// if (formHandle == 0 && scrolledHandle == 0) return;
+// short [] root_x = new short [1], root_y = new short [1];
+// OS.XtTranslateCoords (handle, (short) x, (short) y, root_x, root_y);
+// if (formHandle != 0) {
+// short [] form_x = new short [1], form_y = new short [1];
+// OS.XtTranslateCoords (formHandle, (short) 0, (short) 0, form_x, form_y);
+// redrawHandle (root_x [0] - form_x [0], root_y [0] - form_y [0], width, height, formHandle);
+// }
+// if (scrolledHandle != 0) {
+// short [] scrolled_x = new short [1], scrolled_y = new short [1];
+// OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, scrolled_x, scrolled_y);
+// redrawHandle (root_x [0] - scrolled_x [0], root_y [0] - scrolled_y [0], width, height, scrolledHandle);
+// if (horizontalBar != null && horizontalBar.getVisible ()) {
+// int horizontalHandle = horizontalBar.handle;
+// short [] hscroll_x = new short [1], hscroll_y = new short [1];
+// OS.XtTranslateCoords (horizontalHandle, (short) 0, (short) 0, hscroll_x, hscroll_y);
+// redrawHandle (root_x [0] - hscroll_x [0], root_y [0] - hscroll_y [0], width, height, horizontalHandle);
+// }
+// if (verticalBar != null && verticalBar.getVisible ()) {
+// int verticalHandle = verticalBar.handle;
+// short [] vscroll_x = new short [1], vscroll_y = new short [1];
+// OS.XtTranslateCoords (verticalHandle, (short) 0, (short) 0, vscroll_x, vscroll_y);
+// redrawHandle (root_x [0] - vscroll_x [0], root_y [0] - vscroll_y [0], width, height, verticalHandle);
+// }
+// }
+}
+void register () {
+ super.register ();
+ if (formHandle != 0) WidgetTable.put (formHandle, this);
+ if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
+}
+void releaseHandle () {
+ super.releaseHandle ();
+ scrolledHandle = formHandle = 0;
+}
+void releaseWidget () {
+ if (horizontalBar != null) {
+ horizontalBar.releaseWidget ();
+ horizontalBar.releaseHandle ();
+ }
+ if (verticalBar != null) {
+ verticalBar.releaseWidget ();
+ verticalBar.releaseHandle ();
+ }
+ horizontalBar = verticalBar = null;
+ super.releaseWidget ();
+}
+void setBackgroundPixel (int pixel) {
+ super.setBackgroundPixel (pixel);
+ if (scrolledHandle != 0) {
+ int [] argList1 = {
+ OS.XmNhorizontalScrollBar, 0,
+ OS.XmNverticalScrollBar, 0,
+ };
+ OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2);
+ if (argList1 [1] != 0) OS.XmChangeColor (argList1 [1], pixel);
+ if (argList1 [3] != 0) OS.XmChangeColor (argList1 [3], pixel);
+ }
+}
+int topHandle () {
+ if (scrolledHandle != 0) return scrolledHandle;
+ if (formHandle != 0) return formHandle;
+ return handle;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java
new file mode 100755
index 0000000000..7b590263a7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItem.java
@@ -0,0 +1,320 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class implements common behavior of TreeItem and TableItem.
+ */
+abstract class SelectableItem extends Item {
+ protected static final int CHECKBOX_PADDING = 1; // Space behind check box, before item image or text
+
+ private SelectableItemWidget parent; // parent widget of the receiver
+ private boolean isSelected = false; // item selection state
+ private boolean isChecked = false; // item checked state. Can be one of checked and unchecked
+ private boolean isGrayed = false; // item grayed state. The gray state is combined with the
+ // checked state to create gray checked and gray unchecked.
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver is created in
+ * @param style - widget style. see Widget class for details
+ */
+SelectableItem(SelectableItemWidget parent, int style) {
+ super(parent, style);
+ setParent(parent);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeItem();}});
+}
+/**
+ * Subclasses should free resources here
+ */
+void disposeItem() {
+ setParent(null);
+}
+/**
+ * Draw the check box of the receiver at 'position' using 'gc'.
+ * @param gc - GC to draw on.
+ * @param destinationPosition - position on the GC to draw at.
+ * @return Answer the position where drawing stopped.
+ */
+Point drawCheckbox(GC gc, Point position) {
+ SelectableItemWidget parent = getSelectableParent();
+ Image image;
+ Point imageExtent;
+ Rectangle imageBounds;
+ int imageOffset;
+ int xInset;
+ int yInset;
+
+ if (getGrayed() == true) {
+ image = parent.getGrayUncheckedImage();
+ }
+ else {
+ image = parent.getUncheckedImage();
+ }
+ if (image != null) {
+ imageExtent = parent.getCheckBoxExtent();
+ imageOffset = (parent.getItemHeight() - imageExtent.y) / 2;
+ gc.drawImage(image, position.x, position.y + imageOffset);
+ if (getChecked() == true) {
+ image = parent.getCheckMarkImage();
+ imageBounds = image.getBounds();
+ xInset = (imageExtent.x - imageBounds.width) / 2;
+ yInset = (imageExtent.y - imageBounds.height) / 2;
+ gc.drawImage(image, position.x + xInset, position.y + imageOffset + yInset);
+ }
+ position.x += imageExtent.x;
+ }
+ position.x += CHECKBOX_PADDING; // leave extra space behind check box
+ return position;
+}
+void drawInsertMark(GC gc, Point position) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+ final int markerWidth = getInsertMarkWidth();
+ int insertMarkYOffset = 0;
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (parent.isInsertAfter()) {
+ insertMarkYOffset = selectionExtent.y - markerWidth;
+ }
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ gc.fillRectangle(position.x, position.y + insertMarkYOffset, selectionExtent.x, markerWidth);
+ gc.setBackground(parent.getBackground());
+}
+/**
+ * Answer the bounding rectangle of the item check box.
+ * All points within this rectangle hit the check box.
+ */
+Rectangle getCheckboxBounds() {
+ SelectableItemWidget parent = getSelectableParent();
+ Point checkBoxExtent;
+ int redrawPosition;
+ Rectangle checkboxBounds = new Rectangle(0, 0, 0, 0);
+
+ if (isCheckable() == true) {
+ checkboxBounds.x = getCheckboxXPosition();
+ redrawPosition = parent.getRedrawY(this);
+ if (redrawPosition != -1) {
+ checkboxBounds.y = redrawPosition;
+ }
+ checkBoxExtent = parent.getCheckBoxExtent();
+ checkboxBounds.width = checkBoxExtent.x;
+ checkboxBounds.height = checkBoxExtent.y;
+ checkboxBounds.y += (parent.getItemHeight() - checkBoxExtent.y) / 2;
+ }
+ return checkboxBounds;
+}
+/**
+ * Answer the x position of the item check box
+ */
+abstract int getCheckboxXPosition();
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean checked = false;
+
+ if (isCheckable() == true) {
+ checked = isChecked;
+ }
+ return checked;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ SelectableItemWidget parent = getSelectableParent();
+
+ if (parent == null) {
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return parent.getDisplay();
+}
+
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <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 boolean getGrayed () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean grayed = false;
+
+ if (isCheckable() == true) {
+ grayed = isGrayed;
+ }
+ return grayed;
+}
+/**
+ * Return the width in pixels of the line drawn to indicate the
+ * drop insert position during a drag and drop operation.
+ */
+int getInsertMarkWidth() {
+ return 2;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+SelectableItemWidget getSelectableParent() {
+ return parent;
+}
+/**
+ * Answer the background color to use for drawing the
+ * selection rectangle.
+ */
+Color getSelectionBackgroundColor() {
+ Display display = getSelectableParent().getDisplay();
+
+ return display.getSystemColor(SWT.COLOR_LIST_SELECTION);
+}
+/**
+ * Return the size of the rectangle drawn to indicate the
+ * selected state of the receiver.
+ */
+abstract Point getSelectionExtent();
+/**
+ * Answer the foreground color to use for drawing the
+ * selection rectangle.
+ */
+Color getSelectionForegroundColor() {
+ Display display = getSelectableParent().getDisplay();
+
+ return display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+}
+/**
+ * Return the x position of the selection rectangle
+ */
+abstract int getSelectionX();
+/**
+ * Answer whether 'posiiton' is inside the item check box.
+ * @return
+ * true - item check box hit
+ * false - item check box not hit
+ */
+boolean isCheckHit(Point position) {
+ boolean isCheckHit = false;
+
+ if (isCheckable() == true) {
+ isCheckHit = getCheckboxBounds().contains(position);
+ }
+ return isCheckHit;
+}
+/**
+ * Return whether or not the receiver has a check box and can
+ * be checked.
+ */
+boolean isCheckable() {
+ return (getSelectableParent().getStyle() & SWT.CHECK) != 0;
+}
+/**
+ * Answer whether the receiver is selected.
+ * @return
+ * true - the receiver is selected
+ * false - the receiver is not selected
+ */
+boolean isSelected() {
+ return isSelected;
+}
+/**
+ * Redraw the insert mark
+ * @param yPosition - y position in the receiver's client area
+ * where the item should be drawn.
+ */
+void redrawInsertMark(int yPosition) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+ int redrawHeight = getInsertMarkWidth();
+
+ if (selectionExtent != null) {
+ parent.redraw(getSelectionX(), yPosition, selectionExtent.x, redrawHeight, false);
+ parent.redraw(getSelectionX(), yPosition + selectionExtent.y - redrawHeight, selectionExtent.x, redrawHeight, false);
+ }
+}
+/**
+ * Redraw the selection
+ * @param yPosition - y position in the receiver's client area
+ * where the item should be drawn.
+ */
+void redrawSelection(int yPosition) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent != null) {
+ parent.redraw(getSelectionX(), yPosition, selectionExtent.x, selectionExtent.y, false);
+ }
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItemWidget parent = getSelectableParent();
+ Rectangle redrawRectangle = getCheckboxBounds();
+
+ if (isCheckable() == true && isChecked != checked) {
+ isChecked = checked;
+ parent.redraw(
+ redrawRectangle.x, redrawRectangle.y,
+ redrawRectangle.width, redrawRectangle.height, false);
+ }
+}
+
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <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 setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItemWidget parent = getSelectableParent();
+ Rectangle redrawRectangle = getCheckboxBounds();
+
+ if (isCheckable() == true && isGrayed != grayed) {
+ isGrayed = grayed;
+ parent.redraw(
+ redrawRectangle.x, redrawRectangle.y,
+ redrawRectangle.width, redrawRectangle.height, false);
+ }
+}
+
+/**
+ * Set the receiver's parent widget to 'parent'.
+ */
+void setParent(SelectableItemWidget parent) {
+ this.parent = parent;
+}
+/**
+ * Set whether the receiver is selected.
+ * @param selected - true=the receiver is selected
+ * false=the receiver is not selected
+ */
+void setSelected(boolean selected) {
+ isSelected = selected;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java
new file mode 100755
index 0000000000..0eda6178f2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/SelectableItemWidget.java
@@ -0,0 +1,2027 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class is intended for widgets that display data of
+ * type Item. It provides a framework for scrolling and
+ * handles the screen refresh required when adding and
+ * removing items.
+ */
+abstract class SelectableItemWidget extends Composite {
+ private static final int DEFAULT_WIDTH = 64; // used in computeSize if width could not be calculated
+ private static final int DEFAULT_HEIGHT = 64; // used in computeSize if height could not be calculated
+ private static final int HORIZONTAL_SCROLL_INCREMENT = 5; // number of pixel the tree is moved
+ // during horizontal line scrolling
+ private static ImageData UncheckedImageData; // deselected check box image data. used to create an image at run time
+ private static ImageData GrayUncheckedImageData; // grayed deselected check box image data. used to create an image at run time
+ private static ImageData CheckMarkImageData; // check mark image data for check box. used to create an image at run time
+ static {
+ initializeImageData();
+ }
+
+ private int topIndex = 0; // index of the first visible item
+ private int itemHeight = 0; // height of a table item
+ private Point itemImageExtent = null; // size of the item images. Null unless an image is set for any item
+ private int textHeight = -1;
+ private int contentWidth = 0; // width of the widget data (ie. table rows/tree items)
+ private int horizontalOffset = 0;
+ private Vector selectedItems; // indices of the selected items
+ private SelectableItem lastSelectedItem; // item that was selected last
+ private SelectableItem lastFocusItem; // item that had the focus last. Always equals lastSelectedItem
+ // for mouse selection but may differ for keyboard selection
+ private SelectableItem insertItem; // item that draws the insert marker to indicate the drop location in a drag and drop operation
+ private boolean isInsertAfter; // indicates where the insert marker is rendered, at the top or bottom of 'insertItem'
+ private boolean isCtrlSelection = false; // the most recently selected item was
+ // selected using the Ctrl modifier key
+ private boolean isRemovingAll = false; // true=all items are removed. Used to optimize screen updates and to control item selection on dispose.
+ private boolean hasFocus; // workaround for 1FMITIE
+ private Image uncheckedImage; // deselected check box
+ private Image grayUncheckedImage; // grayed check box
+ private Image checkMarkImage; // check mark for selected check box
+ private Point checkBoxExtent = null; // width, height of the item check box
+ private Listener listener; // event listener used for all events. Events are dispatched
+ // to handler methods in handleEvents(Event)
+ private int drawCount = 0; // used to reimplement setRedraw(boolean)
+/**
+ * Create a new instance of ScrollableItemWidget.
+ * @param parent - the parent window of the new instance
+ * @param style - window style for the new instance
+ */
+SelectableItemWidget(Composite parent, int style) {
+ super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);
+ initialize();
+}
+/**
+ * The SelectableItem 'item' has been added to the tree.
+ * Calculate the vertical scroll bar.
+ * Update the screen to display the new item.
+ * @param item - item that has been added to the receiver.
+ */
+void addedItem(SelectableItem item, int index) {
+ calculateVerticalScrollbar();
+ if (getLastFocus() == null) { // if no item has the focus
+ setLastFocus(item, true); // set focus to new (must be first) item
+ }
+}
+/**
+ * The SelectableItem 'item' is about to be added to the tree.
+ * @param item - item that is about to be added to the receiver.
+ */
+void addingItem(SelectableItem item, int index) {
+ if (index >= 0 && index <= getBottomIndex()) {
+ scrollVerticalAddingItem(index);
+ }
+}
+/**
+ * Set the scroll range of the horizontal scroll bar.
+ * Resize the scroll bar if the scroll range maximum
+ * has changed.
+ */
+void calculateHorizontalScrollbar() {
+ int newMaximum = getContentWidth();
+ ScrollBar horizontalBar = getHorizontalBar();
+
+ if (horizontalBar.getMaximum() != newMaximum) {
+ // The call to setMaximum is ignored if newMaximum is 0.
+ // Therefore we can not rely on getMaximum to subsequently return the number of
+ // items in the receiver. We always have to use getVisibleItemCount().
+ // Never rely on getMaximum to return what you set. It may not accept the
+ // value you set. Even if you use a valid value now the implementation may change
+ // later. That's what caused 1FRLOSG.
+ horizontalBar.setMaximum(newMaximum);
+ if (getVerticalBar().getVisible() == false) { // remove these lines
+ horizontalBar.setMaximum(newMaximum); // when PR 1FIG5CG
+ } // is fixed
+ resizeHorizontalScrollbar();
+ }
+}
+/**
+ * Calculate the height of items in the receiver.
+ * Only the image height is calculated if an item height
+ * has already been calculated. Do nothing if both the item
+ * height and the image height have already been calculated
+ */
+void calculateItemHeight(SelectableItem item) {
+ GC gc;
+ String itemText;
+ int itemHeight = -1;
+
+ if (itemImageExtent != null && textHeight != -1) {
+ return;
+ }
+ itemText = item.getText();
+ if (itemText != null && textHeight == -1) {
+ gc = new GC(this);
+ itemHeight = gc.stringExtent(itemText).y;
+ textHeight = itemHeight;
+ gc.dispose();
+ }
+ if (itemImageExtent == null) {
+ itemImageExtent = getImageExtent(item);
+ if (itemImageExtent != null) {
+ if (itemImageExtent.y > textHeight) {
+ itemHeight = itemImageExtent.y;
+ }
+ else {
+ itemHeight = textHeight;
+ }
+ }
+ }
+ itemHeight += getItemPadding(); // make sure that there is empty space below the image/text
+ if (itemHeight > getItemHeight()) { // only set new item height if it's higher because new,
+ setItemHeight(itemHeight); // smaller item height may not include an icon
+ }
+}
+/**
+ * Calculate the range of items that need to be selected given
+ * the clicked item identified by 'hitItemIndex'
+ * @param hitItemIndex - item that was clicked and that the new
+ * selection range will be based on. This index is relative to
+ * the top index.
+ */
+int [] calculateShiftSelectionRange(int hitItemIndex) {
+ int selectionRange[] = new int[] {-1, -1};
+ SelectableItem closestItem = null;
+ SelectableItem selectedItem;
+ Enumeration selectedItems = getSelectionVector().elements();
+
+ while (selectedItems.hasMoreElements() == true) {
+ selectedItem = (SelectableItem) selectedItems.nextElement();
+ if (closestItem == null) {
+ closestItem = selectedItem;
+ }
+ else
+ if (Math.abs(hitItemIndex - getVisibleIndex(selectedItem)) <
+ Math.abs(hitItemIndex - getVisibleIndex(closestItem))) {
+ closestItem = selectedItem;
+ }
+ }
+ if (closestItem == null) { // no item selected
+ closestItem = getLastSelection(); // item selected last may still have the focus
+ }
+ if (closestItem != null) {
+ selectionRange[0] = getVisibleIndex(closestItem);
+ selectionRange[1] = hitItemIndex;
+ }
+ return selectionRange;
+}
+/**
+ * Set the scroll range of the vertical scroll bar.
+ * Resize the scroll bar if the scroll range maximum
+ * has changed.
+ */
+void calculateVerticalScrollbar() {
+ int newMaximum = getVisibleItemCount();
+ ScrollBar verticalBar = getVerticalBar();
+
+ // The call to setMaximum is ignored if newMaximum is 0.
+ // Therefore we can not rely on getMaximum to subsequently return the number of
+ // items in the receiver. We always have to use getVisibleItemCount().
+ // Never rely on getMaximum to return what you set. It may not accept the
+ // value you set. Even if you use a valid value now the implementation may change
+ // later. That's what caused 1FRLOSG.
+ verticalBar.setMaximum(newMaximum);
+ if (getHorizontalBar().getVisible() == false) { // remove these lines
+ verticalBar.setMaximum(newMaximum); // when PR 1FIG5CG
+ } // is fixed
+ resizeVerticalScrollbar();
+}
+
+/**
+ * Answer the size of the receiver needed to display all items.
+ * The length of the longest item in the receiver is used for the
+ * width.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = getContentWidth();
+ int height = getItemCount() * getItemHeight();
+ int style = getStyle();
+ int scrollBarWidth = computeTrim(0, 0, 0, 0).width;
+
+ if (width == 0) {
+ width = DEFAULT_WIDTH;
+ }
+ if (height == 0) {
+ height = DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ }
+ if ((getStyle() & SWT.V_SCROLL) != 0) {
+ width += scrollBarWidth;
+ }
+ if ((getStyle() & SWT.H_SCROLL) != 0) {
+ height += scrollBarWidth;
+ }
+ return new Point(width, height);
+}
+/**
+ * Do a ctrl+shift selection meaning the ctrl and shift keys
+ * were pressed when the mouse click on an item occurred.
+ * If an already selected item was clicked the focus is moved to
+ * that item.
+ * If the previous selection was a ctrl or ctrl+shift selection
+ * the range between the last selected item and the clicked item
+ * is selected.
+ * Otherwise a regular shift selection is performed.
+ * @param hitItem - specifies the clicked item
+ * @param hitItemIndex - specifies the index of the clicked item
+ * relative to the first item.
+ */
+void ctrlShiftSelect(SelectableItem hitItem, int hitItemIndex) {
+ int fromIndex = -1;
+ int toIndex = -1;
+ int lastSelectionIndex = -1;
+ int selectionRange[];
+ SelectableItem lastSelection = getLastSelection();
+
+ if (lastSelection != null) {
+ lastSelectionIndex = getVisibleIndex(lastSelection);
+ }
+ if ((getSelectionVector().contains(hitItem) == true) && // clicked an already selected item?
+ (hitItemIndex != lastSelectionIndex)) { // and click was not on last selected item?
+ setLastSelection(hitItem, true); // set last selection which also sets the focus
+ }
+ else
+ if (isCtrlSelection() == true) { // was last selection ctrl/ctrl+shift selection?
+ fromIndex = lastSelectionIndex; // select from last selection
+ toIndex = hitItemIndex;
+ }
+ else { // clicked outside existing selection range
+ selectionRange = calculateShiftSelectionRange(hitItemIndex);
+ fromIndex = selectionRange[0];
+ toIndex = selectionRange[1];
+ }
+ if (fromIndex != -1 && toIndex != -1) {
+ selectRange(fromIndex, toIndex);
+ }
+}
+/**
+ * Deselect 'item'.
+ * @param item - item that should be deselected
+ */
+void deselect(SelectableItem item) {
+ Vector selectedItems = getSelectionVector();
+
+ if ((item != null) && (item.isSelected() == true)) {
+ item.setSelected(false);
+ redrawSelection(item);
+ selectedItems.removeElement(item);
+ }
+}
+/**
+ * Deselect all item except 'keepSelected'.
+ * @param keepSelected - item that should remain selected
+ */
+void deselectAllExcept(SelectableItem keepSelected) {
+ Vector selectedItems = getSelectionVector();
+ Vector deselectedItems = new Vector(selectedItems.size());
+ Enumeration elements = selectedItems.elements();
+ SelectableItem item;
+
+ // deselect and repaint previously selected items
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ if (item.isSelected() == true && item != keepSelected) {
+ item.setSelected(false);
+ // always redraw the selection, even if item is redrawn again
+ // in setLastSelection. Fixes 1G0GQ8W
+ redrawSelection(item);
+ deselectedItems.addElement(item);
+ }
+ }
+ elements = deselectedItems.elements();
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ selectedItems.removeElement(item);
+ }
+ setLastSelection(keepSelected, false);
+}
+/**
+ * Deselect all items except those in 'keepSelected'.
+ * @param keepSelected - items that should remain selected
+ */
+void deselectAllExcept(Vector keepSelected) {
+ Vector selectedItems = getSelectionVector();
+ Vector deselectedItems = new Vector(selectedItems.size());
+ Enumeration elements = selectedItems.elements();
+ SelectableItem item;
+
+ // deselect and repaint previously selected items
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ if (item.isSelected() == true && keepSelected.contains(item) == false) {
+ item.setSelected(false);
+ // always redraw the selection, even if item is redrawn again
+ // in setLastSelection. Fixes 1G0GQ8W
+ redrawSelection(item);
+ deselectedItems.addElement(item);
+ }
+ }
+ elements = deselectedItems.elements();
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ selectedItems.removeElement(item);
+ }
+ if (keepSelected.size() > 0) {
+ setLastSelection((SelectableItem) keepSelected.firstElement(), false);
+ }
+}
+/**
+ * Deselect 'item'. Notify listeners.
+ * @param item - item that should be deselected
+ */
+void deselectNotify(SelectableItem item) {
+ Event event = new Event();
+
+ if (item.isSelected() == true) {
+ deselect(item);
+ setLastSelection(item, true);
+ update(); // looks better when event notification takes long to return
+ }
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+}
+/**
+ * Deselect all items starting at and including 'fromIndex'
+ * stopping at and including 'toIndex'.
+ * @param fromIndex - index relative to the first item where
+ * deselection should start. Deselecion includes 'fromIndex'.
+ * @param toIndex - index relative to the first item where
+ * deselection should stop. Deselecion includes 'toIndex'.
+ */
+void deselectRange(int fromIndex, int toIndex) {
+ if (fromIndex > toIndex) {
+ for (int i = toIndex; i <= fromIndex; i++) {
+ deselect(getVisibleItem(i));
+ }
+ }
+ else
+ if (fromIndex < toIndex) {
+ for (int i = toIndex; i >= fromIndex; i--) {
+ deselect(getVisibleItem(i));
+ }
+ }
+ setLastSelection(getVisibleItem(fromIndex), true);
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection down one item
+ * Ctrl Keep old selection, move input focus down one item
+ * Shift Extend selection by one item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowDown(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+
+ if (focusItemIndex < (getVisibleItemCount() - 1)) { // - 1 because indices are 0 based
+ focusItemIndex++;
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Scroll receiver to the left
+ * Ctrl See None above
+ * Shift See None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowLeft(int keyMask) {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int scrollSelection = horizontalBar.getSelection();
+ int scrollAmount;
+
+ if (horizontalBar.getVisible() == false) {
+ return;
+ }
+ scrollAmount = Math.min(HORIZONTAL_SCROLL_INCREMENT, scrollSelection);
+ horizontalBar.setSelection(scrollSelection - scrollAmount);
+ setHorizontalOffset(horizontalBar.getSelection() * -1);
+}
+/**
+ * Modifier Key Action
+ * None Scroll receiver to the right
+ * Ctrl See None above
+ * Shift See None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowRight(int keyMask) {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int scrollSelection = horizontalBar.getSelection();
+ int scrollAmount;
+
+ if (horizontalBar.getVisible() == false) {
+ return;
+ }
+ scrollAmount = Math.min( // scroll by the smaller of
+ HORIZONTAL_SCROLL_INCREMENT, // the scroll increment
+ horizontalBar.getMaximum() // and the remaining scroll range
+ - horizontalBar.getPageIncrement()
+ - scrollSelection);
+ horizontalBar.setSelection(scrollSelection + scrollAmount);
+ setHorizontalOffset(horizontalBar.getSelection() * -1);
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection up one item
+ * Ctrl Keep old selection, move input focus up one item
+ * Shift Extend selection by one item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowUp(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+
+ if (focusItemIndex > 0) {
+ focusItemIndex--;
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Perform a selection operation on the item check box.
+ * @param item - the item that was clicked
+ */
+void doCheckItem(SelectableItem item) {
+ Event event = new Event();
+
+ item.setChecked(!item.getChecked());
+ event.item = item;
+ event.detail = SWT.CHECK;
+ notifyListeners(SWT.Selection, event);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ setRemovingAll(true);
+ getSelectionVector().removeAllElements();
+ lastFocusItem = null;
+ lastSelectedItem = null;
+ if (uncheckedImage != null) {
+ uncheckedImage.dispose();
+ }
+ if (grayUncheckedImage != null) {
+ grayUncheckedImage.dispose();
+ }
+ if (checkMarkImage != null) {
+ checkMarkImage.dispose();
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection to the
+ * last item
+ * Ctrl Keep old selection, move input focus to the
+ * last item
+ * Shift Extend selection to the last item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doEnd(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+ int lastItemIndex = getVisibleItemCount() - 1; // - 1 because indices are 0 based
+
+ if (focusItemIndex < lastItemIndex) {
+ newFocus = getVisibleItem(lastItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, lastItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection to the
+ * first item
+ * Ctrl Keep old selection, move input focus to the
+ * first item
+ * Shift Extend selection to the first item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doHome(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int firstItemIndex = 0;
+
+ if (getVisibleIndex(lastFocus) > firstItemIndex) {
+ newFocus = getVisibleItem(firstItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, firstItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Perform a mouse select action according to the key state
+ * mask in 'eventStateMask'.
+ * Key state mask is ignored when receiver has the single selection
+ * style.
+ * @param item - the item that was clicked
+ * @param itemIndex - the index of the clicked item relative
+ * to the first item of the receiver
+ * @param eventStateMask - the key state mask of the mouse event
+ * @param button - the mouse button that was pressed
+ */
+void doMouseSelect(SelectableItem item, int itemIndex, int eventStateMask, int button) {
+ if (((eventStateMask & SWT.CTRL) != 0) &&
+ ((eventStateMask & SWT.SHIFT) != 0) &&
+ (isMultiSelect() == true)) {
+ if (getSelectionVector().size() == 0) { // no old selection?
+ selectNotify(item); // do standard CTRL selection
+ }
+ else {
+ ctrlShiftSelect(item, itemIndex);
+ }
+ setCtrlSelection(true);
+ }
+ else
+ if (((eventStateMask & SWT.SHIFT) != 0) && (isMultiSelect() == true)) {
+ shiftSelect(item, itemIndex);
+ setCtrlSelection(false);
+ }
+ else
+ if (((eventStateMask & SWT.CTRL) != 0) && (isMultiSelect() == true)) {
+ toggleSelectionNotify(item);
+ setCtrlSelection(true);
+ }
+ else
+ if (button != 3 || item.isSelected() == false) {
+ // only select the item (and deselect all others) if the mouse click is
+ // not a button 3 click or if a previously unselected item was clicked.
+ // Fixes 1G97L65
+ deselectAllExcept(item);
+ selectNotify(item);
+ setCtrlSelection(false);
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection one page down
+ * Ctrl Keep old selection, move input focus one page down
+ * Shift Extend selection one page down
+ * One page is the number of items that can be displayed in the
+ * receiver's canvas without truncating the last item.
+ * The selection is set to the last item if there is no full page
+ * of items left.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doPageDown(int keyMask) {
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(getLastFocus());
+ int lastItemIndex = getVisibleItemCount() - 1; // - 1 because indices are 0 based
+ int visibleItemCount;
+
+ if (focusItemIndex < lastItemIndex) {
+ visibleItemCount = getItemCountWhole();
+ focusItemIndex = Math.min(
+ lastItemIndex,
+ focusItemIndex + (visibleItemCount - 1));
+ newFocus = getVisibleItem(focusItemIndex);
+ if (newFocus == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection one page up
+ * Ctrl Keep old selection, move input focus one page up
+ * Shift Extend selection one page up
+ * One page is the number of items that can be displayed in the
+ * receiver's canvas without truncating the last item.
+ * The selection is set to the first item if there is no full page
+ * of items left.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doPageUp(int keyMask) {
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(getLastFocus());
+ int visibleItemCount;
+
+ if (focusItemIndex > 0) {
+ visibleItemCount = getItemCountWhole();
+ focusItemIndex = Math.max(
+ 0,
+ focusItemIndex - (visibleItemCount - 1));
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * Ctrl Keep old selection, toggle selection of the item
+ * that has the input focus
+ * Shift Extend selection to the item that has the input
+ * focus
+ * Ctrl & Shift Set selection to the item that has input focus
+ * Do nothing if receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+
+void doSpace(int keyMask) {
+ SelectableItem item = getLastFocus();
+ int itemIndex = getVisibleIndex(item);
+
+ if (keyMask == SWT.NULL && item.isSelected() == false) { // do simple space select in SINGLE and MULTI mode
+ deselectAllExcept(item);
+ selectNotify(item);
+ return;
+ }
+ if (isMultiSelect() == false || item == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ toggleSelectionNotify(item);
+ }
+ else
+ if (((keyMask & SWT.CTRL) != 0) && ((keyMask & SWT.SHIFT) != 0)) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ }
+ else
+ if (keyMask == SWT.SHIFT) {
+ shiftSelect(item, itemIndex);
+ }
+}
+/**
+ * Make sure that free space at the bottom of the receiver is
+ * occupied.
+ * There will be new space available below the last item when the
+ * receiver's height is increased. In this case the receiver
+ * is scrolled down to occupy the new space.if the top item is
+ * not the first item of the receiver.
+ */
+void claimBottomFreeSpace() {
+ int clientAreaItemCount = getItemCountWhole();
+ int topIndex = getTopIndex();
+ int newTopIndex;
+ int lastItemIndex = getVisibleItemCount() - topIndex;
+
+ if ((topIndex > 0) &&
+ (lastItemIndex > 0) &&
+ (lastItemIndex < clientAreaItemCount)) {
+ newTopIndex = Math.max(0, topIndex-(clientAreaItemCount-lastItemIndex));
+ setTopIndex(newTopIndex, true);
+ }
+}
+/**
+ * Make sure that free space at the right side of the receiver is
+ * occupied.
+ * There will be new space available at the right side of the receiver
+ * when the receiver's width is increased. In this case the receiver
+ * is scrolled to the right to occupy the new space.if possible.
+ */
+void claimRightFreeSpace() {
+ int clientAreaWidth = getClientArea().width;
+ int newHorizontalOffset = clientAreaWidth - getContentWidth();
+
+ if (newHorizontalOffset - getHorizontalOffset() > 0) { // item is no longer drawn past the right border of the client area
+ newHorizontalOffset = Math.min(0, newHorizontalOffset); // align the right end of the item with the right border of the
+ setHorizontalOffset(newHorizontalOffset); // client area (window is scrolled right)
+ }
+}
+/** Not used right now. Replace focusIn/focusOut with this method once
+ * Display.getFocusWindow returns the new focus window on FocusOut event
+ * (see 1FMITIE)
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusChange(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusIn(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ // Workaround for 1FMITIE
+ hasFocus = true;
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+ // Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ.
+ update();
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusOut(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ // Workaround for 1FMITIE
+ hasFocus = false;
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+ // Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ.
+ update();
+}
+/**
+ * Answer the index of the last item position in the receiver's
+ * client area.
+ * @return 0-based index of the last item position in the tree's
+ * client area.
+ */
+int getBottomIndex() {
+ return getTopIndex() + getItemCountTruncated(getClientArea());
+}
+/**
+ * Answer the size of the check box image.
+ * The calculation is cached and assumes that the images for
+ * the checked and unchecked state are the same size.
+ */
+Point getCheckBoxExtent() {
+ Image checkedImage;
+ Rectangle imageBounds;
+
+ if (checkBoxExtent == null) {
+ checkedImage = getUncheckedImage();
+ if (checkedImage != null) {
+ imageBounds = checkedImage.getBounds();
+ checkBoxExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ else {
+ checkBoxExtent = new Point(0, 0);
+ }
+ }
+ return checkBoxExtent;
+}
+/**
+ * Answer the image for the selected check box
+ * Answer null if the image couldn't be loaded.
+ */
+Image getCheckMarkImage() {
+ InputStream resourceStream;
+
+ if (checkMarkImage == null) {
+ checkMarkImage = new Image(getDisplay(), CheckMarkImageData);
+ }
+ return checkMarkImage;
+}
+/**
+ * Answer the width of the receiver's content.
+ * Needs to be set by subclasses.
+ */
+int getContentWidth() {
+ return contentWidth;
+}
+/**
+ * Answer the horizontal drawing offset used for scrolling.
+ * This is < 0 if the receiver has been scrolled to the left,
+ * > 0 if the receiver has been scrolled to the right and 0
+ * if the receiver has not been scrolled.
+ */
+int getHorizontalOffset() {
+ return horizontalOffset;
+}
+
+/**
+ * Answer the size of item images. Calculated during the item
+ * height calculation.
+ */
+Point getImageExtent() {
+ return itemImageExtent;
+}
+/**
+ * Answer the image extent of 'item'. Overridden by subclasses.
+ */
+Point getImageExtent(SelectableItem item) {
+ Image image = item.getImage();
+ Rectangle imageBounds;
+ Point imageExtent = null;
+
+ if (image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+abstract int getIndex(SelectableItem item);
+/**
+ * Answer the first and last index of items that can be displayed in
+ * the area defined by 'clipRectangle'. This includes partial items.
+ * @return
+ * Array -
+ * First element is the index of the first item in 'clipRectangle'.
+ * Second element is the index of the last item in 'clipRectangle'.
+ */
+int[] getIndexRange(Rectangle clipRectangle) {
+ int visibleRange[] = new int[] {0, 0};
+
+ visibleRange[0] = clipRectangle.y / getItemHeight();
+ visibleRange[1] =
+ visibleRange[0] +
+ getItemCountTruncated(clipRectangle) - 1; // - 1 because item index is 0 based
+ return visibleRange;
+}
+/**
+ * Return the item that draws the marker indicating the insert location
+ * in a drag and drop operation
+ */
+SelectableItem getInsertItem() {
+ return insertItem;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+public abstract int getItemCount();
+/**
+ * Answer the number of items that can be displayed in 'rectangle'.
+ * The result includes partially visible items.
+ */
+int getItemCountTruncated(Rectangle rectangle) {
+ int itemHeight = getItemHeight();
+ int itemCount = 0;
+ int startIndex;
+
+ startIndex = rectangle.y / itemHeight;
+ itemCount = (int) Math.ceil(((float) rectangle.y + rectangle.height) / itemHeight)-startIndex;
+ return itemCount;
+}
+/**
+ * Answer the number of items that can be displayed in the client
+ * area of the receiver.
+ * The result only includes items that completely fit into the
+ * client area.
+ */
+int getItemCountWhole() {
+ return getClientArea().height / getItemHeight();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ GC gc;
+ if (itemHeight == 0) {
+ gc = new GC(this);
+ itemHeight = gc.stringExtent("String").y + getItemPadding(); // initial item height=font height + item spacing
+ // use real font height here when available in SWT, instead of GC.textExtent
+ gc.dispose();
+ }
+ return itemHeight;
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return 2 + getDisplay().textHighlightThickness;
+}
+/**
+ * Answer the item that most recently received the input focus.
+ */
+SelectableItem getLastFocus() {
+ return lastFocusItem;
+}
+/**
+ * Answer the item that was selected most recently.
+ */
+SelectableItem getLastSelection() {
+ return lastSelectedItem;
+}
+/**
+ * Answer the event listener used for all events. Events are
+ * dispatched to handler methods in handleEvents(Event).
+ * This scheme saves a lot of inner classes.
+ */
+Listener getListener() {
+ return listener;
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is not an item of the receiver
+ */
+int getRedrawY(SelectableItem item) {
+ int redrawIndex = getVisibleIndex(item);
+ int redrawY = -1;
+
+ if (redrawIndex != -1) {
+ redrawY = (redrawIndex - getTopIndex()) * getItemHeight();
+ }
+ return redrawY;
+}
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getSelectionVector().size();
+}
+/**
+ * Answer the selected items of the receiver.
+ * @return The selected items of the receiver stored in a Vector.
+ * Returned Vector is empty if no items are selected.
+ */
+Vector getSelectionVector() {
+ return selectedItems;
+}
+/**
+ * Answer the width of 'text' in pixel.
+ * Answer 0 if 'text' is null.
+ */
+int getTextWidth(String text) {
+ int textWidth = 0;
+ GC gc;
+
+ if (text != null) {
+ gc = new GC(this);
+ textWidth = gc.stringExtent(text).x;
+ gc.dispose();
+ }
+ return textWidth;
+}
+/**
+ * Answer the index of the first visible item in the receiver's
+ * client area.
+ * @return 0-based index of the first visible item in the
+ * receiver's client area.
+ */
+int getTopIndex() {
+ return topIndex;
+}
+/**
+ * Answer the image for the deselected check box.
+ */
+Image getUncheckedImage() {
+ InputStream resourceStream;
+
+ if (uncheckedImage == null) {
+ uncheckedImage = new Image(getDisplay(), UncheckedImageData);
+ }
+ return uncheckedImage;
+}
+
+/**
+ * Answer the image for the grayed eck box.
+ */
+Image getGrayUncheckedImage() {
+ InputStream resourceStream;
+
+ if (grayUncheckedImage == null) {
+ grayUncheckedImage = new Image(getDisplay(), GrayUncheckedImageData);
+ }
+ return grayUncheckedImage;
+}
+
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Normally, every item of the receiver is visible.
+ */
+abstract int getVisibleIndex(SelectableItem item);
+/**
+ * Answer the SelectableItem located at 'itemIndex' in the
+ * receiver.
+ * @param itemIndex - location of the SelectableItem object
+ * to return
+ */
+abstract SelectableItem getVisibleItem(int itemIndex);
+/**
+ * Answer the number of visible items of the receiver.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Normally every item of the receiver is visible.
+ */
+int getVisibleItemCount() {
+ return getItemCount();
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+abstract int getVisibleRedrawY(SelectableItem item);
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ doDispose();
+ break;
+ case SWT.KeyDown:
+ keyDown(event);
+ break;
+ case SWT.Resize:
+ resize(event);
+ break;
+ case SWT.Selection:
+ if (event.widget == getVerticalBar()) {
+ scrollVertical(event);
+ }
+ else
+ if (event.widget == getHorizontalBar()) {
+ scrollHorizontal(event);
+ }
+ break;
+ case SWT.FocusOut:
+ focusOut(event);
+ break;
+ case SWT.FocusIn:
+ focusIn(event);
+ break;
+ }
+}
+
+
+
+/**
+ * Answer whether 'item' has the input focus.
+ */
+boolean hasFocus(SelectableItem item) {
+ return (isFocusControl() && item == getLastFocus());
+}
+/**
+ * Initialize the receiver. Add event listeners and set widget
+ * colors.
+ */
+void initialize() {
+ Display display = getDisplay();
+ ScrollBar horizontalBar = getHorizontalBar();
+ ScrollBar verticalBar = getVerticalBar();
+
+ // listener may be needed by overridden installListeners()
+ listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+ setSelectionVector(new Vector());
+ installListeners();
+ calculateVerticalScrollbar();
+ calculateHorizontalScrollbar();
+ horizontalBar.setMinimum(0);
+ verticalBar.setMinimum(0);
+ horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT);
+ setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+}
+/**
+ * Initialize the ImageData used for the checked/unchecked images.
+ */
+static void initializeImageData() {
+ PaletteData uncheckedPalette = new PaletteData(
+ new RGB[] {new RGB(128, 128, 128), new RGB(255, 255, 255)});
+ PaletteData grayUncheckedPalette = new PaletteData(
+ new RGB[] {new RGB(128, 128, 128), new RGB(192, 192, 192)});
+ PaletteData checkMarkPalette = new PaletteData(
+ new RGB[] {new RGB(0, 0, 0), new RGB(252, 3, 251)});
+ byte[] checkbox = new byte[] {0, 0, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 0, 0};
+
+ // Each pixel is represented by one bit in the byte data.
+ // The bit references the palette position (0 or 1). Each pixel row of an image is padded to one byte.
+ // Arguments: width, height, depth, palette, scanline padding, data
+ UncheckedImageData = new ImageData(11, 11, 1, uncheckedPalette, 2, checkbox);
+ GrayUncheckedImageData = new ImageData(11, 11, 1, grayUncheckedPalette, 2, checkbox);
+ CheckMarkImageData = new ImageData(7, 7, 1, checkMarkPalette, 1, new byte[] {-4, -8, 112, 34, 6, -114, -34});
+ CheckMarkImageData.transparentPixel = 1;
+}
+/**
+ * Add event listeners to the tree widget and its scroll bars.
+ */
+void installListeners() {
+ Listener listener = getListener();
+
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.Resize, listener);
+ addListener(SWT.KeyDown, listener);
+ addListener(SWT.FocusOut, listener);
+ addListener(SWT.FocusIn, listener);
+
+ getVerticalBar().addListener(SWT.Selection, listener);
+ getHorizontalBar().addListener(SWT.Selection, listener);
+}
+/**
+ * Answer whether the currently selected items were selected
+ * using the ctrl key.
+ */
+boolean isCtrlSelection() {
+ return isCtrlSelection;
+}
+/**
+ * Answer true if all items in the widget are disposed.
+ * Used to optimize item disposal. Prevents unnecessary screen
+ * updates.
+ */
+boolean isRemovingAll() {
+ return isRemovingAll;
+}
+/**
+ * Answer whether the receiver has the input focus.
+ * Workaround for 1FMITIE
+ */
+public boolean isFocusControl() {
+ return hasFocus;
+}
+/**
+ * Return whether the drop insert position is before or after the
+ * item set using motif_setInsertMark.
+ * @return
+ * true=insert position is after the insert item
+ * false=insert position is before the insert item
+ */
+boolean isInsertAfter() {
+ return isInsertAfter;
+}
+/**
+ * Answer whether the receiver has the MULTI selection style set.
+ * @return
+ * true = receiver is in multiple selection mode.
+ * false = receiver is in single selection mode.
+ */
+boolean isMultiSelect() {
+ return ((getStyle() & SWT.MULTI) != 0);
+}
+/**
+ * The item identified by 'changedItem' has changed.
+ * Calculate the item height based on the new item data (it might
+ * now have an image which could also be the first image in the
+ * receiver)
+ * Redraw the whole window if the item height has changed. Otherwise
+ * redraw only the changed item or part of it depending on the
+ * 'repaintStartX' and 'repaintWidth' parameters.
+ * @param changedItem - the item that has changed
+ * @param repaintStartX - x position of the item redraw.
+ * @param repaintWidth - width of the item redraw.
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ int yPosition;
+ int itemHeight;
+ int oldItemHeight = getItemHeight();
+ Point oldImageExtent = getImageExtent();
+
+ calculateItemHeight(changedItem); // make sure that the item height is recalculated
+ // no redraw necessary if redraw width is 0 or item is not visible
+ if (repaintWidth == 0 || (yPosition = getVisibleRedrawY(changedItem)) == -1) {
+ return;
+ } // if changedItem is the first item with image.
+ itemHeight = getItemHeight();
+ if ((oldItemHeight == itemHeight) && // only redraw changed item if the item height and
+ (oldImageExtent == getImageExtent())) { // image size has not changed. The latter will only change once,
+ // from null to a value-so it's safe to test using !=
+ // redrawing outside the client area redraws the widget border on Motif.
+ // adjust the redraw width if necessary. Workaround for 1G4TQRW
+ repaintWidth = Math.min(repaintWidth, getClientArea().width - repaintStartX);
+ if (repaintWidth > 0) {
+ redraw(repaintStartX, yPosition, repaintWidth, itemHeight, true);
+ }
+ }
+ else {
+ redraw(); // redraw all items if the item height has changed
+ }
+}
+/**
+ * A key was pressed. Call the appropriate handler method.
+ * @param event - the key event
+ */
+void keyDown(Event event) {
+ boolean isCtrlSelection = isCtrlSelection();
+
+ if (event.stateMask != SWT.CTRL) {
+ isCtrlSelection = false;
+ }
+ switch (event.keyCode) {
+ case SWT.ARROW_UP:
+ doArrowUp(event.stateMask);
+ break;
+ case SWT.ARROW_DOWN:
+ doArrowDown(event.stateMask);
+ break;
+ case SWT.ARROW_LEFT:
+ doArrowLeft(event.stateMask);
+ break;
+ case SWT.ARROW_RIGHT:
+ doArrowRight(event.stateMask);
+ break;
+ case SWT.PAGE_UP:
+ doPageUp(event.stateMask);
+ break;
+ case SWT.PAGE_DOWN:
+ doPageDown(event.stateMask);
+ break;
+ case SWT.HOME:
+ doHome(event.stateMask);
+ break;
+ case SWT.END:
+ doEnd(event.stateMask);
+ break;
+ default: // no selection occurred, keep previous
+ isCtrlSelection = isCtrlSelection(); // selection type information
+ }
+ if (event.character == ' ') {
+ doSpace(event.stateMask);
+ isCtrlSelection = (event.stateMask == SWT.CTRL);
+ }
+ setCtrlSelection(isCtrlSelection);
+}
+/**
+ * Sets the drop insert item.
+ * The drop insert item has a visual hint to show where a dragged item
+ * will be inserted when dropped on the tree.
+ * <p>
+ * @param item the insert item
+ * @param after true places the insert mark below 'item'. false places
+ * the insert mark above 'item'.
+ */
+void motif_setInsertMark(SelectableItem item, boolean after) {
+ SelectableItem currentItem = getInsertItem();
+ int redrawY;
+
+ setInsertItem(item);
+ setInsertAfter(after);
+ if (currentItem != null) {
+ redrawY = getVisibleRedrawY(currentItem);
+ if (redrawY != -1) {
+ currentItem.redrawInsertMark(redrawY);
+ }
+ }
+ if (item != null) {
+ redrawY = getVisibleRedrawY(item);
+ if (redrawY != -1) {
+ item.redrawInsertMark(redrawY);
+ }
+ }
+}
+
+
+/**
+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was
+ * set to false.
+ */
+public void redraw () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (drawCount == 0) {
+ super.redraw();
+ }
+}
+/**
+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was
+ * set to false.
+ */
+public void redraw (int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (drawCount == 0) {
+ super.redraw(x, y, width, height, all);
+ }
+}
+
+/**
+ * Redraw the selection of 'item'
+ * @param item - SelectableItem that should have the selection redrawn.
+ */
+void redrawSelection(SelectableItem item) {
+ int redrawPosition = getVisibleRedrawY(item);
+
+ if (redrawPosition != -1) {
+ item.redrawSelection(redrawPosition);
+ }
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Update the display and the scroll bars.
+ */
+void removedItem(SelectableItem item) {
+ claimBottomFreeSpace();
+ calculateVerticalScrollbar();
+ if (getItemCount() == 0) {
+ reset();
+ }
+}
+/**
+ * 'item' is about to be removed from the tree.
+ * Move the selection/input focus if 'item' is selected or has the
+ * input focus,
+ * @param item - item that is about to be removed from the tree.
+ */
+void removingItem(SelectableItem item) {
+ SelectableItem nextFocusItem = null;
+ int itemIndex = getVisibleIndex(item);
+ int itemCount = getVisibleItemCount();
+
+ // deselect item and remove from selection
+ if (item.isSelected() == true) {
+ getSelectionVector().removeElement(item);
+ }
+ if (item == getLastFocus() && itemCount > 1) {
+ // select previous item if removed item is bottom item
+ // otherwise select next item. Fixes 1GA6L85
+ if (itemIndex == itemCount - 1) {
+ nextFocusItem = getVisibleItem(itemIndex - 1);
+ }
+ else {
+ nextFocusItem = getVisibleItem(itemIndex + 1);
+ }
+ setLastFocus(nextFocusItem, true);
+ }
+ // ignore items below widget client area
+ if (itemIndex != -1 && itemIndex <= getBottomIndex()) {
+ scrollVerticalRemovedItem(itemIndex);
+ }
+}
+/**
+ * Reset state that is dependent on or calculated from the state
+ * of the receiver.
+ */
+void reset() {
+ setSelectionVector(new Vector());
+ setTopIndexNoScroll(0, true);
+ lastSelectedItem = null;
+ lastFocusItem = null;
+ resetItemData();
+}
+/**
+ * Reset state that is dependent on or calculated from the items
+ * of the receiver.
+ */
+void resetItemData() {
+ setHorizontalOffset(0);
+ setItemHeight(0);
+ itemImageExtent = null;
+ textHeight = -1;
+ claimRightFreeSpace();
+}
+/**
+ * The receiver has been resized. Update the scroll bars and
+ * make sure that new space is being occupied by items.
+ */
+void resize(Event event) {
+ int horizontalPageSize = getHorizontalBar().getPageIncrement();
+
+ resizeHorizontalScrollbar();
+ resizeVerticalScrollbar();
+ if (getClientArea().width > horizontalPageSize) { // window resized wider? - Do this check here
+ claimRightFreeSpace(); // because claimRightFreeSpace is called elsewhere.
+ }
+ claimBottomFreeSpace();
+}
+/**
+ * Display the horizontal scroll bar if items are drawn off
+ * screen. Update the page size.
+ */
+void resizeHorizontalScrollbar() {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int clientAreaWidth = getClientArea().width;
+
+ if (clientAreaWidth < getContentWidth()) {
+ if (horizontalBar.getVisible() == false) {
+ horizontalBar.setVisible(true);
+ horizontalBar.setSelection(0);
+ }
+ }
+ else
+ if (horizontalBar.getVisible() == true) {
+ horizontalBar.setVisible(false);
+ }
+ horizontalBar.setThumb(clientAreaWidth);
+ horizontalBar.setPageIncrement(clientAreaWidth);
+}
+/**
+ * Display the vertical scroll bar if items are drawn off screen.
+ * Update the page size.
+ */
+void resizeVerticalScrollbar() {
+ int clientAreaItemCount = getItemCountWhole();
+ ScrollBar verticalBar = getVerticalBar();
+
+ if (clientAreaItemCount == 0) {
+ return;
+ }
+ if (clientAreaItemCount < getVisibleItemCount()) {
+ if (verticalBar.getVisible() == false) {
+ verticalBar.setVisible(true);
+ }
+ // Only set the page size to something smaller than the scroll
+ // range maximum. Otherwise the scroll selection will be reset.
+ verticalBar.setPageIncrement(clientAreaItemCount);
+ verticalBar.setThumb(clientAreaItemCount);
+ }
+ else
+ if (verticalBar.getVisible() == true) {
+ verticalBar.setVisible(false);
+ }
+}
+/**
+ * Scroll the rectangle specified by x, y, width, height to the destination
+ * position. Do nothing if redraw is set to false using setRedraw().
+ *
+ * @param destX - destination x position of the scrolled rectangle
+ * @param destY - destination y position of the scrolled rectangle
+ * @param x - x location of the upper left corner of the scroll rectangle
+ * @param y - y location of the upper left corner of the scroll rectangle
+ * @param width - width of the scroll rectangle
+ * @param height - height of the scroll rectangle
+ * @param all - not used. Used to be true=scroll children intersecting the
+ * scroll rectangle.
+ */
+void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
+ if (drawCount == 0) {
+ update();
+ GC gc = new GC(this);
+ gc.copyArea(x, y, width, height, destX, destY);
+ gc.dispose();
+ }
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * numPixel > 0 = scroll to left. numPixel < 0 = scroll to right
+ */
+abstract void scrollHorizontal(int numPixel);
+/**
+ * The position of the horizontal scroll bar has been modified
+ * by the user.
+ * Adjust the horizontal offset to trigger a horizontal scroll.
+ * @param event-the scroll event
+ */
+void scrollHorizontal(Event event) {
+ setHorizontalOffset(getHorizontalBar().getSelection() * -1);
+}
+/**
+ * Scroll 'item' into the receiver's client area if necessary.
+ * @param item - the item that should be scrolled.
+ */
+void scrollShowItem(SelectableItem item) {
+ int itemIndexFromTop = getIndex(item) - getTopIndex();
+ int clientAreaWholeItemCount = getItemCountWhole();
+ int scrollAmount = 0;
+
+ if (itemIndexFromTop >= clientAreaWholeItemCount) { // show item below visible items?
+ scrollAmount = itemIndexFromTop;
+ if (clientAreaWholeItemCount > 0) { // will be 0 if showItem is called and receiver hasn't been displayed yet
+ scrollAmount -= clientAreaWholeItemCount - 1;
+ }
+ }
+ else
+ if (itemIndexFromTop < 0) { // show item above visible items?
+ scrollAmount = itemIndexFromTop;
+ }
+ setTopIndex(getTopIndex() + scrollAmount, true);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+abstract void scrollVertical(int scrollIndexCount);
+/**
+ * The position of the horizontal scroll bar has been modified
+ * by the user.
+ * Adjust the index of the top item to trigger a vertical scroll.
+ * @param event-the scroll event
+ */
+void scrollVertical(Event event) {
+ setTopIndex(getVerticalBar().getSelection(), false);
+}
+/**
+ * Scroll items down to make space for a new item added to
+ * the receiver at position 'index'.
+ * @param index - position at which space for one new item
+ * should be made. This index is relative to the first item
+ * of the receiver.
+ */
+void scrollVerticalAddingItem(int index) {
+ Rectangle clientArea = getClientArea();
+ int itemHeight = getItemHeight();
+ int sourceY = Math.max(0, (index - getTopIndex()) * itemHeight); // need to scroll in visible area
+
+ scroll(
+ 0, sourceY + itemHeight, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll the items below the item at position 'index' up
+ * so that they cover the removed item.
+ * @param index - index of the removed item
+ */
+void scrollVerticalRemovedItem(int index) {
+ Rectangle clientArea = getClientArea();
+ int itemHeight = getItemHeight();
+ int destinationY = Math.max(0, (index - getTopIndex()) * itemHeight);
+
+ scroll(
+ 0, destinationY, // destination x, y
+ 0, destinationY + itemHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select 'item' if it is not selected.
+ * @param item - item that should be selected
+ */
+void select(SelectableItem item) {
+ Vector selectedItems = getSelectionVector();
+
+ if (item != null && item.isSelected() == false && isRemovingAll() == false) {
+ item.setSelected(true);
+ redrawSelection(item);
+ selectedItems.addElement(item);
+ }
+}
+/**
+ * Select 'item' if it is not selected. Send a Selection event
+ * if the selection was changed.
+ * @param item - item that should be selected
+ */
+void selectNotify(SelectableItem item) {
+ Event event;
+
+ if (isRemovingAll() == false) {
+ if (item.isSelected() == false) {
+ select(item);
+ setLastSelection(item, true);
+ update(); // looks better when event notification takes long to return
+ }
+ event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+ }
+}
+/**
+ * Select all items of the receiver starting at 'fromIndex'
+ * and including 'toIndex'.
+ */
+void selectRange(int fromIndex, int toIndex) {
+ if (fromIndex > toIndex) {
+ for (int i = fromIndex; i > toIndex; i--) {
+ select(getVisibleItem(i));
+ }
+ }
+ else {
+ for (int i = fromIndex; i < toIndex; i++) {
+ select(getVisibleItem(i));
+ }
+ }
+ selectNotify(getVisibleItem(toIndex)); // select last item, notifying listeners
+}
+/**
+ * Set the width of the receiver's contents to 'newWidth'.
+ * Content width is used to calculate the horizontal scrollbar.
+ */
+void setContentWidth(int newWidth) {
+ ScrollBar horizontalBar;
+ boolean scrollBarVisible;
+
+ if (contentWidth != newWidth) {
+ horizontalBar = getHorizontalBar();
+ scrollBarVisible = horizontalBar.getVisible();
+ contentWidth = newWidth;
+ calculateHorizontalScrollbar();
+ if (scrollBarVisible != horizontalBar.getVisible()) {
+ resizeVerticalScrollbar(); // the vertical scroll bar needs to be resized if the horizontal
+ } // scroll bar was hidden or made visible during recalculation
+ }
+}
+/**
+ * Set whether the currently selected items were selected using the
+ * ctrl key.
+ * @param isCtrlSelection -
+ * true = currently selected items were selected using the ctrl key.
+ * false = currently selected items were not selected using the
+ * ctrl key.
+ */
+void setCtrlSelection(boolean isCtrlSelection) {
+ this.isCtrlSelection = isCtrlSelection;
+}
+/**
+ * The font is changing. Reset the text height to force a
+ * recalculation during itemChanged().
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setFont(font);
+ textHeight = -1;
+}
+/**
+ * Set the horizontal drawing offset to 'offset'.
+ * Scroll the receiver's contents according to the offset change.
+ * @param offset - value < 0 = widget contents is drawn left of the client area.
+ */
+void setHorizontalOffset(int offset) {
+ int offsetChange = offset - horizontalOffset;
+
+ if (offsetChange != 0) {
+ scrollHorizontal(offsetChange);
+ horizontalOffset = offset;
+ }
+}
+
+/**
+ * Set whether the drop insert position is before or after the
+ * item set using motif_setInsertMark.
+ * @param after true=insert position is after the insert item
+ * false=insert position is before the insert item
+ */
+void setInsertAfter(boolean after) {
+ isInsertAfter = after;
+}
+
+/**
+ * Set the item that draws the marker indicating the insert location
+ * in a drag and drop operation.
+ * @param item the item that draws the insert marker
+ */
+void setInsertItem(SelectableItem item) {
+ insertItem = item;
+}
+/**
+ * Set the height of the receiver's items to 'height'.
+ */
+void setItemHeight(int height) {
+ itemHeight = height;
+}
+/**
+ * Set the item that most recently received the input focus
+ * to 'focusItem'. Redraw both, the item that lost focus
+ * and the one that received focus.
+ * @param focusItem - the item that most recently received
+ * the input focus
+ * @param showItem true=new focus item, if any, should be scrolled
+ * into view. false=don't scroll
+ */
+void setLastFocus(SelectableItem focusItem, boolean showItem) {
+ SelectableItem oldFocusItem = lastFocusItem;
+
+ if (focusItem != lastFocusItem) {
+ lastFocusItem = focusItem;
+ if (oldFocusItem != null) {
+ redrawSelection(oldFocusItem);
+ }
+ if (lastFocusItem != null && isFocusControl() == true) {
+ redrawSelection(lastFocusItem);
+ }
+ }
+ if (focusItem != null && showItem == true) {
+ showSelectableItem(focusItem);
+ }
+}
+/**
+ * Set the item that was selected most recently to 'selectedItem'.
+ * Set the input focus to that item.
+ * @param selectedItem - the item that was selected most recently
+ * @param showItem true=new focus item, if any, should be scrolled
+ * into view. false=don't scroll
+ */
+void setLastSelection(SelectableItem selectedItem, boolean showItem) {
+ if (selectedItem == null) { // always store the item selected last
+ return;
+ }
+ setLastFocus(selectedItem, showItem);
+ lastSelectedItem = selectedItem;
+}
+/**
+ * Sets the redraw flag.
+ * @param redraw -
+ * true = redraw and scroll operations are performed normally
+ * false = redraw and scroll operations are ignored
+ */
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (redraw) {
+ if (--drawCount == 0) redraw();
+ } else {
+ drawCount++;
+ }
+}
+/**
+ * Set whether all items in the widget are disposed.
+ * Used to optimize item disposal. Prevents unnecessary screen
+ * updates.
+ * @param removingAll
+ * true=all items are removed.
+ * false=normal state, no items or not all items are removed.
+ */
+void setRemovingAll(boolean removingAll) {
+ isRemovingAll = removingAll;
+}
+/**
+ * Select the items stored in 'selectionItems'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+void setSelectableSelection(SelectableItem selectionItems[]) {
+ SelectableItem item = null;
+ int selectionCount = selectionItems.length;
+ Vector keepSelected;
+
+ if (isMultiSelect() == false && selectionCount > 1) {
+ selectionCount = 1;
+ }
+ keepSelected = new Vector(selectionItems.length);
+ for (int i = 0; i < selectionCount; i++) {
+ if (selectionItems[i] != null) {
+ keepSelected.addElement(selectionItems[i]);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ // select in the same order as all the other selection and deslection methods.
+ // Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated
+ // selections of the items, causing flash.
+ for (int i = selectionCount - 1; i >= 0; i--) {
+ item = selectionItems[i];
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, true);
+ }
+}
+/**
+ * Set the vector used to store the selected items of the receiver
+ * to 'newVector'.
+ * @param newVector - the vector used to store the selected items
+ * of the receiver
+ */
+void setSelectionVector(Vector newVector) {
+ selectedItems = newVector;
+}
+/**
+ * Scroll the item at 'index' to the top.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndex(int index, boolean adjustScrollbar) {
+ int indexDiff = index-topIndex;
+
+ if (indexDiff != 0) {
+ scrollVertical(indexDiff);
+ setTopIndexNoScroll(index, adjustScrollbar);
+ }
+}
+/**
+ * Set the index of the first visible item in the receiver's client
+ * area to 'index'.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
+ topIndex = index;
+ if (adjustScrollbar == true) {
+ getVerticalBar().setSelection(index);
+ }
+}
+/**
+ * The shift key was pressed when the mouse click on an item
+ * occurred. Do a shift selection. If an already selected item was
+ * clicked the selection is expanded/reduced to that item
+ * @param hitItem - specifies the clicked item
+ * @param hitItemIndex - specifies the index of the clicked item
+ * relative to the first item.
+ */
+void shiftSelect(SelectableItem hitItem, int hitItemIndex) {
+ int fromIndex = -1;
+ int toIndex = -1;
+ int lastSelectionIndex = -1;
+ int selectionRange[];
+ SelectableItem lastSelection = getLastSelection();
+
+ if (lastSelection != null) {
+ lastSelectionIndex = getVisibleIndex(lastSelection);
+ }
+ if (isCtrlSelection() == true) { // was last selection ctrl selection?
+ deselectAllExcept(lastSelection);
+ fromIndex = lastSelectionIndex; // select from last selection
+ toIndex = hitItemIndex;
+ }
+ else
+ if (getSelectionVector().contains(hitItem) == true) { // clicked an item already selected?
+ deselectRange(hitItemIndex, lastSelectionIndex); // reduce selection
+ }
+ else { // clicked outside existing selection range
+ selectionRange = calculateShiftSelectionRange(hitItemIndex);
+ fromIndex = selectionRange[0];
+ toIndex = selectionRange[1];
+ }
+ if (hitItemIndex == lastSelectionIndex) { // was click on last selected item?
+ return;
+ }
+ if (fromIndex == -1 || toIndex == -1) { // are there previously selected items?
+ toggleSelectionNotify(hitItem); // do a single select.
+ }
+ else {
+ if (((lastSelectionIndex < fromIndex) && (hitItemIndex > fromIndex)) || // does selection reverse direction?
+ ((lastSelectionIndex > fromIndex) && (hitItemIndex < fromIndex))) {
+ deselectAllExcept((SelectableItem) null); // remove old selection
+ }
+ selectRange(fromIndex, toIndex);
+ }
+}
+/**
+ * Make 'item' visible by scrolling it into the receiver's client
+ * area if necessary.
+ * @param item - the item that should be made visible to the user.
+ */
+void showSelectableItem(SelectableItem item) {
+ if (item.getSelectableParent() != this) {
+ return;
+ }
+ scrollShowItem(item);
+ scrollShowItem(item); // second call makes sure that the item is still visible
+ // even if the first scroll caused the horizontal scroll
+ // to be displayed and the item to be hidden again.
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selection = getSelectionVector();
+ SelectableItem selectionItem;
+
+ if (selection.size() > 0) {
+ selectionItem = (SelectableItem) selection.firstElement();
+ showSelectableItem(selectionItem);
+ }
+}
+/**
+ * Sorts the specified range in the array.
+ *
+ * @param array the SelectableItem array to be sorted
+ * @param start the start index to sort
+ * @param end the last + 1 index to sort
+ */
+void sort(SelectableItem[] array, int start, int end) {
+ int middle = (start + end) / 2;
+ if (start + 1 < middle) sort(array, start, middle);
+ if (middle + 1 < end) sort(array, middle, end);
+ if (start + 1 >= end) return; // this case can only happen when this method is called by the user
+ if (getVisibleIndex(array[middle-1]) <= getVisibleIndex(array[middle])) return;
+ if (start + 2 == end) {
+ SelectableItem temp = array[start];
+ array[start] = array[middle];
+ array[middle] = temp;
+ return;
+ }
+ int i1 = start, i2 = middle, i3 = 0;
+ SelectableItem[] merge = new SelectableItem[end - start];
+ while (i1 < middle && i2 < end) {
+ merge[i3++] = getVisibleIndex(array[i1]) <= getVisibleIndex(array[i2]) ?
+ array[i1++] : array[i2++];
+ }
+ if (i1 < middle) System.arraycopy(array, i1, merge, i3, middle - i1);
+ System.arraycopy(merge, 0, array, start, i2 - start);
+}
+/**
+ * Toggle the selection of 'item'.
+ * @param item - item that should be selected/deselected
+ */
+void toggleSelectionNotify(SelectableItem item) {
+ if (item.isSelected() == true) {
+ deselectNotify(item);
+ }
+ else {
+ selectNotify(item);
+ }
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
new file mode 100755
index 0000000000..00c268acf0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Shell.java
@@ -0,0 +1,865 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The shell class implements a top level window
+* and dialog windows.
+*
+* Styles
+*
+* ON_TOP
+* DBCS
+*
+* Events
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/* Class Definition */
+public /*final*/ class Shell extends Decorations {
+ Display display;
+ int shellHandle;
+ boolean reparented, realized;
+ int oldX, oldY, oldWidth, oldHeight;
+ Control lastFocus;
+/**
+* Creates a widget.
+*/
+public Shell () {
+ this ((Display) null);
+}
+/**
+* Creates a widget.
+*/
+public Shell (int style) {
+ this ((Display) null, style);
+}
+/**
+* Creates a widget.
+*/
+public Shell (Display display) {
+ this (display, SWT.SHELL_TRIM);
+}
+/**
+* Creates a widget.
+* <p>
+* This method creates a top level shell widget on a
+* display using style bits to select a particular look
+* or set of properties.
+*
+* @param display the Display (or null for the default)
+* @param style the bitwise OR'ing of widget styles
+*
+* @exception SWTError(ERROR_ERROR_INVALID_PARENT)
+* when the parent is invalid
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+*/
+public Shell (Display display, int style) {
+ this (display, null, style, 0);
+}
+Shell (Display display, Shell parent, int style, int handle) {
+ super ();
+ 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.parent = parent;
+ this.display = display;
+ this.handle = handle;
+ createWidget (0);
+}
+/**
+* Creates a widget.
+*/
+public Shell (Shell parent) {
+ this (parent, SWT.DIALOG_TRIM);
+}
+/**
+* Creates a widget.
+*/
+public Shell (Shell parent, int style) {
+ this (parent != null ? parent.getDisplay () : null, parent, style, 0);
+}
+
+static int checkStyle (int style) {
+ style = Decorations.checkStyle (style);
+ 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;
+}
+
+public static Shell motif_new (Display display, int handle) {
+ return new Shell (display, null, SWT.NO_TRIM, handle);
+}
+
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addShellListener(ShellListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener(SWT.Activate,typedListener);
+ addListener(SWT.Close,typedListener);
+ addListener(SWT.Deactivate,typedListener);
+ addListener(SWT.Iconify,typedListener);
+ addListener(SWT.Deiconify,typedListener);
+}
+void adjustTrim () {
+ if ((style & SWT.ON_TOP) != 0) return;
+
+ /* Query the trim insets */
+ int shellWindow = OS.XtWindow (shellHandle);
+ if (shellWindow == 0) return;
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0) return;
+
+ /* Find the direct child of the root window */
+ int [] unused = new int [1];
+ int [] rootWindow = new int [1];
+ int [] parent = new int [1];
+ int [] ptr = new int [1];
+ int trimWindow = shellWindow;
+ OS.XQueryTree (xDisplay, trimWindow, rootWindow, parent, ptr, unused);
+ if (ptr [0] != 0) OS.XFree (ptr [0]);
+ if (parent [0] == 0) return;
+ while (parent [0] != rootWindow [0]) {
+ trimWindow = parent [0];
+ OS.XQueryTree (xDisplay, trimWindow, unused, parent, ptr, unused);
+ if (ptr [0] != 0) OS.XFree (ptr [0]);
+ if (parent [0] == 0) return;
+ }
+
+ /**
+ * Translate the coordinates of the shell window to the
+ * coordinates of the direct child of the root window
+ */
+ if (shellWindow == trimWindow) return;
+
+ /* Query the border width of the direct child of the root window */
+ int [] trimBorder = new int [1];
+ int [] trimWidth = new int [1];
+ int [] trimHeight = new int [1];
+ OS.XGetGeometry (xDisplay, trimWindow, unused, unused, unused, trimWidth, trimHeight, trimBorder, unused);
+
+ /* Query the border width of the direct child of the shell window */
+ int [] shellBorder = new int [1];
+ int [] shellWidth = new int [1];
+ int [] shellHeight = new int [1];
+ OS.XGetGeometry (xDisplay, shellWindow, unused, unused, unused, shellWidth, shellHeight, shellBorder, unused);
+
+ /* Calculate the trim */
+ int width = (trimWidth [0] + (trimBorder [0] * 2)) - (shellWidth [0] + (shellBorder [0] * 2));
+ int height = (trimHeight [0] + (trimBorder [0] * 2)) - (shellHeight [0] + (shellBorder [0] * 2));
+
+ /* Update the trim guesses to match the query */
+ 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 = width;
+ display.titleResizeTrimHeight = height;
+ return;
+ }
+ if (hasBorder) {
+ display.titleBorderTrimWidth = width;
+ display.titleBorderTrimHeight = height;
+ return;
+ }
+ display.titleTrimWidth = width;
+ display.titleTrimHeight = height;
+ return;
+ }
+ if (hasResize) {
+ display.resizeTrimWidth = width;
+ display.resizeTrimHeight = height;
+ return;
+ }
+ if (hasBorder) {
+ display.borderTrimWidth = width;
+ display.borderTrimHeight = height;
+ return;
+ }
+}
+public void close () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ closeWidget ();
+}
+void closeWidget () {
+ if (!isEnabled ()) return;
+ Control widget = parent;
+ while (widget != null && !(widget.getShell ().isModal ())) {
+ widget = widget.parent;
+ }
+ if (widget == null) {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (shell != this && shell.isModal () && shell.isVisible ()) {
+ shell.bringToTop ();
+ return;
+ }
+ }
+ }
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ if (event.doit && !isDisposed ()) dispose ();
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle trim = super.computeTrim (x, y, width, height);
+ int trimWidth = trimWidth (), trimHeight = trimHeight ();
+ trim.x -= trimWidth / 2; trim.y -= trimHeight - (trimWidth / 2);
+ trim.width += trimWidth; trim.height += trimHeight;
+ return trim;
+}
+void createHandle (int index) {
+ state |= HANDLE | CANVAS;
+ int decorations = 0;
+ if ((style & SWT.NO_TRIM) == 0) {
+ if ((style & SWT.MIN) != 0) decorations |= OS.MWM_DECOR_MINIMIZE;
+ if ((style & SWT.MAX) != 0) decorations |= OS.MWM_DECOR_MAXIMIZE;
+ if ((style & SWT.RESIZE) != 0) decorations |= OS.MWM_DECOR_RESIZEH;
+ if ((style & SWT.BORDER) != 0) decorations |= OS.MWM_DECOR_BORDER;
+ if ((style & SWT.MENU) != 0) decorations |= OS.MWM_DECOR_MENU;
+ if ((style & SWT.TITLE) != 0) decorations |= OS.MWM_DECOR_TITLE;
+ /*
+ * Feature in Motif. Under some Window Managers (Sawmill), in order
+ * to get any border at all from the window manager it is necessary
+ * to set MWM_DECOR_BORDER. The fix is to force these bits when any
+ * kind of border is requested.
+ */
+ if ((style & SWT.RESIZE) != 0) decorations |= OS.MWM_DECOR_BORDER;
+ }
+
+ /*
+ * Note: Motif treats the modal values as hints to the Window Manager.
+ * For example, Enlightenment treats all modes except for SWT.MODELESS
+ * as SWT.APPLICATION_MODAL. The Motif Window Manager honours all modes.
+ */
+ int inputMode = OS.MWM_INPUT_MODELESS;
+ if ((style & SWT.PRIMARY_MODAL) != 0) inputMode = OS.MWM_INPUT_PRIMARY_APPLICATION_MODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) inputMode = OS.MWM_INPUT_FULL_APPLICATION_MODAL;
+ if ((style & SWT.SYSTEM_MODAL) != 0) inputMode = OS.MWM_INPUT_SYSTEM_MODAL;
+
+ /*
+ * Bug in Motif. For some reason, if the title string
+ * length is not a multiple of 4, Motif occasionally
+ * draws garbage after the last character in the title.
+ * The fix is to pad the title.
+ */
+ byte [] buffer = {(byte)' ', 0, 0, 0};
+ int ptr = OS.XtMalloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] argList = {
+ OS.XmNmwmInputMode, inputMode,
+ OS.XmNmwmDecorations, decorations,
+ OS.XmNtitle, ptr,
+ };
+ byte [] appClass = display.appClass;
+ if (parent == null && (style & SWT.ON_TOP) == 0) {
+ int xDisplay = display.xDisplay;
+ int widgetClass = OS.TopLevelShellWidgetClass ();
+ shellHandle = OS.XtAppCreateShell (display.appName, appClass, widgetClass, xDisplay, argList, argList.length / 2);
+ } else {
+ int widgetClass = OS.TransientShellWidgetClass ();
+ if ((style & SWT.ON_TOP) != 0) widgetClass = OS.OverrideShellWidgetClass ();
+ int parentHandle = display.shellHandle;
+ if (parent != null) parentHandle = parent.handle;
+ shellHandle = OS.XtCreatePopupShell (appClass, widgetClass, parentHandle, argList, argList.length / 2);
+ }
+ OS.XtFree (ptr);
+ if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+
+ /* Create scrolled handle */
+ createScrolledHandle (shellHandle);
+
+ /*
+ * Feature in Motif. There is no way to get the single pixel
+ * border surrounding a TopLevelShell or a TransientShell.
+ * Also, attempts to set a border on either the shell handle
+ * or the main window handle fail. The fix is to set the border
+ * on the client area.
+ */
+ if ((style & (SWT.NO_TRIM | SWT.BORDER | SWT.RESIZE)) == 0) {
+ int [] argList1 = {OS.XmNborderWidth, 1};
+ OS.XtSetValues (handle, argList1, argList1.length / 2);
+ }
+}
+void deregister () {
+ super.deregister ();
+ WidgetTable.remove (shellHandle);
+}
+void destroyWidget () {
+ /*
+ * Hide the shell before calling XtDestroyWidget ()
+ * so that the shell will disappear without having
+ * to dispatch events. Otherwise, the user will be
+ * able to interact with the trimmings between the
+ * time that the shell is destroyed and the next
+ * event is dispatched.
+ */
+ if (OS.XtIsRealized (shellHandle)) {
+ if (OS.XtIsTopLevelShell (shellHandle)) {
+ OS.XtUnmapWidget (shellHandle);
+ } else {
+ OS.XtPopdown (shellHandle);
+ }
+ }
+ super.destroyWidget ();
+}
+
+public void dispose () {
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when the dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// /*
+// * Note: It is valid to attempt to dispose a widget
+// * more than once. If this happens, fail silently.
+// */
+// if (!isValidWidget ()) return;
+// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+// Display oldDisplay = display;
+ super.dispose ();
+// if (oldDisplay != null) oldDisplay.update ();
+}
+void enableWidget (boolean enabled) {
+ super.enableWidget (enabled);
+ enableHandle (enabled, shellHandle);
+}
+public int getBorderWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ return argList [1];
+}
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ int border = argList [5];
+ int trimWidth = trimWidth (), trimHeight = trimHeight ();
+ int width = argList [1] + trimWidth + (border * 2);
+ int height = argList [3] + trimHeight + (border * 2);
+ return new Rectangle (root_x [0], root_y [0], width, height);
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+public int getImeInputMode () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return SWT.NONE;
+}
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
+ return new Point (root_x [0], root_y [0]);
+}
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return this;
+}
+/**
+* Get dialogs shells.
+* <p>
+* @return the dialog shells
+*
+* @exception SWTError(ERROR_ERROR_INVALID_PARENT)
+* when the parent is invalid
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+*/
+public Shell [] getShells () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ Shell [] shells = display.getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Control shell = shells [i];
+ do {
+ shell = shell.parent;
+ } 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.parent;
+ } while (shell != null && shell != this);
+ if (shell == this) {
+ result [index++] = shells [i];
+ }
+ }
+ return result;
+}
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNborderWidth, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ int border = argList [5];
+ int trimWidth = trimWidth (), trimHeight = trimHeight ();
+ int width = argList [1] + trimWidth + (border * 2);
+ int height = argList [3] + trimHeight + (border * 2);
+ return new Point (width, height);
+}
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (!OS.XtIsRealized (handle)) return false;
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return false;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return false;
+ XWindowAttributes attributes = new XWindowAttributes ();
+ OS.XGetWindowAttributes (xDisplay, xWindow, attributes);
+ if (attributes.map_state == OS.IsViewable) return true;
+ int [] argList = {OS.XmNmappedWhenManaged, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ return minimized && attributes.map_state == OS.IsUnviewable && argList [1] != 0;
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = display.windowProc;
+ OS.XtAddEventHandler (shellHandle, OS.StructureNotifyMask, false, windowProc, SWT.Resize);
+ if ((style & SWT.ON_TOP) != 0) return;
+ OS.XtAddEventHandler (shellHandle, OS.FocusChangeMask, false, windowProc, SWT.FocusIn);
+ int [] argList = {OS.XmNdeleteResponse, OS.XmDO_NOTHING};
+ OS.XtSetValues (shellHandle, argList, argList.length / 2);
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay != 0) {
+ byte [] WM_DETELE_WINDOW = Converter.wcsToMbcs (null, "WM_DELETE_WINDOW\0", false);
+ int atom = OS.XmInternAtom (xDisplay, WM_DETELE_WINDOW, false);
+ OS.XmAddWMProtocolCallback (shellHandle, atom, windowProc, SWT.Dispose);
+ }
+}
+int inputContext () {
+ //NOT DONE
+ return 0;
+}
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled ();
+}
+boolean isModal () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNmwmInputMode, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ return (argList [1] != -1 && argList [1] != OS.MWM_INPUT_MODELESS);
+}
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible ();
+}
+void manageChildren () {
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ super.manageChildren ();
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0) return;
+ int width = OS.XDisplayWidth (xDisplay, OS.XDefaultScreen (xDisplay)) * 5 / 8;
+ int height = OS.XDisplayHeight (xDisplay, OS.XDefaultScreen (xDisplay)) * 5 / 8;
+ OS.XtResizeWidget (shellHandle, width, height, 0);
+}
+public void open () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setVisible (true);
+}
+int processDispose (int callData) {
+ closeWidget ();
+ return 0;
+}
+
+int processResize (int callData) {
+ XConfigureEvent xEvent = new XConfigureEvent ();
+ OS.memmove (xEvent, callData, XConfigureEvent.sizeof);
+ switch (xEvent.type) {
+ case OS.ReparentNotify: {
+ if (reparented) return 0;
+ reparented = true;
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ xEvent.x = root_x [0]; xEvent.y = root_y [0];
+ xEvent.width = argList [1]; xEvent.height = argList [3];
+ // fall through
+ }
+ case OS.ConfigureNotify:
+ if (!reparented) return 0;
+ if (oldX != xEvent.x || oldY != xEvent.y) sendEvent (SWT.Move);
+ if (oldWidth != xEvent.width || oldHeight != xEvent.height) {
+ sendEvent (SWT.Resize);
+ if (layout != null) layout (false);
+ }
+ if (xEvent.x != 0) oldX = xEvent.x;
+ if (xEvent.y != 0) oldY = xEvent.y;
+ oldWidth = xEvent.width;
+ oldHeight = xEvent.height;
+ return 0;
+ case OS.UnmapNotify:
+ int [] argList = {OS.XmNmappedWhenManaged, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ if (argList [1] != 0) {
+ minimized = true;
+ sendEvent (SWT.Iconify);
+ }
+ return 0;
+ case OS.MapNotify:
+ if (minimized) {
+ minimized = false;
+ sendEvent (SWT.Deiconify);
+ }
+ return 0;
+ }
+ return 0;
+}
+
+int processSetFocus (int callData) {
+ XFocusChangeEvent xEvent = new XFocusChangeEvent ();
+ OS.memmove (xEvent, callData, XFocusChangeEvent.sizeof);
+ int handle = OS.XtWindowToWidget (xEvent.display, xEvent.window);
+ if (handle != shellHandle) return super.processSetFocus (callData);
+ if (xEvent.mode != OS.NotifyNormal) return 0;
+ if (xEvent.detail != OS.NotifyNonlinear) return 0;
+ switch (xEvent.type) {
+ case OS.FocusIn:
+ postEvent (SWT.Activate);
+ break;
+ case OS.FocusOut:
+ postEvent (SWT.Deactivate);
+ break;
+ }
+ return 0;
+}
+void propagateWidget (boolean enabled) {
+ super.propagateWidget (enabled);
+ propagateHandle (enabled, shellHandle);
+}
+void realizeWidget () {
+ if (realized) return;
+ OS.XtRealizeWidget (shellHandle);
+ realizeChildren ();
+ realized = true;
+}
+void register () {
+ super.register ();
+ WidgetTable.put (shellHandle, this);
+}
+void releaseHandle () {
+ super.releaseHandle ();
+ shellHandle = 0;
+}
+void releaseShells () {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ shell.releaseWidget ();
+ shell.releaseHandle ();
+ }
+ }
+}
+void releaseWidget () {
+ releaseShells ();
+ super.releaseWidget ();
+ display = null;
+ lastFocus = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeShellListener(ShellListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Activate, listener);
+ eventTable.unhook(SWT.Close, listener);
+ eventTable.unhook(SWT.Deactivate, listener);
+ eventTable.unhook(SWT.Iconify,listener);
+ eventTable.unhook(SWT.Deiconify,listener);
+}
+void saveBounds () {
+ if (!reparented) return;
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (scrolledHandle, (short) 0, (short) 0, root_x, root_y);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (scrolledHandle, argList, argList.length / 2);
+ int trimWidth = trimWidth (), trimHeight = trimHeight ();
+ oldX = root_x [0] - trimWidth; oldY = root_y [0] - trimHeight;
+ oldWidth = argList [1]; oldHeight = argList [3];
+}
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Feature in Motif. Motif will not allow a window
+ * to have a zero width or zero height. The fix is
+ * to ensure these values are never zero.
+ */
+ saveBounds ();
+ int newWidth = Math.max (width - trimWidth (), 1);
+ int newHeight = Math.max (height - trimHeight (), 1);
+ if (!reparented) {
+ super.setBounds (x, y, newWidth, newHeight);
+ return;
+ }
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ OS.XtConfigureWidget (shellHandle, x, y, newWidth, newHeight, 0);
+ if (isFocus) caret.setFocus ();
+}
+public void setImeInputMode (int mode) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ saveBounds ();
+ if (!reparented) {
+ super.setLocation(x, y);
+ return;
+ }
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ OS.XtMoveWidget (shellHandle, x, y);
+ if (isFocus) caret.setFocus ();
+}
+public void setMinimized (boolean minimized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /*
+ * Bug in MOTIF. For some reason, the receiver does not keep the
+ * value of the XmNiconic resource up to date when the user minimizes
+ * and restores the window. As a result, a window that is minimized
+ * by the user and then restored by the programmer is not restored.
+ * This happens because the XmNiconic resource is unchanged when the
+ * window is minimized by the user and subsequent attempts to set the
+ * resource fail because the new value of the resource is the same as
+ * the old value. The fix is to force XmNiconic to be up to date
+ * before setting the desired value.
+ */
+ int [] argList = {OS.XmNiconic, 0};
+ OS.XtGetValues (shellHandle, argList, argList.length / 2);
+ if ((argList [1] != 0) != this.minimized) {
+ argList [1] = this.minimized ? 1 : 0;
+ OS.XtSetValues (shellHandle, argList, argList.length / 2);
+ }
+
+ /* Minimize or restore the shell */
+ argList [1] = (this.minimized = minimized) ? 1 : 0;
+ OS.XtSetValues (shellHandle, argList, argList.length / 2);
+
+ /* Force the XWindowAttributes to be up to date */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay != 0) OS.XSync (xDisplay, false);
+}
+
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Feature in Motif. Motif will not allow a window
+ * to have a zero width or zero height. The fix is
+ * to ensure these values are never zero.
+ */
+ saveBounds ();
+ int newWidth = Math.max (width - trimWidth (), 1);
+ int newHeight = Math.max (height - trimHeight (), 1);
+ if (!reparented) {
+ super.setSize(newWidth, newHeight);
+ return;
+ }
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+ OS.XtResizeWidget (shellHandle, newWidth, newHeight, 0);
+ if (isFocus) caret.setFocus ();
+}
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+
+ /*
+ * Feature in Motif. It is not possible to set a shell
+ * title to an empty string. The fix is to set the title
+ * to be a single space.
+ */
+ if (string.length () == 0) string = " ";
+ byte [] buffer1 = Converter.wcsToMbcs (null, string, true);
+ int length = buffer1.length - 1;
+
+ /*
+ * Bug in Motif. For some reason, if the title string
+ * length is not a multiple of 4, Motif occasionally
+ * draws garbage after the last character in the title.
+ * The fix is to pad the title.
+ */
+ byte [] buffer2 = buffer1;
+ if ((length % 4) != 0) {
+ buffer2 = new byte [(length + 3) / 4 * 4];
+ System.arraycopy (buffer1, 0, buffer2, 0, length);
+ }
+
+ /* Set the title for the shell */
+ int ptr = OS.XtMalloc (buffer2.length + 1);
+ OS.memmove (ptr, buffer2, buffer2.length);
+ int [] argList = {OS.XmNtitle, ptr};
+ OS.XtSetValues (shellHandle, argList, argList.length / 2);
+ OS.XtFree (ptr);
+}
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ realizeWidget ();
+
+ /* Show the shell */
+ if (visible) {
+
+ /* Map the widget */
+ OS.XtSetMappedWhenManaged (shellHandle, true);
+ if (OS.XtIsTopLevelShell (shellHandle)) {
+ OS.XtMapWidget (shellHandle);
+ } else {
+ OS.XtPopup (shellHandle, OS.XtGrabNone);
+ }
+
+ /*
+ * Force the shell to be fully exposed before returning.
+ * This ensures that the shell coordinates are correct
+ * when queried directly after showing the shell.
+ */
+ do {
+ display.update ();
+ } while (!isVisible ());
+ adjustTrim ();
+
+ /* Set the saved focus widget */
+ if (savedFocus != null && !savedFocus.isDisposed ()) {
+ savedFocus.setFocus ();
+ }
+ savedFocus = null;
+
+ sendEvent (SWT.Show);
+ return;
+ }
+
+ /* Hide the shell */
+ OS.XtSetMappedWhenManaged (shellHandle, false);
+ if (OS.XtIsTopLevelShell (shellHandle)) {
+ OS.XtUnmapWidget (shellHandle);
+ } else {
+ OS.XtPopdown (shellHandle);
+ }
+
+ /* If the shell is iconified, hide the icon */
+ int xDisplay = OS.XtDisplay (shellHandle);
+ if (xDisplay == 0) return;
+ int xWindow = OS.XtWindow (shellHandle);
+ if (xWindow == 0) return;
+ OS.XWithdrawWindow (xDisplay, xWindow, OS.XDefaultScreen (xDisplay));
+
+ sendEvent (SWT.Hide);
+}
+int topHandle () {
+ return shellHandle;
+}
+int trimHeight () {
+ if ((style & SWT.NO_TRIM) != 0) 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;
+ 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;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
new file mode 100755
index 0000000000..e72a8c2593
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Slider.java
@@ -0,0 +1,406 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+* A slider is a selectable user interface object
+* that represents a continuous range of numeric values.
+*
+* <b>Styles</b><br>
+* <dd>HORIZONTAL, VERTICAL<br>
+* <br>
+* <b>Events</b><br>
+* <dd>Selection<br>
+*/
+
+/* Class Definition */
+public /*final*/ class Slider extends Control {
+/**
+* Creates a new instance of the widget.
+*/
+public Slider (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ Display display = getDisplay ();
+ int hScroll = display.scrolledMarginX;
+ int vScroll = display.scrolledMarginY;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += hScroll * 10;
+ height += vScroll;
+ } else {
+ width += hScroll;
+ height += vScroll * 10;
+ }
+ 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;
+ int [] argList = {
+ OS.XmNborderWidth, (style & SWT.BORDER) != 0 ? 1 : 0,
+ OS.XmNorientation, ((style & SWT.H_SCROLL) != 0) ? OS.XmHORIZONTAL : OS.XmVERTICAL,
+ };
+ handle = OS.XmCreateScrollBar (parent.handle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+/**
+* Gets the increment.
+* <p>
+* @return the increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNincrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the maximum.
+* <p>
+* @return the maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNmaximum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the minimum.
+* <p>
+* @return the minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNminimum, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the page increment.
+* <p>
+* @return the page increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNpageIncrement, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the selection.
+* <p>
+* @return the selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNvalue, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+/**
+* Gets the thumb.
+* <p>
+* @return the thumb value
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getThumb () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsliderSize, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNdragCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNtoBottomCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNincrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNdecrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNpageIncrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNpageDecrementCallback, windowProc, SWT.Selection);
+ OS.XtAddCallback (handle, OS.XmNtoTopCallback, windowProc, SWT.Selection);
+}
+int processSelection (int callData) {
+ XmAnyCallbackStruct struct = new XmAnyCallbackStruct ();
+ OS.memmove (struct, callData, XmAnyCallbackStruct.sizeof);
+ Event event = new Event ();
+ switch (struct.reason) {
+ case OS.XmCR_DRAG: event.detail = SWT.DRAG; break;
+ /*
+ * Do not set the detail field to SWT.DRAG
+ * to indicate that the dragging has ended.
+ */
+// case OS.XmCR_VALUE_CHANGED: break;
+ case OS.XmCR_TO_TOP: event.detail = SWT.HOME; break;
+ case OS.XmCR_TO_BOTTOM: event.detail = SWT.END; break;
+ case OS.XmCR_DECREMENT: event.detail = SWT.ARROW_UP; break;
+ case OS.XmCR_INCREMENT: event.detail = SWT.ARROW_DOWN; break;
+ case OS.XmCR_PAGE_DECREMENT: event.detail = SWT.PAGE_UP; break;
+ case OS.XmCR_PAGE_INCREMENT: event.detail = SWT.PAGE_DOWN; break;
+ }
+ sendEvent (SWT.Selection, event);
+ return 0;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+/**
+* Sets the increment.
+* <p>
+* @param value the new increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ int [] argList = {OS.XmNincrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the maximum.
+* <p>
+* @param value the new maximum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {OS.XmNmaximum, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the minimum.
+* <p>
+* @param value the new minimum
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {
+ OS.XmNminimum, 0,
+ OS.XmNmaximum, 0,
+ OS.XmNsliderSize, 0,
+ };
+ /*
+ * Feature in Motif. For some reason, when minimium
+ * is set to be greater than or equal to maximum, Motif
+ * does not set the minimum. Instead, the value is
+ * changed and the minimum stays the same. This behavior
+ * differs from setting the maximum where the slider size
+ * is always decreased to make room for the new maximum.
+ * The fix is to decrease the slider to make room for
+ * the new minimum.
+ */
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (argList [3] - value - argList [5] < 0) {
+ argList [5] = argList [3] - value;
+ }
+ argList [1] = value;
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the page increment.
+* <p>
+* @param value the new page increment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ int [] argList = {OS.XmNpageIncrement, value};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the selection.
+* <p>
+* @param value the new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] argList = {OS.XmNvalue, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the thumb.
+* <p>
+* @param value the new thumb
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ int [] argList = {OS.XmNsliderSize, value};
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] argList = {
+ OS.XmNvalue, selection,
+ OS.XmNminimum, minimum,
+ OS.XmNmaximum, maximum,
+ OS.XmNsliderSize, thumb,
+ OS.XmNincrement, increment,
+ OS.XmNpageIncrement, pageIncrement,
+ };
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ display.setWarnings (warnings);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java
new file mode 100755
index 0000000000..ea02526d3d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabFolder.java
@@ -0,0 +1,885 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class emulates a windows TabFolder by using portable
+ * graphics and widgets.
+ */
+public /*final*/ class TabFolder extends Composite {
+ TabItem items[];
+ int selectedIndex = -1;
+ int xClient, yClient;
+ int imageHeight = -1; // all images have the height of the first image ever set
+ int topTabIndex = 0; // index of the first visible tab. Used for tab scrolling
+ boolean scrollButtonDown = false; // true=one of the scroll buttons is being pushed
+ boolean inDispose = false;
+
+ // internal constants
+ static final int SCROLL_BUTTON_SIZE = 20; // width/height of the scroll button used for scrolling tab items
+ static final int CLIENT_MARGIN_WIDTH = 2; // distance between widget border and client rect
+ static final int SELECTED_TAB_TOP_EXPANSION = 2; // amount we expand the selected tab on top
+ static final int SELECTED_TAB_HORIZONTAL_EXPANSION = 2; // amount we expand so it overlays to left and right
+/**
+ * Construct a TabFolder with the specified parent and style.
+ * @param parent org.eclipse.swt.widgets.Composite
+ * @param swtStyle int
+ */
+public TabFolder(Composite parent, int style) {
+ super(parent, checkStyle (style));
+ Listener listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+ addListener (SWT.Dispose, listener);
+ addListener (SWT.MouseDown, listener);
+ addListener (SWT.MouseUp, listener);
+ addListener (SWT.Paint, listener);
+ addListener (SWT.Resize, listener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, 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);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;
+ int height = 0;
+
+ if (items != null && items.length > 0) {
+ TabItem lastItem = items[items.length-1];
+ width = Math.max (width, lastItem.x + lastItem.width);
+ }
+ Point size;
+ Layout layout = getLayout();
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ 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;
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ Rectangle trim = computeTrim (0, 0, width, height);
+ return new Point (trim.width, trim.height);
+}
+/**
+ * Answer the bounds of the trimmings when the client area is defined by
+ * 'x', 'y', 'width' and 'height'.
+ */
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int trimX = x - border - CLIENT_MARGIN_WIDTH - TabItem.SHADOW_WIDTH;
+ int trimY = y - border - CLIENT_MARGIN_WIDTH - TabItem.SHADOW_WIDTH;
+ int tabHeight = 0;
+ if (items != null && items.length > 0) {
+ TabItem item = items [0];
+ tabHeight = item.y + item.height; // only use height of the first item because all items should be the same height
+ }
+ int trimWidth = width + border * 2 + CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;
+ int trimHeight = height + tabHeight + border * 2 + CLIENT_MARGIN_WIDTH * 2 + TabItem.SHADOW_WIDTH * 2;
+ return new Rectangle (trimX, trimY - tabHeight, trimWidth, trimHeight);
+}
+/**
+ * Create the specified item at 'index'.
+ */
+void createChild (TabItem item, int index) {
+ boolean isTabScrolling = isTabScrolling();
+
+ if (!(0 <= index && index <= getItemCount ())) error (SWT.ERROR_INVALID_RANGE);
+ item.parent = this;
+ if (items == null) {
+ items = new TabItem[1];
+ items[0] = item;
+ } else {
+ // grow by one and rearrange the array.
+ TabItem[] newItems = new TabItem [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 ++;
+ }
+ layoutItems();
+ redrawTabs();
+ // redraw scroll buttons if they just became visible
+ // fixes 1G5X1QL
+ if (isTabScrolling() != isTabScrolling && isTabScrolling == false) {
+ redrawScrollButtons();
+ }
+ if (getItemCount() == 1) {
+ // select the first added item and send a selection event.
+ // fixes 1GAP79N
+ setSelectionNotify(0);
+ }
+}
+/**
+ * Destroy the specified item.
+ */
+void destroyChild (TabItem item) {
+ int index = indexOf(item);
+ if (index == -1) return; // should trigger an error?
+ if (items.length == 1) {
+ items = null;
+ selectedIndex = -1;
+ topTabIndex = 0;
+ if (!inDispose){
+ Control control = item.getControl();
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ redraw();
+ }
+ } else {
+ // shrink by one and rearrange the array.
+ TabItem[] newItems = new TabItem [items.length - 1];
+ System.arraycopy(items, 0, newItems, 0, index);
+ System.arraycopy(items, index + 1, newItems, index, items.length - index - 1);
+ items = newItems;
+
+ // move the selection if this item is selected
+ if (selectedIndex == index) {
+ if (!inDispose) {
+ Control control = item.getControl();
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ selectedIndex = -1;
+ setSelectionNotify(Math.max(0, index - 1));
+ }
+ } else if (selectedIndex > index) {
+ selectedIndex--;
+ }
+ if (topTabIndex == items.length) {
+ --topTabIndex;
+ }
+ }
+ // Make sure that the first tab is visible if scroll buttons are no longer drawn.
+ // Fixes 1FXW5DV
+ if (topTabIndex > 0 && !isTabScrolling()) {
+ topTabIndex = 0;
+ }
+ if (!inDispose) {
+ layoutItems();
+ redrawTabs();
+ }
+}
+/**
+ * Dispose the items of the receiver
+ */
+void doDispose() {
+ inDispose = true;
+ // items array is resized during TabItem.dispose
+ // it is set to null if the last item is removed
+ while (items != null) {
+ if (items[items.length-1] != null) {
+ items[items.length-1].dispose();
+ }
+ }
+}
+/**
+ * Draw an arrow like that used in Button with SWT.ARROW style.
+ * @param gc - GC to draw on
+ * @param xPos - x position the underlying button is drawn at
+ * @param yPos - y position the underlying button is drawn at
+ * @param size - size of the underlying button
+ * @param left - true=arrow is facing left. false=arrow is facing right
+ */
+void drawArrow(GC gc, int xPos, int yPos, int size, boolean left) {
+ int arrowWidth = size / 4;
+ int arrow[] = new int[6];
+
+ if (!left) arrowWidth *= -1;
+ // start polygon lines with vertical line which is always the same
+ arrow[0] = xPos + (size + arrowWidth) / 2;
+ arrow[1] = yPos + size / 4;
+ arrow[2] = arrow[0];
+ arrow[3] = arrow[1] + size / 2;
+
+ arrow[4] = arrow[0] - arrowWidth;
+ arrow[5] = yPos + size / 2;
+
+ gc.setBackground(getForeground());
+ gc.fillPolygon(arrow);
+ gc.setBackground(getBackground());
+}
+/**
+ * Draw a border around the receiver.
+ */
+void drawBorder(Event event) {
+ GC gc = event.gc;
+ Rectangle clientArea = getClientArea();
+ int wClient = clientArea.width;
+ int hClient = clientArea.height;
+ int x, y, x1, y1;
+ final Color HighlightShadow = getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW);
+ final Color LightShadow = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+
+ // Draw the left line
+ gc.setForeground(HighlightShadow);
+ gc.drawLine((x = xClient - CLIENT_MARGIN_WIDTH),
+ yClient + hClient + CLIENT_MARGIN_WIDTH,
+ x,
+ (y = yClient - CLIENT_MARGIN_WIDTH) + 1);
+ // Second, darker, line right of the previous line.
+ // Necessary to workaround color constant differences on Windows/Motif
+ gc.setForeground(LightShadow);
+ gc.drawLine(x + 1, yClient + hClient + CLIENT_MARGIN_WIDTH, x + 1, y + 1);
+ gc.setForeground(HighlightShadow);
+
+ // Draw the upper line in two chunks so we don't overwrite the selected tab
+ if (selectedIndex == -1) {
+ gc.setForeground(LightShadow);
+ gc.drawLine(x + 1, y + 1, xClient + wClient + CLIENT_MARGIN_WIDTH, y + 1);
+ } else {
+ TabItem item = items[selectedIndex];
+ gc.setForeground(LightShadow);
+ if (selectedIndex > 0) {
+ gc.drawLine(x + 1, y + 1, item.x - 1 + CLIENT_MARGIN_WIDTH, y + 1);
+ }
+ gc.drawLine(item.x + item.width, y + 1, xClient + wClient + CLIENT_MARGIN_WIDTH, y + 1);
+ }
+
+ // Draw the right and bottom black lines
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
+ gc.drawLine((x = xClient - CLIENT_MARGIN_WIDTH),
+ (y = yClient + hClient + CLIENT_MARGIN_WIDTH),
+ (x1 = xClient + wClient + CLIENT_MARGIN_WIDTH),
+ y);
+ gc.drawLine(x1, y, x1, (y1 = yClient - CLIENT_MARGIN_WIDTH + 1));
+ x1--;
+ x++;
+ y--;
+ y1++;
+
+
+ // There is a dark gray line above the bottom back line
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ gc.drawLine(x, y, x1, y);
+ // On the right there is a dark gray line, left of the black one
+ gc.drawLine(x1, y-1, x1, y1);
+
+ // restore the foreground color.
+ gc.setForeground(getForeground());
+}
+/**
+ * Draw a plain push button
+ * @param gc - GC to draw on
+ * @param xPos - x position the button is drawn at
+ * @param yPos - y position the button is drawn at
+ * @param size - size of the button
+ */
+void drawPlainButton(GC gc, int xPos, int yPos, int size) {
+ Color rightBottomColor = getForeground();
+ Color leftTopColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ Color rightBottomInnerColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
+ Color leftTopInnerColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+ int upper = yPos;
+ int left = xPos;
+ int lower = yPos + size - 1;
+ int right = xPos + size - 1;
+
+ if (scrollButtonDown) { // draw the button in the pressed down state?
+ rightBottomColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
+ leftTopColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW);
+ rightBottomInnerColor = getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ leftTopInnerColor = getForeground();
+ }
+ gc.fillRectangle(left, upper, right - left, lower - upper);
+ // draw right, bottom line in foreground color
+ gc.setForeground(rightBottomColor);
+ gc.drawLine(right, upper, right, lower);
+ gc.drawLine(left, lower, right, lower);
+
+ // draw left, top line in normal shadow (default light gray)
+ gc.setForeground(leftTopColor);
+ gc.drawLine(left, upper, left, lower - 1);
+ gc.drawLine(left, upper, right - 1, upper);
+
+ upper++;
+ left++;
+ lower--;
+ right--;
+ // draw right, bottom line in dark shadow (default dark gray)
+ gc.setForeground(rightBottomInnerColor);
+ gc.drawLine(right, upper, right, lower);
+ gc.drawLine(left, lower, right, lower);
+
+ // draw left, top line in high light shadow (default off white)
+ gc.setForeground(leftTopInnerColor);
+ gc.drawLine(left, upper, left, lower - 1);
+ gc.drawLine(left, upper, right - 1, upper);
+ gc.setForeground(getForeground());
+}
+/**
+ * Draw the buttons used to scroll tab items
+ */
+void drawScrollButtons(Event event) {
+ Rectangle buttonArea = getScrollButtonArea();
+ int buttonSize = buttonArea.width / 2;
+
+ drawPlainButton(event.gc, buttonArea.x, buttonArea.y, buttonSize);
+ drawPlainButton(event.gc, buttonArea.x + buttonSize, buttonArea.y, buttonSize);
+ if (scrollButtonDown) {
+ drawArrow(event.gc, buttonArea.x, buttonArea.y, buttonSize, true);
+ drawArrow(event.gc, buttonArea.x + buttonSize + 1, buttonArea.y, buttonSize + 1, false);
+ }
+ else {
+ drawArrow(event.gc, buttonArea.x - 1, buttonArea.y - 1, buttonSize, true);
+ drawArrow(event.gc, buttonArea.x + buttonSize, buttonArea.y - 1, buttonSize, false);
+ }
+}
+
+/**
+ * Make sure that the first tab is visible if scroll buttons are no
+ * longer drawn.
+ */
+void ensureRightFreeSpaceUsed() {
+ if (topTabIndex > 0 && !isTabScrolling()) {
+ topTabIndex = 0;
+ layoutItems();
+ redrawTabs();
+ }
+}
+
+/**
+ * If the tab at 'tabIndex' is not visible or partially covered by the tab
+ * scroll buttons and there is enough space to completely show the tab,
+ * the tab is scrolled to the left to make it fully visible.
+ */
+void ensureVisible(int tabIndex) {
+ if (items == null || tabIndex < 0 || tabIndex >= items.length) return;
+
+ TabItem tabItem = items[tabIndex];
+ int tabStopX = tabItem.x + tabItem.width;
+ if (isTabScrolling() && tabStopX >= getScrollButtonArea().x && tabIndex != topTabIndex) {
+ scrollRight();
+ }
+}
+/**
+ * Return the client area of the rectangle (in local coordinates).
+ */
+public Rectangle getClientArea() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle clientArea = super.getClientArea();
+
+ if (yClient == 0) { // position not calculated yet
+ layoutItems(); // calculate tab folder bounds as soon as there is tab data to use.
+ }
+ clientArea.x = xClient;
+ clientArea.y = yClient;
+ clientArea.width -= xClient + CLIENT_MARGIN_WIDTH + 1;
+ clientArea.height -= yClient + CLIENT_MARGIN_WIDTH + 1;
+ return clientArea;
+}
+/**
+ * Return the height of item images. All images are scaled to
+ * the height of the first image.
+ */
+int getImageHeight() {
+ return imageHeight;
+}
+/**
+ * Return the tab that is located at the specified index.
+ */
+public TabItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (!(0 <= index && index < getItemCount())) error(SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+/**
+ * Return the number of tabs in the folder.
+ */
+public int getItemCount(){
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (items == null)
+ return 0;
+ else return items.length;
+}
+/**
+ * Return the tab items.
+ */
+public TabItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (items == null) return new TabItem[0];
+ TabItem[] tabItems = new TabItem [items.length];
+ System.arraycopy(items, 0, tabItems, 0, items.length);
+ return tabItems;
+}
+/**
+ * Answer the area where the two scroll buttons are drawn.
+ */
+Rectangle getScrollButtonArea() {
+ return new Rectangle(
+ super.getClientArea().width - SCROLL_BUTTON_SIZE * 2, SELECTED_TAB_TOP_EXPANSION,
+ SCROLL_BUTTON_SIZE * 2, SCROLL_BUTTON_SIZE);
+}
+/**
+ * Return the selected tab item, or an empty array if there
+ * is no selection.
+ */
+public TabItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectedIndex == -1) return new TabItem [0];
+ return new TabItem [] {items[selectedIndex]};
+}
+/**
+ * Return the index of the selected tab item, or -1 if there
+ * is no selection.
+ */
+public int getSelectionIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return selectedIndex;
+}
+/**
+ * Handle the events that I have hooked on the canvas.
+ */
+void handleEvents (Event event){
+ switch (event.type) {
+ case SWT.Dispose:
+ doDispose();
+ break;
+ case SWT.Paint:
+ paint(event);
+ break;
+ case SWT.Resize:
+ resize();
+ break;
+ case SWT.MouseDown:
+ mouseDown(event);
+ break;
+ case SWT.MouseUp:
+ mouseUp(event);
+ break;
+ default:
+ break;
+ }
+}
+/**
+ * Return the index of the specified tab or -1 if the tab is not
+ * in the receiver.
+ */
+public int indexOf(TabItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ if (items[i] == item) return i;
+ }
+ }
+ return -1;
+}
+/**
+ * Answer true when the left scroll button was clicked with mouse button 1.
+ */
+boolean isLeftButtonHit(Event event) {
+ Rectangle buttonArea = getScrollButtonArea();
+
+ buttonArea.width /= 2;
+ return isTabScrolling() && event.button == 1 && buttonArea.contains(event.x, event.y);
+}
+/**
+ * Answer true when the right scroll button was clicked with mouse button 1.
+ */
+boolean isRightButtonHit(Event event) {
+ Rectangle buttonArea = getScrollButtonArea();
+ int buttonSize = buttonArea.width / 2;
+
+ buttonArea.x += buttonSize;
+ buttonArea.width = buttonSize;
+ return isTabScrolling() && event.button == 1 && buttonArea.contains(event.x, event.y);
+}
+/**
+ * Answer true if not all tabs can be visible in the receive
+ * thus requiring the scroll buttons to be visible.
+ */
+boolean isTabScrolling() {
+ boolean isVisible = false;
+
+ if (items != null && items.length > 0) {
+ TabItem tabItem = items[items.length-1];
+ int tabStopX = tabItem.x + tabItem.width;
+ tabItem = items[0];
+ if (tabStopX - tabItem.x > super.getClientArea().width) {
+ isVisible = true; // not all tabs fit in the client area
+ }
+ }
+ return isVisible;
+}
+/**
+ * 'item' has changed. Store the image size if this is the
+ * first item with an image.
+ */
+void itemChanged(TabItem item) {
+ Image itemImage = item.getImage();
+ boolean isTabScrolling = isTabScrolling();
+
+ if (imageHeight == -1 && itemImage != null) {
+ imageHeight = itemImage.getBounds().height;
+ }
+ layoutItems();
+ redrawTabs();
+ // redraw scroll buttons if they just became visible
+ // fixes 1G5X1QL
+ if (isTabScrolling() != isTabScrolling && isTabScrolling == false) {
+ redrawScrollButtons();
+ }
+}
+/**
+ * Layout the items and store the client area size.
+ */
+void layoutItems() {
+ int x = SELECTED_TAB_HORIZONTAL_EXPANSION;
+ int y = SELECTED_TAB_TOP_EXPANSION;
+ int tabHeight = 0;
+
+ if (items != null) {
+ GC gc = new GC(this);
+ for (int i=topTabIndex - 1; i>=0; i--) { // if the first visible tab is not the first tab
+ TabItem tab = items[i];
+ tab.width = tab.preferredWidth(gc);
+ tab.height = tab.preferredHeight(gc);
+ x -= tab.width; // layout tab items from right to left thus making them invisible
+ tab.x = x;
+ tab.y = y;
+ if (tab.height > tabHeight) tabHeight = tab.height;
+ }
+ x = SELECTED_TAB_HORIZONTAL_EXPANSION;
+ for (int i=topTabIndex; i<items.length; i++) { // continue laying out remaining, visible items left to right
+ TabItem tab = items[i];
+ tab.x = x;
+ tab.y = y;
+ tab.width = tab.preferredWidth(gc);
+ tab.height = tab.preferredHeight(gc);
+ x = x + tab.width;
+ if (tab.height > tabHeight) tabHeight = tab.height;
+ }
+ gc.dispose();
+ }
+ xClient = CLIENT_MARGIN_WIDTH;
+ yClient = CLIENT_MARGIN_WIDTH + tabHeight;
+ TabItem selection[] = getSelection();
+ if (selection.length > 0)
+ selection[0].expand(SELECTED_TAB_HORIZONTAL_EXPANSION, SELECTED_TAB_TOP_EXPANSION, SELECTED_TAB_HORIZONTAL_EXPANSION, 0);
+}
+/**
+ * A mouse button was pressed down.
+ * If one of the tab scroll buttons was hit, scroll in the appropriate
+ * direction.
+ * If a tab was hit select the tab.
+ */
+void mouseDown(Event event) {
+ if (items == null) return;
+ if (isLeftButtonHit(event)) {
+ scrollButtonDown = true;
+ redrawHitButton(event);
+ scrollLeft();
+ }
+ else
+ if (isRightButtonHit(event)) {
+ scrollButtonDown = true;
+ redrawHitButton(event);
+ scrollRight();
+ }
+ else {
+ for (int i=0; i<items.length; i++) {
+ if (items[i].getBounds().contains(new Point(event.x, event.y))) {
+ setSelectionNotify(i);
+ return;
+ }
+ }
+ }
+}
+/**
+ * A mouse button was released.
+ */
+void mouseUp(Event event) {
+ if (scrollButtonDown && event.button == 1) {
+ scrollButtonDown = false;
+ redrawHitButton(event);
+ }
+}
+/**
+ * Paint the receiver.
+ */
+void paint(Event event) {
+ // Draw the unselected tabs first.
+ for (int i=0; i<getItemCount(); i++) {
+ if (i != selectedIndex && event.getBounds().intersects(items[i].getBounds())) {
+ items[i].paint(event.gc, false);
+ }
+ }
+ drawBorder(event);
+ // Selected tab comes last since selected tabs overlay adjacent tabs
+ // and the border
+ if (selectedIndex != -1) {
+ items[selectedIndex].paint(event.gc, true);
+ }
+ if (isTabScrolling()) drawScrollButtons(event);
+}
+/**
+ * Redraw the area of the receiver specified by x, y, width, height.
+ * Don't redraw the scroll buttons to avoid flashing.
+ */
+void redraw (int x, int y, int width, int height) {
+ Rectangle buttonArea = getScrollButtonArea();
+ boolean fixScrollButtons = false;
+
+ if (isTabScrolling()) {
+ if (x > buttonArea.x) {
+ x = buttonArea.x;
+ fixScrollButtons = true;
+ }
+ if (x + width > buttonArea.x) {
+ width = buttonArea.x - x;
+ fixScrollButtons = true;
+ }
+ }
+ redraw(x, y, width, height, false);
+ if (fixScrollButtons) {
+ redraw(buttonArea.x, 0, buttonArea.width, buttonArea.y, false); // redraw space above scroll buttons
+ if (buttonArea.height < getClientArea().y) {
+ int redrawY = buttonArea.y + buttonArea.height;
+ redraw(
+ buttonArea.x, redrawY,
+ buttonArea.width, getClientArea().y - redrawY, false); // redraw space below scroll buttons
+ }
+ }
+}
+/**
+ * Redraw the scroll button that was pressed down
+ */
+void redrawHitButton(Event event) {
+ Rectangle scrollButtonArea = getScrollButtonArea();
+ int scrollButtonWidth = scrollButtonArea.width / 2;
+
+ if (isLeftButtonHit(event)) {
+ redraw(
+ scrollButtonArea.x, scrollButtonArea.y,
+ scrollButtonWidth, scrollButtonArea.height, false);
+ }
+ else
+ if (isRightButtonHit(event)) {
+ redraw(
+ scrollButtonArea.x + scrollButtonWidth, scrollButtonArea.y,
+ scrollButtonWidth, scrollButtonArea.height, false);
+ }
+}
+/**
+ * Redraw both scroll buttons
+ */
+void redrawScrollButtons() {
+ Rectangle scrollButtonArea = getScrollButtonArea();
+
+ redraw(
+ scrollButtonArea.x, scrollButtonArea.y,
+ scrollButtonArea.width, scrollButtonArea.height, false);
+}
+/**
+ * Redraw the tabs at the specified indexes.
+ */
+void redrawSelectionChange(int oldSelection, int newSelection) {
+ if (oldSelection != -1) {
+ TabItem tab = items[oldSelection];
+ // since the tab used to be selected, we need to clear its old expanded size
+ redraw(tab.x - SELECTED_TAB_HORIZONTAL_EXPANSION,
+ tab.y - SELECTED_TAB_TOP_EXPANSION,
+ tab.width + 2 * SELECTED_TAB_HORIZONTAL_EXPANSION,
+ tab.height + SELECTED_TAB_TOP_EXPANSION);
+ }
+ if (newSelection != -1) {
+ TabItem tab = items[newSelection];
+ // this tab is already at the expanded size
+ redraw(tab.x, tab.y, tab.width, tab.height);
+ }
+ // make sure the tab is repainted before the new page is made visible.
+ // The latter could take a long time and delay the screen update.
+ update();
+}
+/**
+ * Redraw the whole tab area
+ */
+void redrawTabs() {
+ redraw(0, 0, super.getClientArea().width, getClientArea().y);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+ * The widget was resized. Adjust the size of the currently selected page.
+ */
+void resize() {
+ if (selectedIndex != -1) {
+ Control control = items[selectedIndex].getControl();
+ if (control != null && !control.isDisposed()) {
+ control.setBounds(getClientArea());
+ }
+ }
+ ensureRightFreeSpaceUsed();
+}
+
+/**
+ * Scroll the tab items to the left.
+ */
+void scrollLeft() {
+ if (topTabIndex > 0) {
+ --topTabIndex;
+ layoutItems();
+ redrawTabs();
+ }
+}
+/**
+ * Scroll the tab items to the right.
+ */
+void scrollRight() {
+ if (items != null && items.length > 0 && topTabIndex < items.length - 1) {
+ TabItem lastTabItem = items[items.length-1];
+ int tabStopX = lastTabItem.x + lastTabItem.width;
+ if (tabStopX > super.getClientArea().width - SCROLL_BUTTON_SIZE * 2) {
+ topTabIndex++;
+ layoutItems();
+ redrawTabs();
+ }
+ }
+}
+/**
+ * The font is changing. Layout the tab items.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (font != null && font.equals(getFont())) return;
+ super.setFont(font);
+ layoutItems();
+ redrawTabs();
+}
+/**
+ * Set the selection to the tab at the specified index.
+ */
+public void setSelection(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int oldIndex = selectedIndex;
+
+ if (selectedIndex == index || index >= getItemCount()) return;
+ if (selectedIndex != -1) {
+ Control control = items[selectedIndex].control;
+ if (control != null && !control.isDisposed()) {
+ control.setVisible(false);
+ }
+ }
+ if (index < 0) {
+ index = -1; // make sure the index is always -1 if it's negative
+ }
+ selectedIndex = index;
+ layoutItems();
+ ensureVisible(index);
+ redrawSelectionChange(oldIndex, index);
+ if (index >= 0) {
+ Control control = items[index].control;
+ if (control != null && !control.isDisposed()) {
+ control.setBounds(getClientArea());
+ control.setVisible(true);
+ }
+ }
+}
+/**
+ * Set the selection to the specified items.
+ */
+public void setSelection(TabItem selectedItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectedItems == null) error(SWT.ERROR_NULL_ARGUMENT);
+ int index = -1;
+ if (selectedItems.length > 0) {
+ index = indexOf(selectedItems[0]);
+ }
+ setSelection(index);
+}
+/**
+ * Set the selection to the tab at the specified index.
+ */
+void setSelectionNotify(int index) {
+ int oldSelectedIndex = selectedIndex;
+
+ setSelection(index);
+ if (selectedIndex != oldSelectedIndex && selectedIndex != -1) {
+ Event event = new Event();
+ event.item = getSelection()[0];
+ notifyListeners(SWT.Selection, event);
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java
new file mode 100755
index 0000000000..012f718cb6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TabItem.java
@@ -0,0 +1,337 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class emulates a windows TabItem, which represents a tab
+ * that can be used to switch to a page in the TabbedFolder.
+ */
+
+public /*final*/ class TabItem extends Item {
+ TabFolder parent;
+ int x,y,width,height = 0;
+ String toolTipText;
+ Control control; // the tab page
+
+ // internal constants
+ static final int LEFT_HORIZONTAL_MARGIN = 8;
+ static final int RIGHT_HORIZONTAL_MARGIN = 2;
+ static final int VERTICAL_MARGIN = 1; // space between tab shadow and tab content
+ static final int ICON_MARGIN = 6;
+ static final int SHADOW_WIDTH = 2; // width of the tab shadow
+ static final int DEFAULT_TEXT_WIDTH = 36; // preferred text width if there is no text.
+ // Used for preferred item width calculation
+/**
+ * Construct a TabItem with the specified parent and style.
+ */
+public TabItem (TabFolder parent, int style) {
+ this(parent, style, parent.getItemCount());
+}
+/**
+ * Construct a TabItem with the specified parent and style, inserted at
+ * the specified index.
+ */
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ parent.createChild (this, index);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeItem();}});
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Dispose the receiver.
+ */
+void disposeItem () {
+ parent.destroyChild(this);
+ parent = null;
+ control = null;
+ toolTipText = null;
+}
+/**
+ * Expand the receiver's bounds by the specified number of pixels on
+ * the left,top,right,and bottom.
+ */
+void expand(int left, int top, int right, int bottom) {
+ if (hasLocation()) {
+ x = x - left;
+ y = y - top;
+ width = width + left + right;
+ height = height + top + bottom;
+ }
+}
+/**
+ * Return the bounds of the TabItem.
+ */
+Rectangle getBounds () {
+ return new Rectangle(x, y, width, height);
+}
+/**
+* Gets the control.
+* <p>
+* @return the control
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ if (parent == null) error(SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay();
+}
+/**
+ * Return the parent of the TabItem.
+ */
+public TabFolder getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return parent;
+}
+/**
+* Gets the tool tip text.
+* <p>
+* @return the tool tip text.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+/**
+ * Answer true if the receiver has been layed out.
+ */
+boolean hasLocation() {
+ return !(width == 0 && height == 0 && x == 0 && y == 0);
+}
+/**
+ * Answer the image height.
+ */
+private int imageHeight() {
+ Image image = getImage();
+
+ if (parent.getImageHeight() != -1) {
+ return parent.getImageHeight();
+ } else if (image != null) {
+ return image.getBounds().height;
+ }
+ else {
+ return 0;
+ }
+}
+/**
+ * Answer the icon width.
+ */
+private int imageWidth() {
+ Image image = getImage();
+
+ if (image != null) {
+ return image.getBounds().width;
+ } else {
+ return 0;
+ }
+}
+/**
+ * Paint the receiver.
+ */
+void paint(GC gc, boolean isSelected) {
+ // high light colored line across left and top
+ gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ gc.drawLine(x, y + height - 2, x, y + 2);
+ gc.drawLine(x, y + 2, x + 2, y);
+ gc.drawLine(x + 2, y, x + width - 3, y);
+
+ // light color next to the left and below the top line.
+ // Since tabs expand horizontally when selected, we actually draw
+ // the background color to erase any debris from a selected tab.
+ gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ gc.drawLine(x + 1, y + height - 2, x + 1, y + 2);
+ gc.drawLine(x + 2, y + 1, x + width - 3, y + 1);
+
+ // dark colored line at right
+ gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_FOREGROUND));
+ gc.drawLine(x + width - 1, y + 2, x + width - 1, y + height - 1);
+ // dark pixel on top of shadowed line, inside dark line
+ gc.drawLine(x + width - 2, y + 1, x + width - 2, y + 1);
+
+ // shadowed line on right inside the dark line
+ gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ gc.drawLine(x + width - 2, y + 2, x + width - 2, y + height - 1);
+
+ // icon and bitmap. Should probably be checking style bits to determine
+ // exactly what to paint. Do we just draw the icon when the icon/text combination
+ // is too wide to fit all tabs?
+ gc.setForeground(parent.getForeground());
+ int xDraw = x + LEFT_HORIZONTAL_MARGIN;
+ int yCenter;
+ int decorationHeight = SHADOW_WIDTH * 2 + VERTICAL_MARGIN * 2;
+ Image image = getImage();
+ Rectangle sourceBounds = null;
+ if (image != null) {
+ sourceBounds = image.getBounds();
+ yCenter = y + SHADOW_WIDTH + VERTICAL_MARGIN + (height - decorationHeight - imageHeight()) / 2;
+ gc.drawImage(
+ image,
+ sourceBounds.x, sourceBounds.y, sourceBounds.width, sourceBounds.height,
+ xDraw, yCenter, sourceBounds.width, parent.getImageHeight());
+ }
+ xDraw = xDraw + ICON_MARGIN;
+ if (sourceBounds != null) {
+ xDraw += sourceBounds.width;
+ }
+ yCenter = y + SHADOW_WIDTH + VERTICAL_MARGIN + (height - decorationHeight - textHeight(gc)) / 2;
+ gc.drawString(getText(), xDraw, yCenter);
+}
+/**
+ * Answer the preferred height of the receiver for the GC.
+ */
+int preferredHeight(GC gc) {
+ int height = textHeight(gc);
+ if (imageHeight() > height) height = imageHeight();
+ height += VERTICAL_MARGIN * 2 + SHADOW_WIDTH * 2;
+ return height;
+}
+/**
+ * Answer the preferred width of the receiver for the GC.
+ */
+int preferredWidth(GC gc) {
+ return imageWidth() + textWidth(gc) + LEFT_HORIZONTAL_MARGIN +
+ RIGHT_HORIZONTAL_MARGIN + ICON_MARGIN + SHADOW_WIDTH * 2;
+}
+/**
+* Sets the control.
+* <p>
+* @param control the new control
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && 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);
+}
+/**
+* Sets the image.
+* <p>
+* @param image the new image (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Image oldImage = this.image;
+
+ super.setImage(image);
+ if (image == null || !image.equals(oldImage)) {
+ parent.itemChanged(this);
+ }
+}
+/**
+* Set the widget text.
+*
+* PARAMETERS
+*
+* string - the new label for the widget
+*
+* REMARKS
+*
+* This method sets the widget label. The label may include
+* the mnemonic characters but must not contain line delimiters.
+*
+**/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ String oldText = text;
+
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText(string);
+ if (!string.equals(oldText)) {
+ parent.itemChanged(this);
+ }
+}
+/**
+* Sets the tool tip text.
+* <p>
+* @param string the new tool tip text (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
+}
+/**
+ * Answer the text height.
+ */
+private int textHeight(GC gc) {
+ String text = getText();
+
+ if (text == null) {
+ return 0;
+ } else {
+ return gc.stringExtent(text).y;
+ }
+}
+/**
+ * Answer the text width.
+ */
+private int textWidth(GC gc) {
+ String text = getText();
+ int textWidth = 0;
+
+ if (text != null) {
+ textWidth = gc.stringExtent(text).x;
+ }
+ if (textWidth == 0) {
+ textWidth = DEFAULT_TEXT_WIDTH;
+ }
+ return textWidth;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java
new file mode 100755
index 0000000000..c0897e483c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Table.java
@@ -0,0 +1,2361 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class display rows of items arranged in one or more
+ * columns. Items can be selected, columns can be resized.
+ */
+public /*final*/ class Table extends SelectableItemWidget {
+ private static final int COLUMN_RESIZE_OFFSET = 7; // offset from the start and end of each
+ // column at which the resize cursor is displayed
+ // if the mouse is in the column header
+ static final String DOT_STRING = "..."; // used to indicate truncated item labels
+
+ private Header tableHeader;
+ private Control focusProxy; // used as a proxy to take focus in place of the table.
+ // The latter can't get focus because it has a child
+ // (the header widget). The header widget can't be used
+ // as a focus widget because it may be hidden.
+ private Vector items;
+ private Vector columns;
+ private boolean drawGridLines = false;
+ private boolean hasColumnFocus = false; // true if a column currently has focus
+ private boolean firstColumnImage = false; // true if any item in the first column has an image
+ private int columnResizeX; // last position of the cursor in a column resize operation
+ private Cursor columnResizeCursor; // cursor displayed when a column resize is in progress.
+ // Need to keep reference to the cursor in order to dispose it.
+ private boolean isColumnResizeCursor = false; // set to true if the column resize cursor is active
+ private TableColumn resizeColumn; // column that is currently being resized
+ private TableColumn fillColumn; // column used to fill up space that is not used
+ // by user defined columns
+ private TableColumn defaultColumn; // Default column that is created as soon as the table is created.
+ // Fix for 1FUSJY5
+ private int dotsWidth = -1; // width of the static String dots (see above)
+/**
+ * Create a new instance of Table.
+ * @param parent - the parent window of the new instance
+ * @param style - window style for the new instance
+ */
+public Table(Composite parent, int style) {
+ // use NO_MERGE_PAINTS to avoid flashing during column and widget resize redraw
+ super(parent, checkStyle(style| SWT.NO_MERGE_PAINTS));
+}
+/**
+ * Add 'column' to the receiver.
+ * @param column - new table column that should be added to
+ * the receiver
+ */
+void addColumn(TableColumn column) {
+ int index = column.getIndex();
+
+ getColumnVector().insertElementAt(column, index);
+ // has the column been inserted (vs. appended)?
+ if (index < getColumnCount() - 1) {
+ reindexColumns(index + 1);
+ }
+ // is there more than one user created column?
+ // There always is the data and visual of the default column
+ // so we don't need to create those for the first user column
+ if (getColumnCount() > 1) {
+ insertColumnData(column);
+ }
+ else { // first user created column
+ setContentWidth(0); // pretend it's ground zero for column resizings
+ redraw(); // redraw the table and header. The default column
+ getHeader().redraw(); // won't be drawn anymore, because there now is a user created table.
+ }
+ insertColumnVisual(column);
+}
+/**
+ * Add 'item' to the receiver.
+ * @param item - new table item that should be added to
+ * the receiver
+ * @param index - position the new item should be inserted at
+ */
+void addItem(TableItem item, int index) {
+ Vector items = getItemVector();
+
+ if (index < 0 || index > getItemCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ addingItem(item, index);
+ item.setIndex(index);
+ if (index < items.size()) {
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() + 1);
+ }
+ items.insertElementAt(item, index);
+ }
+ else {
+ items.addElement(item);
+ }
+ addedItem(item, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*/
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ 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);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * The width of 'column' is about to change.
+ * Adjust the position of all columns behind it.
+ */
+void columnChange(TableColumn column, Rectangle newBounds) {
+ Rectangle columnBounds = column.getBounds();
+ Rectangle clientArea = getClientArea();
+ int oldXPosition = columnBounds.x + columnBounds.width;
+ int newXPosition = newBounds.x + newBounds.width;
+ int widthChange = newBounds.width - columnBounds.width;
+ int headerHeight = getHeaderHeight();
+ int columnIndex = column.getIndex();
+
+ if (widthChange != 0) {
+ if (columnIndex != TableColumn.FILL) {
+ if (getLinesVisible() == true) {
+ oldXPosition -= getGridLineWidth(); // include vertical grid line when scrolling resized column.
+ newXPosition -= getGridLineWidth();
+ }
+ scroll( // physically move all following columns
+ newXPosition, headerHeight, // destination x, y
+ oldXPosition, headerHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+ }
+ column.internalSetBounds(newBounds);
+ if (columnIndex != TableColumn.FILL) {
+ resetTableItems(columnIndex);
+ moveColumns(columnIndex + 1, widthChange); // logically move all following columns (set their bounds)
+ setContentWidth(getContentWidth() + widthChange); // set the width of the receiver's content
+ claimRightFreeSpace();
+ resizeRedraw(column, columnBounds.width, newBounds.width);
+ }
+ }
+ getHeader().widthChange(columnIndex, widthChange);
+}
+/**
+ * The mouse pointer was double clicked on the receiver.
+ * Handle the event according to the position of the mouse click
+ * and the modifier key that was pressed, if any.
+ * @param event - the mouse event
+ */
+void columnMouseDoubleClick(Event event) {
+ int itemHeight = getItemHeight();
+ int itemIndex;
+ TableItem hitItem;
+ TableColumn hitColumn = getColumnAtX(event.x);
+ Event columnDblClickEvent;
+
+ if (isFocusControl() == false) {
+ setFocus(); // focus proxy gets focus here because it's the first child of the receiver
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null &&
+ hitColumn.getIndex() == TableColumn.FIRST) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ columnDblClickEvent = new Event();
+ columnDblClickEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, columnDblClickEvent);
+ }
+ }
+ else {
+ deselectAll();
+ }
+ }
+}
+/**
+ * The mouse pointer was pressed down on the receiver.
+ * Handle the event according to the position of the mouse click
+ * and the modifier key that was pressed, if any.
+ * @param event - the mouse event
+ */
+void columnMouseDown(Event event) {
+ int itemHeight = getItemHeight();
+ int itemIndex;
+ TableItem hitItem;
+ TableColumn hitColumn = getColumnAtX(event.x);
+
+ if (isFocusControl() == false) {
+ setFocus(); // focus proxy gets focus here because it's the first child of the receiver
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ doMouseSelect(hitItem, itemIndex, event.stateMask, event.button);
+ }
+ else
+ if (hitItem.isCheckHit(new Point(event.x, event.y)) == true) {
+ doCheckItem(hitItem);
+ }
+ }
+ else {
+ deselectAll();
+ }
+ }
+}
+/**
+ * The mouse pointer was moved over the receiver.
+ * Reset the column resize cursor if it was active.
+ * @param event - the mouse event
+ */
+void columnMouseMove(Event event) {
+ if (isColumnResizeStarted() == false) {
+ setColumnResizeCursor(false);
+ }
+}
+/**
+ * Answer the size of the receiver needed to display all or
+ * the first 50 items whichever is less.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size = super.computeSize(wHint, hHint, changed);
+ Point headerSize;
+ GC gc;
+ final int WidthCalculationCount = Math.min(getItemCount(), 50); // calculate item width for the first couple of items only
+ TableItem item;
+ Image itemImage;
+ String itemText;
+ int width;
+ int newItemWidth = 0;
+
+ if (getHeaderVisible() == true) {
+ headerSize = getHeader().computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
+ size.y += headerSize.y;
+ }
+ if (getContentWidth() == 0 && WidthCalculationCount > 0) {
+ gc = new GC(this);
+ for (int i = 0; i < WidthCalculationCount; i++) {
+ item = getItem(i);
+ if (item == null) {
+ break; // no more items
+ }
+ itemImage = item.getImage();
+ itemText = item.getText();
+ width = 0;
+ if (itemImage != null) {
+ width += itemImage.getBounds().width;
+ }
+ if (itemText != null) {
+ width += gc.stringExtent(itemText).x;
+ }
+ newItemWidth = Math.max(newItemWidth, width);
+ }
+ if (newItemWidth > 0) {
+ size.x = newItemWidth;
+ }
+ gc.dispose();
+ }
+ return size;
+}
+/**
+ * Deselect the items identified by the indices stored
+ * in 'indices'.
+ * A SWT.Selection event will not be sent.
+ * @param indices - indices of the items to deselect
+ */
+public void deselect(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ for (int i = 0; i < indices.length; i++) {
+ item = getVisibleItem(indices[i]);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect the item identified by 'index'.
+ * A SWT.Selection event will not be sent.
+ * @param index - index of the item to deselect
+ */
+public void deselect(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ deselect(item);
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect a range of items starting at index 'start'
+ * and stopping at index 'end'. Indices that are out of
+ * range are ignored. Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void deselect(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+
+ for (int i=start; i<=end; i++) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect all items of the receiver.
+ */
+public void deselectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ deselectAllExcept((SelectableItem) null);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ Vector items = getItemVector();
+
+ super.doDispose();
+ while (items.size() > 0) { // TableItem objects are removed from vector during dispose()
+ ((TableItem) items.lastElement()).dispose();
+ }
+ items = getColumnVector();
+ while (items.size() > 0) { // TableColumn objects are removed from vector during dispose()
+ ((TableColumn) items.lastElement()).dispose();
+ }
+ resizeColumn = null;
+ fillColumn = null;
+ defaultColumn = null;
+ if (columnResizeCursor != null) {
+ columnResizeCursor.dispose();
+ }
+}
+/**
+ * Draw a line tracking the current position of a column
+ * resize operation.
+ * @param xPosition - x coordinate to draw the line at
+ */
+void drawColumnResizeLine(int xPosition) {
+ GC gc = new GC(this);
+ int lineHeight = getClientArea().height;
+
+ redraw(getColumnResizeX(), 0, 1, lineHeight, false);
+ setColumnResizeX(xPosition);
+ gc.drawLine(xPosition, 0, xPosition, lineHeight);
+ gc.dispose();
+}
+/**
+ * Draw the grid lines for the receiver.
+ * @param event - Paint event triggering the drawing operation.
+ * @param drawColumns - The table columns for which the grid
+ * lines should be drawn.
+ */
+void drawGridLines(Event event, Enumeration drawColumns) {
+ GC gc = event.gc;
+ Color oldForeground = getForeground();
+ Rectangle columnBounds;
+ TableColumn column;
+ int lineWidth = getGridLineWidth();
+ int itemHeight = getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int lineXPosition;
+ int lineYPosition = headerHeight + ((event.y-headerHeight) / itemHeight) * itemHeight;
+ int lineYStopPosition = event.y + event.height;
+
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ // Draw the horizontal lines
+ if (itemHeight > 0) {
+ while (lineYPosition < lineYStopPosition) {
+ gc.drawLine(
+ event.x, lineYPosition + itemHeight - lineWidth,
+ event.x + event.width, lineYPosition + itemHeight - lineWidth);
+ lineYPosition += itemHeight;
+ }
+ }
+ // Draw the vertical lines at the right border of each column except the fill column
+ while (drawColumns.hasMoreElements() == true) {
+ column = (TableColumn) drawColumns.nextElement();
+ if (column.getIndex() != TableColumn.FILL) {
+ columnBounds = column.getBounds();
+ lineXPosition = columnBounds.x + columnBounds.width - lineWidth;
+ gc.drawLine(
+ lineXPosition, event.y,
+ lineXPosition, event.y + event.height);
+ }
+ }
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw a filled rectangle indicating the selection state of 'item'
+ * If 'item' is selected the rectangle will be filled with the
+ * selection background color. Otherwise the rectangle will be filled
+ * with the background color to remove selection.
+ * The selection color depends on whether the table widget has
+ * focus or not. See getSelectionBackgroundColor() for details.
+ * The rectangle is drawn in either the first column or in all columns
+ * for full row select.
+ * @param item - item for which the selection state should be drawn
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @param extent - extent of the selection rectangle.
+ */
+void drawSelection(TableItem item, GC gc, Point position, Point extent) {
+ if (item.isSelected() == true) {
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
+ }
+ gc.fillRectangle(position.x, position.y, extent.x, extent.y);
+ if (item.isSelected() == true) {
+ gc.setBackground(getBackground());
+ }
+}
+/**
+ * If the receiver has input focus draw a rectangle enclosing
+ * the label of 'item' to indicate the input focus.
+ * The rectangle is drawn in either the first column or in all columns
+ * for full row select.
+ * @param item - item for which the selection state should be drawn
+ * @param gc - GC to draw on.
+ */
+void drawSelectionFocus(TableItem item, GC gc) {
+ Point extent = item.getSelectionExtent();
+ Point position = new Point(
+ item.getImageStopX(TableColumn.FIRST) + getHorizontalOffset(),
+ getRedrawY(item));
+
+ gc.drawFocus(position.x, position.y, extent.x, extent.y);
+}
+
+/** Not used right now. Replace focusIn/focusOut with this method once
+ * Display.getFocusWindow returns the new focus window on FocusOut event
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusChange(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+ Control focusWindow = getDisplay().getFocusControl();
+
+ if (focusWindow == getFocusWindow() &&
+ focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = true;
+ }
+ else {
+ hasColumnFocus = false;
+ }
+ super.focusChange(event);
+ event.widget = this; // the ficus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * @param event - the focus change event
+ */
+void focusIn(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+
+ if (focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = true;
+ }
+ super.focusIn(event);
+ event.widget = this; // the focus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * @param event - the focus change event
+ */
+void focusOut(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+
+ if (focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = false;
+ }
+ super.focusOut(event);
+ event.widget = this; // the focus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * Answer the TableColumn at 'index'.
+ */
+public TableColumn getColumn(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+
+ if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);
+ if (index < 0 || index >= columns.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ return (TableColumn) columns.elementAt(index);
+}
+/**
+ * Return the column located at 'xPosition' in the widget.
+ * Return null if xPosition is outside the widget.
+ * @param xPosition - position of the desired column
+ */
+TableColumn getColumnAtX(int xPosition) {
+ Enumeration columns = internalGetColumnVector().elements();
+ TableColumn column;
+ TableColumn hitColumn = null;
+ Rectangle bounds;
+
+ while (columns.hasMoreElements() == true && hitColumn == null) {
+ column = (TableColumn) columns.nextElement();
+ bounds = column.getBounds();
+ if ((xPosition >= bounds.x) &&
+ (xPosition <= bounds.x + bounds.width)) {
+ hitColumn = column;
+ }
+ }
+ if (hitColumn == null) {
+ column = getFillColumn();
+ bounds = column.getBounds();
+ if ((xPosition >= bounds.x) &&
+ (xPosition <= bounds.x + bounds.width)) {
+ hitColumn = column;
+ }
+ }
+ return hitColumn;
+}
+/**
+ * Answer the number of columns in the receiver.
+ */
+public int getColumnCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+ int count = 0;
+
+ if (columns != null) {
+ count = columns.size();
+ }
+ return count;
+}
+/** Replace CURSOR_SIZEWE with real column resize cursor
+ * (no standard cursor-have to load from file)
+ * Answer the cursor displayed during a column resize
+ * operation.
+ * Lazy initialize the cursor since it may never be needed.
+ */
+Cursor getColumnResizeCursor() {
+ if (columnResizeCursor == null) {
+ columnResizeCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);
+ }
+ return columnResizeCursor;
+}
+/**
+ * Answer the current position of the mouse cursor during
+ * a column resize operation.
+ */
+int getColumnResizeX() {
+ return columnResizeX;
+}
+/**
+ * Answer an Array containing all columns of receiver except
+ * the fill column to the right of all content columns.
+ */
+public TableColumn [] getColumns() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+ TableColumn columnArray[] = new TableColumn[columns.size()];
+
+ columns.copyInto(columnArray);
+ return columnArray;
+}
+/**
+ * Answer a Vector containing all columns of receiver except
+ * the fill column to the right of all content columns.
+ */
+Vector getColumnVector() {
+ return columns;
+}
+/**
+ * Return the default column that is created as soon as the table
+ * is created.
+ * Fix for 1FUSJY5
+ */
+TableColumn getDefaultColumn() {
+ return defaultColumn;
+}
+/**
+ * Answer the width of the replacement String used to indicate
+ * truncated items.
+ * Cached to speed up calculation of truncated items.
+ * @param gc - GC used to measure the width of the replacement
+ * String
+ */
+int getDotsWidth(GC gc) {
+ if (dotsWidth == -1) {
+ dotsWidth = gc.stringExtent(DOT_STRING).x;
+ }
+ return dotsWidth;
+}
+/**
+ * Answer the column used to occupy any space left to the
+ * right of all the user created columns.
+ */
+TableColumn getFillColumn() {
+ return fillColumn;
+}
+/**
+ * Answer the widget that is used to hold focus for the receiver.
+ * The receiver can not get focus itself because it has children.
+ */
+Control getFocusWindow() {
+ return focusProxy;
+}
+/**
+* Gets the width of a grid line.
+* <p>
+* @return the width of a grid line
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getGridLineWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return 1;
+}
+/**
+ * Answer the table header widget.
+ */
+Header getHeader() {
+ return tableHeader;
+}
+/**
+ * Answer the header height or 0 if the header is not visible.
+ */
+int getHeaderHeight() {
+ Header header = getHeader();
+ int height = 0;
+
+ if (header.getVisible() == true) {
+ height = header.getBounds().height;
+ }
+ return height;
+}
+/**
+ * Answer whether the header is visible.
+ * @return
+ * true = header is visible. false = header is not visible
+ */
+public boolean getHeaderVisible() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getHeader().getVisible();
+}
+/**
+ * Answer the image extent of 'item'. Use the image of any column.
+ */
+Point getImageExtent(SelectableItem item) {
+ Image image = null;
+ Rectangle imageBounds;
+ Point imageExtent = null;
+ int columnCount = internalGetColumnCount();
+
+ for (int i = 0; i < columnCount && image == null; i++) {
+ image = ((TableItem) item).getImage(i);
+ }
+ if (image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+int getIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null && item.getSelectableParent() == this) {
+ index = ((TableItem) item).getIndex();
+ }
+ return index;
+}
+/**
+ * Answer the TableItem located at 'index' in the receiver.
+ * @param index - location of the TableItem object to return
+ */
+public TableItem getItem(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (!(0 <= index && index < getItemCount())) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ return (TableItem) getVisibleItem(index);
+}
+
+/**
+ * Return the item at the specified position in the widget
+ * Return null if the position is outside the widget or in the header widget.
+ */
+public TableItem getItem(Point point) {
+ int headerHeight = getHeaderHeight();
+ TableColumn column = getColumnAtX(point.x);
+ TableItem item = null;
+
+ if (column != null && column.getIndex() != TableColumn.FILL && point.y - headerHeight > 0) {
+ int itemIndex = (point.y - headerHeight) / getItemHeight() + getTopIndex();
+ item = (TableItem) getVisibleItem(itemIndex);
+ if (item != null) {
+ Point itemSize = item.getItemExtent(column);
+ if (point.x - column.getBounds().x > itemSize.x) {
+ item = null;
+ }
+ }
+ }
+ return item;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getItemVector().size();
+}
+/**
+ * Answer the number of items that can be displayed in the
+ * client area of the receiver without truncating any items.
+ */
+int getItemCountWhole() {
+ int clientAreaHeight = Math.max(0, getClientArea().height - getHeaderHeight());
+
+ return clientAreaHeight / getItemHeight();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return getGridLineWidth() + getDisplay().textHighlightThickness + 1;
+}
+/**
+ * Answer all items of the receiver as an Array.
+ */
+public TableItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector items = getItemVector();
+ TableItem itemArray[] = new TableItem[items.size()];
+
+ items.copyInto(itemArray);
+ return itemArray;
+}
+/**
+ * Answer all items of the receiver.
+ */
+Vector getItemVector() {
+ return items;
+}
+/**
+ * Answer whether the receiver is drawing grid lines.
+ * @return
+ * true = receiver draws grid lines
+ * false = receiver does not draw grid lines
+ */
+public boolean getLinesVisible() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return drawGridLines;
+}
+/**
+ * Answer a Vector containing the columns that need repainting
+ * based on the 'paintArea'.
+ * @param paintArea - invalidated rectangle that needs repainting
+ */
+Vector getPaintColumns(Rectangle paintArea) {
+ Enumeration columns = internalGetColumnVector().elements();
+ Vector paintColumns = new Vector();
+ TableColumn column;
+ Rectangle columnBounds;
+ int paintAreaRightBorder = paintArea.x + paintArea.width;
+
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ columnBounds = column.getBounds();
+ if ((columnBounds.x + columnBounds.width >= paintArea.x) && // does the paintArea overlap the current column?
+ (columnBounds.x <= paintAreaRightBorder)) {
+ paintColumns.addElement(column);
+ }
+ }
+ return paintColumns;
+}
+/**
+ * Return the width of the widest item in the column identified by 'columnIndex'
+ * @param columnIndex - index of the column whose preferred width should be
+ * calculated
+ */
+int getPreferredColumnWidth(int columnIndex) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+ int width = 0;
+ int headerWidth;
+
+ if (columnIndex != TableColumn.FILL) {
+ while (tableItems.hasMoreElements() == true) {
+ tableItem = (TableItem) tableItems.nextElement();
+ width = Math.max(width, tableItem.getPreferredWidth(columnIndex));
+ }
+ headerWidth = getHeader().getPreferredWidth(columnIndex);
+ if (width < headerWidth) {
+ width = headerWidth;
+ }
+ }
+ return width;
+}
+/**
+ * Answer the position in the receiver where 'item' is drawn
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is not an item of the receiver
+ */
+int getRedrawY(SelectableItem item) {
+ int redrawY = super.getRedrawY(item);
+
+ if (redrawY != -1) {
+ redrawY += getHeaderHeight();
+ }
+ return redrawY;
+}
+/**
+ * Answer the column that is being resized or null if no
+ * resize operation is in progress.
+ */
+TableColumn getResizeColumn() {
+ return resizeColumn;
+}
+/**
+ * Return the positions at which the column identified by 'columnIndex'
+ * must be redrawn.
+ * These positions may be different for each item since each item may
+ * have a different label
+ * @param columnIndex - the column index
+ * @param columnWidth - width of the column
+ * @return the positions at which the column must be redrawn.
+ * Each item in the widget client area is represented by a slot in
+ * the array. The item at position 'topIndex' is the first item in
+ * the array.
+ */
+int [] getResizeRedrawX(int columnIndex, int columnWidth) {
+ int topIndex = getTopIndex();
+ int bottomIndex = getBottomIndex();
+ int resizeRedrawX[];
+ TableItem item;
+
+ bottomIndex = Math.min(bottomIndex, getItemCount());
+ resizeRedrawX = new int[bottomIndex-topIndex+1];
+ for (int i = topIndex; i < bottomIndex; i++) {
+ item = (TableItem) getVisibleItem(i);
+ resizeRedrawX[i-topIndex] = item.getDotStartX(columnIndex, columnWidth);
+ }
+ return resizeRedrawX;
+}
+/**
+ * Answer the selected items of the receiver.
+ * @return an Array of TableItems containing the selected items.
+ * An empty Array if no items are selected.
+ */
+public TableItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selectionVector = getSelectionVector();
+ TableItem[] selectionArray = new TableItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getSelectionCount();
+}
+/**
+ * Answer the size of the full row selection rectangle for 'item'.
+ */
+Point getFullSelectionExtent(TableItem item) {
+ TableColumn lastColumn = (TableColumn) internalGetColumnVector().lastElement();
+ Point selectionExtent = null;
+ Rectangle columnBounds;
+ int xPosition = item.getImageStopX(TableColumn.FIRST);
+ int gridLineWidth = getGridLineWidth();
+
+ if (lastColumn != null) {
+ columnBounds = lastColumn.getBounds();
+ selectionExtent = new Point(
+ columnBounds.x - getHorizontalOffset() + columnBounds.width - xPosition - gridLineWidth,
+ getItemHeight());
+ if (getLinesVisible() == true) {
+ selectionExtent.y -= gridLineWidth;
+ }
+ }
+ return selectionExtent;
+}
+/**
+ * Answer the index of the first selected item of the receiver.
+ */
+public int getSelectionIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = -1;
+
+ if (getSelectionCount() > 0) {
+ index = getIndex(getSelection()[0]);
+ }
+ return index;
+}
+/**
+ * Answer the indices of the selected items of the receiver.
+ * @return an Array containing the indices of the selected items.
+ * An empty Array if no items are selected.
+ */
+public int [] getSelectionIndices() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TableItem[] items = getSelection();
+ int indices[] = new int[items.length];
+
+ for (int i = 0; i < items.length; i++) {
+ indices[i] = getIndex(items[i]);
+ }
+ return indices;
+}
+/**
+ * Answer the index of the first visible item in the receiver's
+ * client area.
+ * @return 0-based index of the first visible item in the
+ * receiver's client area.
+ */
+public int getTopIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getTopIndex();
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Every item in a table widget should be visible.
+ */
+int getVisibleIndex(SelectableItem item) {
+ return getIndex(item);
+}
+/**
+ * Answer the SelectableItem located at 'itemIndex' in the receiver.
+ * @param itemIndex - location of the SelectableItem object to return
+ */
+SelectableItem getVisibleItem(int itemIndex) {
+ Vector items = getItemVector();
+ TableItem item = null;
+
+ if ((items != null) && (itemIndex >= 0) && (itemIndex < items.size())) {
+ item = (TableItem) items.elementAt(itemIndex);
+ }
+ return item;
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+int getVisibleRedrawY(SelectableItem item) {
+ int redrawY = -1;
+ int index = getTopIndex();
+ int bottomIndex = getBottomIndex();
+
+ if (item == null) {
+ return redrawY;
+ }
+ while (index < bottomIndex && item.equals(getVisibleItem(index)) == false) {
+ index++;
+ }
+ if (index < bottomIndex) {
+ redrawY = getRedrawY(item);
+ }
+ return redrawY;
+}
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.MouseMove:
+ if (event.widget == tableHeader) {
+ headerMouseMove(event);
+ }
+ else {
+ columnMouseMove(event);
+ }
+ break;
+ case SWT.MouseDown:
+ if (event.widget == tableHeader) {
+ headerMouseDown(event);
+ }
+ else {
+ columnMouseDown(event);
+ }
+ break;
+ case SWT.MouseDoubleClick:
+ columnMouseDoubleClick(event);
+ break;
+ case SWT.MouseUp:
+ mouseUp(event);
+ break;
+ case SWT.Paint:
+ paint(event);
+ break;
+ default:
+ super.handleEvents(event);
+ }
+}
+/**
+ * Answer true if any item in the first column has an image.
+ * Answer false otherwise.
+ */
+boolean hasFirstColumnImage() {
+ return firstColumnImage;
+}
+/**
+ * Answer whether the receiver has the input focus.
+ */
+public boolean isFocusControl() {
+ return hasColumnFocus;
+}
+/**
+ * The mouse pointer was pressed down on the receiver's header
+ * widget. Start a column resize operation if apropriate.
+ * @param event - the mouse event that occured over the header
+ * widget
+ */
+void headerMouseDown(Event event) {
+ TableColumn column = getColumnAtX(event.x);
+
+ if (isColumnResize(event) == true) {
+ startColumnResize(event);
+ }
+ else
+ if (column != null) {
+ column.notifyListeners(SWT.Selection, new Event());
+ }
+}
+/**
+ * The mouse pointer was moved over the receiver's header widget.
+ * If a column is currently being resized a vertical line indicating
+ * the new position of the resized column is drawn.
+ * Otherwise, if no column resize operation is in progress, the
+ * column resize cursor is displayed when the mouse is near the border
+ * of a column.
+ */
+void headerMouseMove(Event event) {
+ if (isColumnResizeStarted() == false) { // only check whether cursor is in resize
+ setColumnResizeCursor(isColumnResize(event)); // area if no resize operation is in progress
+ }
+ else
+ if (event.x >= getResizeColumn().getBounds().x) {
+ drawColumnResizeLine(event.x);
+ update(); // looks better if resize line is drawn immediately
+ }
+}
+/**
+ * Answer the index of 'column' in the receiver or -1 if 'column'
+ * does not exist in the receiver.
+ */
+public int indexOf(TableColumn column) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (column == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return internalGetColumnVector().indexOf(column);
+}
+/**
+ * Answer the index of 'item' in the receiver or -1 if 'item'
+ * does not exist in the receiver.
+ */
+public int indexOf(TableItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return getIndex(item);
+}
+/**
+ * Initialize the receiver. Create a header widget and an empty column.
+ */
+void initialize() {
+ columns = new Vector();
+ setItemVector(new Vector());
+ focusProxy = new Button(this, SWT.NULL);
+ focusProxy.setBounds(0, 0, 0, 0); // make the focus proxy invisible
+ tableHeader = new Header(this);
+ tableHeader.setVisible(false); // SWT table header is invisible by default, too
+ fillColumn = TableColumn.createFillColumn(this);
+ setColumnPosition(fillColumn);
+ defaultColumn = TableColumn.createDefaultColumn(this); // Create the default column. Fix for 1FUSJY5
+ super.initialize();
+}
+/**
+ * Insert the new column 'column' into the table data at position
+ * 'index'.
+ */
+void insertColumnData(TableColumn column) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.insertColumn(column);
+ }
+}
+/**
+ * Insert the new column 'column'.
+ * Set the position and move the following columns to the right.
+ */
+void insertColumnVisual(TableColumn column) {
+ Rectangle columnBounds = column.getBounds();
+ Rectangle previousColumnBounds;
+ int index = column.getIndex();
+
+ if (index > 0) {
+ previousColumnBounds = getColumn(index - 1).getBounds();
+ columnBounds.x = previousColumnBounds.x + previousColumnBounds.width;
+ }
+ else {
+ columnBounds.x = 0;
+ }
+ column.setBounds(columnBounds);
+ setColumnPosition(column);
+}
+/**
+ * Set event listeners for the receiver.
+ */
+void installListeners() {
+ Header tableHeader = getHeader();
+ Control focusWindow = getFocusWindow();
+ Listener listener = getListener();
+
+ super.installListeners();
+ tableHeader.addListener(SWT.MouseMove, listener);
+ tableHeader.addListener(SWT.MouseDown, listener);
+ tableHeader.addListener(SWT.MouseUp, listener);
+
+ // HACK: All we're really interested in is focus change and key down
+ // for the table itself. Doesn't work that way because setFocus sets
+ // focus to the first child of the receiver (which is our focus window)
+ removeListener(SWT.FocusOut, listener);
+ removeListener(SWT.FocusIn, listener);
+ focusWindow.addListener(SWT.FocusOut, listener);
+ focusWindow.addListener(SWT.FocusIn, listener);
+ focusWindow.addListener(SWT.KeyDown, listener);
+
+ addListener(SWT.MouseMove, listener);
+ addListener(SWT.MouseDown, listener);
+ addListener(SWT.MouseDoubleClick, listener);
+ addListener(SWT.MouseUp, listener);
+ addListener(SWT.Paint, listener);
+}
+/**
+ * Answer the TableColumn at 'index'.
+ * If the user has not created any columns the default column is
+ * returned if index is 0.
+ * Fix for 1FUSJY5
+ */
+TableColumn internalGetColumn(int index) {
+ Vector columns = internalGetColumnVector();
+
+ if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);
+ if (index < 0 || index >= columns.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ return (TableColumn) columns.elementAt(index);
+
+}
+/**
+ * Answer the number of columns in the receiver.
+ * If the user has not created any columns, 1 is returned since there
+ * always is a default column.
+ * Fix for 1FUSJY5
+ */
+int internalGetColumnCount() {
+ Vector columns = internalGetColumnVector();
+ int count = 0;
+
+ if (columns != null) {
+ count = columns.size();
+ }
+ return count;
+}
+/**
+ * Return a Vector containing all columns of the receiver except
+ * the fill column to the right of all content columns.
+ * Return a Vector containing the default column if the user has
+ * not created any columns.
+ * Fix for 1FUSJY5
+ */
+Vector internalGetColumnVector() {
+ Vector internalColumnVector;
+ TableColumn defaultColumn;
+
+ if (columns.isEmpty() == false) {
+ internalColumnVector = columns;
+ }
+ else {
+ internalColumnVector = new Vector(1);
+ defaultColumn = getDefaultColumn();
+ if (defaultColumn != null) {
+ internalColumnVector.addElement(defaultColumn);
+ }
+ }
+ return internalColumnVector;
+}
+/**
+ * Answer whether the mouse pointer is at a position that can
+ * start a column resize operation. A column resize can be
+ * started if the mouse pointer is at either the left or right
+ * border of a column.
+ * @param event - mouse event specifying the location of the
+ * mouse pointer.
+ */
+boolean isColumnResize(Event event) {
+ TableColumn hotColumn = getColumnAtX(event.x);
+ Rectangle bounds = hotColumn.getBounds();
+ int hotColumnIndex = hotColumn.getIndex();
+ int columnX = event.x - bounds.x;
+ boolean isColumnResize = false;
+
+ if (columnX <= COLUMN_RESIZE_OFFSET && // mouse over left side of column? and
+ hotColumnIndex != TableColumn.FIRST) { // it's not the first column)
+ if (hotColumnIndex == TableColumn.FILL) {
+ hotColumn = (TableColumn) internalGetColumnVector().lastElement();
+ }
+ else {
+ hotColumn = internalGetColumn(hotColumnIndex - 1);
+ }
+ isColumnResize = hotColumn.getResizable(); // check whether left column can be resized
+ }
+ else
+ if (columnX >= bounds.width - COLUMN_RESIZE_OFFSET && // mouse over right side of column and
+ hotColumn != getFillColumn()) { // column is a real one (not the right hand fill column)?
+ isColumnResize = hotColumn.getResizable(); // check whether column under cursor can be resized
+ }
+ return isColumnResize;
+}
+/**
+ * Answer whether a column of the receiver is being resized.
+ */
+boolean isColumnResizeStarted() {
+ return (getResizeColumn() != null);
+}
+/**
+ * Answer whether the item identified by 'index' is selected.
+ * @return
+ * true=item identified by 'index' is selected
+ * false=item identified by 'index' is not selected.
+ */
+public boolean isSelected(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TableItem item = getItem(index);
+
+ return (item != null && item.isSelected() == true);
+}
+/**
+ * 'changedItem' has changed. Update the default column width.
+ * @param changedItem - the item that has changed
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ // call super.itemChanged first to make sure that table image size is
+ // calculated if necessary. Fixes 1FYPBBG.
+ super.itemChanged(changedItem, repaintStartX, repaintWidth);
+ // remember if any item ever had an image in the first column.
+ if (firstColumnImage == false && changedItem.getImage() != null) {
+ firstColumnImage = true;
+ }
+ setFirstColumnWidth((TableItem) changedItem);
+}
+/**
+ * A mouse button was released.
+ * Update the display if a column has been resized.
+ * @param event - the mouse event for the button up action
+ */
+void mouseUp(Event event) {
+ TableColumn resizeColumn = getResizeColumn();
+ Rectangle oldColumnBounds;
+ int resizeXPosition;
+ int widthChange;
+
+ if (isColumnResizeStarted() == true) {
+ oldColumnBounds = resizeColumn.getBounds();
+ resizeXPosition = getColumnResizeX();
+ widthChange = resizeXPosition - (oldColumnBounds.x + oldColumnBounds.width);
+ if (widthChange != 0) {
+ if (widthChange > 0) {
+ redraw(resizeXPosition, 0, 1, getClientArea().height, false); // remove resize line
+ update(); // to avoid cheese caused by scrolling the resize line
+ }
+ resizeColumn.setWidth(oldColumnBounds.width + widthChange);
+ }
+ setResizeColumn(null);
+ }
+}
+/**
+ * Adjust the position of all columns starting at 'startIndex'.
+ * @param startIndex - index at which the column move should begin
+ * If this is the index of the fill column all columns are moved,
+ * including the fill column
+ * @param moveDistance - distance that the columns should be moved.
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void moveColumns(int startIndex, int moveDistance) {
+ Vector columns = internalGetColumnVector();
+ TableColumn moveColumn;
+ Rectangle columnBounds;
+
+ if (startIndex == TableColumn.FILL) {
+ moveColumn = getFillColumn();
+ columnBounds = moveColumn.getBounds();
+ columnBounds.x += moveDistance;
+ moveColumn.setBounds(columnBounds);
+ startIndex = 0; // continue with first data column
+ }
+ for (int i = startIndex; i < columns.size(); i++) {
+ moveColumn = (TableColumn) columns.elementAt(i);
+ columnBounds = moveColumn.getBounds();
+ columnBounds.x += moveDistance;
+ moveColumn.setBounds(columnBounds);
+ }
+}
+/**
+ * Adjust the y position of all columns including the fill column.
+ */
+void moveColumnsVertical() {
+ Enumeration columns = internalGetColumnVector().elements();
+ TableColumn column;
+
+ setColumnPosition(getFillColumn());
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ setColumnPosition(column);
+ }
+}
+/**
+ * A paint event has occurred. Paint the invalidated items.
+ * @param event - paint event specifying the invalidated area.
+ */
+void paint(Event event) {
+ int visibleRange[];
+ int headerHeight = getHeaderHeight();
+ Vector paintColumns = getPaintColumns(event.getBounds());
+ TableItem focusItem = null;
+
+ if (paintColumns.size() > 0) {
+ event.y -= headerHeight;
+ visibleRange = getIndexRange(event.getBounds());
+ event.y += headerHeight;
+ // When the top index is > 0 and the receiver is resized
+ // higher so that the top index becomes 0 the invalidated
+ // rectangle doesn't start below the header widget but at
+ // y position 0. Subtraction of the header height (it is
+ // not above the receiver but on top) causes event.y and
+ // subsequently visibleRange[0] to be negative.
+ // Hack to prevent visibleRange[0] from becoming negative.
+ // Need to find out why the invalidated area starts at 0
+ // in the first place.
+ if (visibleRange[0] < 0) {
+ visibleRange[0] = 0;
+ }
+ //
+ visibleRange[1] = Math.min(visibleRange[1], getItemCount()-1-getTopIndex());
+ focusItem = paintItems(event, visibleRange[0], visibleRange[1], paintColumns);
+ }
+ if (getLinesVisible() == true) {
+ drawGridLines(event, paintColumns.elements());
+ }
+ if (focusItem != null) {
+ // draw focus on top of drawing grid lines so that focus rectangle
+ // is not obscured by grid. Fixes 1G5X20B
+ drawSelectionFocus(focusItem, event.gc);
+ }
+}
+
+/**
+ * Paint items of the receiver starting at index 'topPaintIndex' and
+ * ending at 'bottomPaintIndex'.
+ * @param event - holds the GC to draw on and the clipping rectangle
+ * @param topPaintIndex - index of the first item to draw
+ * @param bottomPaintIndex - index of the last item to draw
+ * @param paintColumns - the table columns that should be painted
+ * @return the item that has focus if it was among the rendered items.
+ * null if the focus item was not rendered or if no item has focus (ie.
+ * because the widget does not have focus)
+ */
+TableItem paintItems(Event event, int topPaintIndex, int bottomPaintIndex, Vector paintColumns) {
+ Enumeration columns;
+ TableColumn column;
+ TableItem paintItem;
+ TableItem focusItem = null;
+ Point selectionExtent;
+ Point selectionPosition;
+ int itemHeight = getItemHeight();
+
+ topPaintIndex += getTopIndex();
+ bottomPaintIndex += getTopIndex();
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ paintItem = (TableItem) getVisibleItem(i);
+ selectionExtent = paintItem.getSelectionExtent();
+ if (selectionExtent != null) {
+ selectionPosition = new Point(paintItem.getSelectionX(), getRedrawY(paintItem));
+ drawSelection(paintItem, event.gc, selectionPosition, selectionExtent);
+ }
+ columns = paintColumns.elements();
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ paintSubItem(event, paintItem, column, i * itemHeight);
+ }
+ if (hasFocus(paintItem)) {
+ focusItem = paintItem;
+ }
+ }
+ return focusItem;
+}
+
+/**
+ * Paint the table item 'paintItem' in 'column' at y position
+ * 'paintYPosition' of the receiver.
+ * @param event - holds the GC to draw on and the clipping
+ * rectangle.
+ * @param paintItem - the item to draw
+ * @param column - column to draw 'paintItem' in
+ * @param paintYPosition - y position in the receiver to draw
+ * 'paintItem' at.
+ */
+void paintSubItem(Event event, TableItem paintItem, TableColumn column, int paintYPosition) {
+ Rectangle columnBounds = column.getBounds();
+ int gridLineWidth = getGridLineWidth();
+ int itemDrawStopX = columnBounds.x + columnBounds.width - gridLineWidth;
+ int clipX;
+
+ if (event.x + event.width > itemDrawStopX) { // does the invalidated area stretch past the current column's right border?
+ clipX = Math.max(columnBounds.x, event.x);
+ event.gc.setClipping( // clip the drawing area
+ clipX, event.y,
+ itemDrawStopX - clipX, event.height);
+ }
+ column.paint(paintItem, event.gc, paintYPosition);
+ if (event.x + event.width > itemDrawStopX) {
+ event.gc.setClipping(event.x, event.y, event.width, event.height); // restore original clip rectangle
+ }
+}
+/**
+ * Reindex all columns starting at 'startIndex'.
+ * Reindexing is necessary when a new column has been inserted.
+ */
+void reindexColumns(int startIndex) {
+ Vector columns = getColumnVector();
+ TableColumn column;
+
+ for (int i = startIndex; i < getColumnCount(); i++) {
+ column = (TableColumn) columns.elementAt(i);
+ column.setIndex(i);
+ }
+}
+/**
+ * Remove the items identified by the indices stored in
+ * 'indices' from the receiver.
+ * @param indices - indices of the items to dispose
+ */
+public void remove(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+ int [] sortedIndices;
+ int last = -1;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ sortedIndices = new int[indices.length];
+ System.arraycopy (indices, 0, sortedIndices, 0, indices.length);
+ sort(sortedIndices); // sort indices in descending order
+ for (int i = 0; i < sortedIndices.length; i++) {
+ if (sortedIndices[i] != last) {
+ item = getVisibleItem(sortedIndices[i]);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ last = sortedIndices[i];
+ }
+ }
+}
+/**
+ * Remove the item identified by 'index'.
+ * @param index - index of the item to dispose
+ */
+public void remove(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+}
+/**
+ * Remove a range of items starting at index 'start' and
+ * stopping at index 'end'.
+ * This operation will fail when the index is out of range
+ * Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void remove(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ }
+}
+/**
+ * Remove all items of the receiver.
+ */
+public void removeAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector items = getItemVector();
+
+ setRedraw(false);
+ setRemovingAll(true);
+ for (int i = 0; i < items.size(); i++) {
+ ((TableItem) items.elementAt(i)).dispose();
+ }
+ setItemVector(new Vector());
+ reset();
+ calculateVerticalScrollbar();
+ setRemovingAll(false);
+ setRedraw(true);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ TableColumn lastColumn;
+ int index = column.getIndex();
+ int columnWidth = column.getWidth();
+ int columnCount;
+
+ if (isRemovingAll() == true) {
+ getColumnVector().removeElementAt(index);
+ }
+ else {
+ getColumnVector().removeElementAt(index);
+ columnCount = getColumnCount();
+ // Never remove the data of the last user created column.
+ // SWT for Windows does the same.
+ if (columnCount > 0) {
+ removeColumnData(column);
+ }
+ removeColumnVisual(column);
+ if (index < columnCount) { // is there a column after the removed one?
+ reindexColumns(index);
+ }
+ // last user created column is about to be removed.
+ if (columnCount == 0) {
+ TableColumn defaultColumn = getDefaultColumn();
+ defaultColumn.pack(); // make sure the default column has the right size...
+ setColumnPosition(defaultColumn); // ...and is at the right position
+ }
+ // Fixes for 1G1L0UT
+ // Reduce the content width by the width of the removed column
+ setContentWidth(getContentWidth() - columnWidth);
+ // claim free space
+ claimRightFreeSpace();
+ //
+ }
+}
+/**
+ * Remove the column 'column' from the table data.
+ */
+void removeColumnData(TableColumn column) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.removeColumn(column);
+ }
+}
+/**
+ * Remove the column 'column'.
+ * Set the position of the following columns.
+ */
+void removeColumnVisual(TableColumn column) {
+ int columnWidth = column.getWidth();
+
+ // move following columns to the left
+ moveColumns(column.getIndex() + 1, columnWidth * -1);
+ redraw();
+ getHeader().redraw();
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - item that should be removed from the receiver
+ */
+void removeItem(TableItem item) {
+ Vector items = getItemVector();
+ int index = items.indexOf(item);
+
+ if (index != -1) {
+ if (isRemovingAll() == false) {
+ removingItem(item);
+ }
+ items.removeElementAt(index);
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() - 1);
+ }
+ if (isRemovingAll() == false) {
+ removedItem(item);
+ }
+ }
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+ * Reset cached data of column at 'columnIndex' for the items of the receiver.
+ * @param columnIndex - index of the column for which the item data should be
+ * reset.
+ */
+void resetTableItems(int columnIndex) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.reset(columnIndex);
+ }
+}
+/**
+ * The receiver has been resized. Resize the fill column
+ * and the header widget.
+ */
+void resize(Event event) {
+ TableColumn fillColumn = getFillColumn();
+ Rectangle fillColumnBounds;
+
+ super.resize(event);
+ // the x position may change in super.resize.
+ // get the column bounds after calling super.resize. Fixes 1G7ALGG
+ fillColumnBounds = fillColumn.getBounds();
+ fillColumnBounds.width = Math.max(0, getClientArea().width - getContentWidth());
+ fillColumn.setBounds(fillColumnBounds);
+ resizeHeader();
+}
+/**
+ * Resize the header widget to occupy the whole width of the
+ * receiver.
+ */
+void resizeHeader() {
+ Header tableHeader = getHeader();
+ Point size = tableHeader.getSize();
+
+ size.x = Math.max(getContentWidth(), getClientArea().width);
+ tableHeader.setSize(size);
+}
+/**
+ * Redraw 'column' after its width has been changed.
+ * @param column - column whose width has changed.
+ * @param oldColumnWidth - column width before resize
+ * @param oldColumnWidth - column width after resize
+ */
+void resizeRedraw(TableColumn column, int oldColumnWidth, int newColumnWidth) {
+ Rectangle columnBounds = column.getBounds();
+ int columnIndex = column.getIndex();
+ int oldRedrawStartX[] = getResizeRedrawX(columnIndex, oldColumnWidth);
+ int newRedrawStartX[] = getResizeRedrawX(columnIndex, newColumnWidth);
+ int itemHeight = getItemHeight();
+ int widthChange = newColumnWidth - oldColumnWidth;
+ int topIndex = getTopIndex();
+
+ for (int i = 0; i < newRedrawStartX.length; i++) {
+ if (newRedrawStartX[i] != oldRedrawStartX[i]) {
+ if (widthChange > 0) {
+ newRedrawStartX[i] = oldRedrawStartX[i];
+ }
+ redraw(
+ columnBounds.x + newRedrawStartX[i], columnBounds.y + itemHeight * (i + topIndex),
+ columnBounds.width - newRedrawStartX[i], itemHeight, false);
+ }
+ }
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void scrollHorizontal(int numPixel) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ getHeader().scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ moveColumns(TableColumn.FILL, numPixel);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+void scrollVertical(int scrollIndexCount) {
+ int scrollAmount = scrollIndexCount * getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int destY;
+ int sourceY;
+ boolean scrollUp = scrollIndexCount < 0;
+ Rectangle clientArea = getClientArea();
+
+ if (scrollIndexCount == 0) {
+ return;
+ }
+ if (scrollUp == true) {
+ destY = headerHeight - scrollAmount;
+ sourceY = headerHeight;
+ }
+ else {
+ destY = headerHeight;
+ sourceY = destY + scrollAmount;
+ }
+ scroll(
+ 0, destY, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll items down to make space for a new item added to
+ * the receiver at position 'index'.
+ * @param index - position at which space for one new item
+ * should be made. This index is relative to the first item
+ * of the receiver.
+ */
+void scrollVerticalAddingItem(int index) {
+ int itemHeight = getItemHeight();
+ int sourceY = getHeaderHeight();
+ Rectangle clientArea = getClientArea();
+
+ if (index >= getTopIndex()) {
+ sourceY += (index-getTopIndex()) * itemHeight;
+ }
+ scroll(
+ 0, sourceY + itemHeight, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll the items below the item at position 'index' up
+ * so that they cover the removed item.
+ * @param index - index of the removed item
+ */
+void scrollVerticalRemovedItem(int index) {
+ int itemHeight = getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int destY;
+ Rectangle clientArea = getClientArea();
+
+ destY = Math.max(headerHeight, headerHeight + (index - getTopIndex()) * itemHeight);
+ scroll(
+ 0, destY, // destination x, y
+ 0, destY + itemHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select the items identified by the indices stored in
+ * 'indices'.
+ * A SWT.Selection event will not be sent.
+ * @param indices - indices of the items to select
+ */
+public void select(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+ int selectionCount;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ selectionCount = indices.length;
+ if (isMultiSelect() == false && selectionCount > 1) {
+ selectionCount = 1;
+ deselectAllExcept(getVisibleItem(indices[0]));
+ }
+ for (int i = selectionCount - 1; i >= 0; --i) {
+ item = getVisibleItem(indices[i]);
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select the item identified by 'index'.
+ * A SWT.Selection event will not be sent.
+ * @param index - index of the item to select
+ */
+public void select(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (isMultiSelect() == false) {
+ deselectAllExcept(getVisibleItem(index));
+ }
+ if (item != null) {
+ select(item);
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select a range of items starting at index 'start' and
+ * stopping at index 'end'. Indices that are out of range
+ * are ignored. Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void select(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+ int selectionCount = 1;
+
+ if (isMultiSelect() == false) {
+ if (start < 0 && end >= 0) {
+ start = 0;
+ }
+ end = start;
+ deselectAllExcept(getVisibleItem(end));
+ }
+ // select in the same order as all the other selection and deslection methods.
+ // Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated
+ // selections of the items, causing flash.
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select all items of the receiver if it is in multiple
+ * selection mode.
+ * A SWT.Selection event will not be sent.
+ * Do nothing if the receiver is in single selection mode.
+ */
+public void selectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Enumeration items = getItemVector().elements();
+ TableItem item = null;
+
+ if (isMultiSelect() == false) {
+ return;
+ }
+ while (items.hasMoreElements() == true) {
+ item = (TableItem) items.nextElement();
+ select(item);
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Set the y position of 'column'.
+ * @param column - the TableColumn that should be set to
+ * a new y position.
+ */
+void setColumnPosition(TableColumn column) {
+ Rectangle bounds = column.getBounds();
+
+ bounds.y = getHeaderHeight() - getTopIndex() * getItemHeight();
+ column.setBounds(bounds);
+}
+/**
+ * Change the cursor of the receiver.
+ * @param isColumnResizeCursor - indicates whether the column
+ * resize cursor or the regular cursor should be set.
+ */
+void setColumnResizeCursor(boolean isColumnResizeCursor) {
+ if (isColumnResizeCursor != this.isColumnResizeCursor) {
+ this.isColumnResizeCursor = isColumnResizeCursor;
+ if (isColumnResizeCursor == true) {
+ setCursor(getColumnResizeCursor());
+ }
+ else {
+ setCursor(null);
+ }
+ }
+}
+/**
+ * Set the current position of the resized column to 'xPosition'.
+ * @param xPosition - the current position of the resized column
+ */
+void setColumnResizeX(int xPosition) {
+ columnResizeX = xPosition;
+}
+/**
+ * Set the width of the receiver's contents to 'newWidth'.
+ * Content width is used to calculate the horizontal scrollbar.
+ */
+void setContentWidth(int newWidth) {
+ TableColumn fillColumn = getFillColumn();
+ Rectangle fillColumnBounds;
+ int widthDiff = newWidth - getContentWidth();
+
+ super.setContentWidth(newWidth);
+ if (fillColumn != null) {
+ fillColumnBounds = fillColumn.getBounds();
+ fillColumnBounds.x += widthDiff;
+ fillColumnBounds.width = Math.max(0, getClientArea().width - newWidth);
+ fillColumn.setBounds(fillColumnBounds);
+ }
+}
+/**
+ * Set the width of the first column to fit 'item' if it is longer than
+ * the current column width.
+ * Do nothing if the user has already set a width.
+ */
+void setFirstColumnWidth(TableItem item) {
+ int newWidth;
+ TableColumn column;
+
+ if (internalGetColumnCount() > 0) {
+ column = internalGetColumn(TableColumn.FIRST);
+ if (column.isDefaultWidth() == true) {
+ newWidth = Math.max(column.getWidth(), item.getPreferredWidth(TableColumn.FIRST));
+ column.setWidth(newWidth);
+ column.setDefaultWidth(true); // reset to true so that we know when the user has set
+ // the width instead of us setting a default width.
+ }
+ }
+}
+/**
+ * The font is changing. Trigger a recalculation of the item
+ * height using all items of the receiver.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+ int itemCount = getItemCount();
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+ for (int i = 0; i < itemCount; i++) {
+ itemChanged(getItem(i), 0, getClientArea().width);
+ }
+ setRedraw(true); // re-enable redraw
+ getHeader().setFont(font);
+}
+/**
+ * Set whether or not the header is visible.
+ * @param headerVisible -
+ * true = header is visible. false = header is not visible
+ */
+public void setHeaderVisible(boolean headerVisible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (headerVisible != getHeaderVisible()) {
+ getHeader().setLocation(0, 0);
+ getHeader().setVisible(headerVisible);
+ // Windows resets scrolling so do we
+ setTopIndex(0, true);
+ moveColumnsVertical();
+ resizeVerticalScrollbar();
+ redraw();
+ }
+}
+/**
+ * Set the vector that stores the items of the receiver
+ * to 'newVector'.
+ * @param newVector - Vector to use for storing the items of
+ * the receiver.
+ */
+void setItemVector(Vector newVector) {
+ items = newVector;
+}
+/**
+ * Set whether the receiver is drawing grid lines to
+ * 'drawGridLines'.
+ * @param drawGridLines -
+ * true = receiver draws grid lines
+ * false = receiver does not draw grid lines
+ */
+public void setLinesVisible(boolean drawGridLines) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (this.drawGridLines != drawGridLines) {
+ this.drawGridLines = drawGridLines;
+ redraw();
+ }
+}
+/**
+ * Set whether the receiver and it's children should be
+ * drawn or not.
+ * @param redraw -
+ * true = redraw the receiver and its children
+ * false = do not draw the receiver or its children
+ */
+public void setRedraw(boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setRedraw(redraw);
+ getHeader().setRedraw(redraw);
+}
+/**
+ * Set the column that is being resized to 'column'.
+ * @param column - the TableColumn that is being resized.
+ * A null value indicates that no column resize operation is
+ * in progress.
+ */
+void setResizeColumn(TableColumn column) {
+ resizeColumn = column;
+}
+/**
+* Sets the selection.
+* <p>
+* The previous selection is cleared
+* before new items are selected.
+*
+* @see Table#deselectAll()
+* @see Table#select(int [])
+*
+* @param indices the indices of the items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection(int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector keepSelected;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ keepSelected = new Vector(indices.length);
+ for (int i = 0; i < indices.length; i++) {
+ SelectableItem item = getVisibleItem(indices[i]);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(indices);
+}
+/**
+ * Select the items stored in 'items'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+public void setSelection(TableItem selectionItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * Set the selection to the item identified by 'index'.
+ * SWT.Selection events are not going to be sent.
+ * @param index - index of the item that should be selected
+ */
+public void setSelection(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ deselectAllExcept(getVisibleItem(index));
+ select(index);
+}
+/**
+ * Set the selection to a range of items starting at index
+ * 'start' and stopping at index 'end'. Indices that are out
+ * of range are ignored. Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void setSelection(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector keepSelected = new Vector(end - start + 1);
+
+ for (int i = start; i <= end; i++) {
+ SelectableItem item = getVisibleItem(i);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(start, end);
+}
+/**
+ * Scroll the item at position 'index' to the top of the receiver.
+ * If the scroll operation would result in empty space being
+ * displayed below the last item of the receiver, the last item is
+ * scrolled into view. This results in the specified item not being
+ * displayed at the top of the receiver but after the top item.
+ * @param index - 0-based index of the item that should be
+ * displayed at the top of the receiver's client area.
+ */
+public void setTopIndex(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemCount = getItemCount();
+ int itemCountWhole = getItemCountWhole();
+
+ if (index < 0 || itemCount == 0) {
+ return;
+ }
+ if (index >= itemCount) {
+ index = itemCount - itemCountWhole;
+ }
+ super.setTopIndex(index, true);
+}
+/**
+ * Set the index of the first visible item in the receiver's client
+ * area to 'index'.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
+ super.setTopIndexNoScroll(index, adjustScrollbar);
+ moveColumnsVertical();
+}
+/**
+ * Make 'item' visible by scrolling it into the receiver's
+ * client area if necessary.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+public void showItem(TableItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ showSelectableItem(item);
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.showSelection();
+}
+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;
+ }
+ }
+ }
+ }
+}
+/**
+ * Start a column resize operation.
+ * @param event - the mouse event that occured over the header
+ * widget
+ */
+void startColumnResize(Event event) {
+ Vector columns = internalGetColumnVector();
+ TableColumn hitColumn = getColumnAtX(event.x);
+ Rectangle hitColumnBounds;
+ int hitIndex = hitColumn.getIndex();
+
+ if (hitColumn == getFillColumn()) { // clicked on the fill column?
+ hitColumn = (TableColumn) columns.lastElement(); // resize the last real column
+ }
+ else
+ if ((event.x - hitColumn.getBounds().x <= COLUMN_RESIZE_OFFSET) && // check if left side of a column was clicked
+ (hitIndex > 0)) {
+ hitColumn = (TableColumn) columns.elementAt(hitIndex - 1); // resize the preceding column
+ }
+ hitColumnBounds = hitColumn.getBounds();
+ setColumnResizeX(hitColumnBounds.x + hitColumnBounds.width);
+ setResizeColumn(hitColumn);
+}
+/**
+ * Return 'text' after it has been checked to be no longer than 'maxWidth'
+ * when drawn on 'gc'.
+ * If it is too long it will be truncated up to the last character.
+ * @param text - the String that should be checked for length
+ * @param maxWidth - maximum width of 'text'
+ * @param gc - GC to use for String measurement
+ */
+String trimItemText(String text, int maxWidth, GC gc) {
+ int textWidth;
+ int dotsWidth;
+
+ if (text != null && text.length() > 1) {
+ textWidth = gc.stringExtent(text).x;
+ if (textWidth >= maxWidth) {
+ dotsWidth = getDotsWidth(gc);
+ while (textWidth + dotsWidth >= maxWidth && text.length() > 1) {
+ text = text.substring(0, text.length() - 1); // chop off one character at the end
+ textWidth = gc.stringExtent(text).x;
+ }
+ text = text.concat(Table.DOT_STRING);
+ }
+ }
+ return text;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java
new file mode 100755
index 0000000000..55c9ba604c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableColumn.java
@@ -0,0 +1,461 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * A TableColumn stores such data as column label, label alignmentand size.
+ * It routes paint requests to the corresponding table item.
+ */
+public /*final*/ class TableColumn extends Item {
+ static final int FIRST = 0; // index of the first column
+ static final int FILL = -1; // index that identifies the column used to
+ // fill space not used by other columns.
+ private static final int DEFAULT_WIDTH = 10;
+
+ private Table parent;
+ private int index; // 0-based column index
+ private Rectangle bounds = new Rectangle(0, 0, 0, 0);
+ private boolean isDefaultWidth = true;
+ private boolean resize = true;
+/**
+ * Create a new TableColumn without adding it to the parent.
+ * Currently used to create fill columns and default columns.
+ * @see createFillColumn
+ * @see createDefaultColumn
+ * @param parent - Table widget the new instance will be a child of.
+ */
+TableColumn(Table parent) {
+ super(parent, SWT.NULL);
+ this.parent = parent;
+}
+/**
+ * Create a new instance of TableColumn and append it to the existing
+ * columns in 'parent'.
+ * @param parent - Table widget the new instance will be a child of.
+ * @param syle - style of the new TableColumn
+ */
+public TableColumn(Table parent, int style) {
+ this(parent, style, checkNull(parent).getColumnCount());
+}
+/**
+ * Create a new instance of TableColumn at position 'index' in the Table
+ * identified by 'parent'.
+ * @param parent - Table widget the new instance will be a child of.
+ * @param index - position in the 'parent' at which the new instance will
+ * be located relative to the other columns.
+ * @param syle - style of the new TableColumn
+ */
+public TableColumn(Table parent, int style, int index) {
+ super(parent, checkStyle (style), index);
+
+ this.parent = parent;
+ if (index < 0 || index > parent.getColumnCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ setIndex(index);
+ parent.addColumn(this);
+ setWidth(DEFAULT_WIDTH);
+ setDefaultWidth(true);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeColumn();}
+ });
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
+ */
+static Table checkNull(Table table) {
+ if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return table;
+}
+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);
+}
+/**
+ * Create a new instance of TableColumn that acts as a default column
+ * if the user does not create a TableColumn.
+ * @param parent - Table widget the new instance will be a child of.
+ */
+static TableColumn createDefaultColumn(Table parent) {
+ TableColumn defaultColumn = new TableColumn(parent);
+
+ defaultColumn.setIndex(FIRST);
+ defaultColumn.setWidth(DEFAULT_WIDTH);
+ defaultColumn.setDefaultWidth(true);
+ return defaultColumn;
+}
+/**
+ * Create a new instance of TableColumn that acts as the rightmost
+ * fill column in a Table. The new object is not added to the parent
+ * like a regular column is.
+ * @param parent - Table widget the new instance will be a child of.
+ */
+static TableColumn createFillColumn(Table parent) {
+ TableColumn fillColumn = new TableColumn(parent);
+
+ fillColumn.setIndex(FILL);
+ return fillColumn;
+}
+/**
+ * Remove the receiver from its parent
+ */
+void disposeColumn() {
+ getParent().removeColumn(this);
+}
+/**
+* Gets the alignment.
+* <p>
+* The alignment of a widget controls the position of the
+* text or image in the widget. The alignment may be one
+* of LEFT, RIGHT or CENTER.
+*
+* @return the alignment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+}
+
+/**
+ * Answer the bounding rectangle of the receiver.
+ */
+Rectangle getBounds() {
+ return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); // copy the object to prevent changes
+}
+/**
+ * Gets the Display.
+ */
+public Display getDisplay() {
+ if (parent == null) { // access parent field directly to prevent endless recursion
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return parent.getDisplay();
+}
+/**
+ * Answer the index of the receiver. Specifies the position of the
+ * receiver relative to other columns in the parent.
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Table getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return parent;
+}
+/**
+* Gets the resize attribute.
+* <p>
+* @return the resize attribute
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getResizable() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return resize;
+}
+/**
+* Gets the width.
+* <p>
+* @return the width
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getBounds().width;
+}
+/**
+ * Set the colun bounds.
+ */
+void internalSetBounds(Rectangle newBounds) {
+ bounds = newBounds;
+}
+/**
+ * Answer whether the column has a default width or if a width has been
+ * set by the user.
+ * @return
+ * true=column width is a default width set internally
+ * false=column width has been set by the user.
+ */
+boolean isDefaultWidth() {
+ return isDefaultWidth;
+}
+/**
+* Packs the widget.
+* <p>
+* Packing a widget causes it to be resized to the
+* preferred size for the widget.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void pack() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ int index = parent.indexOf(this);
+
+ if (getIndex() != TableColumn.FILL && index != -1) {
+ setWidth(parent.getPreferredColumnWidth(index));
+ }
+}
+/**
+ * Draw the 'item' at 'yPosition' in the receiver column.
+ * @param item - TableItem that should be drawn.
+ * @param gc - GC to draw on
+ * @param yPosition - y position to draw at in the column.
+ */
+void paint(TableItem item, GC gc, int yPosition) {
+ Rectangle bounds = getBounds();
+ Point paintPosition = new Point(bounds.x, bounds.y + yPosition);
+
+ item.paint(gc, paintPosition, this);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+* Sets the alignment.
+* <p>
+* The alignment of a widget controls the position of the
+* text or image in the widget. The alignement may be one
+* of LEFT, RIGHT or CENTER.
+*
+* @param alignment the new alignment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setAlignment(int alignment) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ int index = getIndex();
+
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) != 0 && index != 0) { // ignore calls for the first column to match Windows behavior
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ getParent().getHeader().redraw(index);
+ }
+}
+/**
+ * Set the bounding rectangle of the receiver to 'newBounds'.
+ * Notify the table widget if the column width changes.
+ * @param newBounds - the new bounding rectangle of the receiver,
+ * consisting of x, y, width, height
+ */
+void setBounds(Rectangle newBounds) {
+ if (newBounds.width != bounds.width) {
+ if (isDefaultWidth() == true) {
+ setDefaultWidth(false);
+ }
+ getParent().columnChange(this, newBounds);
+ }
+ else {
+ // columnChange causes update (via scroll) which may flush redraw
+ // based on old bounds. Setting bounds after notifying table fixes 1GABZR5
+ // Table sets column bounds at appropriate time when called above with
+ // width change. Only set bounds when table was not called. Fixes 1GCGDPB
+ bounds = newBounds;
+ }
+}
+/**
+ * Set whether the column has a default width or if a width has been
+ * set by the user.
+ * @param isDefaultWidth
+ * true=column width is a default width set internally
+ * false=column width has been set by the user
+ */
+void setDefaultWidth(boolean isDefaultWidth) {
+ this.isDefaultWidth = isDefaultWidth;
+}
+/**
+ * Set the index of the receiver to 'newIndex'. The index specifies the
+ * position of the receiver relative to other columns in the parent.
+ */
+void setIndex(int newIndex) {
+ this.index = newIndex;
+}
+/**
+* Sets the resize attribute.
+* <p>
+* @param resizee the resize attribute
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setResizable(boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ this.resize = resize;
+}
+/**
+ * Set the text of the receiver to 'text'.
+ */
+public void setText(String newText) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = getIndex();
+
+ if (newText == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (index != FILL && (text == null || text.equals(newText) == false)) {
+ super.setText(newText);
+ getParent().getHeader().redraw(index);
+ }
+}
+/**
+* Sets the width.
+* <p>
+* @param width the width
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setWidth(int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ Rectangle bounds = getBounds();
+ int oldWidth = bounds.width;
+ int redrawX;
+
+ if (width != oldWidth) {
+ redrawX = bounds.x;
+ bounds.width = width;
+ setBounds(bounds);
+ // redraw at old column position if column was resized wider.
+ // fixes focus rectangle.
+ redrawX += Math.min(width, oldWidth);
+ parent.redraw(
+ redrawX - 2, 0,
+ 2, parent.getClientArea().height, false); // redraw 2 pixels wide to redraw item focus rectangle and grid line
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java
new file mode 100755
index 0000000000..6919d84766
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TableItem.java
@@ -0,0 +1,1032 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * A table item is a selectable user interface object
+ * that represents an item in a table.
+ * Table items can consist of multiple columns called sub items.
+ */
+public /*final*/ class TableItem extends SelectableItem {
+ private static final int FIRST_COLUMN_IMAGE_INDENT = 2; // Space in front of image - first column only
+ private static final int FIRST_COLUMN_TEXT_INDENT = 4; // Space in front of text - first column only
+ private static final int TEXT_INDENT_NO_IMAGE = 2; // Space in front of item text when no item in the column has an image - first column only
+ private static final int TEXT_INDENT = 6; // Space in front of item text - all other columns
+ private static final int SELECTION_PADDING = 6; // Space behind text in a selected item
+
+ private Vector dataLabels = new Vector(); // Original text set by the user. Items that don't
+ // have a label are represented by a null slot
+ private String[] trimmedLabels = new String[0]; // Text that is actually displayed, may be trimmed
+ // to fit the column
+ private Vector images = new Vector(); // Item images. Items that don't have an image
+ // are represented by a null slot
+ private Point selectionExtent; // Size of the rectangle drawn to indicate a
+ // selected item.
+ private int imageIndent = 0; // the factor by which the item image and check box, if any,
+ // are indented. The multiplier is the image width.
+ private int index; // index of the item in the parent widget
+/**
+ * Create a table item in the table widget 'parent'. Append the new
+ * item to the existing items in 'parent'.
+ * @param parent - table widget the new item is added to.
+ * @param style - widget style. See Widget class for details
+ */
+public TableItem(Table parent, int style) {
+ this(parent, style, checkNull(parent).getItemCount());
+}
+/**
+ * Create a table item in the table widget 'parent'. Add the new
+ * item at position 'index' to the existing items in 'parent'.
+ * @param parent - table widget the new item is added to.
+ * @param style - widget style. See Widget class for details
+ * @param index - position the new item is inserted at in 'parent'
+ */
+public TableItem(Table parent, int style, int index) {
+ super(parent, style);
+ parent.addItem(this, index);
+}
+/**
+ * Calculate the size of the rectangle drawn to indicate a selected
+ * item. This is also used to draw the selection focus rectangle.
+ * The selection extent is calculated for the first column only (the
+ * only column the selection is drawn in).
+ */
+void calculateSelectionExtent() {
+ Table parent = getParent();
+ TableColumn column = parent.internalGetColumn(TableColumn.FIRST);
+ GC gc = new GC(parent);
+ String trimmedText = getText(gc, column);
+ int gridLineWidth = parent.getGridLineWidth();
+
+ if (trimmedText != null) {
+ selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight());
+ selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING;
+ selectionExtent.x = Math.min(
+ selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth);
+ if (parent.getLinesVisible() == true) {
+ selectionExtent.y -= gridLineWidth;
+ }
+ }
+ gc.dispose();
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
+ */
+static Table checkNull(Table table) {
+ if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return table;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * The receiver is destroyed. Remove it from its parent widget.
+ */
+void disposeItem() {
+ getParent().removeItem(this);
+ dataLabels = null;
+ trimmedLabels = null;
+ images = null;
+ selectionExtent = null;
+ super.disposeItem();
+}
+/**
+ * Draw the image of the receiver for column 'index' at
+ * 'destinationPosition' using 'gc'.
+ * Stretch/shrink the image to the fixed image size of the receiver's
+ * parent.
+ * @param gc - GC to draw on.
+ * @param destinationPosition - position on the GC to draw at.
+ * @param index - index of the image to draw
+ * @return Answer the position where drawing stopped.
+ */
+Point drawImage(GC gc, Point destinationPosition, int index) {
+ Table parent = getParent();
+ Image image = getImage(index);
+ Rectangle sourceImageBounds;
+ Point destinationImageExtent = parent.getImageExtent();
+
+ if (image != null) {
+ sourceImageBounds = image.getBounds();
+ // full row select would obscure transparent images in all but the first column
+ // so always clear the image area in this case. Fixes 1FYNITC
+ if ((parent.getStyle() & SWT.FULL_SELECTION) != 0 && index != TableColumn.FIRST) {
+ gc.fillRectangle(
+ destinationPosition.x, destinationPosition.y,
+ destinationImageExtent.x, destinationImageExtent.y);
+ }
+ gc.drawImage(
+ image, 0, 0, // source x, y
+ sourceImageBounds.width, sourceImageBounds.height, // source width, height
+ destinationPosition.x, destinationPosition.y, // destination x, y
+ destinationImageExtent.x, destinationImageExtent.y); // destination width, height
+ }
+ if (((index == TableColumn.FIRST && // always add the image width for the first column
+ parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
+ (index != TableColumn.FIRST && // add the image width if it's not the first column
+ image != null)) && // only when the item actually has an image
+ destinationImageExtent != null) {
+ destinationPosition.x += destinationImageExtent.x;
+ }
+ return destinationPosition;
+}
+/**
+ * Draw the label of the receiver for column 'index' at 'position'
+ * using 'gc'.
+ * The background color is set to the selection background color if
+ * the item is selected and the text is drawn for the first column.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @param index - specifies which subitem text to draw
+ */
+void drawText(String label, GC gc, Point position, int index) {
+ Table parent = getParent();
+ boolean drawSelection;
+ int textOffset;
+ int textHeight;
+
+ if (label != null) {
+ drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ }
+ textHeight = gc.stringExtent(label).y;
+ textOffset = (parent.getItemHeight() - textHeight) / 2; // vertically center the text
+ gc.drawString(label, position.x, position.y + textOffset);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setBackground(parent.getBackground());
+ gc.setForeground(parent.getForeground());
+ }
+ }
+}
+
+/**
+* Gets the item bounds at an index
+* <p>
+* @return the item bounds
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Rectangle getBounds(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle itemBounds;
+ Rectangle columnBounds;
+ Rectangle checkboxBounds;
+ Table parent = getParent();
+ TableColumn column;
+ int itemIndex = parent.indexOf(this);
+ int itemHeight = parent.getItemHeight();
+ int gridLineWidth = parent.getGridLineWidth();
+ int itemYPos;
+
+ if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) {
+ itemBounds = new Rectangle(0, 0, 0, 0);
+ }
+ else {
+ column = parent.internalGetColumn(index);
+ columnBounds = column.getBounds();
+ itemYPos = columnBounds.y + itemHeight * itemIndex;
+ itemBounds = new Rectangle(
+ columnBounds.x, itemYPos,
+ columnBounds.width - gridLineWidth, itemHeight - gridLineWidth);
+ if (index == TableColumn.FIRST) {
+ if (isCheckable() == true) {
+ checkboxBounds = getCheckboxBounds();
+ itemBounds.x += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING; // add checkbox start, width and space behind checkbox
+ itemBounds.width -= itemBounds.x;
+ }
+ else {
+ itemBounds.x += getImageIndentPixel();
+ }
+ }
+ }
+ return itemBounds;
+}
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getChecked();
+}
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return getImageIndentPixel();
+}
+/**
+ * Answer the item labels set by the user.
+ * These may not be the same as those drawn on the screen. The latter
+ * may be trimmed to fit the column. Items that don't have a label are
+ * represented by a null slot in the vector.
+ * @return Vector - the item labels set by the user.
+ */
+Vector getDataLabels() {
+ return dataLabels;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ return super.getDisplay();
+}
+/**
+ * Return the position at which the string starts that is used
+ * to indicate a truncated item text.
+ * @param columnIndex - index of the column for which the position of
+ * the truncation replacement should be calculated
+ * @param columnWidth - width of the column for which the position of
+ * the truncation replacement should be calculated
+ * @return -1 when the item text is not truncated
+ */
+int getDotStartX(int columnIndex, int columnWidth) {
+ GC gc;
+ Table parent = getParent();
+ String label = getText(columnIndex);
+ int dotStartX = -1;
+ int maxWidth;
+
+ if (label != null) {
+ gc = new GC(parent);
+ maxWidth = getMaxTextWidth(columnIndex, columnWidth);
+ label = parent.trimItemText(label, maxWidth, gc);
+ if (label.endsWith(Table.DOT_STRING) == true) {
+ dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);
+ // add indents, margins and image width
+ dotStartX += getImageStopX(columnIndex);
+ dotStartX += getTextIndent(columnIndex);
+ }
+ gc.dispose();
+ }
+ return dotStartX;
+}
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <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 boolean getGrayed() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getGrayed();
+}
+/**
+ * Answer the item image of the first column.
+ */
+public Image getImage() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getImage(0);
+}
+/**
+ * Answer the item image of the column identified by 'columnIndex' or
+ * null if no image has been set for that column.
+ * @param columnIndex - the column whose image should be answered
+ */
+public Image getImage(int columnIndex) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Image image = null;
+ Vector images = getImages();
+ int itemIndex = getParent().indexOf(this);
+
+ if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) {
+ image = (Image) images.elementAt(columnIndex);
+ }
+ return image;
+}
+/**
+* Gets the image bounds at an index
+* <p>
+* @return the item icon's bounds
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Rectangle getImageBounds(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ int itemIndex = parent.indexOf (this);
+ int imageWidth = 0;
+ Point imageExtent = parent.getImageExtent();
+ Rectangle checkboxBounds;
+ Rectangle imageBounds = getBounds(index);
+
+ if (itemIndex == -1) {
+ imageBounds = new Rectangle(0, 0, 0, 0);
+ }
+ else
+ if (imageExtent != null) {
+ if (index == TableColumn.FIRST || getImage(index) != null) {
+ imageWidth = imageExtent.x;
+ }
+ }
+ imageBounds.width = imageWidth;
+ return imageBounds;
+}
+/**
+* Gets the image indent.
+* <p>
+* @return the indent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getImageIndent() {
+ if (isValidThread() == false) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isValidWidget() == false) error(SWT.ERROR_WIDGET_DISPOSED);
+ int index = getParent().indexOf(this);
+
+ if (index == -1) {
+ return 0;
+ }
+ return imageIndent;
+}
+/**
+ * Answer the number of pixels the image in the first column is
+ * indented. Calculation starts at the column start and counts
+ * all pixels except the check box.
+ */
+int getImageIndentPixel() {
+ int indentPixel = FIRST_COLUMN_IMAGE_INDENT;
+ Point imageExtent = getParent().getImageExtent();
+
+ if (imageExtent != null) {
+ indentPixel += imageExtent.x * getImageIndent();
+ }
+ return indentPixel;
+}
+/**
+ * Answer the item images set by the user. Items that don't have an
+ * image are represented by a null slot in the vector.
+ */
+Vector getImages() {
+ return images;
+}
+/**
+ * Calculate the x coordinate where the item image of column
+ * 'columnIndex' stops.
+ * @param columnIndex - the column for which the stop position of the
+ * image should be calculated.
+ */
+int getImageStopX(int columnIndex) {
+ int imageStopX = 0;
+ Table parent = getParent();
+ Rectangle checkboxBounds;
+
+ if (columnIndex == TableColumn.FIRST) {
+ if (isCheckable() == true) {
+ checkboxBounds = getCheckboxBounds();
+ imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;
+ }
+ else {
+ imageStopX = getImageIndentPixel();
+ }
+ }
+ if (((columnIndex == TableColumn.FIRST && // always add the image width for the first column
+ parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
+ (columnIndex != TableColumn.FIRST && // add the image width if it's not the first column
+ getImage(columnIndex) != null)) && // only when the item actually has an image
+ parent.getImageExtent() != null) {
+ imageStopX += parent.getImageExtent().x;
+ }
+ return imageStopX;
+}
+/**
+ * Return the index of the item in its parent widget.
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Return the item extent in the specified column
+ * The extent includes the actual width of the item including checkbox,
+ * image and text.
+ */
+Point getItemExtent(TableColumn column) {
+ Table parent = getParent();
+ int columnIndex = column.getIndex();
+ Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth());
+ GC gc = new GC(parent);
+ String trimmedText = getText(gc, column);
+
+ if (trimmedText != null && trimmedText.length() > 0) {
+ extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex);
+ }
+ if (columnIndex == TableColumn.FIRST) {
+ extent.x += SELECTION_PADDING;
+ }
+ gc.dispose();
+ return extent;
+}
+/**
+ * Answer the maximum width in pixel of the text that fits in the
+ * column identified by 'columnIndex' without trimming the text.
+ * @param columnIndex - the column for which the maximum text width
+ * should be calculated.
+ * @param columnWidth - width of the column 'columnIndex'
+ */
+int getMaxTextWidth(int columnIndex, int columnWidth) {
+ int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;
+
+ return columnWidth - itemWidth;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Table getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return (Table) super.getSelectableParent();
+}
+/**
+ * Answer the width of the item required to display the complete contents.
+ */
+int getPreferredWidth(int index) {
+ int size = getImageStopX(index);
+ String text = getText(index);
+
+ if (text != null) {
+ size += getParent().getTextWidth(text) + getTextIndent(index) * 2 + 1;
+ }
+ return size;
+}
+/**
+ * Return the size of the rectangle drawn to indicate a selected item.
+ * This is also used to draw the selection focus rectangle and drop
+ * insert marker.
+ * Implements SelectableItem#getSelectionExtent
+ */
+Point getSelectionExtent() {
+ Table parent = getParent();
+ Point extent;
+
+ if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) { // regular, first column, selection?
+ if (selectionExtent == null) {
+ calculateSelectionExtent();
+ }
+ extent = selectionExtent;
+ }
+ else {
+ extent = parent.getFullSelectionExtent(this);
+ }
+ return extent;
+}
+/**
+ * Return the x position of the selection rectangle
+ * Implements SelectableItem#getSelectionX
+ */
+int getSelectionX() {
+ return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
+}
+/**
+ * Answer the item text of the first column.
+ */
+public String getText() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getText(0);
+}
+/**
+ * Answer the item tezt of the column identified by 'columnIndex'.
+ * Answer null if no text has been set for that column.
+ * @param columnIndex - the column whose text should be answered.
+ * null if no text has been set for that column.
+ */
+public String getText(int columnIndex) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemIndex = getParent().indexOf(this);
+ Vector labels = getDataLabels();
+ String label = null;
+
+ if (itemIndex == -1) {
+ error(SWT.ERROR_CANNOT_GET_TEXT);
+ }
+ if (columnIndex >= 0 && columnIndex < labels.size()) {
+ label = (String) labels.elementAt(columnIndex);
+ }
+ if (label == null) {
+ label = ""; // label vector is initialized with null instead of empty Strings
+ }
+ return label;
+}
+/**
+ * Answer the text that is going to be drawn in 'column'. This
+ * text may be a trimmed copy of the original text set by the
+ * user if it doesn't fit into the column. In that case the last
+ * characters are replaced with Table.DOT_STRING.
+ * A cached copy of the trimmed text is returned if available.
+ * @param gc - GC to use for measuring the text extent
+ * @param column - TableColumn for which the text should be returned
+ */
+String getText(GC gc, TableColumn column) {
+ int columnIndex = column.getIndex();
+ String label = getTrimmedText(columnIndex);
+ int maxWidth;
+
+ if (label == null) {
+ maxWidth = getMaxTextWidth(columnIndex, column.getWidth());
+ label = getParent().trimItemText(getText(columnIndex), maxWidth, gc);
+ }
+ return label;
+}
+/**
+ * Answer the indent of the text in column 'columnIndex' in pixel.
+ * This indent is used in front of and behind the item text.
+ * @param columnIndex - specifies the column for which the indent
+ * should be calculated.
+ */
+int getTextIndent(int columnIndex) {
+ int textIndent;
+
+ if (columnIndex == TableColumn.FIRST) {
+ if (getParent().hasFirstColumnImage() == false) {
+ textIndent = TEXT_INDENT_NO_IMAGE;
+ }
+ else {
+ textIndent = FIRST_COLUMN_TEXT_INDENT;
+ }
+ }
+ else {
+ textIndent = TEXT_INDENT;
+ }
+ return textIndent;
+}
+/**
+ * Answer the cached trimmed text for column 'columnIndex'.
+ * Answer null if it hasn't been calculated yet.
+ * @param columnIndex - specifies the column for which the
+ * trimmed text should be answered.
+ */
+String getTrimmedText(int columnIndex) {
+ String label = null;
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ label = labels[columnIndex];
+ }
+ return label;
+}
+/**
+ * Answer an array of cached trimmed labels.
+ */
+String [] getTrimmedTexts() {
+ return trimmedLabels;
+}
+/**
+ * Ensure that the image and label vectors have at least
+ * 'newSize' number of elements.
+ */
+void growVectors(int newSize) {
+ Vector images = getImages();
+ Vector labels = getDataLabels();
+
+ if (newSize > images.size()){
+ images.setSize(newSize);
+ }
+ if (newSize > labels.size()){
+ labels.setSize(newSize);
+ }
+}
+/**
+ * Insert 'column' into the receiver.
+ */
+void insertColumn(TableColumn column) {
+ Vector data = getDataLabels();
+ Vector images = getImages();
+ String stringData[];
+ Image imageData[];
+ int index = column.getIndex();
+
+ if (index < data.size()) {
+ data.insertElementAt(null, index);
+ }
+ else {
+ data.addElement(null);
+ }
+ stringData = new String[data.size()];
+ data.copyInto(stringData);
+ setText(stringData);
+
+ if (index < images.size()) {
+ images.insertElementAt(null, index);
+ }
+ else {
+ images.addElement(null);
+ }
+ imageData = new Image[images.size()];
+ images.copyInto(imageData);
+ setImage(imageData);
+}
+/**
+ * Sets the image at an index.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+void internalSetImage(int columnIndex, Image image) {
+ Vector images = getImages();
+ boolean imageWasNull = false;
+ Table parent = getParent();
+
+ if (columnIndex >= 0 &&
+ columnIndex < parent.internalGetColumnCount()) {
+ if (columnIndex >= images.size()) {
+ growVectors(columnIndex + 1);
+ }
+ if (((Image) images.elementAt(columnIndex)) == null && image != null) {
+ imageWasNull = true;
+ }
+ images.setElementAt(image, columnIndex);
+ reset(columnIndex); // new image may cause text to no longer fit in the column
+ notifyImageChanged(columnIndex, imageWasNull);
+ }
+}
+/**
+* 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
+*
+*/
+void internalSetText(int columnIndex, String string) {
+ Vector labels = getDataLabels();
+ Table parent = getParent();
+ String oldText;
+
+ if (columnIndex >= 0 &&
+ columnIndex < parent.internalGetColumnCount()) {
+ if (columnIndex >= labels.size()) {
+ growVectors(columnIndex + 1);
+ }
+ oldText = (String) labels.elementAt(columnIndex);
+ if (string.equals(oldText) == false) {
+ labels.setElementAt(string, columnIndex);
+ reset(columnIndex);
+ notifyTextChanged(columnIndex, oldText == null);
+ }
+ }
+}
+/**
+ * Answer whether the click at 'xPosition' on the receiver is a
+ * selection click.
+ * A selection click occurred when the click was behind the image
+ * and before the end of the item text.
+ * @return
+ * true - 'xPosition' is a selection click.
+ * false - otherwise
+ */
+boolean isSelectionHit(int xPosition) {
+ int itemStopX = getImageStopX(TableColumn.FIRST);
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent != null) {
+ itemStopX += selectionExtent.x;
+ }
+ return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX);
+}
+/**
+ * The image for the column identified by 'columnIndex' has changed.
+ * Notify the parent widget and supply redraw coordinates, if possible.
+ * @param columnIndex - index of the column that has a new image.
+ */
+void notifyImageChanged(int columnIndex, boolean imageWasNull) {
+ Table parent = getParent();
+ Rectangle changedColumnBounds;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ redrawStartX = Math.max(0, getImageBounds(columnIndex).x);
+ if (parent.getImageExtent() != null && imageWasNull == false) {
+ redrawWidth = getImageStopX(columnIndex);
+ }
+ else {
+ redrawWidth = changedColumnBounds.width;
+ }
+ redrawWidth += changedColumnBounds.x - redrawStartX;
+ }
+ parent.itemChanged(this, redrawStartX, redrawWidth);
+}
+
+/**
+ * The label for the column identified by 'columnIndex' has changed.
+ * Notify the parent widget and supply redraw coordinates, if possible.
+ * @param columnIndex - index of the column that has a new label.
+ */
+void notifyTextChanged(int columnIndex, boolean textWasNull) {
+ Table parent = getParent();
+ String text;
+ Rectangle columnBounds;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ text = (String) getDataLabels().elementAt(columnIndex);
+ columnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ redrawStartX = columnBounds.x;
+ if (getImage(columnIndex) != null) {
+ redrawStartX += getImageStopX(columnIndex);
+ }
+ redrawStartX = Math.max(0, redrawStartX);
+ // don't redraw if text changed from null to empty string
+ if (textWasNull == false || text.length() > 0) {
+ redrawWidth = columnBounds.x + columnBounds.width - redrawStartX;
+ }
+ }
+ parent.itemChanged(this, redrawStartX, redrawWidth);
+}
+/**
+ * Draw the receiver at 'paintPosition' in the column identified by
+ * 'columnIndex' using 'gc'.
+ * @param gc - GC to use for drawing
+ * @param paintPosition - position where the receiver should be drawing.
+ * @param column - the column to draw in
+ */
+void paint(GC gc, Point paintPosition, TableColumn column) {
+ int columnIndex = column.getIndex();
+ String label = getText(gc, column);
+ String oldLabel = getTrimmedText(columnIndex);
+
+ if (label != null && label.equals(oldLabel) == false) {
+ setTrimmedText(label, columnIndex);
+ selectionExtent = null; // force a recalculation next time the selection extent is needed
+ }
+ if (columnIndex == TableColumn.FIRST) {
+ paintPosition.x += getImageIndentPixel();
+ if (isCheckable() == true) {
+ paintPosition = drawCheckbox(gc, paintPosition);
+ }
+ }
+ paintPosition = drawImage(gc, paintPosition, columnIndex);
+ paintPosition.x += getTextIndent(columnIndex);
+ drawText(label, gc, paintPosition, columnIndex);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ Vector data = getDataLabels();
+ Vector images = getImages();
+ String stringData[];
+ Image imageData[];
+ int index = column.getIndex();
+
+ if (index < data.size()) {
+ data.removeElementAt(index);
+ stringData = new String[data.size()];
+ data.copyInto(stringData);
+ setText(stringData);
+ }
+ if (index < images.size()) {
+ images.removeElementAt(index);
+ imageData = new Image[images.size()];
+ images.copyInto(imageData);
+ setImage(imageData);
+ }
+}
+/**
+ * Reset the cached trimmed label for the sub item identified by
+ * 'index'.
+ * @param index - index of the label that should be reset.
+ */
+void reset(int index) {
+ String trimmedLabels[] = getTrimmedTexts();
+
+ if (index >= 0 && index < trimmedLabels.length) {
+ trimmedLabels[index] = null;
+ }
+ if (index == TableColumn.FIRST) {
+ selectionExtent = null;
+ }
+}
+/**
+* Warning: API under construction.
+*/
+public void setImage(Image [] images) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (images == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) == -1) {
+ return;
+ }
+ for (int i = 0; i < images.length; i++) {
+ internalSetImage(i, images[i]);
+ }
+}
+/**
+ * Sets the image at an index.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public void setImage(int columnIndex, Image image) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (getParent().indexOf(this) != -1) {
+ internalSetImage(columnIndex, image);
+ }
+}
+/**
+ * Set the item image of the first column to 'image'.
+ * @param image - the item image of the first column. Image
+ * will be removed if this is null.
+ */
+public void setImage(Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ setImage(0, image);
+}
+/**
+* Sets the image indent.
+* <p>
+* @param indent the new indent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setImageIndent(int indent) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ TableColumn column;
+ int index = parent.indexOf(this);
+
+ if (index != -1 && indent >= 0 && indent != imageIndent) {
+ imageIndent = indent;
+ column = parent.internalGetColumn(TableColumn.FIRST);
+ parent.redraw(
+ 0, parent.getRedrawY(this),
+ column.getWidth(), parent.getItemHeight(), false);
+ }
+}
+/**
+ * Warning: API under construction.
+ */
+public void setText(String [] strings) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (strings == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) == -1) {
+ return;
+ }
+ for (int i = 0; i < strings.length; i++) {
+ String string = strings[i];
+ if (string != null) {
+ internalSetText(i, string);
+ }
+ }
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (int columnIndex, String string) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (string == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) != -1) {
+ internalSetText(columnIndex, string);
+ }
+}
+/**
+ * Set the item text of the first column to 'text'.
+ * @param text - the item text of the first column. May be null if the
+ * text label should be removed.
+ */
+public void setText(String text) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (text == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setText(0, text);
+}
+/**
+ * Set the trimmed text of column 'columnIndex' to label. The trimmed
+ * text is the one that is displayed in a column. It may be shorter than
+ * the text originally set by the user via setText(...) to fit the
+ * column.
+ * @param label - the text label of column 'columnIndex'. May be trimmed
+ * to fit the column.
+ * @param columnIndex - specifies the column whose text label should be
+ * set.
+ */
+void setTrimmedText(String label, int columnIndex) {
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ labels[columnIndex] = label;
+ }
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setChecked(checked);
+}
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <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 setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setGrayed(grayed);
+}
+/**
+ * Set the index of this item in its parent widget to 'newIndex'.
+ */
+void setIndex(int newIndex) {
+ index = newIndex;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
new file mode 100755
index 0000000000..ccb7d4dd5f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java
@@ -0,0 +1,1261 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+* A Text is an editable user interface object that
+* displays a single line of text or multiple lines
+* of text.
+* <p>
+* <b>Styles</b><br>
+* <dd>SINGLE, MULTI,<br>
+* <dd>READ_ONLY, WRAP<br>
+* <br>
+* <b>Events</b><br>
+* <dd>Modify<br>
+* <dd>Verify<br>
+*/
+
+/* Class Definition */
+public class Text extends Scrollable {
+ char echoCharacter;
+ boolean ignoreChange;
+ String hiddenText;
+ XmTextVerifyCallbackStruct textVerify;
+ int drawCount;
+
+ public static final int LIMIT;
+ public static final 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";
+ }
+/**
+* Creates a new instance of the widget.
+*/
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addVerifyListener (VerifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Verify, typedListener);
+}
+/**
+* Appends a string.
+* <p>
+*
+* @param string the string to be appended
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void append (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int position = OS.XmTextGetLastPosition (handle);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetInsertionPosition (handle, position);
+ OS.XmTextInsert (handle, position, buffer);
+ position = OS.XmTextGetLastPosition (handle);
+ OS.XmTextSetInsertionPosition (handle, position);
+ display.setWarnings(warnings);
+}
+static int checkStyle (int style) {
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ 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;
+}
+/**
+* Clears the selection.
+* <p>
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void clearSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ OS.XmTextClearSelection (handle, OS.XtLastTimestampProcessed (xDisplay));
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = wHint;
+ int height = hHint;
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ int [] argList = {OS.XmNfontList, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int ptr = OS.XmTextGetString (handle);
+ if (ptr == 0) return new Point (0, 0);
+ int size = OS.strlen (ptr);
+ if (size == 0) {
+ if (hHint == SWT.DEFAULT) {
+ if ((style & SWT.SINGLE) != 0) {
+ height = getLineHeight ();
+ } else {
+ height = DEFAULT_HEIGHT;
+ }
+ }
+ if (wHint == SWT.DEFAULT) {
+ width = DEFAULT_WIDTH;
+ }
+ } else {
+ byte [] buffer = new byte [size + 1];
+ OS.memmove (buffer, ptr, size);
+ int xmString = OS.XmStringParseText (
+ buffer,
+ 0,
+ OS.XmFONTLIST_DEFAULT_TAG,
+ OS.XmCHARSET_TEXT,
+ null,
+ 0,
+ 0);
+ if (hHint == SWT.DEFAULT) {
+ if ((style & SWT.SINGLE) != 0) {
+ height = getLineHeight ();
+ } else {
+ height = OS.XmStringHeight (argList [1], xmString);
+ }
+ }
+ if (wHint == SWT.DEFAULT) width = OS.XmStringWidth(argList [1], xmString);
+ OS.XmStringFree (xmString);
+ }
+ OS.XtFree (ptr);
+ }
+ if (horizontalBar != null) {
+ int [] argList1 = {OS.XmNheight, 0};
+ OS.XtGetValues (horizontalBar.handle, argList1, argList1.length / 2);
+ height += argList1 [1] + 4;
+ }
+ if (verticalBar != null) {
+ int [] argList1 = {OS.XmNwidth, 0};
+ OS.XtGetValues (verticalBar.handle, argList1, argList1.length / 2);
+ width += argList1 [1] + 4;
+ }
+ XRectangle rect = new XRectangle ();
+ OS.XmWidgetGetDisplayRect (handle, rect);
+ width += rect.x * 2; height += rect.y * 2;
+ if ((style & (SWT.MULTI | SWT.BORDER)) != 0) height++;
+ return new Point (width, height);
+}
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle trim = super.computeTrim(x, y, width, height);
+ XRectangle rect = new XRectangle ();
+ OS.XmWidgetGetDisplayRect (handle, rect);
+ trim.x -= rect.x;
+ trim.y -= rect.y;
+ trim.width += rect.x;
+ trim.height += rect.y;
+ if ((style & (SWT.MULTI | SWT.BORDER)) != 0) trim.height += 3;
+ return trim;
+}
+/**
+* Copies the selected text to the clipboard.
+*
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void copy () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ OS.XmTextCopy (handle, OS.XtLastTimestampProcessed (xDisplay));
+}
+void createHandle (int index) {
+ state |= HANDLE;
+ int [] argList1 = {
+ OS.XmNverifyBell, 0,
+ OS.XmNeditMode, (style & SWT.SINGLE) != 0 ? OS.XmSINGLE_LINE_EDIT : OS.XmMULTI_LINE_EDIT,
+ OS.XmNscrollHorizontal, (style & SWT.H_SCROLL) != 0 ? 1 : 0,
+ OS.XmNscrollVertical, (style & SWT.V_SCROLL) != 0 ? 1 : 0,
+ OS.XmNwordWrap, (style & SWT.WRAP) != 0 ? 1: 0,
+ OS.XmNeditable, (style & SWT.READ_ONLY) != 0 ? 0 : 1,
+ OS.XmNcursorPositionVisible, (style & SWT.READ_ONLY) != 0 && (style & SWT.SINGLE) != 0 ? 0 : 1,
+// OS.XmNmarginWidth, 3,
+// OS.XmNmarginHeight, 1,
+ };
+ if ((style & SWT.SINGLE) != 0) {
+ handle = OS.XmCreateTextField (parent.handle, null, argList1, argList1.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ int [] argList2 = new int [] {
+ OS.XmNcursorPositionVisible, 0,
+ };
+ OS.XtSetValues (handle, argList2, argList2.length / 2);
+ if ((style & SWT.BORDER) == 0) {
+ int [] argList3 = new int [] {
+ OS.XmNmarginHeight, 0,
+ OS.XmNshadowThickness, 0
+ };
+ OS.XtSetValues (handle, argList3, argList3.length / 2);
+ }
+ } else {
+ handle = OS.XmCreateScrolledText (parent.handle, null, argList1, argList1.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ scrolledHandle = OS.XtParent (handle);
+ }
+}
+ScrollBar createScrollBar (int type) {
+ return createStandardBar (type);
+}
+public void cut () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ OS.XmTextCut (handle, OS.XtLastTimestampProcessed (xDisplay));
+}
+int defaultBackground () {
+ return getDisplay ().textBackground;
+}
+int defaultFont () {
+ return getDisplay ().textFont;
+}
+int defaultForeground () {
+ return getDisplay ().textForeground;
+}
+/**
+* Gets the line number of the caret.
+* <p>
+* The line number of the caret is returned.
+*
+* @return the line number
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getCaretLineNumber () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getLineNumber (OS.XmTextGetInsertionPosition (handle));
+}
+public Point getCaretLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int position;
+ if (textVerify != null) {
+ position = textVerify.currInsert;
+ } else {
+ position = OS.XmTextGetInsertionPosition (handle);
+ }
+ short [] x = new short [1], y = new short [1];
+ OS.XmTextPosToXY (handle, position, x, y);
+ return new Point (x [0], y [0] - getFontAscent ());
+}
+/**
+* Gets the position of the caret.
+* <p>
+* The character position of the caret is returned.
+*
+* @return the position of the caret
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getCaretPosition () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.XmTextGetInsertionPosition (handle);
+}
+/**
+* Gets the number of characters.
+* <p>
+*
+* @return number of characters in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getCharCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.XmTextGetLastPosition (handle);
+}
+/**
+* Gets the double click enabled flag.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getDoubleClickEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNselectionArrayCount, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 1;
+}
+/**
+* Gets the echo character.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public char getEchoChar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return echoCharacter;
+}
+public boolean getEditable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * Bug in MOTIF. For some reason, when XmTextGetEditable () is called
+ * from inside an XmNvalueChangedCallback or XmNModifyVerifyCallback,
+ * it always returns TRUE. Calls to XmTextGetEditable () outside of
+ * these callbacks return the correct value. The fix is to query the
+ * resource directly instead of using the convenience function.
+ */
+ int [] argList = {OS.XmNeditable, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets the number of lines.
+*/
+public int getLineCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getLineNumber (echoCharacter != '\0' ? hiddenText.length () : OS.XmTextGetLastPosition (handle));
+}
+/**
+* Gets the line delimiter.
+* <p>
+* @return a string that is the line delimiter
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getLineDelimiter () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return "\n";
+}
+/**
+* Gets the height of each line.
+* <p>
+* @return the height (in pixels) of each row in the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getLineHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getFontHeight ();
+}
+int getLineNumber (int position) {
+ if (position == 0) return 0;
+ int count = 0, start = 0, page = 1024;
+ char [] buffer = new char [page + 1];
+ /*
+ * Bug in Linux. For some reason, XmTextGetSubstringWcs () does
+ * not copy wchar_t characters into the buffer. Instead, it
+ * copies 4 bytes per character. This does not happen on other
+ * platforms such as AIX. The fix is to call XmTextGetSubstring ()
+ * instead on Linux and rely on the fact that Metrolink Motif 1.2
+ * does not support multibyte locales.
+ */
+ byte [] buffer1 = null;
+ if (IsLinux) buffer1 = new byte [page + 1];
+ int end = ((position + page - 1) / page) * page;
+ while (start < end) {
+ int length = page;
+ if (start + page > position) length = position - start;
+ if (echoCharacter != '\0') {
+ hiddenText.getChars (start, start + length, buffer, 0);
+ } else {
+ if (IsLinux) {
+ OS.XmTextGetSubstring (handle, start, length, buffer1.length, buffer1);
+ for (int i=0; i<length; i++) buffer [i] = (char) buffer1 [i];
+ } else {
+ OS.XmTextGetSubstringWcs (handle, start, length, buffer.length, buffer);
+ }
+ }
+ for (int i=0; i<length; i++) {
+ if (buffer [i] == '\n') count++;
+ }
+ start += page;
+ }
+ return count;
+}
+/**
+* Gets the position of the selected text.
+* <p>
+* @return a point (a pair of ints) that represent the beginning and end of the current selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Point getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (textVerify != null) {
+ return new Point (textVerify.startPos, textVerify.endPos);
+ }
+ int [] start = new int [1], end = new int [1];
+ OS.XmTextGetSelectionPosition (handle, start, end);
+ if (start [0] == end [0]) {
+ start [0] = end [0] = OS.XmTextGetInsertionPosition (handle);
+ }
+ return new Point (start [0], end [0]);
+}
+/**
+* Gets the number of selected characters.
+* <p>
+* @reurn the number of selected characters.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getSelectionCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (textVerify != null) {
+ return textVerify.endPos - textVerify.startPos;
+ }
+ int [] start = new int [1], end = new int [1];
+ OS.XmTextGetSelectionPosition (handle, start, end);
+ return end [0] - start [0];
+}
+/**
+* Gets the selected text.
+* <p>
+* If no text is selected an empty string is returned.
+*
+* @return the selected text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getSelectionText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter != '\0' || textVerify != null) {
+ Point selection = getSelection ();
+ return getText (selection.x, selection.y);
+ }
+ int ptr = OS.XmTextGetSelection (handle);
+ if (ptr == 0) return "";
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ OS.XtFree (ptr);
+ return new String (Converter.mbcsToWcs (null, buffer));
+}
+/**
+* Gets the number of space characters used to represent one tab.
+* <p>
+* @return the number of space characters that are used to represent one tab ('\t') character
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getTabs () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /* Tabs are not supported in MOTIF. */
+ return 8;
+}
+/**
+* Gets the text.
+* <p>
+* If there is no text in the widget, an empty string is returned.
+*
+* @return the content of the widget
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter != '\0') return hiddenText;
+ int ptr = OS.XmTextGetString (handle);
+ if (ptr == 0) return "";
+ int length = OS.strlen (ptr);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, ptr, length);
+ OS.XtFree (ptr);
+ return new String (Converter.mbcsToWcs (null, buffer));
+}
+/**
+* Gets the text.
+* <p>
+* Indexing is zero based. The range of text
+* is from the start index up to and including
+* the end index + 1.
+*
+* @param start the start of the range
+* @param end the end of the range
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getText (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int numChars = end - start + 1;
+ if (numChars < 0 || start < 0) return "";
+ if (echoCharacter != '\0') {
+ return hiddenText.substring (start, Math.min (hiddenText.length (), end));
+ }
+ int length = (numChars * 4 /* MB_CUR_MAX */) + 1;
+ byte [] buffer = new byte [length];
+ int code = OS.XmTextGetSubstring (handle, start, numChars, length, buffer);
+ if (code == OS.XmCOPY_FAILED) return "";
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ if (code == OS.XmCOPY_TRUNCATED) {
+ numChars = OS.XmTextGetLastPosition (handle) - start;
+ }
+ return new String (unicode, 0, numChars);
+}
+/**
+* Gets the text limit.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getTextLimit () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.XmTextGetMaxLength (handle);
+}
+/**
+* Gets the top index.
+* <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 is zero based.
+*
+* @return the index of the top line
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getTopIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return 0;
+ if (scrolledHandle == 0) return 0;
+ int [] argList1 = {OS.XmNverticalScrollBar, 0};
+ OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2);
+ if (argList1 [1] == 0) return 0;
+ int [] argList2 = {OS.XmNvalue, 0};
+ OS.XtGetValues (argList1 [1], argList2, argList2.length / 2);
+ return argList2 [1];
+}
+/**
+* Gets 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>
+* The top pixel changes when the widget is scrolled.
+* The top pixel does not include the widget trimming.
+*
+* @return the pixel position of the top line
+*
+* @exception SWTError <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 getTopPixel () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getTopIndex () * getLineHeight ();
+}
+boolean getWrap () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNwordWrap, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, SWT.DefaultSelection);
+ OS.XtAddCallback (handle, OS.XmNvalueChangedCallback, windowProc, SWT.Modify);
+ OS.XtAddCallback (handle, OS.XmNmodifyVerifyCallback, windowProc, SWT.Verify);
+}
+int inputContext () {
+ /* Answer zero. The text widget uses the default MOTIF input context. */
+ return 0;
+}
+/**
+* Replaces the selection with a string.
+* <p>
+* If the no text is selected (the beginning and the end of the selection are equal)
+* the string is inserted.
+*
+* @param string the string
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void insert (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] start = new int [1], end = new int [1];
+ OS.XmTextGetSelectionPosition (handle, start, end);
+ if (start [0] == end [0]) {
+ start [0] = end [0] = OS.XmTextGetInsertionPosition (handle);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextReplace (handle, start [0], end [0], buffer);
+ int position = start [0] + buffer.length - 1;
+ OS.XmTextSetInsertionPosition (handle, position);
+ display.setWarnings (warnings);
+}
+public void paste () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ /*
+ * Bug in Motif. Despite the fact that the documentation
+ * claims that XmText functions work for XmTextFields, when
+ * a text field is passed to XmTextPaste, Motif segment faults.
+ * The fix is to call XmTextFieldPaste instead.
+ */
+ if ((style & SWT.SINGLE) != 0) {
+ OS.XmTextFieldPaste (handle);
+ } else {
+ OS.XmTextPaste (handle);
+ }
+ display.setWarnings (warnings);
+}
+int processFocusIn () {
+ super.processFocusIn ();
+ if ((style & SWT.READ_ONLY) != 0) return 0;
+ if ((style & SWT.MULTI) != 0) return 0;
+ int [] argList = {OS.XmNcursorPositionVisible, 1};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ return 0;
+}
+int processFocusOut () {
+ super.processFocusOut ();
+ if ((style & SWT.READ_ONLY) != 0) return 0;
+ if ((style & SWT.MULTI) != 0) return 0;
+ int [] argList = {OS.XmNcursorPositionVisible, 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ return 0;
+}
+int processModify (int callData) {
+ if (!ignoreChange) super.processModify (callData);
+ return 0;
+}
+int processVerify (int callData) {
+ super.processVerify (callData);
+ if (echoCharacter == '\0' && !hooks (SWT.Verify)) return 0;
+ XmTextVerifyCallbackStruct textVerify = new XmTextVerifyCallbackStruct ();
+ OS.memmove (textVerify, callData, XmTextVerifyCallbackStruct.sizeof);
+ XmTextBlockRec textBlock = new XmTextBlockRec ();
+ OS.memmove (textBlock, textVerify.text, XmTextBlockRec.sizeof);
+ byte [] buffer = new byte [textBlock.length];
+ OS.memmove (buffer, textBlock.ptr, textBlock.length);
+ String text = new String (Converter.mbcsToWcs (null, buffer));
+ String newText = text;
+ if (!ignoreChange) {
+ Event event = new Event ();
+ if (textVerify.event != 0) {
+ XKeyEvent xEvent = new XKeyEvent ();
+ OS.memmove (xEvent, textVerify.event, XKeyEvent.sizeof);
+ setKeyState (event, xEvent);
+ }
+ event.start = textVerify.startPos;
+ event.end = textVerify.endPos;
+ event.doit = textVerify.doit == 1;
+ event.text = text;
+ sendEvent (SWT.Verify, event);
+ newText = event.text;
+ textVerify.doit = (byte) ((event.doit && newText != null) ? 1 : 0);
+ }
+ if (newText != null) {
+ if (echoCharacter != '\0' && (textVerify.doit != 0)) {
+ String prefix = hiddenText.substring (0, textVerify.startPos);
+ String suffix = hiddenText.substring (textVerify.endPos, hiddenText.length ());
+ hiddenText = prefix + newText + suffix;
+ char [] charBuffer = new char [newText.length ()];
+ for (int i=0; i<charBuffer.length; i++) {
+ charBuffer [i] = echoCharacter;
+ }
+ newText = new String (charBuffer);
+ }
+ if (newText != text) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, newText, true);
+ int length = buffer2.length;
+ int ptr = OS.XtMalloc (length);
+ OS.memmove (ptr, buffer2, length);
+ textBlock.ptr = ptr;
+ textBlock.length = buffer2.length - 1;
+ OS.memmove (textVerify.text, textBlock, XmTextBlockRec.sizeof);
+ }
+ }
+ OS.memmove (callData, textVerify, XmTextVerifyCallbackStruct.sizeof);
+ textVerify = null;
+ return 0;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeVerifyListener (VerifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Verify, listener);
+}
+/**
+* Selects all of the text.
+* <p>
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void selectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /* Clear the highlight before setting the selection. */
+ int position = OS.XmTextGetLastPosition (handle);
+// OS.XmTextSetHighlight (handle, 0, position, OS.XmHIGHLIGHT_NORMAL);
+
+ /*
+ * Bug in MOTIF. XmTextSetSelection () fails to set the
+ * selection when the receiver is not realized. The fix
+ * is to force the receiver to be realized by forcing the
+ * shell to be realized. If the receiver is realized before
+ * the shell, MOTIF fails to draw the text widget and issues
+ * lots of X BadDrawable errors.
+ */
+ if (!OS.XtIsRealized (handle)) getShell ().realizeWidget ();
+
+ /* Set the selection. */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetSelection (handle, 0, position, OS.XtLastTimestampProcessed (xDisplay));
+
+ /* Force the i-beam to follow the highlight/selection. */
+ OS.XmTextSetInsertionPosition (handle, 0);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the bounds.
+*/
+public void setBounds (int x, int y, int width, int height) {
+ super.setBounds (x, y, width, height);
+ /*
+ * Bug in Motif. When the receiver is a Text widget
+ * (not a Text Field) and is resized to be smaller than
+ * the inset that surrounds the text and the selection
+ * is set, the receiver scrolls to the left. When the
+ * receiver is resized larger, the text is not scrolled
+ * back. The fix is to detect this case and scroll the
+ * text back.
+ */
+// inset := self inset.
+// nWidth := self dimensionAt: XmNwidth.
+// self noWarnings: [super resizeWidget].
+// nWidth > inset x ifTrue: [^self].
+// self showPosition: self topCharacter
+}
+/**
+* Sets the double click enabled flag.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setDoubleClickEnabled (boolean doubleClick) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNselectionArrayCount, doubleClick ? 4 : 1};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the echo character.
+* <p>
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setEchoChar (char echo) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter == echo) return;
+ String newText;
+ if (echo == 0) {
+ newText = hiddenText;
+ hiddenText = null;
+ } else {
+ newText = hiddenText = getText();
+ }
+ echoCharacter = echo;
+ Point selection = getSelection();
+ boolean oldValue = ignoreChange;
+ ignoreChange = true;
+ setText(newText);
+ setSelection(selection);
+ ignoreChange = oldValue;
+}
+public void setEditable (boolean editable) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.XmTextSetEditable (handle, editable);
+ style &= ~SWT.READ_ONLY;
+ if (!editable) style |= SWT.READ_ONLY;
+ if ((style & SWT.MULTI) != 0) return;
+ int [] argList = {OS.XmNcursorPositionVisible, editable && hasFocus () ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the redraw flag.
+*/
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return;
+ if (redraw) {
+ if (--drawCount == 0) OS.XmTextEnableRedisplay(handle);
+ } else {
+ if (drawCount++ == 0) OS.XmTextDisableRedisplay(handle);
+ }
+}
+/**
+* Sets the selection.
+* <p>
+* @param start new i-beam position
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /* Clear the selection and highlight before moving the i-beam. */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int position = OS.XmTextGetLastPosition (handle);
+ int nStart = Math.min (Math.max (start, 0), position);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+// OS.XmTextSetHighlight (handle, 0, position, OS.XmHIGHLIGHT_NORMAL);
+ OS.XmTextClearSelection (handle, OS.XtLastTimestampProcessed (xDisplay));
+
+ /* Set the i-beam position. */
+ OS.XmTextSetInsertionPosition (handle, nStart);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the selection.
+* <p>
+* Indexing is zero based. The range of text
+* is from the start index up to and including
+* the end index + 1.
+*
+* @param start the start of the range
+* @param end the end of the range
+
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /* Clear the highlight before setting the selection. */
+ int position = OS.XmTextGetLastPosition (handle);
+// OS.XmTextSetHighlight (handle, 0, position, OS.XmHIGHLIGHT_NORMAL);
+
+ /*
+ * Bug in MOTIF. XmTextSetSelection () fails to set the
+ * selection when the receiver is not realized. The fix
+ * is to force the receiver to be realized by forcing the
+ * shell to be realized. If the receiver is realized before
+ * the shell, MOTIF fails to draw the text widget and issues
+ * lots of X BadDrawable errors.
+ */
+ if (!OS.XtIsRealized (handle)) getShell ().realizeWidget ();
+
+ /* Set the selection. */
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return;
+ int nStart = Math.min (Math.max (Math.min (start, end), 0), position);
+ int nEnd = Math.min (Math.max (Math.max (start, end), 0), position);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetSelection (handle, nStart, nEnd, OS.XtLastTimestampProcessed (xDisplay));
+
+ /* Force the i-beam to follow the highlight/selection. */
+ OS.XmTextSetInsertionPosition (handle, nEnd);
+ display.setWarnings (warnings);
+}
+/**
+* Sets the selection.
+* <p>
+* @param selection the point whose x and y fields specify the beginning and the end
+* of the new selection
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when selection is null
+*/
+public void setSelection (Point selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+/**
+* Sets the size.
+*/
+public void setSize (int width, int height) {
+ super.setSize (width, height);
+ /*
+ * Bug in Motif. When the receiver is a Text widget
+ * (not a Text Field) and is resized to be smaller than
+ * the inset that surrounds the text and the selection
+ * is set, the receiver scrolls to the left. When the
+ * receiver is resized larger, the text is not scrolled
+ * back. The fix is to detect this case and scroll the
+ * text back.
+ */
+// inset := self inset.
+// nWidth := self dimensionAt: XmNwidth.
+// self noWarnings: [super resizeWidget].
+// nWidth > inset x ifTrue: [^self].
+// self showPosition: self topCharacter
+}
+/**
+* Sets the number of space characters used to represent one tab.
+* <p>
+* @return the number of space characters that are used to represent one tab ('\t') character
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setTabs (int tabs) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /* Do nothing. Tabs are not supported in MOTIF. */
+}
+/**
+* Sets the text.
+* <p>
+* @param string the new text.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ OS.XmTextSetString (handle, buffer);
+ OS.XmTextSetInsertionPosition (handle, 0);
+ display.setWarnings(warnings);
+ /*
+ * Bug in Linux. When the widget is multi-line
+ * it does not send a Modify to notify the application
+ * that the text has changed. The fix is to send the event.
+ */
+ if (IsLinux && (style & SWT.MULTI) != 0) sendEvent (SWT.Modify);
+}
+/**
+* Sets the text limit.
+* <p>
+* @param limit the new text limit.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setTextLimit (int limit) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.XmTextSetMaxLength (handle, limit);
+}
+/**
+* Sets the top index.
+* <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.
+*
+* @param index the new top index
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setTopIndex (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return;
+ if (scrolledHandle == 0) return;
+ int [] argList1 = {OS.XmNverticalScrollBar, 0};
+ OS.XtGetValues (scrolledHandle, argList1, argList1.length / 2);
+ if (argList1 [1] == 0) return;
+ int [] argList2 = {OS.XmNvalue, 0};
+ OS.XtGetValues (argList1 [1], argList2, argList2.length / 2);
+ OS.XmTextScroll (handle, index - argList2 [1]);
+}
+void setWrap (boolean wrap) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNwordWrap, wrap ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void showSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Display display = getDisplay ();
+ boolean warnings = display.getWarnings ();
+ display.setWarnings (false);
+ int position = OS.XmTextGetInsertionPosition (handle);
+ OS.XmTextShowPosition (handle, position);
+ display.setWarnings (warnings);
+}
+int traversalCode () {
+ if ((style & SWT.SINGLE) != 0) return super.traversalCode ();
+ return SWT.TRAVERSE_ESCAPE;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
new file mode 100755
index 0000000000..4ed8ef2251
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolBar.java
@@ -0,0 +1,211 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* The tool bar class supports the layout of
+* selectable tool bar items.
+*
+* Styles
+*
+* WRAP, FLAT
+*
+* Events
+*
+**/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/* Class Definition */
+public /*final*/ class ToolBar extends Composite {
+ int drawCount, itemCount;
+ ToolItem [] items;
+/**
+* Creates a new instance of the widget.
+*/
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+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);
+}
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT) width = 0x7FFFFFFF;
+ if (hHint == SWT.DEFAULT) height = 0x7FFFFFFF;
+ int [] result = layout (width, height, false);
+ int border = getBorderWidth () * 2;
+ Point extent = new Point (result [1], result [2]);
+ if (wHint != SWT.DEFAULT) extent.x = wHint;
+ if (hHint != SWT.DEFAULT) extent.y = hHint;
+ extent.x += border;
+ extent.y += border;
+ return extent;
+}
+void createItem (ToolItem item, int index) {
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ if (itemCount == items.length) {
+ ToolItem [] newItems = new ToolItem [itemCount + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ item.createWidget (index);
+ System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+ items [index] = item;
+}
+
+void createHandle (int index) {
+ super.createHandle (index);
+ state &= ~CANVAS;
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ items = new ToolItem [4];
+ itemCount = 0;
+}
+void destroyItem (ToolItem 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;
+}
+public ToolItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] items = getItems ();
+ if (0 <= index && index < items.length) return items [index];
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+
+public ToolItem getItem (Point pt) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ Rectangle rect = items [i].getBounds ();
+ if (rect.contains (pt)) return items [i];
+ }
+ return null;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return itemCount;
+}
+public ToolItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] result = new ToolItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ return result;
+}
+public int getRowCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle rect = getClientArea ();
+ return layout (rect.width, rect.height, false) [0];
+}
+public int indexOf (ToolItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ ToolItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+int [] layout (int nWidth, int nHeight, boolean resize) {
+ int xSpacing = 0, ySpacing = 4;
+ int marginWidth = 0, marginHeight = 0;
+ ToolItem [] children = getItems ();
+ int length = children.length;
+ int x = marginWidth, y = marginHeight;
+ int maxHeight = 0, maxX = 0, rows = 1;
+ boolean wrap = (style & SWT.WRAP) != 0;
+ for (int i=0; i<length; i++) {
+ ToolItem child = children [i];
+ Rectangle rect = child.getBounds ();
+ if (wrap && i != 0 && x + rect.width > nWidth) {
+ rows++;
+ x = marginWidth; y += ySpacing + maxHeight;
+ maxHeight = 0;
+ }
+ maxHeight = Math.max (maxHeight, rect.height);
+ if (resize) {
+ child.setBounds (x, y, rect.width, rect.height);
+ }
+ x += xSpacing + rect.width;
+ maxX = Math.max (maxX, x);
+ }
+ return new int [] {rows, maxX, y + maxHeight};
+}
+void relayout () {
+ if (drawCount > 0) return;
+ Rectangle rect = getClientArea ();
+ layout (rect.width, rect.height, true);
+}
+void relayout (int width, int height) {
+ if (drawCount > 0) return;
+ layout (width, height, true);
+}
+void releaseWidget () {
+ for (int i=0; i<itemCount; i++) {
+ ToolItem item = items [i];
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ items = null;
+ super.releaseWidget ();
+}
+public void setBounds (int x, int y, int width, int height) {
+ super.setBounds (x, y, width, height);
+ Rectangle rect = getClientArea ();
+ relayout (rect.width, rect.height);
+}
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (redraw) {
+ if (--drawCount == 0) relayout();
+ } else {
+ drawCount++;
+ }
+}
+public void setSize (int width, int height) {
+ super.setSize (width, height);
+ Rectangle rect = getClientArea ();
+ relayout (rect.width, rect.height);
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java
new file mode 100755
index 0000000000..6a84ef8a75
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolDrawable.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.internal.motif.*;
+
+class ToolDrawable implements Drawable {
+
+ Device device;
+ int display;
+ int drawable;
+ int fontList;
+ int colormap;
+
+public int internal_new_GC (GCData data) {
+ int xGC = OS.XCreateGC (display, drawable, 0, null);
+ if (xGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ data.device = device;
+ data.display = display;
+ data.drawable = drawable;
+ data.fontList = fontList;
+ data.colormap = colormap;
+ }
+ return xGC;
+}
+
+public void internal_dispose_GC (int xGC, GCData data) {
+ OS.XFreeGC (display, xGC);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
new file mode 100755
index 0000000000..17b8beac50
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/ToolItem.java
@@ -0,0 +1,763 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+* A tool item is a selectable user interface object
+* that represents a button in a tool bar.
+*
+* <p>
+* <b>Styles</b><br>
+* <dd>CHECK, PUSH, RADIO, SEPARATOR<br>
+* <b>Events</b><br>
+* <dd>Selection<br>
+*/
+
+/* Class Definition */
+public /*final*/ class ToolItem extends Item {
+ ToolBar parent;
+ Image hotImage, disabledImage;
+ String toolTipText;
+ Control control;
+ boolean set, drawHotImage;
+
+/**
+* Creates a new instance of the widget.
+*/
+public ToolItem (ToolBar parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+/**
+* Creates a new instance of the widget.
+*/
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+ int parentHandle = parent.handle;
+ if ((style & SWT.SEPARATOR) != 0) {
+ int [] argList = {
+ OS.XmNwidth, 8,
+ OS.XmNheight, 5,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNpositionIndex, index,
+ OS.XmNmappedWhenManaged, 0,
+ };
+ handle = OS.XmCreateDrawnButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ int [] argList = {
+ OS.XmNwidth, 24,
+ OS.XmNheight, 22,
+ OS.XmNrecomputeSize, 0,
+ OS.XmNhighlightThickness, 0,
+ OS.XmNmarginWidth, 2,
+ OS.XmNmarginHeight, 1,
+ OS.XmNtraversalOn, 0,
+ OS.XmNpositionIndex, index,
+ OS.XmNshadowType, OS.XmSHADOW_OUT,
+ };
+ handle = OS.XmCreateDrawnButton (parentHandle, null, argList, argList.length / 2);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if ((parent.style & SWT.FLAT) != 0) {
+ argList = new int [] {OS.XmNshadowThickness, 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+}
+
+Point computeSize () {
+ //if (control != null) return control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
+
+ int [] argList = {
+ OS.XmNmarginHeight, 0,
+ OS.XmNmarginWidth, 0,
+ OS.XmNshadowThickness, 0,
+ OS.XmNhighlightThickness, 0,
+ };
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int marginHeight = argList[1];
+ int marginWidth = argList[3];
+ int shadowThickness = 2; //argList[5];
+ int highlightThickness = argList[7];
+
+ int textWidth = 0, textHeight = 0;
+ if (text != null && text.length() > 0) {
+ GC gc = new GC (parent);
+ Point textExtent = gc.textExtent (text);
+ textWidth = textExtent.x;
+ textHeight = textExtent.y;
+ gc.dispose ();
+ }
+ int imageWidth = 0, imageHeight = 0;
+ if (image != null) {
+ Rectangle rect = image.getBounds();
+ imageWidth = rect.width;
+ imageHeight= rect.height;
+ }
+
+ int contentHeight = 0, contentWidth = 0;
+ if ((parent.style & SWT.RIGHT) > 0) {
+ contentHeight = Math.max(imageHeight, textHeight);
+ contentWidth = imageWidth + textWidth;
+ if (imageWidth > 0 && textWidth > 0) contentWidth += marginWidth;
+ } else {
+ contentHeight = imageHeight + textHeight;
+ if (imageHeight > 0 && textHeight > 0) contentHeight += marginHeight;
+ contentWidth = Math.max(imageWidth, textWidth);
+ }
+
+ /* This value comes from Windows */
+ int height = 22;
+ if (contentHeight != 0) {
+ height = contentHeight
+ + (2 * marginHeight)
+ + (2 * shadowThickness)
+ + (2 * highlightThickness);
+ }
+
+ /* This value comes from Windows */
+ int width = 24;
+ if (contentWidth != 0) {
+ width = contentWidth
+ + (2 * marginWidth)
+ + (2 * shadowThickness)
+ + (2 * highlightThickness);
+ }
+
+ return new Point (width, height);
+}
+void createWidget (int index) {
+ super.createWidget (index);
+ toolTipText = "";
+ parent.relayout ();
+}
+public void dispose () {
+ ToolBar parent = this.parent;
+ super.dispose ();
+ parent.relayout ();
+}
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNx, 0, OS.XmNy, 0, OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return new Rectangle ((short) argList [1], (short) argList [3], argList [5], argList [7]);
+}
+/**
+* Gets the control.
+* <p>
+* @return the control
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+/**
+* Gets the disabled image.
+* <p>
+* @return the image
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Image getDisabledmage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return disabledImage;
+}
+/**
+* Gets the enabled state.
+* <p>
+* A disabled widget is typically not selectable from
+* the user interface and draws with an inactive or
+* grayed look.
+*
+* @return a boolean that is the enabled state of the widget.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1] != 0;
+}
+/**
+* Gets the Display.
+*/
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+* Gets the hot image.
+* <p>
+* @return the image
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Image getHotImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hotImage;
+}
+/**
+* Gets the parent.
+* <p>
+* @return the parent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public ToolBar getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+/**
+* Gets the selection state.
+* <p>
+* @return the selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return false;
+ return set;
+}
+/**
+* Gets the hover help text.
+* <p>
+* @return the hover help text
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNwidth, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ return argList [1];
+}
+void hookEvents () {
+ super.hookEvents ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = getDisplay ().windowProc;
+ OS.XtAddCallback (handle, OS.XmNexposeCallback, windowProc, SWT.Paint);
+// OS.XtAddCallback (handle, OS.XmNactivateCallback, windowProc, SWT.Selection);
+ OS.XtAddEventHandler (handle, OS.ButtonPressMask, false, windowProc, SWT.MouseDown);
+ OS.XtAddEventHandler (handle, OS.ButtonReleaseMask, false, windowProc, SWT.MouseUp);
+ OS.XtAddEventHandler (handle, OS.PointerMotionMask, false, windowProc, SWT.MouseMove);
+ OS.XtAddEventHandler (handle, OS.EnterWindowMask, false, windowProc, SWT.MouseEnter);
+ OS.XtAddEventHandler (handle, OS.LeaveWindowMask, false, windowProc, SWT.MouseExit);
+}
+/**
+* Gets the enabled status.
+* <p>
+* When an ancestor of the widget is disabled, the enabled
+* stats of the widget in the widget hierarchy is disabled
+* regardless of the actual enabled state of the widget.
+*
+* @param enabled a boolean that is the enabled state.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+void manageChildren () {
+ OS.XtManageChild (handle);
+}
+int processSelection (int callData) {
+ if ((style & SWT.RADIO) != 0) {
+ selectRadio ();
+ } else {
+ if ((style & SWT.CHECK) != 0) setSelection(!set);
+ }
+ postEvent (SWT.Selection);
+ return 0;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+void releaseWidget () {
+ getDisplay ().releaseToolTipHandle (handle);
+ super.releaseWidget ();
+ parent = null;
+ control = null;
+ toolTipText = null;
+ disabledImage = hotImage = null;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Selection, listener);
+ eventTable.unhook(SWT.DefaultSelection,listener);
+}
+void selectRadio () {
+ this.setSelection (true);
+ ToolItem [] items = parent.getItems ();
+ int index = 0;
+ while (index < items.length && items [index] != this) index++;
+ ToolItem item;
+ int i = index;
+ while (--i >= 0 && ((item = items [i]).style & SWT.RADIO) != 0) {
+ item.setSelection (false);
+ }
+ i = index;
+ while (++i < items.length && ((item = items [i]).style & SWT.RADIO) != 0) {
+ item.setSelection (false);
+ }
+}
+void setBounds (int x, int y, int width, int height) {
+ if (control != null) control.setBounds(x, y, width, height);
+ /*
+ * Feature in Motif. Motif will not allow a window
+ * to have a zero width or zero height. The fix is
+ * to ensure these values are never zero.
+ */
+ int newWidth = Math.max (width, 1), newHeight = Math.max (height, 1);
+ OS.XtConfigureWidget (handle, x, y, newWidth, newHeight, 0);
+}
+/**
+* Sets the control.
+* <p>
+* @param control the new control
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ this.control = control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+/**
+* Sets the enabled state.
+* <p>
+* A disabled widget is typically not selectable from
+* the user interface and draws with an inactive or
+* grayed look.
+*
+* @param enabled the new value of the enabled flag
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] argList = {OS.XmNsensitive, enabled ? 1 : 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+}
+/**
+* Sets the hot image.
+* <p>
+* @param image the new image (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setDisabledImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+}
+/**
+* Sets the hot image.
+* <p>
+* @param image the new image (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setHotImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ hotImage = image;
+}
+/**
+* Sets the widget image.
+* <p>
+* @param image the widget image (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ super.setImage (image);
+
+ /* Resize */
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ Point size = computeSize();
+ if (argList[1] != size.x || argList[3] != size.y) {
+ OS.XtResizeWidget (handle, size.x, size.y, 0);
+ }
+ parent.relayout ();
+}
+
+/**
+* Sets the selection state.
+* <p>
+* @param selected the new selection state
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO)) == 0) return;
+ if (selected == set) return;
+ set = selected;
+ setDrawPressed(set);
+ if ((parent.style & SWT.FLAT) != 0) {
+ int shadowThickness = set ? getDisplay().buttonShadowThickness : 0;
+ int [] argList = {OS.XmNshadowThickness, shadowThickness};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+}
+/**
+* Sets the widget text.
+*/
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+
+ /* Resize */
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ Point size = computeSize();
+ if (argList[1] != size.x || argList[3] != size.y) {
+ OS.XtResizeWidget (handle, size.x, size.y, 0);
+ }
+ parent.relayout ();
+}
+
+/**
+* Sets the hover help text.
+* <p>
+* @param string the hover help text (or null)
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
+}
+
+public void setWidth (int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) == 0) return;
+ if (width < 0) return;
+ int [] argList = {OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ OS.XtResizeWidget (handle, width, argList [1], 0);
+ parent.relayout ();
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+
+void setDrawPressed (boolean value) {
+ int shadowType = value ? OS.XmSHADOW_IN : OS.XmSHADOW_OUT;
+ int [] argList = {OS.XmNshadowType, shadowType};
+ OS.XtSetValues(handle, argList, argList.length / 2);
+}
+
+int processMouseDown (int callData) {
+ getDisplay ().hideToolTip();
+ if (set && (style & SWT.RADIO) != 0) return 0;
+ setDrawPressed(!set);
+ return 0;
+}
+
+int processMouseEnter (int callData) {
+ if ((parent.style & SWT.FLAT) != 0) {
+ int [] argList = {OS.XmNshadowThickness, getDisplay().buttonShadowThickness};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, callData, XCrossingEvent.sizeof);
+ boolean button1Pressed = (xEvent.state & OS.Button1Mask) != 0;
+ if (button1Pressed) {
+ setDrawPressed(!set);
+ }
+ drawHotImage = (parent.style & SWT.FLAT) != 0 && hotImage != null;
+ if (drawHotImage) {
+ OS.XClearArea (xEvent.display, xEvent.window, 0, 0, 0, 0, true);
+ }
+ return 0;
+}
+
+int processMouseExit (int callData) {
+ Display display = getDisplay ();
+ display.removeMouseHoverTimeOut ();
+ display.hideToolTip ();
+
+ if ((parent.style & SWT.FLAT) != 0 && !set) {
+ int [] argList = {OS.XmNshadowThickness, 0};
+ OS.XtSetValues (handle, argList, argList.length / 2);
+ }
+
+ XCrossingEvent xEvent = new XCrossingEvent ();
+ OS.memmove (xEvent, callData, XCrossingEvent.sizeof);
+ boolean button1Pressed = (xEvent.state & OS.Button1Mask) != 0;
+ if (button1Pressed) {
+ setDrawPressed(set);
+ }
+ if (drawHotImage) {
+ drawHotImage = false;
+ OS.XClearArea (xEvent.display, xEvent.window, 0, 0, 0, 0, true);
+ }
+ return 0;
+}
+
+Point toControl (Point point) {
+ short [] root_x = new short [1], root_y = new short [1];
+ OS.XtTranslateCoords (handle, (short) 0, (short) 0, root_x, root_y);
+ return new Point (point.x - root_x [0], point.y - root_y [0]);
+}
+
+int processMouseHover (int id) {
+ Display display = getDisplay();
+ Point local = toControl(display.getCursorLocation());
+ display.showToolTip(handle, toolTipText);
+ return 0;
+}
+
+int processMouseMove (int callData) {
+ Display display = getDisplay ();
+ display.addMouseHoverTimeOut (handle);
+ return 0;
+}
+
+int processMouseUp (int callData) {
+ getDisplay ().hideToolTip();
+
+ /**
+ * Bug in Motif. The activate callback is unreliable on
+ * drawn buttons. Rather than relying on it to generate
+ * selection events, use the mouseUp event.
+ */
+ XButtonEvent xEvent = new XButtonEvent ();
+ OS.memmove (xEvent, callData, XButtonEvent.sizeof);
+ int [] argList = {OS.XmNwidth, 0, OS.XmNheight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ if (xEvent.x >= 0 && xEvent.y >= 0 && xEvent.x <= argList[1] && xEvent.y <= argList[3]) {
+ processSelection(0);
+ }
+
+ setDrawPressed(set);
+ return 0;
+}
+
+int processPaint (int callData) {
+ if ((style & SWT.SEPARATOR) != 0) return 0;
+ int xDisplay = OS.XtDisplay (handle);
+ if (xDisplay == 0) return 0;
+ int xWindow = OS.XtWindow (handle);
+ if (xWindow == 0) return 0;
+
+ int [] argList = {OS.XmNcolormap, 0, OS.XmNwidth, 0, OS.XmNheight, 0, OS.XmNmarginWidth, 0, OS.XmNmarginHeight, 0};
+ OS.XtGetValues (handle, argList, argList.length / 2);
+ int x = 0, y = 0, width = argList [3], height = argList [5], marginWidth = argList [7], marginHeight = argList [9];
+
+ ToolDrawable wrapper = new ToolDrawable ();
+ wrapper.device = getDisplay ();
+ wrapper.display = xDisplay;
+ wrapper.drawable = xWindow;
+ wrapper.fontList = parent.getFontList ();
+ wrapper.colormap = argList [1];
+ GC gc = new GC (wrapper);
+
+ XmAnyCallbackStruct cb = new XmAnyCallbackStruct ();
+ OS.memmove (cb, callData, XmAnyCallbackStruct.sizeof);
+ if (cb.event != 0) {
+ XExposeEvent xEvent = new XExposeEvent ();
+ OS.memmove (xEvent, cb.event, XExposeEvent.sizeof);
+ Rectangle rect = new Rectangle (xEvent.x, xEvent.y, xEvent.width, xEvent.height);
+ gc.setClipping (rect);
+ }
+
+ Image currentImage = drawHotImage ? hotImage : image;
+ if (!getEnabled()) {
+ Display display = getDisplay ();
+ currentImage = disabledImage;
+ if (currentImage == null) {
+ currentImage = new Image (display, image, SWT.IMAGE_DISABLE);
+ }
+ Color disabledColor = display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ gc.setForeground(disabledColor);
+ } else {
+ gc.setForeground (parent.getForeground ());
+ }
+ gc.setBackground (parent.getBackground ());
+
+ int textX = 0, textY = 0, textWidth = 0, textHeight = 0;
+ if (text != null && text.length() > 0) {
+ Point textExtent = gc.textExtent(text);
+ textWidth = textExtent.x;
+ textHeight = textExtent.y;
+ }
+ int imageX = 0, imageY = 0, imageWidth = 0, imageHeight = 0;
+ if (currentImage != null) {
+ Rectangle imageBounds = currentImage.getBounds();
+ imageWidth = imageBounds.width;
+ imageHeight = imageBounds.height;
+ }
+
+ if ((parent.style & SWT.RIGHT) > 0) {
+ imageX = x + ((width - imageWidth - textWidth - marginWidth) / 2) + 1;
+ imageY = y + ((height - imageHeight) / 2);
+ textX = imageX + imageWidth + marginWidth;
+ textY = y + ((height - textHeight) / 2);
+ } else {
+ imageX = x + ((width - imageWidth) / 2) + 1;
+ imageY = y + ((height - imageHeight - textHeight - marginHeight) / 2) + 1;
+ textX = x + ((width - textWidth) / 2) + 2;
+ textY = imageY + imageHeight + marginHeight;
+ }
+
+ if (textWidth > 0) gc.drawText(text, textX, textY, false);
+ if (imageWidth > 0) gc.drawImage(currentImage, imageX, imageY);
+
+ gc.dispose ();
+
+ if (!getEnabled() && disabledImage == null) {
+ if (currentImage != null) currentImage.dispose ();
+ }
+ return 0;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
new file mode 100755
index 0000000000..3f8db147f9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tracker.java
@@ -0,0 +1,193 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+*/
+
+/* Class Definition */
+public /*final*/ class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles = new Rectangle [0];
+/**
+* Creates a new instance of the widget.
+*/
+public Tracker (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+/**
+* Creates a new instance of the widget.
+*/
+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 = style;
+ this.display = display;
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+public void close () {
+ tracking = false;
+}
+void drawRectangles () {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+ int xDisplay = display.xDisplay;
+ int color = OS.XWhitePixel (xDisplay, 0);
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ if (parent != null) {
+ xWindow = OS.XtWindow (parent.handle);
+ if (xWindow == 0) return;
+ int [] argList = {OS.XmNforeground, 0, OS.XmNbackground, 0};
+ OS.XtGetValues (parent.handle, argList, argList.length / 2);
+ color = argList [1] ^ argList [3];
+ }
+ int gc = OS.XCreateGC (xDisplay, xWindow, 0, null);
+ OS.XSetForeground (xDisplay, gc, color);
+ OS.XSetSubwindowMode (xDisplay, gc, OS.IncludeInferiors);
+ OS.XSetFunction (xDisplay, gc, OS.GXxor);
+ int stipplePixmap = 0;
+ if (stippled) {
+ byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
+ stipplePixmap = OS.XCreateBitmapFromData (xDisplay, xWindow, bits, 8, 8);
+ OS.XSetStipple (xDisplay, gc, stipplePixmap);
+ OS.XSetFillStyle (xDisplay, gc, OS.FillStippled);
+ OS.XSetLineAttributes (xDisplay, gc, 3, OS.LineSolid, OS.CapButt, OS.JoinMiter);
+ }
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle rect = rectangles [i];
+ OS.XDrawRectangle (xDisplay, xWindow, gc, rect.x, rect.y, rect.width, rect.height);
+ }
+ if (stippled) {
+ OS.XFreePixmap (xDisplay, stipplePixmap);
+ }
+ OS.XFreeGC (xDisplay, gc);
+}
+public Display getDisplay () {
+ return display;
+}
+public Rectangle [] getRectangles () {
+ return rectangles;
+}
+public boolean getStippled () {
+ return stippled;
+}
+public boolean open () {
+ int xDisplay = display.xDisplay;
+ int color = OS.XWhitePixel (xDisplay, 0);
+ int xWindow = OS.XDefaultRootWindow (xDisplay);
+ if (parent != null) {
+ xWindow = OS.XtWindow (parent.handle);
+ if (xWindow == 0) return false;
+ }
+ boolean cancelled = false;
+ tracking = true;
+ drawRectangles ();
+ Event event = new Event ();
+ XAnyEvent xEvent = new XAnyEvent ();
+ int [] unused = new int [1];
+ int [] newX = new int [1], newY = new int [1], oldX = new int [1], oldY = new int [1];
+ int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, oldX, oldY, unused, unused, unused);
+ while (tracking) {
+ if (parent != null && parent.isDisposed ()) break;
+ OS.XtAppNextEvent (xtContext, xEvent);
+ switch (xEvent.type) {
+ case OS.ButtonRelease:
+ case OS.MotionNotify:
+ OS.XQueryPointer (xDisplay, xWindow, unused, unused, newX, newY, unused, unused, unused);
+ if (oldX [0] != newX [0] || oldY [0] != newY [0]) {
+ drawRectangles ();
+ for (int i=0; i<rectangles.length; i++) {
+ rectangles [i].x += newX [0] - oldX [0];
+ rectangles [i].y += newY [0] - oldY [0];
+ }
+ sendEvent (SWT.Move);
+ drawRectangles ();
+ oldX [0] = newX [0]; oldY [0] = newY [0];
+ }
+ tracking = xEvent.type != OS.ButtonRelease;
+ break;
+ case OS.KeyPress:
+ XKeyEvent keyEvent = new XKeyEvent ();
+ OS.memmove (keyEvent, xEvent, XKeyEvent.sizeof);
+ if (keyEvent.keycode != 0) {
+ int [] keysym = new int [1];
+ OS.XLookupString (keyEvent, null, 0, keysym, unused);
+ keysym [0] &= 0xFFFF;
+ tracking = keysym [0] != OS.XK_Escape && keysym [0] != OS.XK_Cancel;
+ cancelled = !tracking;
+ }
+ break;
+ }
+ }
+ drawRectangles ();
+ tracking = false;
+ return !cancelled;
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+}
+public void setRectangles (Rectangle [] rectangles) {
+ this.rectangles = rectangles;
+}
+public void setStippled (boolean stippled) {
+ this.stippled = stippled;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java
new file mode 100755
index 0000000000..463f425b91
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Tree.java
@@ -0,0 +1,1469 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * Displays a hierarchy of items that can be selected.
+ * Sub hierarchies can be expanded and collapsed.
+ */
+public /*final*/ class Tree extends SelectableItemWidget {
+ // These constants are used internally for item hit test on mouse click
+ private static final int ActionNone = 0; // The mouse event was not handled
+ private static final int ActionExpandCollapse = 1; // Do an expand/collapse
+ private static final int ActionSelect = 2; // Select the item
+ private static final int ActionCheck = 3; // Toggle checked state of the item
+ private static ImageData CollapsedImageData; // collapsed sub tree image data. used to create an image at run time
+ private static ImageData ExpandedImageData; // expanded sub tree image data. used to create an image at run time
+ static {
+ initializeImageData();
+ }
+
+ private TreeRoots root;
+ private TreeItem expandingItem;
+
+ private Image collapsedImage;
+ private Image expandedImage;
+
+ // The following fields are needed for painting tree items
+ final Color CONNECTOR_LINE_COLOR; // Color constant used during painting. Can't keep this in TreeItem
+ // because we only need one instance per tree widget/display and can't
+ // have it static. Initialized in c'tor and freed in dispose();
+ Rectangle hierarchyIndicatorRect = null; // bounding rectangle of the hierarchy indication image (plus/minus)
+
+/**
+ * Create a new instance of the receiver with 'parent'
+ * as its parent widget.
+ */
+public Tree(Composite parent, int style) {
+ super(parent, checkStyle (style));
+ CONNECTOR_LINE_COLOR = new Color(getDisplay(), 170, 170, 170); // Light gray;
+}
+/**
+ * Add 'item' to the list of root items.
+ * @param 'item' - the tree item that should be added as a root.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void addItem(TreeItem item, int index) {
+ if (index < 0 || index > getItemCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ getRoot().add(item, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void addTreeListener(TreeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Expand, typedListener);
+ addListener(SWT.Collapse, typedListener);
+}
+/**
+ * The SelectableItem 'item' has been added to the tree.
+ * Prevent screen updates when 'item' is inserted due to an
+ * expand operation.
+ * @param item - item that has been added to the receiver.
+ */
+void addedItem(SelectableItem item, int index) {
+ super.addedItem(item, index);
+ redrawAfterModify(item, index); // redraw plus/minus image, hierarchy lines
+}
+/**
+ * Answer the y position of both the first child of 'item' and
+ * the item following the last child of 'item'.
+ * Used to scroll items on expand/collapse.
+ * @param item - TreeItem to use for calculating the y boundary
+ * of child items.
+ * @return Array - first element is the position of the first
+ * child of 'item'. Second element is the position of the item
+ * following the last child of 'item'.
+ * Both elements are -1 if 'item' is not a child of the receiver.
+ */
+int[] calculateChildrenYPos(TreeItem item) {
+ int itemIndex = item.getVisibleIndex();
+ int itemCount = item.getVisibleItemCount();
+ int itemHeight = getItemHeight();
+ int yPos;
+ int[] yPosition = new int[] {-1, -1};
+
+ if (itemIndex != -1) {
+ itemIndex -= getTopIndex();
+ yPos = (itemIndex + itemCount + 1) * itemHeight; // y position of the item following
+ // the last child of 'item'
+ yPosition = new int[] {yPos - (itemCount * itemHeight), yPos};
+ }
+ return yPosition;
+}
+/**
+ * Calculate the widest of the children of 'item'.
+ * Items that are off screen and that may be scrolled into view are
+ * included in the calculation.
+ * @param item - the tree item that was expanded
+ */
+void calculateWidestExpandingItem(TreeItem item) {
+ int itemIndex = item.getVisibleIndex();
+ int newMaximumItemWidth = getContentWidth();
+ int stopIndex = itemIndex + item.getVisibleItemCount();
+
+ for (int i = itemIndex + 1; i <= stopIndex; i++) {
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+/**
+ * Calculate the width of new items as they are scrolled into view.
+ * Precondition:
+ * topIndex has already been set to the new index.
+ * @param topIndexDifference - difference between old and new top
+ * index.
+ */
+void calculateWidestScrolledItem(int topIndexDifference) {
+ int visibleItemCount = getItemCountTruncated(getClientArea());
+ int newMaximumItemWidth = getContentWidth();
+ int topIndex = getTopIndex();
+ int stopIndex = topIndex;
+
+ if (topIndexDifference < 0) { // scrolled up?
+ if (Math.abs(topIndexDifference) > visibleItemCount) { // scrolled down more than one page (via quick thumb dragging)?
+ topIndexDifference = visibleItemCount * -1;
+ }
+ for (int i = stopIndex - topIndexDifference; i >= stopIndex; i--) { // check item width from old top index up to new one
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ }
+ else
+ if (topIndexDifference > 0) { // scrolled down?
+ if (topIndexDifference > visibleItemCount) { // scrolled down more than one page (via quick thumb dragging)?
+ topIndexDifference = visibleItemCount;
+ }
+ stopIndex += visibleItemCount;
+ for (int i = stopIndex - topIndexDifference; i < stopIndex; i++) {
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+/**
+ * Calculate the maximum item width of all displayed items.
+ */
+void calculateWidestShowingItem() {
+ TreeItem visibleItem;
+ int newMaximumItemWidth = 0;
+ int bottomIndex = getBottomIndex();
+ int paintStopX;
+
+ // add one to the loop end index because otherwise an item covered
+ // by the horizontal scroll bar would not be taken into acount and
+ // may become visible after this calculation. We're in trouble if
+ // that item is wider than the client area.
+ if (getHorizontalBar().getVisible() == true) {
+ bottomIndex++;
+ }
+ for (int i = getTopIndex(); i < bottomIndex; i++) {
+ visibleItem = getRoot().getVisibleItem(i);
+ if (visibleItem != null) {
+ paintStopX = visibleItem.getPaintStopX();
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, paintStopX);
+ }
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Collapse the tree item identified by 'item' if it is not
+ * already collapsed. Move the selection to the parent item
+ * if one of the collapsed items is currently selected.
+ * @param item - item that should be collapsed.
+ * @param notifyListeners -
+ * true=a Collapse event is sent
+ * false=no event is sent
+ */
+void collapse(TreeItem item, boolean notifyListeners) {
+ Event event;
+ int itemIndex;
+
+ if (item.getExpanded() == false) {
+ return;
+ }
+ collapseNoRedraw(item);
+ itemIndex = item.getVisibleIndex();
+ if (itemIndex != -1) { // if the item's parent is not collapsed (and the item is thus visible) do the screen updates
+ item.redrawExpanded(itemIndex - getTopIndex());
+ showSelectableItem(item);
+ calculateVerticalScrollbar();
+ calculateWidestShowingItem();
+ claimRightFreeSpace();
+ claimBottomFreeSpace();
+ }
+ if (notifyListeners == true) {
+ event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Collapse, event);
+ }
+}
+
+/**
+ * Collapse the tree item identified by 'item' if it is not
+ * already collapsed. Move the selection to the parent item
+ * if one of the collapsed items is currently selected.
+ * This method is used to hide the children if an item is deleted.
+ * certain redraw and scroll operations are not needed for this
+ * case.
+ * @param item - item that should be collapsed.
+ */
+void collapseNoRedraw(TreeItem item) {
+ int itemIndex;
+
+ if (item.getExpanded() == false) {
+ return;
+ }
+ if (isSelectedItemCollapsing(item) == true) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ update(); // call update to make sure that new selection is
+ // drawn before items are collapsed (looks better)
+ }
+ scrollForCollapse(item);
+ item.internalSetExpanded(false);
+}
+
+/**
+ * Answer the size of the receiver needed to display all or
+ * the first 50 items whichever is less.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size = super.computeSize(wHint, hHint, changed);
+ GC gc;
+ final int WidthCalculationCount = 50; // calculate item width for the first couple of items only
+ TreeRoots root = getRoot();
+ TreeItem item;
+ Image itemImage;
+ String itemText;
+ int width;
+ int newItemWidth = 0;
+
+ if (getContentWidth() == 0 && getItemCount() > 0) {
+ gc = new GC(this);
+ for (int i = 0; i < WidthCalculationCount; i++) {
+ item = root.getVisibleItem(i);
+ if (item == null) {
+ break; // no more items
+ }
+ itemImage = item.getImage();
+ itemText = item.getText();
+ width = 0;
+ if (itemImage != null) {
+ width += itemImage.getBounds().width;
+ }
+ if (itemText != null) {
+ width += gc.stringExtent(itemText).x;
+ }
+ newItemWidth = Math.max(newItemWidth, width);
+ }
+ if (newItemWidth > 0) {
+ size.x = newItemWidth;
+ }
+ gc.dispose();
+ }
+ return size;
+}
+/**
+ * Deselect all items of the receiver.
+ */
+public void deselectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ getRoot().deselectAll();
+ getSelectionVector().removeAllElements();
+ redraw();
+}
+/**
+ * Modifier Key Action
+ * None Collapse the selected item if expanded. Select
+ * parent item if selected item is already
+ * collapsed and if it's not the root item.
+ * Ctrl super.doArrowLeft(int);
+ * Shift see None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowLeft(int keyMask) {
+ TreeItem focusItem = (TreeItem) getLastFocus();
+ TreeItem parentItem;
+
+ if (focusItem == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ super.doArrowLeft(keyMask);
+ }
+ else
+ if (focusItem.getExpanded() == true) { // collapse if expanded
+ collapse(focusItem, true);
+ }
+ else
+ if (focusItem.isRoot() == false) { // go to the parent if there is one
+ parentItem = focusItem.getParentItem();
+ deselectAllExcept(parentItem);
+ selectNotify(parentItem);
+ }
+}
+/**
+ * Modifier Key Action
+ * None Expand selected item if collapsed. Select
+ * first child item if selected item is
+ * already expanded and there is a child item.
+ * Ctrl super.doArrowRight(keyMask);
+ * Shift see None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowRight(int keyMask) {
+ TreeItem focusItem = (TreeItem) getLastFocus();
+ TreeItem childItem;
+
+ if (focusItem == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ super.doArrowRight(keyMask);
+ }
+ else
+ if (focusItem.isLeaf() == false) {
+ if (focusItem.getExpanded() == false) { // expand if collapsed
+ expand(focusItem, true);
+ }
+ else { // go to the first child if there is one
+ childItem = focusItem.getItems()[0];
+ deselectAllExcept(childItem);
+ selectNotify(childItem);
+ }
+ }
+}
+/**
+ * Expand the selected item and all of its children.
+ */
+void doAsterix() {
+ expandAll((TreeItem) getLastFocus());
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ super.doDispose();
+ if (collapsedImage != null) {
+ collapsedImage.dispose();
+ }
+ if (expandedImage != null) {
+ expandedImage.dispose();
+ }
+ getRoot().dispose();
+ CONNECTOR_LINE_COLOR.dispose();
+ resetHierarchyIndicatorRect();
+}
+/**
+ * Collapse the selected item if it is expanded.
+ */
+void doMinus() {
+ TreeItem selectedItem = (TreeItem) getLastFocus();
+
+ if (selectedItem != null) {
+ collapse(selectedItem, true);
+ }
+}
+/**
+ * Expand the selected item if it is collapsed and if it
+ * has children.
+ */
+void doPlus() {
+ TreeItem selectedItem = (TreeItem) getLastFocus();
+
+ if (selectedItem != null && selectedItem.isLeaf() == false) {
+ expand(selectedItem, true);
+ }
+}
+/**
+ * Expand the tree item identified by 'item' if it is not already
+ * expanded. Scroll the expanded items into view.
+ * @param item - item that should be expanded
+ * @param notifyListeners -
+ * true=an Expand event is sent
+ * false=no event is sent
+ */
+void expand(TreeItem item, boolean notifyListeners) {
+ Event event = new Event();
+ int indexFromTop;
+ boolean nestedExpand = expandingItem != null;
+
+ if (item.getExpanded() == true) {
+ return;
+ }
+ if (nestedExpand == false) {
+ setExpandingItem(item);
+ }
+ scrollForExpand(item);
+ item.internalSetExpanded(true);
+ if (notifyListeners == true) {
+ event.item = item;
+ notifyListeners(SWT.Expand, event);
+ }
+ // redraw hierarchy image
+ item.redrawExpanded(item.getVisibleIndex() - getTopIndex());
+ calculateVerticalScrollbar();
+ if (nestedExpand == false && isVisible() == true) {
+ // Save the index here because showSelectableItem may change it
+ indexFromTop = item.getVisibleIndex() - getTopIndex();
+ showSelectableItem(item); // make expanded item visible. Could be invisible if the expand was caused by a key press.
+ calculateWidestExpandingItem(item);
+ scrollExpandedItemsIntoView(item);
+ }
+ if (nestedExpand == false) {
+ setExpandingItem(null);
+ }
+}
+/**
+ * Expand 'item' and all its children.
+ */
+void expandAll(TreeItem item) {
+ TreeItem items[];
+
+ if (item != null && item.isLeaf() == false) {
+ expand(item, true);
+ update();
+ items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ expandAll(items[i]);
+ }
+ }
+}
+/**
+ * Answer the image that is used as a hierarchy indicator
+ * for a collapsed hierarchy.
+ */
+Image getCollapsedImage() {
+ if (collapsedImage == null) {
+ collapsedImage = new Image(getDisplay(), CollapsedImageData);
+ }
+ return collapsedImage;
+}
+/**
+ * Answer the width of the item identified by 'itemIndex'.
+ */
+int getContentWidth(int itemIndex) {
+ TreeItem item = getRoot().getVisibleItem(itemIndex);
+ int paintStopX = 0;
+
+ if (item != null) {
+ paintStopX = item.getPaintStopX();
+ }
+ return paintStopX;
+}
+/**
+ * Answer the image that is used as a hierarchy indicator
+ * for an expanded hierarchy.
+ */
+Image getExpandedImage() {
+ if (expandedImage == null) {
+ expandedImage = new Image(getDisplay(), ExpandedImageData);
+ }
+ return expandedImage;
+}
+/**
+ * Answer the rectangle enclosing the hierarchy indicator of a tree item.
+ *
+ * Note:
+ * Assumes that the hierarchy indicators for expanded and
+ * collapsed state are the same size.
+ * @return
+ * The rectangle enclosing the hierarchy indicator.
+ */
+Rectangle getHierarchyIndicatorRect() {
+ int itemHeight = getItemHeight();
+ Image hierarchyImage;
+ Rectangle imageBounds;
+
+ if (hierarchyIndicatorRect == null && itemHeight != -1) {
+ hierarchyImage = getCollapsedImage();
+ if (hierarchyImage != null) {
+ imageBounds = hierarchyImage.getBounds();
+ }
+ else {
+ imageBounds = new Rectangle(0, 0, 0, 0);
+ }
+ hierarchyIndicatorRect = new Rectangle(
+ 0,
+ (itemHeight - imageBounds.height) / 2 + (itemHeight - imageBounds.height) % 2,
+ imageBounds.width,
+ imageBounds.height);
+ }
+ return hierarchyIndicatorRect;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+int getIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null) {
+ index = ((TreeItem) item).getGlobalIndex();
+ }
+ return index;
+}
+/**
+ * Answer the number of root items.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getRoot().getItemCount();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the root items of the receiver as an Array.
+ */
+public TreeItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TreeItem childrenArray[] = new TreeItem[getItemCount()];
+
+ getRoot().getChildren().copyInto(childrenArray);
+ return childrenArray;
+}
+/**
+ * Answer the number of sub items of 'item' that do not fit in the
+ * tree client area.
+ */
+int getOffScreenItemCount(TreeItem item) {
+ int itemIndexFromTop = item.getVisibleIndex() - getTopIndex();
+ int spaceRemaining = getItemCountWhole()-(itemIndexFromTop+1);
+ int expandedItemCount = item.getVisibleItemCount();
+
+ return expandedItemCount - spaceRemaining;
+}
+/**
+ * Answer the parent item of the receiver.
+ * This is null because the Tree widget does not have a parent item.
+ */
+public TreeItem getParentItem() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return null;
+}
+/**
+ * Answer the object that holds the root items of the receiver.
+ */
+TreeRoots getRoot() {
+ return root;
+}
+/**
+ * Answer the selected tree items.
+ * @return an Array of DrawnTreeItems containing the selected items.
+ * An empty Array if no items are selected.
+ */
+public TreeItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selectionVector = getSelectionVector();
+ TreeItem[] selectionArray = new TreeItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Collapsed items are not visible.
+ */
+int getVisibleIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null) {
+ index = ((AbstractTreeItem) item).getVisibleIndex();
+ }
+ return index;
+}
+/**
+ * Answer the SelectableItem located at 'itemIndex'
+ * in the receiver.
+ * @param itemIndex - location of the SelectableItem
+ * object to return
+ */
+SelectableItem getVisibleItem(int itemIndex) {
+ return getRoot().getVisibleItem(itemIndex);
+}
+/**
+ * Answer the number of visible items of the receiver.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Collapsed items are not visible.
+ */
+int getVisibleItemCount() {
+ return getRoot().getVisibleItemCount();
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+int getVisibleRedrawY(SelectableItem item) {
+ int redrawY = getRedrawY(item);
+
+ if (redrawY < 0 || redrawY > getClientArea().height) {
+ redrawY = -1;
+ }
+ return redrawY;
+}
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.Paint:
+ paint(event);
+ break;
+ case SWT.MouseDown:
+ mouseDown(event);
+ break;
+ case SWT.MouseDoubleClick:
+ mouseDoubleClick(event);
+ break;
+ default:
+ super.handleEvents(event);
+ }
+}
+/**
+ * Initialize the receiver.
+ */
+void initialize() {
+ resetRoot(); // has to be at very top because super class uses
+ // functionality that relies on the TreeRoots object
+ super.initialize();
+}
+/**
+ * Initialize the ImageData used for the expanded/collapsed images.
+ */
+static void initializeImageData() {
+ PaletteData fourBit = new PaletteData(
+ new RGB[] {new RGB(0, 0, 0), new RGB (128, 0, 0), new RGB (0, 128, 0), new RGB (128, 128, 0), new RGB (0, 0, 128), new RGB (128, 0, 128), new RGB (0, 128, 128), new RGB (128, 128, 128), new RGB (192, 192, 192), new RGB (255, 0, 0), new RGB (0, 255, 0), new RGB (255, 255, 0), new RGB (0, 0, 255), new RGB (255, 0, 255), new RGB (0, 255, 255), new RGB (255, 255, 255)});
+
+ CollapsedImageData = new ImageData(
+ 9, 9, 4, // width, height, depth
+ fourBit, 4,
+ new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});
+ CollapsedImageData.transparentPixel = 15; // use white for transparency
+ ExpandedImageData = new ImageData(
+ 9, 9, 4, // width, height, depth
+ fourBit, 4,
+ new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});
+ ExpandedImageData.transparentPixel = 15; // use white for transparency
+}
+/**
+ * Set event listeners for the receiver.
+ */
+void installListeners() {
+ Listener listener = getListener();
+
+ super.installListeners();
+ addListener(SWT.Paint, listener);
+ addListener(SWT.MouseDown, listener);
+ addListener(SWT.MouseDoubleClick, listener);
+}
+/**
+ * Answer whether the receiver is currently expanding a sub tree
+ * with 'item' in it.
+ * Used for performance optimizations.
+ */
+boolean isExpandingItem(SelectableItem item) {
+ TreeItem parentItem;
+
+ if (expandingItem == null || item == null || (item instanceof TreeItem) == false) {
+ return false;
+ }
+ parentItem = ((TreeItem) item).getParentItem();
+ return (parentItem == expandingItem || isExpandingItem(parentItem));
+}
+/**
+ * Answer whether the children of 'collapsingItem' contain
+ * at least one selected item.
+ */
+boolean isSelectedItemCollapsing(TreeItem collapsingItem) {
+ Enumeration selection = getSelectionVector().elements();
+ TreeItem item;
+ int selectedItemIndex;
+ int collapsingItemIndex = collapsingItem.getVisibleIndex();
+ int lastCollapsedItemIndex = collapsingItemIndex + collapsingItem.getVisibleItemCount();
+
+ if (collapsingItemIndex == -1) { // is the collapsing item in a collapsed subtree?
+ return false; // then neither it nor its children are selected
+ }
+ while (selection.hasMoreElements() == true) {
+ item = (TreeItem) selection.nextElement();
+ selectedItemIndex = item.getVisibleIndex();
+ if ((selectedItemIndex > collapsingItemIndex) &&
+ (selectedItemIndex <= lastCollapsedItemIndex)) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Test whether the mouse click specified by 'event' was a
+ * valid selection or expand/collapse click.
+ * @return
+ * One of ActionExpandCollapse, ActionSelect, ActionNone, ActionCheck
+ * specifying the action to be taken on the click.
+ */
+int itemAction(TreeItem item, int x, int y) {
+ int action = ActionNone;
+ int itemHeight = getItemHeight();
+ int offsetX;
+ int offsetY;
+ Point offsetPoint;
+
+ if (item != null) {
+ offsetX = x - item.getPaintStartX();
+ offsetY = y - itemHeight * (y / itemHeight);
+ offsetPoint = new Point(offsetX, offsetY);
+ if ((item.isLeaf() == false) &&
+ (getHierarchyIndicatorRect().contains(offsetPoint) == true)) {
+ action |= ActionExpandCollapse;
+ }
+ else
+ if (item.isSelectionHit(offsetPoint) == true) {
+ action |= ActionSelect;
+ }
+ else
+ if (item.isCheckHit(new Point(x, y)) == true) {
+ action |= ActionCheck;
+ }
+ }
+ return action;
+}
+/**
+ * The table item 'changedItem' has changed. Redraw the whole
+ * item in that column. Include the text in the redraw because
+ * an image set to null requires a redraw of the whole item anyway.
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ int oldItemHeight = getItemHeight();
+ Point oldImageExtent = getImageExtent();
+
+ if (isExpandingItem(changedItem) == false) {
+ super.itemChanged(changedItem, repaintStartX, repaintWidth);
+ }
+ else {
+ calculateItemHeight(changedItem);
+ }
+ if ((oldItemHeight != getItemHeight()) || // only reset items if the item height or
+ (oldImageExtent != getImageExtent())) { // image size has changed. The latter will only change once,
+ // from null to a value-so it's safe to test using !=
+ getRoot().reset(); // reset cached data of all items in the receiver
+ resetHierarchyIndicatorRect();
+ redraw(); // redraw all items if the image extent has changed. Fixes 1FRIHPZ
+ }
+ else {
+ ((AbstractTreeItem) changedItem).reset(); // reset the item that has changed when the tree item
+ // height has not changed (otherwise the item caches old data)
+ // Fixes 1FF6B42
+ }
+ if (repaintWidth != 0) {
+ calculateWidestShowingItem();
+ claimRightFreeSpace(); // otherwise scroll bar may be reset, but not horizontal offset
+ // Fixes 1G4SBJ3
+ }
+}
+/**
+ * A key was pressed.
+ * Call the appropriate key handler method.
+ * @param event - the key event
+ */
+void keyDown(Event event) {
+ super.keyDown(event);
+ switch (event.character) {
+ case '+':
+ doPlus();
+ break;
+ case '-':
+ doMinus();
+ break;
+ case '*':
+ doAsterix();
+ break;
+ }
+}
+
+/**
+ * A mouse double clicked occurred over the receiver.
+ * Expand/collapse the clicked item. Do nothing if no item was clicked.
+ */
+void mouseDoubleClick(Event event) {
+ int hitItemIndex = event.y / getItemHeight();
+ TreeItem hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ Event newEvent;
+
+ if (hitItem == null) {
+ return;
+ }
+ if (hooks(SWT.DefaultSelection) == true) {
+ newEvent = new Event();
+ newEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, newEvent);
+ return;
+ }
+ if (hitItem.getItemCount() == 0) {
+ return; // an item was hit but it does not have children
+ }
+ if (itemAction(hitItem, event.x, event.y) == ActionSelect) {
+ if (hitItem.getExpanded() == true) {
+ collapse(hitItem, true);
+ }
+ else {
+ expand(hitItem, true);
+ }
+ }
+}
+/**
+ * The mouse pointer was pressed down on the receiver.
+ * Handle the event according to the position of the mouse click.
+ */
+void mouseDown(Event event) {
+ int hitItemIndex;
+ TreeItem hitItem;
+ SelectableItem selectionItem = getLastSelection();
+ int itemAction;
+
+ if (event.button != 1) { // only react to button one clicks.
+ return;
+ }
+ hitItemIndex = event.y / getItemHeight();
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem == null) {
+ return;
+ }
+ switch (itemAction = itemAction(hitItem, event.x, event.y)) {
+ case ActionExpandCollapse:
+ if (hitItem.getExpanded() == true) {
+ collapse(hitItem, true);
+ }
+ else {
+ expand(hitItem, true);
+ }
+ break;
+ case ActionSelect:
+ doMouseSelect(hitItem, hitItemIndex + getTopIndex(), event.stateMask, event.button);
+ break;
+ case ActionCheck:
+ doCheckItem(hitItem);
+ break;
+ }
+ if (itemAction != ActionSelect && selectionItem == null) {
+ selectionItem = getRoot().getVisibleItem(getTopIndex()); // select the top item if no item was selected before
+ selectNotify(selectionItem);
+ }
+}
+/**
+ * A paint event has occurred. Display the invalidated items.
+ * @param event - expose event specifying the invalidated area.
+ */
+void paint(Event event) {
+ int visibleRange[] = getIndexRange(event.getBounds());
+
+ paintItems(event.gc, visibleRange[0], visibleRange[1] + 1); // + 1 to paint the vertical line
+ // connection the last item we really
+ // want to paint with the item after that.
+}
+/**
+ * Paint tree items on 'gc' starting at index 'topPaintIndex' and
+ * stopping at 'bottomPaintIndex'.
+ * @param gc - GC to draw tree items on.
+ * @param topPaintIndex - index of the first item to draw
+ * @param bottomPaintIndex - index of the last item to draw
+ */
+void paintItems(GC gc, int topPaintIndex, int bottomPaintIndex) {
+ TreeItem visibleItem;
+ int itemHeight = getItemHeight();
+
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ visibleItem = getRoot().getVisibleItem(i + getTopIndex());
+ if (visibleItem != null) {
+ visibleItem.paint(gc, i * itemHeight);
+ }
+ }
+}
+/**
+ * 'item' has been added to or removed from the receiver.
+ * Repaint part of the tree to update the vertical hierarchy
+ * connectors and hierarchy image.
+ * @param modifiedItem - the added/removed item
+ * @param modifiedIndex - index of the added/removed item
+ */
+void redrawAfterModify(SelectableItem modifiedItem, int modifiedIndex) {
+ int redrawStartY;
+ int redrawStopY;
+ int itemChildIndex = ((TreeItem) modifiedItem).getIndex();
+ int topIndex = getTopIndex();
+ int itemHeight = getItemHeight();
+ int redrawItemIndex;
+ int itemCount;
+ AbstractTreeItem parentItem = ((TreeItem) modifiedItem).getParentItem();
+ AbstractTreeItem redrawItem = null;
+
+ if (redrawParentItem(modifiedItem) == false) {
+ return;
+ }
+ if (parentItem == null) { // a root item is added/removed
+ parentItem = getRoot();
+ }
+ itemCount = parentItem.getItemCount();
+ // redraw hierarchy decorations of preceeding item if the last item at a tree
+ // level was added/removed
+ // otherwise, if the first item was removed, redraw the parent to update hierarchy icon
+ if (itemChildIndex > 0) { // more than one item left at this tree level
+ // added/removed last item at this tree level? have to test >=.
+ // when removing last item, item index is outside itemCount
+ if (itemChildIndex >= itemCount - 1) {
+ redrawItem = (AbstractTreeItem) parentItem.getChildren().elementAt(itemChildIndex - 1);
+ }
+ }
+ else
+ if (getVisibleItemCount() > 0 && itemCount < 2) { // last item at this level removed/first item added?
+ redrawItem = parentItem; // redraw parent item to update hierarchy icon
+ }
+ if (redrawItem != null) {
+ redrawItemIndex = redrawItem.getVisibleIndex();
+ if (modifiedIndex == -1) {
+ modifiedIndex = redrawItemIndex + 1;
+ }
+ redrawStartY = (redrawItemIndex - topIndex) * itemHeight;
+ redrawStopY = (modifiedIndex - topIndex) * itemHeight;
+ redraw(
+ 0,
+ redrawStartY,
+ redrawItem.getCheckboxXPosition(), // only redraw up to and including hierarchy icon to avoid flashing
+ redrawStopY - redrawStartY, false);
+ }
+ if (modifiedIndex == 0) { // added/removed first item ?
+ redraw(0, 0, getClientArea().width, getItemHeight() * 2, false);// redraw new first two items to
+ // fix vertical hierarchy line
+ }
+}
+
+/**
+ * Determine if part of the tree hierarchy needs to be redrawn.
+ * The hierarchy icon of the parent item of 'item' needs to be redrawn if
+ * 'item' is added as the first child or removed as the last child.
+ * Hierarchy lines need to be redrawn if 'item' is the last in a series of
+ * children.
+ * @param item - tree item that is added or removed.
+ * @return true=tree hierarchy needs to be redrawn. false=no redraw necessary
+ */
+boolean redrawParentItem(SelectableItem item) {
+ TreeItem parentItem = ((TreeItem) item).getParentItem();
+ TreeItem parentItem2;
+ boolean redraw = false;
+
+ // determine if only the hierarchy icon needs to be redrawn
+ if (parentItem != null) {
+ parentItem2 = parentItem.getParentItem();
+ if ((parentItem2 == null || parentItem2.getExpanded() == true) && parentItem.getChildren().size() < 2) {
+ redraw = true;
+ }
+ }
+ // redraw is only neccessary when the receiver is not currently
+ // expanding 'item' or a parent item or if the parent item is expanded
+ // or if the hierarchy icon of the parent item needs to be redrawn
+ if (isExpandingItem(item) == false && parentItem == null || parentItem.getExpanded() == true || redraw == true) {
+ redraw = true;
+ }
+ else {
+ redraw = false;
+ }
+ return redraw;
+}
+
+/**
+ * Remove all items of the receiver.
+ */
+public void removeAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ setRedraw(false);
+ getRoot().dispose();
+ resetRoot();
+ reset();
+ calculateWidestShowingItem();
+ calculateVerticalScrollbar();
+ setRedraw(true);
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - tree item that should be removed from the
+ * receiver-must be a root item.
+ */
+void removeItem(TreeItem item) {
+ getRoot().removeItem(item);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener (SWT.Selection, listener);
+ removeListener (SWT.DefaultSelection, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeTreeListener(TreeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener (SWT.Expand, listener);
+ removeListener (SWT.Collapse, listener);
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Recalculate the content width.
+ */
+void removedItem(SelectableItem item) {
+ if (isExpandingItem(item) == false) {
+ super.removedItem(item);
+ }
+ calculateWidestShowingItem();
+ claimRightFreeSpace();
+}
+/**
+ * Notification that 'item' is about to be removed from the tree.
+ * Update the item selection if neccessary.
+ * @param item - item that is about to be removed from the tree.
+ */
+void removingItem(SelectableItem item) {
+ Vector selection = getSelectionVector();
+ TreeItem parentItem = ((TreeItem) item).getParentItem();
+ TreeItem newSelectionItem = null;
+ boolean isLastSelected = (selection.size() == 1) && (selection.elementAt(0) == item);
+ int itemIndex = getVisibleIndex(item);
+
+ if (isLastSelected == true) {
+ // try selecting the following item
+ newSelectionItem = (TreeItem) getVisibleItem(itemIndex + 1);
+ if (newSelectionItem == null || newSelectionItem.getParentItem() != parentItem) {
+ // select parent item if there is no item following the removed
+ // one on the same tree level
+ newSelectionItem = parentItem;
+ }
+ if (newSelectionItem != null) {
+ selectNotify(newSelectionItem);
+ }
+ }
+ super.removingItem(item);
+ if (isExpandingItem(item) == false) {
+ // redraw plus/minus image, hierarchy lines,
+ // redrawing here assumes that no update happens between now and
+ // after the item has actually been removed. Otherwise this call
+ // would need to be in removedItem and we would need to store the
+ // "itemIndex" here to redraw correctly.
+ redrawAfterModify(item, itemIndex);
+ }
+}
+/**
+ * Reset the rectangle enclosing the hierarchy indicator to null.
+ * Forces a recalculation next time getHierarchyIndicatorRect is called.
+ */
+void resetHierarchyIndicatorRect() {
+ hierarchyIndicatorRect = null;
+}
+/**
+ * Reset state that is dependent on or calculated from the items
+ * of the receiver.
+ */
+void resetItemData() {
+ setContentWidth(0);
+ resetHierarchyIndicatorRect();
+ super.resetItemData();
+}
+/**
+ * Reset the object holding the root items of the receiver.
+ */
+void resetRoot() {
+ root = new TreeRoots(this);
+}
+/**
+ * The receiver has been resized. Recalculate the content width.
+ */
+void resize(Event event) {
+ int oldItemCount = getVerticalBar().getPageIncrement();
+
+ super.resize(event);
+ if (getItemCountWhole() > oldItemCount) { // window resized higher?
+ calculateWidestShowingItem(); // recalculate widest item since a longer item may be visible now
+ }
+}
+/**
+ * Display as many expanded tree items as possible.
+ * Scroll the last expanded child to the bottom if all expanded
+ * children can be displayed.
+ * Otherwise scroll the expanded item to the top.
+ * @param item - the tree item that was expanded
+ */
+void scrollExpandedItemsIntoView(TreeItem item) {
+ int itemCountOffScreen = getOffScreenItemCount(item);
+ int newTopIndex = getTopIndex() + itemCountOffScreen;
+
+ if (itemCountOffScreen > 0) {
+ newTopIndex = Math.min(item.getVisibleIndex(), newTopIndex); // make sure the expanded item is never scrolled out of view
+ setTopIndex(newTopIndex, true);
+ }
+}
+/**
+ * Scroll the items following the children of 'collapsedItem'
+ * below 'collapsedItem' to cover the collapsed children.
+ * @param collapsedItem - item that has been collapsed
+ */
+void scrollForCollapse(TreeItem collapsedItem) {
+ Rectangle clientArea = getClientArea();
+ int topIndex = getTopIndex();
+ int itemCount = collapsedItem.getVisibleItemCount();
+ int scrollYPositions[] = calculateChildrenYPos(collapsedItem);
+
+ if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {
+ return;
+ }
+ if (topIndex + getItemCountWhole() == getVisibleItemCount() && itemCount < topIndex) {
+ // scroll from top if last item is at bottom and will stay at
+ // bottom after collapse. Avoids flash caused by too much bit
+ // blitting (which force update and thus premature redraw)
+ int height = scrollYPositions[1] - scrollYPositions[0];
+ scroll(
+ 0, 0, // destination x, y
+ 0, -height, // source x, y
+ clientArea.width, scrollYPositions[0]+height, true);
+ setTopIndexNoScroll(topIndex - itemCount, true);
+ }
+ else {
+ scroll(
+ 0, scrollYPositions[0], // destination x, y
+ 0, scrollYPositions[1], // source x, y
+ clientArea.width, clientArea.height - scrollYPositions[0], true);
+ }
+}
+/**
+ * Scroll the items following 'expandedItem' down to make
+ * space for the children of 'expandedItem'.
+ * @param expandedItem - item that has been expanded.
+ */
+void scrollForExpand(TreeItem expandedItem) {
+ int scrollYPositions[];
+ Rectangle clientArea = getClientArea();
+
+ expandedItem.internalSetExpanded(true);
+ scrollYPositions = calculateChildrenYPos(expandedItem);
+ expandedItem.internalSetExpanded(false);
+ if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {
+ return;
+ }
+ scroll(
+ 0, scrollYPositions[1], // destination x, y
+ 0, scrollYPositions[0], // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void scrollHorizontal(int numPixel) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+void scrollVertical(int scrollIndexCount) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ 0, 0, // destination x, y
+ 0, scrollIndexCount * getItemHeight(), // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select all items of the receiver if it is in multiple
+ * selection mode.
+ * A SWT.Selection event will not be sent.
+ * Do nothing if the receiver is in single selection mode.
+ */
+public void selectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selection = getSelectionVector();
+
+ if (isMultiSelect() == true) {
+ selection = getRoot().selectAll(selection);
+ setSelectionVector(selection);
+ }
+}
+/**
+ * Set the item that is currently being expanded to 'item'.
+ * Used for performance optimizations.
+ */
+void setExpandingItem(TreeItem item) {
+ expandingItem = item;
+}
+/**
+ * The font is changing. Reset and recalculate the item
+ * height using all items of the receiver.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Stack children = new Stack(); // traverse the tree depth first
+ Enumeration elements;
+ AbstractTreeItem item;
+
+ if (font != null && font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+
+ // Call itemChanged for all tree items
+ elements = getRoot().getChildren().elements();
+ while (elements.hasMoreElements() == true) {
+ children.push(elements.nextElement());
+ }
+ while (children.empty() == false) {
+ item = (AbstractTreeItem) children.pop();
+ itemChanged(item, 0, getClientArea().width);
+ elements = item.getChildren().elements();
+ while (elements.hasMoreElements() == true) {
+ children.push(elements.nextElement());
+ }
+ }
+ setRedraw(true); // re-enable redraw
+}
+/**
+ * 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.
+ * <p>
+ * @param item the insert item. Null will clear the insertion mark.
+ * @param after true places the insert mark above 'item'. false places
+ * the insert mark below 'item'.
+ */
+public void setInsertMark(TreeItem item, boolean before){
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ motif_setInsertMark(item, !before);
+}
+/**
+ * Select the items stored in 'selectionItems'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+public void setSelection(TreeItem selectionItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * Set the index of the first visible item in the tree client area
+ * to 'index'.
+ * Scroll the new top item to the top of the tree.
+ * @param index - 0-based index of the first visible item in the
+ * tree's client area.
+ * @param adjustScrollbar -
+ * true = the vertical scroll bar is set to reflect the new top index.
+ * false = the vertical scroll bar position is not modified.
+ */
+void setTopIndex(int index, boolean adjustScrollbar) {
+ int indexDiff = index-getTopIndex();
+
+ super.setTopIndex(index, adjustScrollbar);
+ calculateWidestScrolledItem(indexDiff);
+}
+/**
+ * Make 'item' visible by expanding its parent items and scrolling
+ * it into the receiver's client area if necessary.
+ * An SWT.Expand event is going to be sent for every parent item
+ * that is expanded to make 'item' visible.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+public void showItem(TreeItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ showSelectableItem(item);
+}
+/**
+ * Make 'item' visible by expanding its parent items and scrolling
+ * it into the receiver's client area if necessary.
+ * An SWT.Expand event is going to be sent for every parent item
+ * that is expanded to make 'item' visible.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+void showSelectableItem(SelectableItem item) {
+ if (item.getSelectableParent() != this) {
+ return;
+ }
+ if (((TreeItem) item).isVisible() == false) {
+ ((TreeItem) item).makeVisible();
+ }
+ super.showSelectableItem(item);
+}
+/**
+ * Return the item at the specified location in the widget.
+ * Return null if there is no item at the specified location
+ * or if the location is outside the widget client area.
+ */
+public TreeItem getItem(Point point) {
+ int itemHeight;
+ int hitItemIndex;
+ TreeItem hitItem;
+
+ if (getClientArea().contains(point) == false) {
+ return null;
+ }
+ itemHeight = getItemHeight();
+ hitItemIndex = point.y / itemHeight;
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem != null) {
+ point.x -= hitItem.getPaintStartX();
+ point.y -= itemHeight * hitItemIndex;
+ if (hitItem.isSelectionHit(point) == false) {
+ hitItem = null;
+ }
+ }
+ return hitItem;
+}
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getSelectionCount();
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.showSelection();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java
new file mode 100755
index 0000000000..cb0aba6a89
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeItem.java
@@ -0,0 +1,1146 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class represents leaf, non-leaf and root tree items.
+ * leaf items don't have any children. non-leaf items have one
+ * or more children.
+ * Root items don't have a parent item. Root items are either
+ * leaf or non-leaf items.
+ *
+ * This class caches geometrical data for drawing..
+ * A description of the cached data follows:
+ *
+ * | 1 || 5 |
+ * | 2 | | 6 |
+ * |3 7|
+ * _____ | 4 |f| |8
+ * | | ____
+ * | - | ===== {image} root 9
+ * |_____| |
+ * |b|c| |d|
+ * | e |
+ *
+ * Widths are measured between vertical lines.
+ *
+ * Cached item rendering data:
+ * 1 = getDecorationsWidth
+ * 2 = getHierarchyIndicatorRect
+ * 3 = getPaintStartX
+ * 4 = getItemConnectorWidth
+ * 5 = getItemWidth
+ * 6 = getSelectionWidth
+ * 7 = getPaintStopX
+ * 8 - getTextXPos
+ * 9 = getTextYPosition
+ *
+ * Rendering constants:
+ * 4 = DEFAULT_ITEM_CONNECTOR_WIDTH, used when no image is set in the tree.
+ * Otherwise it is the image width.
+ * b = IMAGE_PADDING
+ * c = TEXT_INDENT
+ * d = SELECTION_PADDING
+ * e = ITEM_NOIMAGE_OFFSET
+ * f = ITEM_CONNECTOR_PADDING;
+
+ */
+public /*final*/ class TreeItem extends AbstractTreeItem {
+ private static final int DEFAULT_ITEM_CONNECTOR_WIDTH = 8; // Default width of the horizontal line connecting
+ // items with the vertical lines. Only used when
+ // no image is set in the tree. Normally connector
+ // line width is half the image width.
+ private static final int ITEM_CONNECTOR_PADDING = 2; // Added to the calculated item connector width
+ private static final int IMAGE_PADDING = 3; // Space behind bitmap
+ private static final int ITEM_NOIMAGE_OFFSET = 8; // Offset added to the calculated paint position where
+ // an item starts drawing. To be used when no item
+ // image has been set. Otherwise children would start
+ // drawing at the end of the horizontal item connector
+ // of their parent.
+ private static final int ROOT_INDENT = 5; // Indent of root items
+ private static final int SELECTION_PADDING = 2; // Space behind text
+ private static final int TEXT_INDENT = 2; // Identation of the item label
+
+ // basic item info
+ private TreeItem parentItem;
+ private int index; // index in the parent item
+
+ // geometrical item info
+ private int paintStartX = -1; // X coordinate of the upper-left corner of the
+ // receivers bounding rectangle
+ private Point itemExtent; // Size of the item (image + label)
+ private Point imageExtent; // original size of the item image
+ private int textYPosition = -1; // Centered y position of the item text
+/**
+ * Create a root item and add it to the tree widget identified
+ * by 'parent'.
+ * @param parent - Tree widget the receiver is added to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+public TreeItem(Tree parent, int swtStyle) {
+ this(parent, swtStyle, checkNull(parent).getItemCount());
+}
+/**
+ * Create a root item and add it to the tree widget identified
+ * by 'parent'.
+ * @param parent - Tree widget the receiver is added to.
+ * @param swtStyle - widget style. see Widget class for details
+ * @param position - position in 'parentItem' the receiver will
+ * be inserted at
+ */
+public TreeItem(Tree parent, int swtStyle, int position) {
+ super(parent, swtStyle);
+ parent.addItem(this, position);
+}
+/**
+ * Create a root item with 'parentItem' as the parent item.
+ * @param parentItem - the parent item of the receiver
+ * @param swtStyle - widget style. see Widget class for details
+ */
+public TreeItem(TreeItem parentItem, int swtStyle) {
+ this(parentItem, swtStyle, checkNull(parentItem).getItemCount());
+}
+/**
+ * Create a root item with 'parentItem' as the parent item.
+ * @param parentItem - the parent item of the receiver
+ * @param swtStyle - widget style. see Widget class for details
+ * @param position - position in 'parentItem' the receiver will
+ * be inserted at
+ */
+public TreeItem(TreeItem parentItem, int swtStyle, int position) {
+ super(checkNull(parentItem).getParent(), swtStyle);
+ setParentItem(parentItem);
+ parentItem.add(this, position);
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+void calculateVisibleItemCount() {
+ Vector children;
+ TreeItem child;
+ int visibleItemCount = 0;
+
+ // check isExpanded field directly for performance
+ if (internalGetExpanded() == true) {
+ children = getChildren();
+ visibleItemCount = children.size();
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ visibleItemCount += child.getVisibleItemCount();
+ }
+ }
+ setVisibleItemCount(visibleItemCount);
+ calculateVisibleItemCountParent();
+}
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+void calculateVisibleItemCountParent() {
+ TreeItem parentItem = getParentItem();
+
+ if (parentItem != null) {
+ parentItem.calculateVisibleItemCount();
+ }
+ else {
+ getParent().getRoot().calculateVisibleItemCount();
+ }
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'tree' is null.
+ * Otherwise return 'tree'
+ */
+static Tree checkNull(Tree tree) {
+ if (tree == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return tree;
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'item' is null.
+ * Otherwise return 'item'
+ */
+static TreeItem checkNull(TreeItem item) {
+ if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Notify the parent that the receiver is being removed.
+ * Reset cached data.
+ */
+void doDispose() {
+ TreeItem parentItem = getParentItem();
+
+ if (parentItem != null) {
+ parentItem.removeItem(this);
+ }
+ else {
+ getParent().removeItem(this);
+ }
+ setParentItem(null);
+ setImageExtent(null);
+ setItemExtent(null);
+ setIndex(-1);
+ setPaintStartX(-1);
+ setTextYPosition(-1);
+}
+/**
+ * Draw the hierarchy indicator at 'position'.
+ *
+ * Note:
+ * Assumes that the hierarchy indicators for the expanded and
+ * collapsed state are the same size.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawHierarchyIndicator(GC gc, Point position) {
+ Tree parent = getParent();
+ Image hierarchyImage;
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int x = position.x;
+ int y = position.y;
+ int yCenter = y + parent.getItemHeight() / 2;
+ Point connectorLinePosition;
+
+ if (isLeaf() == false) {
+ if (getExpanded() == true) {
+ hierarchyImage = parent.getExpandedImage();
+ }
+ else {
+ hierarchyImage = parent.getCollapsedImage();
+ }
+ if (hierarchyImage != null) {
+ gc.drawImage(hierarchyImage, x + indicatorRectangle.x, y + indicatorRectangle.y);
+ }
+ connectorLinePosition = new Point(x + indicatorRectangle.width, yCenter);
+ }
+ else {
+ connectorLinePosition = new Point(
+ x + indicatorRectangle.width / 2
+ + indicatorRectangle.width % 2, yCenter); // % 2 in order to not start the next hierarchy
+ // component at the middle of the icon but after.
+ }
+ return connectorLinePosition;
+}
+/**
+ * Draw a horizontal line connecting the item image (or label
+ * if there is no image) to the vertical line connecting to
+ * the parent.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawHorizontalItemConnector(GC gc, Point position) {
+ int itemConnectorEndPos = position.x + getItemConnectorWidth() - 1; // -1 because the position of the last pixel needs to be calculated
+
+ gc.drawLine(position.x, position.y, itemConnectorEndPos, position.y);
+ return new Point(itemConnectorEndPos + 1, position.y); // + 1 in order to resume drawing after line not on end of line
+}
+/**
+ * Display the item image at 'position' using 'gc'.
+ * @param gc - GC to draw on
+ * @param position - position on the GC to draw at
+ * @return position to continue drawing
+ */
+Point drawImage(GC gc, Point destinationPosition) {
+ Tree parent = getParent();
+ Image image = getImage();
+ Point sourceImageExtent;
+ Point destinationImageExtent = parent.getImageExtent();
+ int yCenter;
+
+ if (image != null) {
+ sourceImageExtent = getImageExtent();
+ yCenter = (parent.getItemHeight() - destinationImageExtent.y) / 2;
+ gc.drawImage(
+ image,
+ 0, 0, // source x, y
+ sourceImageExtent.x, sourceImageExtent.y, // source width, height
+ destinationPosition.x, destinationPosition.y + yCenter, // destination x, y
+ destinationImageExtent.x, destinationImageExtent.y); // destination width, height
+ }
+ if (destinationImageExtent != null) {
+ destinationPosition.x += destinationImageExtent.x + IMAGE_PADDING;
+ }
+ return destinationPosition;
+}
+/**
+ * Draw a filled rectangle indicating the item selection state
+ * The rectangle will be filled with the selection color if the
+ * receiver is selected. Otherwise the rectangle will be filled
+ * in the background color to remove the selection.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawSelection(GC gc, Point position) {
+ Tree parent = getParent();
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ }
+ gc.fillRectangle(position.x, position.y, selectionExtent.x, selectionExtent.y);
+ if (isSelected() == true) {
+ gc.setBackground(parent.getBackground());
+ }
+}
+/**
+ * Draw a rectangle enclosing the item label. The rectangle
+ * indicates that the receiver was selected last and that it has
+ * the input focus.
+ * The rectangle will only be drawn if the receiver is selected.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawSelectionFocus(GC gc, Point position) {
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (getParent().hasFocus(this) == true) {
+ gc.drawFocus(
+ position.x, position.y,
+ selectionExtent.x, selectionExtent.y);
+ }
+}
+/**
+ * Draw the item label at 'position' using 'gc'.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawText(GC gc, Point position) {
+ Tree parent = getParent();
+ String text = getText();
+
+ if (text != null) {
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ }
+ gc.drawString(text, position.x, position.y);
+ if (isSelected() == true) {
+ gc.setBackground(parent.getBackground());
+ gc.setForeground(parent.getForeground());
+ }
+ }
+}
+/**
+ * Draw a vertical line connecting the horizontal connector line
+ * with that of the previous item.
+ * Called recursively to draw the lines on all tree levels.
+ * @param gc - GC to draw on.
+ * @param yPosition - y position of the upper side of the
+ * receiver's bounding box.
+ * @param isFirstChild - method is called to draw a vertical
+ * line for the first child. Leave room for the hierarchy icon.
+ */
+void drawVerticalItemConnector(GC gc, int yPosition, boolean isFirstChild) {
+ Tree parent = getParent();
+ TreeItem nextDrawItem = getParentItem();
+ AbstractTreeItem parentItem = nextDrawItem;
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int itemHeight = parent.getItemHeight();
+ int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;
+ int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;
+ int lineX = getPaintStartX() + indicatorRectangle.width / 2;
+ int lineStartY = yPosition - itemHeightDiv2;
+ int lineEndY = yPosition + itemHeightDiv2;
+
+ if (parentItem == null) {
+ parentItem = parent.getRoot();
+ }
+ if (getIndex() != parentItem.getItemCount()-1) { // if item is not the last child
+ if (isFirstChild == true) {
+ lineStartY += indicatorHeightDiv2; // leave space for the hierarchy image
+ }
+ gc.drawLine(lineX, lineStartY, lineX, lineEndY);
+ }
+
+ if (nextDrawItem != null) {
+ nextDrawItem.drawVerticalItemConnector(gc, yPosition, false);
+ }
+}
+/**
+ * Draw a vertical line connecting the horizontal connector line
+ * with that of the previous item.
+ * Do this on all tree levels up to the root level.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawVerticalItemConnector(GC gc, Point position) {
+ Tree parent = getParent();
+ TreeItem parentItem = getParentItem();
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int itemHeight = parent.getItemHeight();
+ int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;
+ int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;
+ int lineX = position.x + indicatorRectangle.width / 2;
+ int lineStartY = position.y - itemHeightDiv2;
+ int lineEndY = position.y + itemHeightDiv2 - itemHeight % 2;
+ TreeItem predecessor;
+ boolean isFirstChild = false;
+
+ if (isRoot() == true) {
+ if (getIndex() == 0) {
+ return position; // first root, don't draw vertical line
+ }
+ }
+ else
+ if (getIndex() == 0) { // if item is first child
+ lineStartY += itemHeightDiv2;
+ isFirstChild = true;
+ }
+ predecessor = getPredecessor();
+ if (predecessor != null && predecessor.isLeaf() == false) {
+ lineStartY += indicatorHeightDiv2; // leave space for the hierarchy image
+ }
+ if (isLeaf() == false) {
+ lineEndY -= indicatorHeightDiv2;
+ }
+ gc.drawLine(lineX, lineStartY, lineX, lineEndY);
+ if (parentItem != null) {
+ parentItem.drawVerticalItemConnector(gc, position.y, isFirstChild);
+ }
+ return position;
+}
+
+/**
+ * Gets the widget bounds.
+ * The widget bounds is the rectangle around the item text. It is
+ * the same as the selection rectangle.
+ * <p>
+ * @return a rectangle that is the widget bounds.
+ *
+ * @exception SWTError <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 Rectangle getBounds() {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ Point extent = getItemExtent();
+ int x = getTextXPos() - TEXT_INDENT;
+
+ return new Rectangle(x, parent.getRedrawY(this), extent.x - (x - getItemStartX()), extent.y);
+}
+
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return getPaintStartX() + getDecorationsWidth();
+}
+/**
+ * Answer the combined width of the hierarchy indicator and
+ * the horizontal item connector line.
+ */
+int getDecorationsWidth() {
+ int indicatorWidth = getParent().getHierarchyIndicatorRect().width;
+ int width = indicatorWidth + getItemConnectorWidth();
+
+ if (isLeaf() == true) {
+ width -= indicatorWidth / 2;
+ }
+ return width;
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * @return
+ * The index of the receiver relative to the first root item.
+ */
+int getGlobalIndex() {
+ int globalItemIndex = getIndex();
+ AbstractTreeItem item = null;
+
+ if (isRoot() == false) {
+ item = getParentItem();
+ globalItemIndex++; // adjust for 0-based non-root items
+ }
+ else {
+ item = getParent().getRoot();
+ }
+
+ globalItemIndex += item.getVisibleIndex(getIndex());
+ return globalItemIndex;
+}
+/**
+ * Answer the original size of the image of the receiver.
+ */
+Point getImageExtent() {
+ Image image = getImage();
+ Rectangle imageBounds;
+
+ if (imageExtent == null && image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the receiver's index into its parent's list of children
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Answer the width of the horizontal item connector line.
+ */
+int getItemConnectorWidth() {
+ Tree parent = getParent();
+ Point imageExtent = parent.getImageExtent();
+ int itemConnectorWidth;
+ int indicatorWidth = parent.getHierarchyIndicatorRect().width;
+
+ if (imageExtent != null) {
+ itemConnectorWidth = imageExtent.x / 2 + ITEM_CONNECTOR_PADDING;
+ }
+ else {
+ itemConnectorWidth = DEFAULT_ITEM_CONNECTOR_WIDTH;
+ }
+ if (isLeaf() == false) { // has children = has hierarchy indicator = shorter connector
+ itemConnectorWidth -= indicatorWidth / 2;
+ }
+ return itemConnectorWidth;
+}
+/**
+ * Return the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemCount();
+}
+/**
+ * Answer the size of the receiver as displayed on the screen.
+ */
+Point getItemExtent() {
+ Tree parent;
+ Point imageExtent;
+ String text;
+ int itemWidth;
+
+ if (itemExtent == null) {
+ parent = getParent();
+ imageExtent = parent.getImageExtent();
+ text = getText();
+ itemWidth = SELECTION_PADDING;
+ if (text != null) {
+ itemWidth += parent.getTextWidth(text) + TEXT_INDENT;
+ }
+ if (imageExtent != null) {
+ itemWidth += imageExtent.x + IMAGE_PADDING;
+ }
+ itemExtent = new Point(itemWidth, parent.getItemHeight());
+ }
+ return itemExtent;
+}
+/**
+ * Answer the x position at which painting of the receiver's
+ * contents (ie. image, text) can begin.
+ */
+int getItemStartX() {
+ int itemStartX = getPaintStartX() + getDecorationsWidth();
+
+ if (isCheckable() == true) {
+ itemStartX += getCheckboxBounds().width + CHECKBOX_PADDING;
+ }
+ return itemStartX;
+}
+/**
+ * Answer the child items of the receiver as an Array.
+ */
+public TreeItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TreeItem childrenArray[] = new TreeItem[getItemCount()];
+
+ getChildren().copyInto(childrenArray);
+ return childrenArray;
+}
+/**
+ * Answer the x position where the receiver is drawn.
+ */
+int getPaintStartX() {
+ Tree parent = getParent();
+ Point imageExtent;
+ TreeItem parentItem;
+
+ if (paintStartX == -1) {
+ if (isRoot() == true) {
+ paintStartX = ROOT_INDENT;
+ }
+ else {
+ parentItem = getParentItem();
+ // subtract parent.getHorizontalOffset() to calculate the cached start
+ // position independent of the horizontal scroll offset. Fixes 1G1L7EU.
+ paintStartX = parentItem.getPaintStartX()
+ - parent.getHorizontalOffset()
+ + parentItem.getDecorationsWidth()
+ - parent.getHierarchyIndicatorRect().width / 2;
+ imageExtent = parent.getImageExtent();
+ if (imageExtent != null) {
+ paintStartX += imageExtent.x / 2;
+ }
+ else {
+ paintStartX += ITEM_NOIMAGE_OFFSET;
+ }
+ }
+ }
+ return paintStartX + parent.getHorizontalOffset();
+}
+/**
+ * Answer the pixel at which the receiver stops drawing.
+ */
+int getPaintStopX() {
+ return (getItemStartX() + getItemExtent().x - getParent().getHorizontalOffset());
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Tree getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return (Tree) super.getSelectableParent();
+}
+/**
+ * Answer the parent item of the receiver or null if the
+ * receiver is a root.
+ */
+public TreeItem getParentItem() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return parentItem;
+}
+/**
+ * Answer the item that directly precedes the receiver.
+ * Answer null if this is the first item in a hierarchy level
+ * or if there are expanded children in the previous item.
+ */
+TreeItem getPredecessor() {
+ AbstractTreeItem parentItem = getParentItem();
+ Vector children;
+ int previousIndex = getIndex() - 1;
+ TreeItem previousItem = null;
+
+ if (parentItem == null) {
+ parentItem = getParent().getRoot();
+ }
+ if (previousIndex >= 0) {
+ children = parentItem.getChildren();
+ previousItem = (TreeItem) children.elementAt(previousIndex);
+ if (previousItem.isLeaf() == false && previousItem.getExpanded() == true) {
+ previousItem = null; // no immediate predecessor because there are expanded children
+ }
+ }
+ return previousItem;
+}
+/**
+ * Answer the size of the rectangle drawn to indicate the
+ * selected state of the receiver.
+ * This is also used to draw the selection focus rectangle.
+ */
+Point getSelectionExtent() {
+ Point selectionExtent = getItemExtent();
+ Point imageExtent = getParent().getImageExtent();
+ int x = selectionExtent.x;
+
+ if (imageExtent != null) {
+ x -= imageExtent.x + IMAGE_PADDING;
+ }
+ return new Point(x, selectionExtent.y);
+}
+/**
+ * Return the x position of the selection rectangle
+ */
+int getSelectionX() {
+ return getTextXPos() - TEXT_INDENT;
+}
+/**
+ * Answer the x position where the receiver draws the item text.
+ * This position is relative to the item start position.
+ */
+int getTextXPos() {
+ Point imageExtent = getParent().getImageExtent();
+ int textXPos = getItemStartX() + TEXT_INDENT;
+
+ if (imageExtent != null) {
+ textXPos += imageExtent.x + IMAGE_PADDING;
+ }
+ return textXPos;
+}
+/**
+ * Answer the y position of the receiver's text.
+ * @param
+ * gc - GC to use for calculating the text y position
+ */
+int getTextYPosition(GC gc) {
+ String text;
+
+ if (textYPosition == -1) {
+ text = getText();
+ if (text != null) {
+ textYPosition = (getParent().getItemHeight() - gc.stringExtent(text).y) / 2;
+ }
+ else {
+ textYPosition = 0;
+ }
+ }
+ return textYPosition;
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+int getVisibleIndex() {
+ int visibleItemIndex = getIndex();
+ AbstractTreeItem item = null;
+
+ if (isRoot() == false) {
+ if (isVisible() == false) {
+ return -1;
+ }
+ item = getParentItem();
+ visibleItemIndex++; // adjust for 0-based non-root items
+ }
+ else {
+ item = getParent().getRoot();
+ }
+
+ visibleItemIndex += item.getVisibleIndex(getIndex());
+ return visibleItemIndex;
+}
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+int getVisibleIndex(int childIndex) {
+ Enumeration children = getChildren().elements();
+ TreeItem child;
+ int visibleItemIndex = getIndex();
+
+ if (isRoot() == false) {
+ visibleItemIndex++; // adjust for 0-based non-root items
+ }
+
+ while (children.hasMoreElements() == true) {
+ child = (TreeItem) children.nextElement();
+ if (child.getIndex() == childIndex) {
+ if (isRoot() == false) {
+ visibleItemIndex += getParentItem().getVisibleIndex(getIndex());
+ }
+ else {
+ visibleItemIndex += getParent().getRoot().getVisibleIndex(getIndex());
+ }
+ break;
+ }
+ visibleItemIndex += child.getVisibleItemCount();
+ }
+ return visibleItemIndex;
+}
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the widget client area.
+ */
+TreeItem getVisibleItem(int searchIndex) {
+ TreeItem child;
+ TreeItem foundItem = null;
+ Enumeration children = getChildren().elements();
+
+ if (searchIndex == 0) {
+ return this;
+ }
+ else
+ if (getExpanded() == false) { // trying to find a child when this item isn't expanded ?
+ return null;
+ }
+
+ // Search for expanded items first. Count all subitems in the process.
+ while (children.hasMoreElements() == true && foundItem == null) {
+ child = (TreeItem) children.nextElement();
+ searchIndex--;
+ if (child.getExpanded() == true) {
+ searchIndex -= child.getVisibleItemCount(); // count children of all expanded items
+ }
+ if (searchIndex <= 0) { // is searched item past child ?
+ // add back children of current item (that's what we want to search)
+ foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());
+ }
+ }
+
+ return foundItem;
+}
+/**
+ * Answer whether 'item' is a child, direct or indirect, of the receiver.
+ * It is an indirect child if it is a child of one of the receiver's children.
+ */
+boolean isChild(TreeItem item) {
+ Vector children = getChildren();
+ TreeItem child;
+
+ if (children.contains(item) == true) {
+ return true;
+ }
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ if (child.isChild(item) == true) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it does not have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return (getParentItem() == null);
+}
+/**
+ * Answer whether the click at 'position' on the receiver is a selection
+ * click.
+ * @param position - location of the mouse click relative to the
+ * upper left corner of the receiver.
+ * @return true - receiver was clicked.
+ * false - receiver was not clicked.
+ */
+boolean isSelectionHit(Point position) {
+ Point itemExtent = getItemExtent();
+
+ if (itemExtent == null) { // neither image nor text have been set
+ return false;
+ }
+ return (new Rectangle(
+ getItemStartX() - getPaintStartX(), 0,
+ itemExtent.x, itemExtent.y)).contains(position);
+}
+/**
+ * Answer whether the receiver is visible
+ * An item is visible when its parent item is visible and
+ * expanded. Root items are always visible.
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ * @return
+ * true - the receiver is visible
+ * false - the receiver is not visible
+ */
+boolean isVisible() {
+ boolean isVisible = true;
+ TreeItem parentItem = getParentItem();
+
+ if (isRoot() == false) {
+ isVisible = parentItem.getExpanded();
+ if (isVisible == true) {
+ isVisible = parentItem.isVisible();
+ }
+ }
+ return isVisible;
+}
+/**
+ * Make this item visible by expanding its parent item.
+ */
+void makeVisible() {
+ TreeItem parentItem = getParentItem();
+
+ if (isVisible() == false && parentItem != null) {
+ getParent().expand(parentItem, true); // have to call Tree.expand directly in order to trigger Expand event
+ parentItem.makeVisible();
+ }
+}
+/**
+ * Draw the receiver at 'yPosition' in the client area of the parent.
+ * @param gc - GC to draw on.
+ * @param yPosition - y coordinate where the receiver should draw at.
+ */
+void paint(GC gc, int yPosition) {
+ Tree parent = getParent();
+ Point paintPosition = new Point(getPaintStartX(), yPosition);
+
+ if (isVisible() == false) {
+ return;
+ }
+ gc.setForeground(parent.CONNECTOR_LINE_COLOR);
+ paintPosition = drawVerticalItemConnector(gc, paintPosition);
+ paintPosition = drawHierarchyIndicator(gc, paintPosition);
+ paintPosition = drawHorizontalItemConnector(gc, paintPosition);
+ gc.setForeground(parent.getForeground());
+ // paint the rest
+ if (isCheckable() == true) {
+ paintPosition = drawCheckbox(gc, new Point(paintPosition.x, yPosition));
+ }
+ paintPosition = drawImage(gc, new Point(paintPosition.x, yPosition));
+ drawSelection(gc, paintPosition);
+ if (this == parent.getInsertItem()) {
+ drawInsertMark(gc, paintPosition);
+ }
+ drawText(gc, new Point(getTextXPos(), paintPosition.y + getTextYPosition(gc)));
+ drawSelectionFocus(gc, paintPosition);
+}
+/**
+ * Update the display to reflect the expanded state of the
+ * receiver.
+ * @param itemIndex - index position in the receiver's client
+ * area where should be drawn.
+ */
+void redrawExpanded(int itemIndex) {
+ Tree parent = getParent();
+ int indicatorWidth = parent.getHierarchyIndicatorRect().width;
+ int itemHeight = parent.getItemHeight();
+
+ parent.redraw(
+ getPaintStartX(), itemIndex * itemHeight,
+ indicatorWidth, itemHeight, false);
+}
+/**
+ * Reset cached size and position data.
+ */
+void reset() {
+ super.reset();
+ setImageExtent(null);
+ setItemExtent(null);
+ setPaintStartX(-1);
+ setTextYPosition(-1);
+}
+/**
+ * Set whether the receiver is expanded or not.
+ * If the receiver is expanded its child items are visible.
+ * @param expand -
+ * true=the receiver will be expanded, making its child items
+ * visible.
+ * false=the receiver will be collapsed, making its child items
+ * invisible
+ */
+public void setExpanded(boolean expand) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (isLeaf() == false && expand == true) {
+ getParent().expand(this, false);
+ }
+ else {
+ getParent().collapse(this, false);
+ }
+}
+/**
+ * Set the image of the receiver to 'newImage'.
+ * Reset cached data and notify the parent if the image has changed.
+ */
+public void setImage(Image newImage) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ Image oldImage = getImage();
+ boolean isSameImage;
+ int imageWidth = 0;
+ int redrawX = 0;
+
+ super.setImage(newImage);
+ if (newImage != null && oldImage != null) {
+ isSameImage = newImage.equals(oldImage);
+ }
+ else {
+ isSameImage = newImage == oldImage;
+ }
+ if (isSameImage == false) {
+ if (parent.getVisibleRedrawY(this) != -1) {
+ if (parent.getImageExtent() != null) {
+ imageWidth = parent.getImageExtent().x;
+ }
+ else
+ if (newImage != null) {
+ imageWidth = newImage.getBounds().x;
+ }
+ redrawX = getItemStartX();
+ }
+ parent.itemChanged(this, redrawX, imageWidth);
+ }
+}
+/**
+ * Set the size of the original image of the receiver to 'imageExtent'.
+ */
+void setImageExtent(Point imageExtent) {
+ this.imageExtent = imageExtent;
+}
+/**
+ * Set the index of the receiver to 'index'.
+ * This index is used to reference children in their parent.
+ */
+void setIndex(int index) {
+ this.index = index;
+}
+/**
+ * Set the size of the receiver to 'extent'.
+ */
+void setItemExtent(Point extent) {
+ itemExtent = extent;
+}
+/**
+ * Set the x position where the receiver is drawn to 'startX'.
+ * @param startX - the x position where the receiver is drawn
+ */
+void setPaintStartX(int startX) {
+ paintStartX = startX;
+}
+/**
+ * Set the parent item of the receiver to 'parentItem'.
+ * @param parentItem - the receiver's parent item.
+ * Receiver is a root if this is null.
+ */
+void setParentItem(TreeItem parentItem) {
+ this.parentItem = parentItem;
+}
+/**
+ * Set the label text of the receiver to 'string'.
+ * Reset cached data and notify the parent if the text has
+ * changed.
+ * This label will be displayed to the right of the bitmap,
+ * or, if the receiver doesn't have a bitmap to the right of
+ * the horizontal hierarchy connector line.
+ */
+public void setText(String newText) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ String oldText = getText();
+ int redrawX = 0;
+ int redrawWidth = 0;
+
+ if (newText == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ super.setText(newText);
+ if (newText.equals(oldText) == false) {
+ if (parent.getVisibleRedrawY(this) != -1) {
+ redrawX = getTextXPos();
+ redrawWidth = parent.getClientArea().width - redrawX;
+ }
+ parent.itemChanged(this, redrawX, redrawWidth);
+ }
+}
+/**
+ * Set the y position of the receiver's text to 'yPosition'.
+ */
+void setTextYPosition(int yPosition) {
+ textYPosition = yPosition;
+}
+/**
+ * Destroy all children of the receiver
+ * Collapsing the item speeds up deleting the children.
+ */
+void disposeItem() {
+ Tree parent = getParent();
+
+ // if the tree is being disposed don't bother collapsing the item since all
+ // items in the tree will be deleted and redraws will not be processed anyway
+ if (parent.isRemovingAll() == false) {
+ parent.collapseNoRedraw(this);
+ }
+ super.disposeItem();
+}
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getChecked();
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ return super.getDisplay();
+}
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <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 boolean getGrayed() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getGrayed();
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setChecked(checked);
+}
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <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 setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setGrayed(grayed);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java
new file mode 100755
index 0000000000..c9e4dea7ab
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/TreeRoots.java
@@ -0,0 +1,157 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class is used to store tree root items.
+ * Instances of this class are never displayed.
+ */
+class TreeRoots extends AbstractTreeItem {
+/**
+ * Create a tree item that holds one or more root items
+ * @param parent - Tree widget the receiver belongs to
+ */
+TreeRoots(Tree parent) {
+ super(parent, 0);
+ initialize();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+void calculateVisibleItemCount() {
+ Vector children = getChildren();
+ TreeItem child;
+ int visibleItemCount = children.size();
+
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ visibleItemCount += child.getVisibleItemCount();
+ }
+ setVisibleItemCount(visibleItemCount);
+}
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+void calculateVisibleItemCountParent() {}
+/**
+ * Destroy all children of the receiver
+ */
+void disposeItem() {
+ Tree parent = (Tree) getSelectableParent();
+
+ // all tree items are removed so we don't need to do
+ // time consuming screen updates for each removed item
+ parent.setRemovingAll(true);
+ super.disposeItem();
+ parent.setRemovingAll(false);
+}
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return 0;
+}
+/**
+ * Implements SelectableItem#getSelectionExtent
+ * Should never be called since objects of this type are never
+ * rendered
+ */
+Point getSelectionExtent() {
+ return new Point(0, 0);
+}
+/**
+ * Implements SelectableItem#getSelectionX
+ * Should never be called since objects of this type are never
+ * rendered
+ */
+int getSelectionX() {
+ return 0;
+}
+/**
+ * Always answer -1 to indicate that the receiver is not visible.
+ */
+int getVisibleIndex() {
+ return -1;
+}
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+int getVisibleIndex(int childIndex) {
+ Enumeration children = getChildren().elements();
+ TreeItem child;
+ int globalItemIndex = 0;
+
+ while (children.hasMoreElements() == true) {
+ child = (TreeItem) children.nextElement();
+ if (child.getIndex() == childIndex) {
+ break;
+ }
+ globalItemIndex += child.getVisibleItemCount();
+ }
+ return globalItemIndex;
+}
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the widget client area.
+ */
+TreeItem getVisibleItem(int searchIndex) {
+ TreeItem child;
+ TreeItem foundItem = null;
+ Enumeration children = getChildren().elements();
+
+ searchIndex++; // skip this fake root item
+
+ // Search for expanded items first. Count all subitems in the process.
+ while (children.hasMoreElements() == true && foundItem == null) {
+ child = (TreeItem) children.nextElement();
+ searchIndex--;
+ if (child.internalGetExpanded() == true) {
+ searchIndex -= child.getVisibleItemCount(); // count children of all expanded items
+ }
+ if (searchIndex <= 0) { // is searched item past child ?
+ // add back children of current item (that's what we want to search)
+ foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());
+ }
+ }
+ return foundItem;
+}
+/**
+ * Initialize the receiver
+ */
+void initialize() {
+ internalSetExpanded(true);
+}
+
+/**
+ * Select the receiver and all children
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
new file mode 100755
index 0000000000..6aaaa08b44
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Widget.java
@@ -0,0 +1,725 @@
+package org.eclipse.swt.widgets;
+
+/*
+* Licensed Materials - Property of IBM,
+* SWT - The Simple Widget Toolkit,
+* (c) Copyright IBM Corp 1998, 1999.
+*/
+
+/**
+* See JavaDoc for Windows.
+*/
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.motif.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import java.util.EventListener;
+
+/* Class Definition */
+public abstract class Widget {
+
+ public int handle;
+ int style, state;
+ EventTable eventTable;
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ /* Global state flags */
+// static final int AUTOMATIC = 0x00000001;
+// static final int ACTIVE = 0x00000002;
+// static final int AUTOGRAB = 0x00000004;
+// static final int MULTIEXPOSE = 0x00000008;
+// static final int RESIZEREDRAW = 0x00000010;
+// static final int WRAP = 0x00000020;
+// static final int DISABLED = 0x00000040;
+// static final int HIDDEN = 0x00000080;
+// static final int FOREGROUND = 0x00000100;
+// static final int BACKGROUND = 0x00000200;
+ static final int DISPOSED = 0x00000400;
+ static final int HANDLE = 0x00000800;
+ static final int CANVAS = 0x00001000;
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ /* Global widget variables */
+ static final char Mnemonic = '&';
+ static final boolean IsAIX, IsSunOS, IsLinux;
+ static {
+
+ /* Initialize the X/MOTIF flags */
+ String osName = System.getProperty ("os.name");
+ if (osName.equals("Linux")) {
+ IsLinux = true;
+ IsAIX = IsSunOS = false;
+ } else {
+ if (osName.equals("AIX")) {
+ IsAIX = true;
+ IsLinux = IsSunOS = false;
+ } else {
+ if (osName.equals("Solaris")) {
+ IsSunOS = true;
+ IsLinux = IsAIX = false;
+ } else {
+ IsLinux = IsSunOS = IsAIX = false;
+ }
+ }
+ }
+ }
+Widget () {
+ /* Do nothing */
+}
+/**
+* Creates a widget.
+* <p>
+* This method creates a child widget using style bits
+* to select a particular look or set of properties.
+*
+* @param parent a composite widget (cannot be null)
+* @param style the bitwise OR'ing of widget styles
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_ERROR_NULL_ARGUMENT)
+* when the parent is null
+*/
+public Widget (Widget parent, int style) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ this.style = style;
+}
+/**
+* Adds a listener for an event.
+* <p>
+* This method adds a listener for an event. When the
+* event occurs in the widget, the listener is notified
+* using <code>handleEvent ()</code>.
+*
+* @param eventType the desired SWT event
+* @param handler the event handler
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when handler is null
+*/
+public void addListener (int eventType, Listener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, handler);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addDisposeListener (DisposeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Dispose, typedListener);
+}
+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;
+}
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+}
+/**
+ * Checks that this class can be subclassed.
+ * <p>
+ * IMPORTANT: By providing an implementation of this method that
+ * allows subclassing in a subclass of this class, you agree to
+ * be fully responsible for the fact that any such subclass will
+ * likely fail between releases and will be strongly platform
+ * specific. No support is provided for classes which are implemented
+ * as subclasses of this class. The use of subclassing is intended
+ * purely to enable those outside of the development team to implement
+ * a patched version of the class in an emergency. Subclassing should
+ * not be attempted without an intimate and detailed understanding of
+ * the hierarchy.
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_ILLEGAL_SUBCLASS when called</li>
+ * </ul>
+ */
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+* Checks access to a widget.
+* <p>
+* Throws an exception when access to the widget
+* is denied.
+*
+* It is an error to call a method on a widget that
+* has been disposed or to call a method on a widget
+* from a thread that is different from the thread
+* that created the widget. There may be more or
+* less error checks in future or different versions
+* of SWT may issue different errors.
+*
+* This method is intended to be called by widget
+* implementors to enforce the standard SWT error
+* checking prologue in API methods.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+protected void checkWidget () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+void createHandle (int index) {
+ /* Do nothing */
+}
+void createWidget (int index) {
+ createHandle (index);
+ hookEvents ();
+ register ();
+ manageChildren ();
+}
+void deregister () {
+ if (handle == 0) return;
+ WidgetTable.remove (handle);
+}
+void destroyWidget () {
+ int topHandle = topHandle ();
+ releaseHandle ();
+ if (topHandle != 0) {
+ OS.XtDestroyWidget (topHandle);
+ }
+}
+/**
+* Disposes a widget.
+* <p>
+* This method destroys the widget and all children
+* and releases all platform resources associated with
+* the widget tree.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void dispose () {
+ /*
+ * Note: It is valid to attempt to dispose a widget
+ * more than once. If this happens, fail silently.
+ */
+ if (!isValidWidget ()) return;
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+void error (int code) {
+ SWT.error(code);
+}
+/**
+* Gets the widget data.
+* <p>
+* This method gets the application defined data that
+* is associated with the widget.
+*
+* @return the widget data
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Object getData () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return data;
+}
+
+/**
+ * Searches for the property with the specified name.
+ * If the property is not found, null is returned.
+ *
+ * @param key the name of the property to find
+ * @return the named property value
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when the name is null</li>
+ * </ul>
+ */
+public Object getData (String key) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (keys == null) return null;
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) return values [i];
+ }
+ return null;
+}
+
+/**
+* Gets the Display.
+* <p>
+* This method gets the Display that is associated
+* with the widget.
+*
+* @return the widget data
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public abstract Display getDisplay ();
+String getName () {
+ String string = getClass ().getName ();
+ int index = string.lastIndexOf ('.');
+ if (index == -1) return string;
+ return string.substring (index + 1, string.length ());
+}
+String getNameText () {
+ return "";
+}
+/**
+* Gets the widget style.
+* <p>
+* This method gets the widget style bits.
+*
+* @return an integer that is the widget style bits.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getStyle () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return style;
+}
+void hookEvents () {
+ /* Do nothing */
+}
+boolean hooks (int eventType) {
+ if (eventTable == null) return false;
+ return eventTable.hooks (eventType);
+}
+/**
+* Gets the disposed state.
+* <p>
+* This method gets the dispose state for the widget.
+* When a widget has been disposed, it is an error to
+* to invoke any other method on the widget.
+*
+* @return true when the widget is disposed
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+*/
+public boolean isDisposed () {
+ if (handle != 0) return false;
+ if ((state & HANDLE) != 0) return true;
+ return (state & DISPOSED) != 0;
+}
+/**
+ * Return the listening state.
+ * <p>
+ * Returns true if there is a listener, listening for the eventType.
+ * Otherwise, returns false.
+ *
+ * @param eventType the type of event
+ * @return true if the event is hooked
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when the name is null</li>
+ * </ul>
+ */
+protected boolean isListening (int eventType) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hooks (eventType);
+}
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+boolean isValidWidget () {
+ if (handle != 0) return true;
+ if ((state & HANDLE) != 0) return false;
+ return (state & DISPOSED) == 0;
+}
+void manageChildren () {
+ /* Do nothing */
+}
+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];
+}
+/**
+* Notify listeners of an event.
+* <p>
+* This method notifies all listeners that an event
+* has occurred.
+*
+* @param eventType the desired SWT event
+* @param event the event data
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when handler is null
+*/
+public void notifyListeners (int eventType, Event event) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ eventTable.sendEvent (event);
+}
+void postEvent (int eventType) {
+ if (eventTable == null) return;
+ postEvent (eventType, new Event ());
+}
+void postEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ Display display = getDisplay ();
+ if (event.time == 0) {
+ event.time = OS.XtLastTimestampProcessed (display.xDisplay);
+ }
+ display.postEvent (event);
+}
+int processArm (int callData) {
+ return 0;
+}
+int processDispose (int callData) {
+ return 0;
+}
+int processDefaultSelection (int callData) {
+ return 0;
+}
+int processEvent (int eventNumber, int callData) {
+ switch (eventNumber) {
+ case SWT.Arm: return processArm (callData);
+ case SWT.Dispose: return processDispose (callData);
+ case SWT.DefaultSelection: return processDefaultSelection (callData);
+ case SWT.FocusIn: return processSetFocus (callData);
+ case SWT.Help: return processHelp (callData);
+ case SWT.Hide: return processHide (callData);
+ case SWT.KeyDown: return processKeyDown (callData);
+ case SWT.KeyUp: return processKeyUp (callData);
+ case SWT.Modify: return processModify (callData);
+ case SWT.MouseDown: return processMouseDown (callData);
+ case SWT.MouseEnter: return processMouseEnter (callData);
+ case SWT.MouseExit: return processMouseExit (callData);
+ case SWT.MouseHover: return processMouseHover (callData);
+ case SWT.MouseMove: return processMouseMove (callData);
+ case SWT.MouseUp: return processMouseUp (callData);
+ case SWT.Paint: return processPaint (callData);
+ case SWT.Resize: return processResize (callData);
+ case SWT.Show: return processShow (callData);
+ case SWT.Selection: return processSelection (callData);
+ case SWT.Verify: return processVerify (callData);
+ case -1: return processNonMaskable (callData);
+ }
+ return 0;
+}
+int processHelp (int callData) {
+ return 0;
+}
+int processHide (int callData) {
+ return 0;
+}
+int processKeyDown (int callData) {
+ return 0;
+}
+int processKeyUp (int callData) {
+ return 0;
+}
+int processModify (int callData) {
+ return 0;
+}
+int processMouseDown (int callData) {
+ return 0;
+}
+int processMouseEnter (int callData) {
+ return 0;
+}
+int processMouseExit (int callData) {
+ return 0;
+}
+int processMouseHover (int id) {
+ return 0;
+}
+int processMouseMove (int callData) {
+ return 0;
+}
+int processMouseUp (int callData) {
+ return 0;
+}
+int processNonMaskable (int callData) {
+ return 0;
+}
+int processPaint (int callData) {
+ return 0;
+}
+int processResize (int callData) {
+ return 0;
+}
+int processSelection (int callData) {
+ return 0;
+}
+int processSetFocus (int callData) {
+ return 0;
+}
+int processShow (int callData) {
+ return 0;
+}
+int processVerify (int callData) {
+ return 0;
+}
+void register () {
+ if (handle == 0) return;
+ WidgetTable.put (handle, this);
+}
+void releaseChild () {
+ /* Do nothing */
+}
+void releaseHandle () {
+ handle = 0;
+ state |= DISPOSED;
+}
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+ deregister ();
+ eventTable = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+/**
+* Removes a listener for an event.
+* <p>
+* This method removes a listener for an event. When the
+* event occurs in the widget, the listener is no longer
+* notified.
+*
+* @param eventType the desired SWT event
+* @param handler the event handler
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when handler is null
+*/
+public void removeListener (int eventType, Listener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+/**
+* Warning: API under construction.
+*/
+protected void removeListener (int eventType, EventListener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeDisposeListener (DisposeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+void sendEvent (int eventType) {
+ if (eventTable == null) return;
+ sendEvent (eventType, new Event ());
+}
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ if (event.time == 0) {
+ Display display = getDisplay ();
+ event.time = OS.XtLastTimestampProcessed (display.xDisplay);
+ }
+ eventTable.sendEvent (event);
+}
+/**
+* Sets the widget data.
+* <p>
+* This method sets the application defined data that
+* is associated with the widget.
+*
+* @param the widget data
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setData (Object data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.data = data;
+}
+
+/**
+ * Maps the specified key to the specified value.
+ * If the key already exists, the old value is replaced.
+ * The key cannot be null.
+ *
+ * @param key the name of the property
+ * @param value the value of the property
+ *
+ * @exception SWTError <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+ * <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+ * <li>ERROR_NULL_ARGUMENT when the name is null</li>
+ * </ul>
+ */
+public void setData (String key, Object value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* 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;
+}
+
+/**
+* Returns a string representation of the object.
+*/
+public String toString () {
+ String string = "*Disposed*";
+ if (!isDisposed ()) {
+ string = "*Wrong Thread*";
+ if (isValidThread ()) string = getNameText ();
+ }
+ return getName () + " {" + string + "}";
+}
+int topHandle () {
+ return handle;
+}
+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;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/WidgetTable.java
new file mode 100755
index 0000000000..e0858ec93b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/WidgetTable.java
@@ -0,0 +1,121 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.internal.motif.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+class WidgetTable {
+ static int FreeSlot = 0;
+ static int GrowSize = 1024;
+ static int [] IndexTable = new int [GrowSize];
+ static Shell [] Shells = new Shell [GrowSize / 8];
+ static Widget [] WidgetTable = new Widget [GrowSize];
+ static int [] ArgList = {OS.XmNuserData, 0};
+ static {
+ for (int i=0; i<GrowSize-1; i++) IndexTable [i] = i + 1;
+ IndexTable [GrowSize - 1] = -1;
+ }
+public static synchronized Widget get (int handle) {
+ if (handle == 0) return null;
+ if (OS.XtIsSubclass (handle, OS.ShellWidgetClass ())) {
+ for (int i=0; i<Shells.length; i++) {
+ Widget shell = Shells [i];
+ if ((shell != null) && (shell.topHandle () == handle)) return shell;
+ }
+ return null;
+ }
+ ArgList [1] = 0;
+ OS.XtGetValues (handle, ArgList, ArgList.length / 2);
+ if (ArgList [1] == 0) return null;
+ int index = ArgList [1] - 1;
+ if (0 <= index && index < WidgetTable.length) return WidgetTable [index];
+ return null;
+}
+public synchronized static void put (int handle, Widget widget) {
+ if (handle == 0) return;
+ if (OS.XtIsSubclass (handle, OS.ShellWidgetClass ())) {
+ for (int i=0; i<Shells.length; i++) {
+ if (Shells [i] == null) {
+ Shells [i] = (Shell) widget;
+ return;
+ }
+ }
+ Shell [] newShells = new Shell [Shells.length + GrowSize / 8];
+ System.arraycopy (Shells, 0, newShells, 0, Shells.length);
+ newShells [Shells.length] = (Shell) widget;
+ Shells = newShells;
+ return;
+ }
+ if (FreeSlot == -1) {
+ int length = (FreeSlot = IndexTable.length) + GrowSize;
+ 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;
+ }
+ ArgList [1] = FreeSlot + 1;
+ OS.XtSetValues (handle, ArgList, ArgList.length / 2);
+ int oldSlot = FreeSlot;
+ FreeSlot = IndexTable [oldSlot];
+ IndexTable [oldSlot] = -2;
+ WidgetTable [oldSlot] = widget;
+}
+public static synchronized Widget remove (int handle) {
+ if (handle == 0) return null;
+ if (OS.XtIsSubclass (handle, OS.ShellWidgetClass ())) {
+ for (int i=0; i<Shells.length; i++) {
+ Widget shell = Shells [i];
+ if ((shell != null) && (shell.topHandle () == handle)) {
+ Shells [i] = null;
+ return shell;
+ }
+ }
+ return null;
+ }
+ ArgList [1] = 0;
+ Widget widget = null;
+ OS.XtGetValues (handle, ArgList, ArgList.length / 2);
+ int index = ArgList [1] - 1;
+ if (0 <= index && index < WidgetTable.length) {
+ widget = WidgetTable [index];
+ WidgetTable [index] = null;
+ IndexTable [index] = FreeSlot;
+ FreeSlot = index;
+ ArgList [1] = 0;
+ OS.XtSetValues (handle, ArgList, ArgList.length / 2);
+ }
+ return widget;
+}
+public static synchronized Shell [] shells () {
+ int length = 0;
+ for (int i=0; i<Shells.length; i++) {
+ if (Shells [i] != null) length++;
+ }
+ int index = 0;
+ Shell [] result = new Shell [length];
+ for (int i=0; i<Shells.length; i++) {
+ Shell widget = Shells [i];
+ if (widget != null) result [index++] = widget;
+ }
+ return result;
+}
+public static synchronized int size () {
+ int length = 0;
+ for (int i=0; i<Shells.length; i++) {
+ if (Shells [i] != null) length++;
+ }
+ for (int i=0; i<WidgetTable.length; i++) {
+ if (WidgetTable [i] != null) length++;
+ }
+ return length;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/build.sh b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/build.sh
new file mode 100755
index 0000000000..51c583add4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/build.sh
@@ -0,0 +1,12 @@
+ #!/bin/sh
+# (c) Copyright IBM Corp 1999, 2000
+#
+
+export IVE_HOME=~/ive/bin
+export PATH=$IVE_HOME:$PATH
+
+# TEMPORARY CODE
+make -f makefile.mak clean
+make -f makefile.mak
+
+cp *.so $IVE_HOME
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/library.c b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/library.c
new file mode 100755
index 0000000000..8f539152ab
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/library.c
@@ -0,0 +1,32 @@
+/**
+ * library.c
+ *
+ * This file contains the implementation of the
+ * shared libraries functions.
+ *
+ */
+
+#include <dlfcn.h>
+#include <stdio.h>
+
+unsigned int OpenLibrary(char *name)
+{
+ void * handle = dlopen (name, RTLD_LAZY | RTLD_GLOBAL);
+ if (handle == NULL) {
+ char buf[512];
+ sprintf(buf, "lib%s.so", name);
+ handle = dlopen (buf, 1);
+ }
+ return (unsigned int)handle;
+}
+
+unsigned int LibraryLookupName(unsigned int handle, char *name)
+{
+ if (handle == 0) return 0;
+ return (unsigned int)dlsym ((void *)handle, name);
+}
+
+void CloseLibrary(unsigned int handle)
+{
+ if (handle != 0) dlclose ((void *)handle);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak
new file mode 100755
index 0000000000..049e3c3f4e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/makefile.mak
@@ -0,0 +1,34 @@
+ # Makefile for module 'swt'
+
+maj_ver=0
+min_ver=104
+revision=0
+
+#assumes IVE_HOME is set in the environment
+
+DLLPREFIX=swt
+DLLNAME=lib$(DLLPREFIX)$(maj_ver)$(min_ver).so
+#DLLNAME=lib$(DLLPREFIX)$(maj_ver)$(min_ver)r$(revision).so
+
+DEBUG =
+CFLAGS = -c -shared -DSWT_LIBRARY_MAJOR_VERSION=$(maj_ver) -DSWT_LIBRARY_MINOR_VERSION=$(min_ver) -w8 $(DEBUG) -DPHOTON -I$(IVE_HOME)/include
+LFLAGS = -shared -lph -lphrender
+
+SWTOBJS = swt.o structs.o callback.o globals.o library.o
+
+all: \
+ $(DLLNAME)
+
+BUILDLIB: $(DLLNAME)
+
+.c.o:
+ cc $(CFLAGS) $*.c
+
+$(DLLNAME):\
+ $(SWTOBJS)
+ cc $(LFLAGS) -o $(DLLNAME) \
+ $(SWTOBJS)
+
+clean:
+ rm -f *.o
+ rm -f $(DLLNAME) \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c
new file mode 100755
index 0000000000..375f7e22e0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.c
@@ -0,0 +1,1091 @@
+ /**
+ * JNI SWT object field getters and setters declarations for Motif structs.
+ */
+
+#include <jni.h>
+#include "globals.h"
+#include "structs.h"
+
+void cachePhPoint_tFids(JNIEnv *env, jobject lpObject, PPhPoint_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->x = (*env)->GetFieldID(env, lpCache->clazz, "x", "S");
+ lpCache->y = (*env)->GetFieldID(env, lpCache->clazz, "y", "S");
+ lpCache->cached = 1;
+}
+
+void getPhPoint_tFields(JNIEnv *env, jobject lpObject, PhPoint_t *lpStruct, PPhPoint_t_FID_CACHE lpCache)
+{
+ lpStruct->x = (*env)->GetShortField(env, lpObject, lpCache->x);
+ lpStruct->y = (*env)->GetShortField(env, lpObject, lpCache->y);
+}
+
+void setPhPoint_tFields(JNIEnv *env, jobject lpObject, PhPoint_t *lpStruct, PPhPoint_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->x, lpStruct->x);
+ (*env)->SetShortField(env, lpObject, lpCache->y, lpStruct->y);
+}
+
+void cachePhRect_tFids(JNIEnv *env, jobject lpObject, PPhRect_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->ul_x = (*env)->GetFieldID(env, lpCache->clazz, "ul_x", "S");
+ lpCache->ul_y = (*env)->GetFieldID(env, lpCache->clazz, "ul_y", "S");
+ lpCache->lr_x = (*env)->GetFieldID(env, lpCache->clazz, "lr_x", "S");
+ lpCache->lr_y = (*env)->GetFieldID(env, lpCache->clazz, "lr_y", "S");
+ lpCache->cached = 1;
+}
+
+void getPhRect_tFields(JNIEnv *env, jobject lpObject, PhRect_t *lpStruct, PPhRect_t_FID_CACHE lpCache)
+{
+ lpStruct->ul.x = (*env)->GetShortField(env, lpObject, lpCache->ul_x);
+ lpStruct->ul.y = (*env)->GetShortField(env, lpObject, lpCache->ul_y);
+ lpStruct->lr.x = (*env)->GetShortField(env, lpObject, lpCache->lr_x);
+ lpStruct->lr.y = (*env)->GetShortField(env, lpObject, lpCache->lr_y);
+}
+
+void setPhRect_tFields(JNIEnv *env, jobject lpObject, PhRect_t *lpStruct, PPhRect_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->ul_x, lpStruct->ul.x);
+ (*env)->SetShortField(env, lpObject, lpCache->ul_y, lpStruct->ul.y);
+ (*env)->SetShortField(env, lpObject, lpCache->lr_x, lpStruct->lr.x);
+ (*env)->SetShortField(env, lpObject, lpCache->lr_y, lpStruct->lr.y);
+}
+
+void cachePhTile_tFids(JNIEnv *env, jobject lpObject, PPhTile_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->rect_ul_x = (*env)->GetFieldID(env, lpCache->clazz, "rect_ul_x", "S");
+ lpCache->rect_ul_y = (*env)->GetFieldID(env, lpCache->clazz, "rect_ul_y", "S");
+ lpCache->rect_lr_x = (*env)->GetFieldID(env, lpCache->clazz, "rect_lr_x", "S");
+ lpCache->rect_lr_y = (*env)->GetFieldID(env, lpCache->clazz, "rect_lr_y", "S");
+ lpCache->next = (*env)->GetFieldID(env, lpCache->clazz, "next", "I");
+ lpCache->cached = 1;
+}
+
+void getPhTile_tFields(JNIEnv *env, jobject lpObject, PhTile_t *lpStruct, PPhTile_t_FID_CACHE lpCache)
+{
+ lpStruct->rect.ul.x = (*env)->GetShortField(env, lpObject, lpCache->rect_ul_x);
+ lpStruct->rect.ul.y = (*env)->GetShortField(env, lpObject, lpCache->rect_ul_y);
+ lpStruct->rect.lr.x = (*env)->GetShortField(env, lpObject, lpCache->rect_lr_x);
+ lpStruct->rect.lr.y = (*env)->GetShortField(env, lpObject, lpCache->rect_lr_y);
+ lpStruct->next = (PhTile_t *)(*env)->GetIntField(env, lpObject, lpCache->next);
+}
+
+void setPhTile_tFields(JNIEnv *env, jobject lpObject, PhTile_t *lpStruct, PPhTile_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->rect_ul_x, lpStruct->rect.ul.x);
+ (*env)->SetShortField(env, lpObject, lpCache->rect_ul_y, lpStruct->rect.ul.y);
+ (*env)->SetShortField(env, lpObject, lpCache->rect_lr_x, lpStruct->rect.lr.x);
+ (*env)->SetShortField(env, lpObject, lpCache->rect_lr_y, lpStruct->rect.lr.y);
+ (*env)->SetIntField(env, lpObject, lpCache->next, (jint)lpStruct->next);
+}
+
+void cachePtCallbackInfo_tFids(JNIEnv *env, jobject lpObject, PPtCallbackInfo_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->reason = (*env)->GetFieldID(env, lpCache->clazz, "reason", "I");
+ lpCache->reason_subtype = (*env)->GetFieldID(env, lpCache->clazz, "reason_subtype", "I");
+ lpCache->event = (*env)->GetFieldID(env, lpCache->clazz, "event", "I");
+ lpCache->cbdata = (*env)->GetFieldID(env, lpCache->clazz, "cbdata", "I");
+ lpCache->cached = 1;
+}
+
+void getPtCallbackInfo_tFields(JNIEnv *env, jobject lpObject, PtCallbackInfo_t *lpStruct, PPtCallbackInfo_t_FID_CACHE lpCache)
+{
+ lpStruct->reason = (*env)->GetIntField(env, lpObject, lpCache->reason);
+ lpStruct->reason_subtype = (*env)->GetIntField(env, lpObject, lpCache->reason_subtype);
+ lpStruct->event = (PhEvent_t *)(*env)->GetIntField(env, lpObject, lpCache->event);
+ lpStruct->cbdata = (void *)(*env)->GetIntField(env, lpObject, lpCache->cbdata);
+}
+
+void setPtCallbackInfo_tFields(JNIEnv *env, jobject lpObject, PtCallbackInfo_t *lpStruct, PPtCallbackInfo_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->reason, lpStruct->reason);
+ (*env)->SetIntField(env, lpObject, lpCache->reason_subtype, lpStruct->reason_subtype);
+ (*env)->SetIntField(env, lpObject, lpCache->event, (jint)lpStruct->event);
+ (*env)->SetIntField(env, lpObject, lpCache->cbdata, (jint)lpStruct->cbdata);
+}
+
+void cachePhWindowEvent_tFids(JNIEnv *env, jobject lpObject, PPhWindowEvent_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->event_f = (*env)->GetFieldID(env, lpCache->clazz, "event_f", "I");
+ lpCache->state_f = (*env)->GetFieldID(env, lpCache->clazz, "state_f", "I");
+ lpCache->rid = (*env)->GetFieldID(env, lpCache->clazz, "rid", "I");
+ lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
+ lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
+ lpCache->size_w = (*env)->GetFieldID(env, lpCache->clazz, "size_w", "S");
+ lpCache->size_h = (*env)->GetFieldID(env, lpCache->clazz, "size_h", "S");
+ lpCache->event_state = (*env)->GetFieldID(env, lpCache->clazz, "event_state", "S");
+ lpCache->input_group = (*env)->GetFieldID(env, lpCache->clazz, "input_group", "S");
+ lpCache->rsvd0 = (*env)->GetFieldID(env, lpCache->clazz, "rsvd0", "I");
+ lpCache->rsvd1 = (*env)->GetFieldID(env, lpCache->clazz, "rsvd1", "I");
+ lpCache->rsvd2 = (*env)->GetFieldID(env, lpCache->clazz, "rsvd2", "I");
+ lpCache->rsvd3 = (*env)->GetFieldID(env, lpCache->clazz, "rsvd3", "I");
+ lpCache->cached = 1;
+}
+
+void getPhWindowEvent_tFields(JNIEnv *env, jobject lpObject, PhWindowEvent_t *lpStruct, PPhWindowEvent_t_FID_CACHE lpCache)
+{
+ lpStruct->event_f = (*env)->GetIntField(env, lpObject, lpCache->event_f);
+ lpStruct->state_f = (*env)->GetIntField(env, lpObject, lpCache->state_f);
+ lpStruct->rid = (*env)->GetIntField(env, lpObject, lpCache->rid);
+ lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
+ lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
+ lpStruct->size.w = (*env)->GetShortField(env, lpObject, lpCache->size_w);
+ lpStruct->size.h = (*env)->GetShortField(env, lpObject, lpCache->size_h);
+ lpStruct->event_state = (*env)->GetShortField(env, lpObject, lpCache->event_state);
+ lpStruct->input_group = (*env)->GetShortField(env, lpObject, lpCache->input_group);
+ lpStruct->rsvd[0] = (*env)->GetIntField(env, lpObject, lpCache->rsvd0);
+ lpStruct->rsvd[1] = (*env)->GetIntField(env, lpObject, lpCache->rsvd1);
+ lpStruct->rsvd[2] = (*env)->GetIntField(env, lpObject, lpCache->rsvd2);
+ lpStruct->rsvd[3] = (*env)->GetIntField(env, lpObject, lpCache->rsvd3);
+}
+
+void setPhWindowEvent_tFields(JNIEnv *env, jobject lpObject, PhWindowEvent_t *lpStruct, PPhWindowEvent_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->event_f, lpStruct->event_f);
+ (*env)->SetIntField(env, lpObject, lpCache->state_f, lpStruct->state_f);
+ (*env)->SetIntField(env, lpObject, lpCache->rid, lpStruct->rid);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
+ (*env)->SetShortField(env, lpObject, lpCache->size_w, lpStruct->size.w);
+ (*env)->SetShortField(env, lpObject, lpCache->size_h, lpStruct->size.h);
+ (*env)->SetShortField(env, lpObject, lpCache->event_state, lpStruct->event_state);
+ (*env)->SetShortField(env, lpObject, lpCache->input_group, lpStruct->input_group);
+ (*env)->SetIntField(env, lpObject, lpCache->rsvd0, lpStruct->rsvd[0]);
+ (*env)->SetIntField(env, lpObject, lpCache->rsvd1, lpStruct->rsvd[1]);
+ (*env)->SetIntField(env, lpObject, lpCache->rsvd2, lpStruct->rsvd[2]);
+ (*env)->SetIntField(env, lpObject, lpCache->rsvd3, lpStruct->rsvd[3]);
+}
+
+
+void cachePhEvent_tFids(JNIEnv *env, jobject lpObject, PPhEvent_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->type = (*env)->GetFieldID(env, lpCache->clazz, "type", "I");
+ lpCache->subtype = (*env)->GetFieldID(env, lpCache->clazz, "subtype", "S");
+ lpCache->processing_flags = (*env)->GetFieldID(env, lpCache->clazz, "processing_flags", "S");
+ lpCache->emitter_rid = (*env)->GetFieldID(env, lpCache->clazz, "emitter_rid", "I");
+ lpCache->emitter_handle = (*env)->GetFieldID(env, lpCache->clazz, "emitter_handle", "I");
+ lpCache->collector_rid = (*env)->GetFieldID(env, lpCache->clazz, "collector_rid", "I");
+ lpCache->collector_handle = (*env)->GetFieldID(env, lpCache->clazz, "collector_handle", "I");
+ lpCache->input_group = (*env)->GetFieldID(env, lpCache->clazz, "input_group", "S");
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "S");
+ lpCache->timestamp = (*env)->GetFieldID(env, lpCache->clazz, "timestamp", "I");
+ lpCache->translation_x = (*env)->GetFieldID(env, lpCache->clazz, "translation_x", "S");
+ lpCache->translation_y = (*env)->GetFieldID(env, lpCache->clazz, "translation_y", "S");
+ lpCache->num_rects = (*env)->GetFieldID(env, lpCache->clazz, "num_rects", "S");
+ lpCache->data_len = (*env)->GetFieldID(env, lpCache->clazz, "data_len", "S");
+ lpCache->cached = 1;
+}
+
+void getPhEvent_tFields(JNIEnv *env, jobject lpObject, PhEvent_t *lpStruct, PPhEvent_t_FID_CACHE lpCache)
+{
+ lpStruct->type = (*env)->GetIntField(env, lpObject, lpCache->type);
+ lpStruct->subtype = (*env)->GetShortField(env, lpObject, lpCache->subtype);
+ lpStruct->processing_flags = (*env)->GetShortField(env, lpObject, lpCache->processing_flags);
+ lpStruct->emitter.rid = (*env)->GetIntField(env, lpObject, lpCache->emitter_rid);
+ lpStruct->emitter.handle = (*env)->GetIntField(env, lpObject, lpCache->emitter_handle);
+ lpStruct->collector.rid = (*env)->GetIntField(env, lpObject, lpCache->collector_rid);
+ lpStruct->collector.handle = (*env)->GetIntField(env, lpObject, lpCache->collector_handle);
+ lpStruct->input_group = (*env)->GetShortField(env, lpObject, lpCache->input_group);
+ lpStruct->flags = (*env)->GetShortField(env, lpObject, lpCache->flags);
+ lpStruct->timestamp = (*env)->GetIntField(env, lpObject, lpCache->timestamp);
+ lpStruct->translation.x = (*env)->GetShortField(env, lpObject, lpCache->translation_x);
+ lpStruct->translation.y = (*env)->GetShortField(env, lpObject, lpCache->translation_y);
+ lpStruct->num_rects = (*env)->GetShortField(env, lpObject, lpCache->num_rects);
+ lpStruct->data_len = (*env)->GetShortField(env, lpObject, lpCache->data_len);
+}
+
+void setPhEvent_tFields(JNIEnv *env, jobject lpObject, PhEvent_t *lpStruct, PPhEvent_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->type, lpStruct->type);
+ (*env)->SetShortField(env, lpObject, lpCache->subtype, lpStruct->subtype);
+ (*env)->SetShortField(env, lpObject, lpCache->processing_flags, lpStruct->processing_flags);
+ (*env)->SetIntField(env, lpObject, lpCache->emitter_rid, lpStruct->emitter.rid);
+ (*env)->SetIntField(env, lpObject, lpCache->emitter_handle, lpStruct->emitter.handle);
+ (*env)->SetIntField(env, lpObject, lpCache->collector_rid, lpStruct->collector.rid);
+ (*env)->SetIntField(env, lpObject, lpCache->collector_handle, lpStruct->collector.handle);
+ (*env)->SetShortField(env, lpObject, lpCache->input_group, lpStruct->input_group);
+ (*env)->SetShortField(env, lpObject, lpCache->flags, lpStruct->flags);
+ (*env)->SetIntField(env, lpObject, lpCache->timestamp, lpStruct->timestamp);
+ (*env)->SetShortField(env, lpObject, lpCache->translation_x, lpStruct->translation.x);
+ (*env)->SetShortField(env, lpObject, lpCache->translation_y, lpStruct->translation.y);
+ (*env)->SetShortField(env, lpObject, lpCache->num_rects, lpStruct->num_rects);
+ (*env)->SetShortField(env, lpObject, lpCache->data_len, lpStruct->data_len);
+}
+
+void cacheFontQueryInfoFids(JNIEnv *env, jobject lpObject, PFontQueryInfo_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->font = (*env)->GetFieldID(env, lpCache->clazz, "font", "[B");
+ lpCache->desc = (*env)->GetFieldID(env, lpCache->clazz, "desc", "[B");
+ lpCache->size = (*env)->GetFieldID(env, lpCache->clazz, "size", "S");
+ lpCache->style = (*env)->GetFieldID(env, lpCache->clazz, "style", "S");
+ lpCache->ascender = (*env)->GetFieldID(env, lpCache->clazz, "ascender", "S");
+ lpCache->descender = (*env)->GetFieldID(env, lpCache->clazz, "descender", "S");
+ lpCache->width = (*env)->GetFieldID(env, lpCache->clazz, "width", "S");
+ lpCache->lochar = (*env)->GetFieldID(env, lpCache->clazz, "lochar", "I");
+ lpCache->hichar = (*env)->GetFieldID(env, lpCache->clazz, "hichar", "I");
+ lpCache->cached = 1;
+}
+
+void getFontQueryInfoFields(JNIEnv *env, jobject lpObject, FontQueryInfo *lpStruct, PFontQueryInfo_FID_CACHE lpCache)
+{
+ jbyteArray desc, font = (*env)->GetObjectField(env, lpObject, lpCache->font);
+ if (font) {
+ jbyte *font1 = (*env)->GetByteArrayElements(env, font, NULL);
+ memcpy(lpStruct->font, font1, MAX_FONT_TAG);
+ (*env)->ReleaseByteArrayElements(env, font, font1, JNI_ABORT);
+ }
+ desc = (*env)->GetObjectField(env, lpObject, lpCache->desc);
+ if (desc) {
+ jbyte *desc1 = (*env)->GetByteArrayElements(env, desc, NULL);
+ memcpy(lpStruct->desc, desc1, MAX_DESC_LENGTH);
+ (*env)->ReleaseByteArrayElements(env, desc, desc1, JNI_ABORT);
+ }
+ lpStruct->size = (*env)->GetShortField(env, lpObject, lpCache->size);
+ lpStruct->style = (*env)->GetShortField(env, lpObject, lpCache->style);
+ lpStruct->ascender = (*env)->GetShortField(env, lpObject, lpCache->ascender);
+ lpStruct->descender = (*env)->GetShortField(env, lpObject, lpCache->descender);
+ lpStruct->width = (*env)->GetShortField(env, lpObject, lpCache->width);
+ lpStruct->lochar = (*env)->GetIntField(env, lpObject, lpCache->lochar);
+ lpStruct->hichar = (*env)->GetIntField(env, lpObject, lpCache->hichar);
+}
+
+void setFontQueryInfoFields(JNIEnv *env, jobject lpObject, FontQueryInfo *lpStruct, PFontQueryInfo_FID_CACHE lpCache)
+{
+ jbyteArray desc, font = (*env)->GetObjectField(env, lpObject, lpCache->font);
+ if (font) {
+ jbyte *font1 = (*env)->GetByteArrayElements(env, font, NULL);
+ memcpy(font1, lpStruct->font, MAX_FONT_TAG);
+ (*env)->ReleaseByteArrayElements(env, font, font1, 0);
+ }
+ desc = (*env)->GetObjectField(env, lpObject, lpCache->desc);
+ if (desc) {
+ jbyte *desc1 = (*env)->GetByteArrayElements(env, desc, NULL);
+ memcpy(desc1, lpStruct->desc, MAX_DESC_LENGTH);
+ (*env)->ReleaseByteArrayElements(env, desc, desc1, 0);
+ }
+ (*env)->SetShortField(env, lpObject, lpCache->size, lpStruct->size);
+ (*env)->SetShortField(env, lpObject, lpCache->style, lpStruct->style);
+ (*env)->SetShortField(env, lpObject, lpCache->ascender, lpStruct->ascender);
+ (*env)->SetShortField(env, lpObject, lpCache->descender, lpStruct->descender);
+ (*env)->SetShortField(env, lpObject, lpCache->width, lpStruct->width);
+ (*env)->SetIntField(env, lpObject, lpCache->lochar, lpStruct->lochar);
+ (*env)->SetIntField(env, lpObject, lpCache->hichar, lpStruct->hichar);
+}
+
+void cachePhDim_tFids(JNIEnv *env, jobject lpObject, PPhDim_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->w = (*env)->GetFieldID(env, lpCache->clazz, "w", "S");
+ lpCache->h = (*env)->GetFieldID(env, lpCache->clazz, "h", "S");
+ lpCache->cached = 1;
+}
+
+void getPhDim_tFields(JNIEnv *env, jobject lpObject, PhDim_t *lpStruct, PPhDim_t_FID_CACHE lpCache)
+{
+ lpStruct->w = (*env)->GetShortField(env, lpObject, lpCache->w);
+ lpStruct->h = (*env)->GetShortField(env, lpObject, lpCache->h);
+}
+
+void setPhDim_tFields(JNIEnv *env, jobject lpObject, PhDim_t *lpStruct, PPhDim_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->w, lpStruct->w);
+ (*env)->SetShortField(env, lpObject, lpCache->h, lpStruct->h);
+}
+
+void cachePhImage_tFids(JNIEnv *env, jobject lpObject, PPhImage_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->type = (*env)->GetFieldID(env, lpCache->clazz, "type", "I");
+ lpCache->image_tag = (*env)->GetFieldID(env, lpCache->clazz, "image_tag", "I");
+ lpCache->bpl = (*env)->GetFieldID(env, lpCache->clazz, "bpl", "I");
+ lpCache->size_w = (*env)->GetFieldID(env, lpCache->clazz, "size_w", "S");
+ lpCache->size_h = (*env)->GetFieldID(env, lpCache->clazz, "size_h", "S");
+ lpCache->palette_tag = (*env)->GetFieldID(env, lpCache->clazz, "palette_tag", "I");
+ lpCache->colors = (*env)->GetFieldID(env, lpCache->clazz, "colors", "I");
+ lpCache->alpha = (*env)->GetFieldID(env, lpCache->clazz, "alpha", "I");
+ lpCache->transparent = (*env)->GetFieldID(env, lpCache->clazz, "transparent", "I");
+ lpCache->format = (*env)->GetFieldID(env, lpCache->clazz, "format", "B");
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "B");
+ lpCache->ghost_bpl = (*env)->GetFieldID(env, lpCache->clazz, "ghost_bpl", "B");
+ lpCache->spare1 = (*env)->GetFieldID(env, lpCache->clazz, "spare1", "B");
+ lpCache->ghost_bitmap = (*env)->GetFieldID(env, lpCache->clazz, "ghost_bitmap", "I");
+ lpCache->mask_bpl = (*env)->GetFieldID(env, lpCache->clazz, "mask_bpl", "I");
+ lpCache->mask_bm = (*env)->GetFieldID(env, lpCache->clazz, "mask_bm", "I");
+ lpCache->palette = (*env)->GetFieldID(env, lpCache->clazz, "palette", "I");
+ lpCache->image = (*env)->GetFieldID(env, lpCache->clazz, "image", "I");
+ lpCache->cached = 1;
+}
+
+void getPhImage_tFields(JNIEnv *env, jobject lpObject, PhImage_t *lpStruct, PPhImage_t_FID_CACHE lpCache)
+{
+ lpStruct->type = (*env)->GetIntField(env, lpObject, lpCache->type);
+ lpStruct->image_tag = (*env)->GetIntField(env, lpObject, lpCache->image_tag);
+ lpStruct->bpl = (*env)->GetIntField(env, lpObject, lpCache->bpl);
+ lpStruct->size.w = (*env)->GetShortField(env, lpObject, lpCache->size_w);
+ lpStruct->size.h = (*env)->GetShortField(env, lpObject, lpCache->size_h);
+ lpStruct->palette_tag = (*env)->GetIntField(env, lpObject, lpCache->palette_tag);
+ lpStruct->colors = (*env)->GetIntField(env, lpObject, lpCache->colors);
+ lpStruct->alpha = (PgAlpha_t *)(*env)->GetIntField(env, lpObject, lpCache->alpha);
+ lpStruct->transparent = (PgColor_t)(*env)->GetIntField(env, lpObject, lpCache->transparent);
+ lpStruct->format = (*env)->GetByteField(env, lpObject, lpCache->format);
+ lpStruct->flags = (*env)->GetByteField(env, lpObject, lpCache->flags);
+ lpStruct->ghost_bpl = (*env)->GetByteField(env, lpObject, lpCache->ghost_bpl);
+ lpStruct->spare1 = (*env)->GetByteField(env, lpObject, lpCache->spare1);
+ lpStruct->ghost_bitmap = (char *)(*env)->GetIntField(env, lpObject, lpCache->ghost_bitmap);
+ lpStruct->mask_bpl = (*env)->GetIntField(env, lpObject, lpCache->mask_bpl);
+ lpStruct->mask_bm = (char *)(*env)->GetIntField(env, lpObject, lpCache->mask_bm);
+ lpStruct->palette = (PgColor_t *)(*env)->GetIntField(env, lpObject, lpCache->palette);
+ lpStruct->image = (char *)(*env)->GetIntField(env, lpObject, lpCache->image);
+}
+
+void setPhImage_tFields(JNIEnv *env, jobject lpObject, PhImage_t *lpStruct, PPhImage_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->type, lpStruct->type);
+ (*env)->SetIntField(env, lpObject, lpCache->image_tag, lpStruct->image_tag);
+ (*env)->SetIntField(env, lpObject, lpCache->bpl, lpStruct->bpl);
+ (*env)->SetShortField(env, lpObject, lpCache->size_w, lpStruct->size.w);
+ (*env)->SetShortField(env, lpObject, lpCache->size_h, lpStruct->size.h);
+ (*env)->SetIntField(env, lpObject, lpCache->palette_tag, lpStruct->palette_tag);
+ (*env)->SetIntField(env, lpObject, lpCache->colors, lpStruct->colors);
+ (*env)->SetIntField(env, lpObject, lpCache->alpha, (jint)lpStruct->alpha);
+ (*env)->SetIntField(env, lpObject, lpCache->transparent, (jint)lpStruct->transparent);
+ (*env)->SetByteField(env, lpObject, lpCache->format, lpStruct->format);
+ (*env)->SetByteField(env, lpObject, lpCache->flags, lpStruct->flags);
+ (*env)->SetByteField(env, lpObject, lpCache->ghost_bpl, lpStruct->ghost_bpl);
+ (*env)->SetByteField(env, lpObject, lpCache->spare1, lpStruct->spare1);
+ (*env)->SetIntField(env, lpObject, lpCache->ghost_bitmap, (jint)lpStruct->ghost_bitmap);
+ (*env)->SetIntField(env, lpObject, lpCache->mask_bpl, lpStruct->mask_bpl);
+ (*env)->SetIntField(env, lpObject, lpCache->mask_bm, (jint)lpStruct->mask_bm);
+ (*env)->SetIntField(env, lpObject, lpCache->palette, (jint)lpStruct->palette);
+ (*env)->SetIntField(env, lpObject, lpCache->image, (jint)lpStruct->image);
+}
+
+
+void cachePhPointerEvent_tFids(JNIEnv *env, jobject lpObject, PPhPointerEvent_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
+ lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
+ lpCache->buttons = (*env)->GetFieldID(env, lpCache->clazz, "buttons", "S");
+ lpCache->button_state = (*env)->GetFieldID(env, lpCache->clazz, "button_state", "S");
+ lpCache->click_count = (*env)->GetFieldID(env, lpCache->clazz, "click_count", "B");
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "B");
+ lpCache->z = (*env)->GetFieldID(env, lpCache->clazz, "z", "S");
+ lpCache->key_mods = (*env)->GetFieldID(env, lpCache->clazz, "key_mods", "I");
+ lpCache->zero = (*env)->GetFieldID(env, lpCache->clazz, "zero", "I");
+ lpCache->cached = 1;
+}
+
+void getPhPointerEvent_tFields(JNIEnv *env, jobject lpObject, PhPointerEvent_t *lpStruct, PPhPointerEvent_t_FID_CACHE lpCache)
+{
+ lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
+ lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
+ lpStruct->buttons = (*env)->GetShortField(env, lpObject, lpCache->buttons);
+ lpStruct->button_state = (*env)->GetShortField(env, lpObject, lpCache->button_state);
+ lpStruct->click_count = (*env)->GetByteField(env, lpObject, lpCache->click_count);
+ lpStruct->flags = (*env)->GetByteField(env, lpObject, lpCache->flags);
+ lpStruct->z = (*env)->GetShortField(env, lpObject, lpCache->z);
+ lpStruct->key_mods = (*env)->GetIntField(env, lpObject, lpCache->key_mods);
+ lpStruct->zero = (*env)->GetIntField(env, lpObject, lpCache->zero);
+}
+
+void setPhPointerEvent_tFields(JNIEnv *env, jobject lpObject, PhPointerEvent_t *lpStruct, PPhPointerEvent_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
+ (*env)->SetShortField(env, lpObject, lpCache->buttons, lpStruct->buttons);
+ (*env)->SetShortField(env, lpObject, lpCache->button_state, lpStruct->button_state);
+ (*env)->SetByteField(env, lpObject, lpCache->click_count, lpStruct->click_count);
+ (*env)->SetByteField(env, lpObject, lpCache->flags, lpStruct->flags);
+ (*env)->SetShortField(env, lpObject, lpCache->z, lpStruct->z);
+ (*env)->SetIntField(env, lpObject, lpCache->key_mods, lpStruct->key_mods);
+ (*env)->SetIntField(env, lpObject, lpCache->zero, lpStruct->zero);
+}
+
+void cachePhKeyEvent_tFids(JNIEnv *env, jobject lpObject, PPhKeyEvent_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->key_flags = (*env)->GetFieldID(env, lpCache->clazz, "key_flags", "I");
+ lpCache->key_mods = (*env)->GetFieldID(env, lpCache->clazz, "key_mods", "I");
+ lpCache->key_sym = (*env)->GetFieldID(env, lpCache->clazz, "key_sym", "I");
+ lpCache->key_cap = (*env)->GetFieldID(env, lpCache->clazz, "key_cap", "I");
+ lpCache->key_scan = (*env)->GetFieldID(env, lpCache->clazz, "key_scan", "B");
+ lpCache->key_zero1 = (*env)->GetFieldID(env, lpCache->clazz, "key_zero1", "B");
+ lpCache->key_zero2 = (*env)->GetFieldID(env, lpCache->clazz, "key_zero2", "S");
+ lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
+ lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
+ lpCache->button_state = (*env)->GetFieldID(env, lpCache->clazz, "button_state", "S");
+ lpCache->cached = 1;
+}
+
+void getPhKeyEvent_tFields(JNIEnv *env, jobject lpObject, PhKeyEvent_t *lpStruct, PPhKeyEvent_t_FID_CACHE lpCache)
+{
+ lpStruct->key_flags = (*env)->GetIntField(env, lpObject, lpCache->key_flags);
+ lpStruct->key_mods = (*env)->GetIntField(env, lpObject, lpCache->key_mods);
+ lpStruct->key_sym = (*env)->GetIntField(env, lpObject, lpCache->key_sym);
+ lpStruct->key_cap = (*env)->GetIntField(env, lpObject, lpCache->key_cap);
+ lpStruct->key_scan = (*env)->GetByteField(env, lpObject, lpCache->key_scan);
+ lpStruct->key_zero1 = (*env)->GetByteField(env, lpObject, lpCache->key_zero1);
+ lpStruct->key_zero2 = (*env)->GetShortField(env, lpObject, lpCache->key_zero2);
+ lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
+ lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
+ lpStruct->button_state = (*env)->GetShortField(env, lpObject, lpCache->button_state);
+}
+
+void setPhKeyEvent_tFields(JNIEnv *env, jobject lpObject, PhKeyEvent_t *lpStruct, PPhKeyEvent_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->key_flags, lpStruct->key_flags);
+ (*env)->SetIntField(env, lpObject, lpCache->key_mods, lpStruct->key_mods);
+ (*env)->SetIntField(env, lpObject, lpCache->key_sym, lpStruct->key_sym);
+ (*env)->SetIntField(env, lpObject, lpCache->key_cap, lpStruct->key_cap);
+ (*env)->SetByteField(env, lpObject, lpCache->key_scan, lpStruct->key_scan);
+ (*env)->SetByteField(env, lpObject, lpCache->key_zero1, lpStruct->key_zero1);
+ (*env)->SetShortField(env, lpObject, lpCache->key_zero2, lpStruct->key_zero2);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
+ (*env)->SetShortField(env, lpObject, lpCache->button_state, lpStruct->button_state);
+}
+
+void cachePtScrollbarCallback_tFids(JNIEnv *env, jobject lpObject, PPtScrollbarCallback_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->action = (*env)->GetFieldID(env, lpCache->clazz, "action", "I");
+ lpCache->position = (*env)->GetFieldID(env, lpCache->clazz, "position", "I");
+ lpCache->cached = 1;
+}
+
+void getPtScrollbarCallback_tFields(JNIEnv *env, jobject lpObject, PtScrollbarCallback_t *lpStruct, PPtScrollbarCallback_t_FID_CACHE lpCache)
+{
+ lpStruct->action = (*env)->GetIntField(env, lpObject, lpCache->action);
+ lpStruct->position = (*env)->GetIntField(env, lpObject, lpCache->position);
+}
+
+void setPtScrollbarCallback_tFields(JNIEnv *env, jobject lpObject, PtScrollbarCallback_t *lpStruct, PPtScrollbarCallback_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->action, lpStruct->action);
+ (*env)->SetIntField(env, lpObject, lpCache->position, lpStruct->position);
+}
+
+void cachePhCursorInfo_tFids(JNIEnv *env, jobject lpObject, PPhCursorInfo_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
+ lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
+ lpCache->region = (*env)->GetFieldID(env, lpCache->clazz, "region", "I");
+ lpCache->ig_region = (*env)->GetFieldID(env, lpCache->clazz, "ig_region", "I");
+ lpCache->color = (*env)->GetFieldID(env, lpCache->clazz, "color", "I");
+ lpCache->last_press_x = (*env)->GetFieldID(env, lpCache->clazz, "last_press_x", "S");
+ lpCache->last_press_y = (*env)->GetFieldID(env, lpCache->clazz, "last_press_y", "S");
+ lpCache->msec = (*env)->GetFieldID(env, lpCache->clazz, "msec", "I");
+ lpCache->steady_x = (*env)->GetFieldID(env, lpCache->clazz, "steady_x", "I");
+ lpCache->steady_y = (*env)->GetFieldID(env, lpCache->clazz, "steady_y", "I");
+ lpCache->dragger = (*env)->GetFieldID(env, lpCache->clazz, "dragger", "I");
+ lpCache->drag_boundary_xUL = (*env)->GetFieldID(env, lpCache->clazz, "drag_boundary_xUL", "S");
+ lpCache->drag_boundary_yUL = (*env)->GetFieldID(env, lpCache->clazz, "drag_boundary_yUL", "S");
+ lpCache->drag_boundary_xLR = (*env)->GetFieldID(env, lpCache->clazz, "drag_boundary_xLR", "S");
+ lpCache->drag_boundary_yLR = (*env)->GetFieldID(env, lpCache->clazz, "drag_boundary_yLR", "S");
+ lpCache->phantom_rid = (*env)->GetFieldID(env, lpCache->clazz, "phantom_rid", "I");
+ lpCache->type = (*env)->GetFieldID(env, lpCache->clazz, "type", "S");
+ lpCache->ig = (*env)->GetFieldID(env, lpCache->clazz, "ig", "S");
+ lpCache->button_state = (*env)->GetFieldID(env, lpCache->clazz, "button_state", "S");
+ lpCache->click_count = (*env)->GetFieldID(env, lpCache->clazz, "click_count", "B");
+ lpCache->zero10 = (*env)->GetFieldID(env, lpCache->clazz, "zero10", "B");
+ lpCache->zero11 = (*env)->GetFieldID(env, lpCache->clazz, "zero11", "B");
+ lpCache->zero12 = (*env)->GetFieldID(env, lpCache->clazz, "zero12", "B");
+ lpCache->key_mods = (*env)->GetFieldID(env, lpCache->clazz, "key_mods", "I");
+ lpCache->zero2 = (*env)->GetFieldID(env, lpCache->clazz, "zero2", "I");
+ lpCache->cached = 1;
+}
+
+void getPhCursorInfo_tFields(JNIEnv *env, jobject lpObject, PhCursorInfo_t *lpStruct, PPhCursorInfo_t_FID_CACHE lpCache)
+{
+ lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
+ lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
+ lpStruct->region = (*env)->GetIntField(env, lpObject, lpCache->region);
+ lpStruct->ig_region = (*env)->GetIntField(env, lpObject, lpCache->ig_region);
+ lpStruct->color = (*env)->GetIntField(env, lpObject, lpCache->color);
+ lpStruct->last_press.x = (*env)->GetShortField(env, lpObject, lpCache->last_press_x);
+ lpStruct->last_press.y = (*env)->GetShortField(env, lpObject, lpCache->last_press_y);
+ lpStruct->msec = (*env)->GetIntField(env, lpObject, lpCache->msec);
+ lpStruct->steady.x = (*env)->GetIntField(env, lpObject, lpCache->steady_x);
+ lpStruct->steady.y = (*env)->GetIntField(env, lpObject, lpCache->steady_y);
+ lpStruct->dragger = (*env)->GetIntField(env, lpObject, lpCache->dragger);
+ lpStruct->drag_boundary.ul.x = (*env)->GetShortField(env, lpObject, lpCache->drag_boundary_xUL);
+ lpStruct->drag_boundary.ul.y = (*env)->GetShortField(env, lpObject, lpCache->drag_boundary_yUL);
+ lpStruct->drag_boundary.lr.x = (*env)->GetShortField(env, lpObject, lpCache->drag_boundary_xLR);
+ lpStruct->drag_boundary.lr.y = (*env)->GetShortField(env, lpObject, lpCache->drag_boundary_yLR);
+ lpStruct->phantom_rid = (*env)->GetIntField(env, lpObject, lpCache->phantom_rid);
+ lpStruct->type = (*env)->GetShortField(env, lpObject, lpCache->type);
+ lpStruct->ig = (*env)->GetShortField(env, lpObject, lpCache->ig);
+ lpStruct->button_state = (*env)->GetShortField(env, lpObject, lpCache->button_state);
+ lpStruct->click_count = (*env)->GetByteField(env, lpObject, lpCache->click_count);
+// lpStruct->zero10 = (*env)->GetByteField(env, lpObject, lpCache->zero10);
+// lpStruct->zero11 = (*env)->GetByteField(env, lpObject, lpCache->zero11);
+// lpStruct->zero12 = (*env)->GetByteField(env, lpObject, lpCache->zero12);
+ lpStruct->key_mods = (*env)->GetIntField(env, lpObject, lpCache->key_mods);
+ lpStruct->zero2 = (*env)->GetIntField(env, lpObject, lpCache->zero2);
+}
+
+void setPhCursorInfo_tFields(JNIEnv *env, jobject lpObject, PhCursorInfo_t *lpStruct, PPhCursorInfo_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
+ (*env)->SetIntField(env, lpObject, lpCache->region, lpStruct->region);
+ (*env)->SetIntField(env, lpObject, lpCache->ig_region, lpStruct->ig_region);
+ (*env)->SetIntField(env, lpObject, lpCache->color, lpStruct->color);
+ (*env)->SetShortField(env, lpObject, lpCache->last_press_x, lpStruct->last_press.x);
+ (*env)->SetShortField(env, lpObject, lpCache->last_press_y, lpStruct->last_press.y);
+ (*env)->SetIntField(env, lpObject, lpCache->msec, lpStruct->msec);
+ (*env)->SetIntField(env, lpObject, lpCache->steady_x, lpStruct->steady.x);
+ (*env)->SetIntField(env, lpObject, lpCache->steady_y, lpStruct->steady.y);
+ (*env)->SetIntField(env, lpObject, lpCache->dragger, lpStruct->dragger);
+ (*env)->SetShortField(env, lpObject, lpCache->drag_boundary_xUL, lpStruct->drag_boundary.ul.x);
+ (*env)->SetShortField(env, lpObject, lpCache->drag_boundary_yUL, lpStruct->drag_boundary.ul.y);
+ (*env)->SetShortField(env, lpObject, lpCache->drag_boundary_xLR, lpStruct->drag_boundary.lr.x);
+ (*env)->SetShortField(env, lpObject, lpCache->drag_boundary_yLR, lpStruct->drag_boundary.lr.y);
+ (*env)->SetIntField(env, lpObject, lpCache->phantom_rid, lpStruct->phantom_rid);
+ (*env)->SetShortField(env, lpObject, lpCache->type, lpStruct->type);
+ (*env)->SetShortField(env, lpObject, lpCache->ig, lpStruct->ig);
+ (*env)->SetShortField(env, lpObject, lpCache->button_state, lpStruct->button_state);
+ (*env)->SetByteField(env, lpObject, lpCache->click_count, lpStruct->click_count);
+// (*env)->SetByteField(env, lpObject, lpCache->zero10, lpStruct->zero10);
+// (*env)->SetByteField(env, lpObject, lpCache->zero11, lpStruct->zero11);
+// (*env)->SetByteField(env, lpObject, lpCache->zero12, lpStruct->zero12);
+ (*env)->SetIntField(env, lpObject, lpCache->key_mods, lpStruct->key_mods);
+ (*env)->SetIntField(env, lpObject, lpCache->zero2, lpStruct->zero2);
+}
+
+void cacheFontDetailsFids(JNIEnv *env, jobject lpObject, PFontDetails_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->desc = (*env)->GetFieldID(env, lpCache->clazz, "desc", "[B");
+ lpCache->stem = (*env)->GetFieldID(env, lpCache->clazz, "stem", "[B");
+ lpCache->losize = (*env)->GetFieldID(env, lpCache->clazz, "losize", "S");
+ lpCache->hisize = (*env)->GetFieldID(env, lpCache->clazz, "hisize", "S");
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "S");
+ lpCache->cached = 1;
+}
+
+void getFontDetailsFields(JNIEnv *env, jobject lpObject, FontDetails *lpStruct, PFontDetails_FID_CACHE lpCache)
+{
+ jbyteArray desc, stem = (*env)->GetObjectField(env, lpObject, lpCache->stem);
+ if (stem) {
+ jbyte *stem1 = (*env)->GetByteArrayElements(env, stem, NULL);
+ memcpy(lpStruct->stem, stem1, MAX_FONT_TAG);
+ (*env)->ReleaseByteArrayElements(env, stem, stem1, JNI_ABORT);
+ }
+ desc = (*env)->GetObjectField(env, lpObject, lpCache->desc);
+ if (desc) {
+ jbyte *desc1 = (*env)->GetByteArrayElements(env, desc, NULL);
+ memcpy(lpStruct->desc, desc1, MAX_DESC_LENGTH);
+ (*env)->ReleaseByteArrayElements(env, desc, desc1, JNI_ABORT);
+ }
+ lpStruct->losize = (*env)->GetShortField(env, lpObject, lpCache->losize);
+ lpStruct->hisize = (*env)->GetShortField(env, lpObject, lpCache->hisize);
+ lpStruct->flags = (*env)->GetShortField(env, lpObject, lpCache->flags);
+}
+
+void setFontDetailsFields(JNIEnv *env, jobject lpObject, FontDetails *lpStruct, PFontDetails_FID_CACHE lpCache)
+{
+ jbyteArray desc, stem = (*env)->GetObjectField(env, lpObject, lpCache->stem);
+ if (stem) {
+ jbyte *stem1 = (*env)->GetByteArrayElements(env, stem, NULL);
+ memcpy(stem1, lpStruct->stem, MAX_FONT_TAG);
+ (*env)->ReleaseByteArrayElements(env, stem, stem1, 0);
+ }
+ desc = (*env)->GetObjectField(env, lpObject, lpCache->desc);
+ if (desc) {
+ jbyte *desc1 = (*env)->GetByteArrayElements(env, desc, NULL);
+ memcpy(desc1, lpStruct->desc, MAX_DESC_LENGTH);
+ (*env)->ReleaseByteArrayElements(env, desc, desc1, 0);
+ }
+ (*env)->SetShortField(env, lpObject, lpCache->losize, lpStruct->losize);
+ (*env)->SetShortField(env, lpObject, lpCache->hisize, lpStruct->hisize);
+ (*env)->SetShortField(env, lpObject, lpCache->flags, lpStruct->flags);
+}
+
+void cachePhArea_tFids(JNIEnv *env, jobject lpObject, PPhArea_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
+ lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
+ lpCache->size_w = (*env)->GetFieldID(env, lpCache->clazz, "size_w", "S");
+ lpCache->size_h = (*env)->GetFieldID(env, lpCache->clazz, "size_h", "S");
+ lpCache->cached = 1;
+}
+
+void getPhArea_tFields(JNIEnv *env, jobject lpObject, PhArea_t *lpStruct, PPhArea_t_FID_CACHE lpCache)
+{
+ lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
+ lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
+ lpStruct->size.w = (*env)->GetShortField(env, lpObject, lpCache->size_w);
+ lpStruct->size.h = (*env)->GetShortField(env, lpObject, lpCache->size_h);
+}
+
+void setPhArea_tFields(JNIEnv *env, jobject lpObject, PhArea_t *lpStruct, PPhArea_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
+ (*env)->SetShortField(env, lpObject, lpCache->size_w, lpStruct->size.w);
+ (*env)->SetShortField(env, lpObject, lpCache->size_h, lpStruct->size.h);
+}
+
+void cachePtFileSelectionInfo_tFids(JNIEnv *env, jobject lpObject, PPtFileSelectionInfo_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->ret = (*env)->GetFieldID(env, lpCache->clazz, "ret", "S");
+ lpCache->path = (*env)->GetFieldID(env, lpCache->clazz, "path", "[B");
+ lpCache->dim = (*env)->GetFieldID(env, lpCache->clazz, "dim", "Lorg/eclipse/swt/internal/photon/PhDim_t;");
+ lpCache->pos = (*env)->GetFieldID(env, lpCache->clazz, "pos", "Lorg/eclipse/swt/internal/photon/PhPoint_t;");
+ lpCache->format = (*env)->GetFieldID(env, lpCache->clazz, "format", "[B");
+ lpCache->fspec = (*env)->GetFieldID(env, lpCache->clazz, "fspec", "[B");
+ lpCache->user_data = (*env)->GetFieldID(env, lpCache->clazz, "user_data", "I");
+ lpCache->confirm_display = (*env)->GetFieldID(env, lpCache->clazz, "confirm_display", "I");
+ lpCache->confirm_selection = (*env)->GetFieldID(env, lpCache->clazz, "confirm_selection", "I");
+ lpCache->new_directory = (*env)->GetFieldID(env, lpCache->clazz, "new_directory", "I");
+ lpCache->btn1 = (*env)->GetFieldID(env, lpCache->clazz, "btn1", "I");
+ lpCache->btn2 = (*env)->GetFieldID(env, lpCache->clazz, "btn2", "I");
+ lpCache->num_args = (*env)->GetFieldID(env, lpCache->clazz, "num_args", "I");
+ lpCache->args = (*env)->GetFieldID(env, lpCache->clazz, "args", "I");
+ lpCache->spare = (*env)->GetFieldID(env, lpCache->clazz, "spare", "[I");
+ lpCache->cached = 1;
+}
+
+void getPtFileSelectionInfo_tFields(JNIEnv *env, jobject lpObject, PtFileSelectionInfo_t *lpStruct, PPtFileSelectionInfo_t_FID_CACHE lpCache)
+{
+ DECL_GLOB(pGlob)
+
+ lpStruct->ret = (*env)->GetShortField(env, lpObject, lpCache->ret);
+ {
+ jbyteArray path = (*env)->GetObjectField(env, lpObject, lpCache->path);
+ if (path) {
+ jbyte *path1 = (*env)->GetByteArrayElements(env, path, NULL);
+ memcpy(lpStruct->path, path1, sizeof (lpStruct->path));
+ (*env)->ReleaseByteArrayElements(env, path, path1, 0);
+ }
+ }
+ {
+ jobject dim = (*env)->GetObjectField(env, lpObject, lpCache->dim);
+ if (dim) {
+ cachePhDim_tFids(env, dim, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, dim, &lpStruct->dim, &PGLOB(PhDim_tFc));
+ }
+ }
+ {
+ jobject pos = (*env)->GetObjectField(env, lpObject, lpCache->pos);
+ if (pos) {
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, &lpStruct->pos, &PGLOB(PhPoint_tFc));
+ }
+ }
+ {
+ jbyteArray format = (*env)->GetObjectField(env, lpObject, lpCache->format);
+ if (format) {
+ jbyte *format1 = (*env)->GetByteArrayElements(env, format, NULL);
+ memcpy(lpStruct->format, format1, sizeof (lpStruct->format));
+ (*env)->ReleaseByteArrayElements(env, format, format1, 0);
+ }
+ }
+ {
+ jbyteArray fspec = (*env)->GetObjectField(env, lpObject, lpCache->fspec);
+ if (fspec) {
+ jbyte *fspec1 = (*env)->GetByteArrayElements(env, fspec, NULL);
+ memcpy(lpStruct->fspec, fspec1, sizeof (lpStruct->fspec));
+ (*env)->ReleaseByteArrayElements(env, fspec, fspec1, 0);
+ }
+ }
+ lpStruct->user_data = (void *) (*env)->GetIntField(env, lpObject, lpCache->user_data);
+ lpStruct->confirm_display = (void *) (*env)->GetIntField(env, lpObject, lpCache->confirm_display);
+ lpStruct->confirm_selection = (void *) (*env)->GetIntField(env, lpObject, lpCache->confirm_selection);
+ lpStruct->new_directory = (void *) (*env)->GetIntField(env, lpObject, lpCache->new_directory);
+ lpStruct->btn1 = (char *) (*env)->GetIntField(env, lpObject, lpCache->btn1);
+ lpStruct->btn2 = (char *) (*env)->GetIntField(env, lpObject, lpCache->btn2);
+ lpStruct->num_args = (*env)->GetIntField(env, lpObject, lpCache->num_args);
+ lpStruct->args = (void *)(*env)->GetIntField(env, lpObject, lpCache->args);
+ {
+ jintArray spare = (*env)->GetObjectField(env, lpObject, lpCache->spare);
+ if (spare) {
+ jint *spare1 = (*env)->GetIntArrayElements(env, spare, NULL);
+ memcpy(lpStruct->spare, spare1, sizeof (lpStruct->spare));
+ (*env)->ReleaseIntArrayElements(env, spare, spare1, 0);
+ }
+ }
+}
+
+void setPtFileSelectionInfo_tFields(JNIEnv *env, jobject lpObject, PtFileSelectionInfo_t *lpStruct, PPtFileSelectionInfo_t_FID_CACHE lpCache)
+{
+ DECL_GLOB(pGlob)
+
+ (*env)->SetShortField(env, lpObject, lpCache->ret, lpStruct->ret);
+ {
+ jbyteArray path = (*env)->GetObjectField(env, lpObject, lpCache->path);
+ if (path) {
+ jbyte *path1 = (*env)->GetByteArrayElements(env, path, NULL);
+ memcpy(path1, lpStruct->path, sizeof (lpStruct->path));
+ (*env)->ReleaseByteArrayElements(env, path, path1, 0);
+ }
+ }
+ {
+ jobject dim = (*env)->GetObjectField(env, lpObject, lpCache->dim);
+ if (dim) {
+ cachePhDim_tFids(env, dim, &PGLOB(PhDim_tFc));
+ setPhDim_tFields(env, dim, &lpStruct->dim, &PGLOB(PhDim_tFc));
+ }
+ }
+ {
+ jobject pos = (*env)->GetObjectField(env, lpObject, lpCache->pos);
+ if (pos) {
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ setPhPoint_tFields(env, pos, &lpStruct->pos, &PGLOB(PhPoint_tFc));
+ }
+ }
+ {
+ jbyteArray format = (*env)->GetObjectField(env, lpObject, lpCache->format);
+ if (format) {
+ jbyte *format1 = (*env)->GetByteArrayElements(env, format, NULL);
+ memcpy(format1, lpStruct->format, sizeof (lpStruct->format));
+ (*env)->ReleaseByteArrayElements(env, format, format1, 0);
+ }
+ }
+ {
+ jbyteArray fspec = (*env)->GetObjectField(env, lpObject, lpCache->fspec);
+ if (fspec) {
+ jbyte *fspec1 = (*env)->GetByteArrayElements(env, fspec, NULL);
+ memcpy(fspec1, lpStruct->fspec, sizeof (lpStruct->fspec));
+ (*env)->ReleaseByteArrayElements(env, fspec, fspec1, 0);
+ }
+ }
+ (*env)->SetIntField(env, lpObject, lpCache->user_data, (int) lpStruct->user_data);
+ (*env)->SetIntField(env, lpObject, lpCache->confirm_display, (int) lpStruct->confirm_display);
+ (*env)->SetIntField(env, lpObject, lpCache->confirm_selection, (int) lpStruct->confirm_selection);
+ (*env)->SetIntField(env, lpObject, lpCache->new_directory, (int) lpStruct->new_directory);
+ (*env)->SetIntField(env, lpObject, lpCache->btn1, (int) lpStruct->btn1);
+ (*env)->SetIntField(env, lpObject, lpCache->btn2, (int) lpStruct->btn2);
+ (*env)->SetIntField(env, lpObject, lpCache->num_args, lpStruct->num_args);
+ (*env)->SetIntField(env, lpObject, lpCache->args, (int) lpStruct->args);
+ {
+ jintArray spare = (*env)->GetObjectField(env, lpObject, lpCache->spare);
+ if (spare) {
+ jint *spare1 = (*env)->GetIntArrayElements(env, spare, NULL);
+ memcpy(spare1, lpStruct->spare, sizeof (lpStruct->spare));
+ (*env)->ReleaseIntArrayElements(env, spare, spare1, 0);
+ }
+ }
+}
+
+void cachePgAlpha_tFids(JNIEnv *env, jobject lpObject, PPgAlpha_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->alpha_op = (*env)->GetFieldID(env, lpCache->clazz, "alpha_op", "I");
+ lpCache->src_alpha_map_dim_w = (*env)->GetFieldID(env, lpCache->clazz, "src_alpha_map_dim_w", "S");
+ lpCache->src_alpha_map_dim_h = (*env)->GetFieldID(env, lpCache->clazz, "src_alpha_map_dim_h", "S");
+ lpCache->src_alpha_map_bpl = (*env)->GetFieldID(env, lpCache->clazz, "src_alpha_map_bpl", "S");
+ lpCache->src_alpha_map_bpp = (*env)->GetFieldID(env, lpCache->clazz, "src_alpha_map_bpp", "S");
+ lpCache->src_alpha_map_map = (*env)->GetFieldID(env, lpCache->clazz, "src_alpha_map_map", "I");
+ lpCache->src_global_alpha = (*env)->GetFieldID(env, lpCache->clazz, "src_global_alpha", "B");
+ lpCache->dest_global_alpha = (*env)->GetFieldID(env, lpCache->clazz, "dest_global_alpha", "B");
+ lpCache->cached = 1;
+}
+
+void getPgAlpha_tFields(JNIEnv *env, jobject lpObject, PgAlpha_t *lpStruct, PPgAlpha_t_FID_CACHE lpCache)
+{
+ lpStruct->alpha_op = (*env)->GetIntField(env, lpObject, lpCache->alpha_op);
+ lpStruct->src_alpha_map.dim.w = (*env)->GetShortField(env, lpObject, lpCache->src_alpha_map_dim_w);
+ lpStruct->src_alpha_map.dim.h = (*env)->GetShortField(env, lpObject, lpCache->src_alpha_map_dim_h);
+ lpStruct->src_alpha_map.bpl = (*env)->GetShortField(env, lpObject, lpCache->src_alpha_map_bpl);
+ lpStruct->src_alpha_map.bpp = (*env)->GetShortField(env, lpObject, lpCache->src_alpha_map_bpp);
+ lpStruct->src_alpha_map.map = (char *)(*env)->GetIntField(env, lpObject, lpCache->src_alpha_map_map);
+ lpStruct->src_global_alpha = (*env)->GetByteField(env, lpObject, lpCache->src_global_alpha);
+ lpStruct->dest_global_alpha = (*env)->GetByteField(env, lpObject, lpCache->dest_global_alpha);
+}
+
+void setPgAlpha_tFields(JNIEnv *env, jobject lpObject, PgAlpha_t *lpStruct, PPgAlpha_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->alpha_op, lpStruct->alpha_op);
+ (*env)->SetShortField(env, lpObject, lpCache->src_alpha_map_dim_w, lpStruct->src_alpha_map.dim.w);
+ (*env)->SetShortField(env, lpObject, lpCache->src_alpha_map_dim_h, lpStruct->src_alpha_map.dim.h);
+ (*env)->SetShortField(env, lpObject, lpCache->src_alpha_map_bpl, lpStruct->src_alpha_map.bpl);
+ (*env)->SetShortField(env, lpObject, lpCache->src_alpha_map_bpp, lpStruct->src_alpha_map.bpp);
+ (*env)->SetIntField(env, lpObject, lpCache->src_alpha_map_map, (jint)lpStruct->src_alpha_map.map);
+ (*env)->SetByteField(env, lpObject, lpCache->src_global_alpha, lpStruct->src_global_alpha);
+ (*env)->SetByteField(env, lpObject, lpCache->dest_global_alpha, lpStruct->dest_global_alpha);
+}
+
+void cachePtTextCallback_tFids(JNIEnv *env, jobject lpObject, PPtTextCallback_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->start_pos = (*env)->GetFieldID(env, lpCache->clazz, "start_pos", "I");
+ lpCache->end_pos = (*env)->GetFieldID(env, lpCache->clazz, "end_pos", "I");
+ lpCache->cur_insert = (*env)->GetFieldID(env, lpCache->clazz, "cur_insert", "I");
+ lpCache->new_insert = (*env)->GetFieldID(env, lpCache->clazz, "new_insert", "I");
+ lpCache->length = (*env)->GetFieldID(env, lpCache->clazz, "length", "I");
+ lpCache->reserved = (*env)->GetFieldID(env, lpCache->clazz, "reserved", "S");
+ lpCache->text = (*env)->GetFieldID(env, lpCache->clazz, "text", "I");
+ lpCache->doit = (*env)->GetFieldID(env, lpCache->clazz, "doit", "I");
+ lpCache->cached = 1;
+}
+
+void getPtTextCallback_tFields(JNIEnv *env, jobject lpObject, PtTextCallback_t *lpStruct, PPtTextCallback_t_FID_CACHE lpCache)
+{
+ lpStruct->start_pos = (*env)->GetIntField(env, lpObject, lpCache->start_pos);
+ lpStruct->end_pos = (*env)->GetIntField(env, lpObject, lpCache->end_pos);
+ lpStruct->cur_insert = (*env)->GetIntField(env, lpObject, lpCache->cur_insert);
+ lpStruct->new_insert = (*env)->GetIntField(env, lpObject, lpCache->new_insert);
+ lpStruct->length = (*env)->GetIntField(env, lpObject, lpCache->length);
+ lpStruct->reserved = (*env)->GetShortField(env, lpObject, lpCache->reserved);
+ lpStruct->text = (char *)(*env)->GetIntField(env, lpObject, lpCache->text);
+ lpStruct->doit = (*env)->GetIntField(env, lpObject, lpCache->doit);
+}
+
+void setPtTextCallback_tFields(JNIEnv *env, jobject lpObject, PtTextCallback_t *lpStruct, PPtTextCallback_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->start_pos, lpStruct->start_pos);
+ (*env)->SetIntField(env, lpObject, lpCache->end_pos, lpStruct->end_pos);
+ (*env)->SetIntField(env, lpObject, lpCache->cur_insert, lpStruct->cur_insert);
+ (*env)->SetIntField(env, lpObject, lpCache->new_insert, lpStruct->new_insert);
+ (*env)->SetIntField(env, lpObject, lpCache->length, lpStruct->length);
+ (*env)->SetShortField(env, lpObject, lpCache->reserved, lpStruct->reserved);
+ (*env)->SetIntField(env, lpObject, lpCache->text, (jint)lpStruct->text);
+ (*env)->SetIntField(env, lpObject, lpCache->doit, lpStruct->doit);
+}
+void cachePtTreeItem_tFids(JNIEnv *env, jobject lpObject, PPtTreeItem_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->list_flags = (*env)->GetFieldID(env, lpCache->clazz, "list_flags", "I");
+ lpCache->list_size_w = (*env)->GetFieldID(env, lpCache->clazz, "list_size_w", "S");
+ lpCache->list_size_h = (*env)->GetFieldID(env, lpCache->clazz, "list_size_h", "S");
+ lpCache->list_next = (*env)->GetFieldID(env, lpCache->clazz, "list_next", "I");
+ lpCache->list_prev = (*env)->GetFieldID(env, lpCache->clazz, "list_prev", "I");
+ lpCache->father = (*env)->GetFieldID(env, lpCache->clazz, "father", "I");
+ lpCache->son = (*env)->GetFieldID(env, lpCache->clazz, "son", "I");
+ lpCache->brother = (*env)->GetFieldID(env, lpCache->clazz, "brother", "I");
+ lpCache->dim_w = (*env)->GetFieldID(env, lpCache->clazz, "dim_w", "S");
+ lpCache->dim_h = (*env)->GetFieldID(env, lpCache->clazz, "dim_h", "S");
+ lpCache->img_set = (*env)->GetFieldID(env, lpCache->clazz, "img_set", "S");
+ lpCache->img_unset = (*env)->GetFieldID(env, lpCache->clazz, "img_unset", "S");
+ lpCache->data = (*env)->GetFieldID(env, lpCache->clazz, "data", "I");
+ lpCache->cached = 1;
+}
+
+void getPtTreeItem_tFields(JNIEnv *env, jobject lpObject, PtTreeItem_t *lpStruct, PPtTreeItem_t_FID_CACHE lpCache)
+{
+ lpStruct->gen.list.flags = (*env)->GetIntField(env, lpObject, lpCache->list_flags);
+ lpStruct->gen.list.size.w = (*env)->GetShortField(env, lpObject, lpCache->list_size_w);
+ lpStruct->gen.list.size.h = (*env)->GetShortField(env, lpObject, lpCache->list_size_h);
+ lpStruct->gen.list.next = (void *) (*env)->GetIntField(env, lpObject, lpCache->list_next);
+ lpStruct->gen.list.prev = (void *) (*env)->GetIntField(env, lpObject, lpCache->list_prev);
+ lpStruct->gen.father = (void *) (*env)->GetIntField(env, lpObject, lpCache->father);
+ lpStruct->gen.son = (void *) (*env)->GetIntField(env, lpObject, lpCache->son);
+ lpStruct->gen.brother = (void *) (*env)->GetIntField(env, lpObject, lpCache->brother);
+ lpStruct->gen.dim.w = (*env)->GetShortField(env, lpObject, lpCache->dim_w);
+ lpStruct->gen.dim.h = (*env)->GetShortField(env, lpObject, lpCache->dim_h);
+ lpStruct->attr.img.set = (*env)->GetShortField(env, lpObject, lpCache->img_set);
+ lpStruct->attr.img.unset = (*env)->GetShortField(env, lpObject, lpCache->img_unset);
+ lpStruct->data = (void *)(*env)->GetIntField(env, lpObject, lpCache->data);
+}
+
+void setPtTreeItem_tFields(JNIEnv *env, jobject lpObject, PtTreeItem_t *lpStruct, PPtTreeItem_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->list_flags, lpStruct->gen.list.flags);
+ (*env)->SetShortField(env, lpObject, lpCache->list_size_w, lpStruct->gen.list.size.w);
+ (*env)->SetShortField(env, lpObject, lpCache->list_size_h, lpStruct->gen.list.size.h);
+ (*env)->SetIntField(env, lpObject, lpCache->list_next, (int) lpStruct->gen.list.next);
+ (*env)->SetIntField(env, lpObject, lpCache->list_prev, (int) lpStruct->gen.list.prev);
+ (*env)->SetIntField(env, lpObject, lpCache->father, (int) lpStruct->gen.father);
+ (*env)->SetIntField(env, lpObject, lpCache->son, (int) lpStruct->gen.son);
+ (*env)->SetIntField(env, lpObject, lpCache->brother, (int) lpStruct->gen.brother);
+ (*env)->SetShortField(env, lpObject, lpCache->dim_w, lpStruct->gen.dim.w);
+ (*env)->SetShortField(env, lpObject, lpCache->dim_h, lpStruct->gen.dim.h);
+ (*env)->SetShortField(env, lpObject, lpCache->img_set, lpStruct->attr.img.set);
+ (*env)->SetShortField(env, lpObject, lpCache->img_unset, lpStruct->attr.img.unset);
+ (*env)->SetIntField(env, lpObject, lpCache->data, (int) lpStruct->data);
+}
+
+void cachePgMap_tFids(JNIEnv *env, jobject lpObject, PPgMap_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->dim_w = (*env)->GetFieldID(env, lpCache->clazz, "dim_w", "S");
+ lpCache->dim_h = (*env)->GetFieldID(env, lpCache->clazz, "dim_h", "S");
+ lpCache->bpl = (*env)->GetFieldID(env, lpCache->clazz, "bpl", "S");
+ lpCache->bpp = (*env)->GetFieldID(env, lpCache->clazz, "bpp", "S");
+ lpCache->map = (*env)->GetFieldID(env, lpCache->clazz, "map", "I");
+ lpCache->cached = 1;
+}
+
+void getPgMap_tFields(JNIEnv *env, jobject lpObject, PgMap_t *lpStruct, PPgMap_t_FID_CACHE lpCache)
+{
+ lpStruct->dim.w = (*env)->GetShortField(env, lpObject, lpCache->dim_w);
+ lpStruct->dim.h = (*env)->GetShortField(env, lpObject, lpCache->dim_h);
+ lpStruct->bpl = (*env)->GetShortField(env, lpObject, lpCache->bpl);
+ lpStruct->bpp = (*env)->GetShortField(env, lpObject, lpCache->bpp);
+ lpStruct->map = (char *)(*env)->GetIntField(env, lpObject, lpCache->map);
+}
+
+void setPgMap_tFields(JNIEnv *env, jobject lpObject, PgMap_t *lpStruct, PPgMap_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->dim_w, lpStruct->dim.w);
+ (*env)->SetShortField(env, lpObject, lpCache->dim_h, lpStruct->dim.h);
+ (*env)->SetShortField(env, lpObject, lpCache->bpl, lpStruct->bpl);
+ (*env)->SetShortField(env, lpObject, lpCache->bpp, lpStruct->bpp);
+ (*env)->SetIntField(env, lpObject, lpCache->map, (jint)lpStruct->map);
+}
+
+void cachePtColorSelectInfo_tFids(JNIEnv *env, jobject lpObject, PPtColorSelectInfo_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "S");
+ lpCache->nselectors = (*env)->GetFieldID(env, lpCache->clazz, "nselectors", "B");
+ lpCache->ncolor_models = (*env)->GetFieldID(env, lpCache->clazz, "ncolor_models", "B");
+ lpCache->color_models = (*env)->GetFieldID(env, lpCache->clazz, "color_models", "I");
+ lpCache->selectors = (*env)->GetFieldID(env, lpCache->clazz, "selectors", "I");
+ lpCache->pos_x = (*env)->GetFieldID(env, lpCache->clazz, "pos_x", "S");
+ lpCache->pos_y = (*env)->GetFieldID(env, lpCache->clazz, "pos_y", "S");
+ lpCache->size_w = (*env)->GetFieldID(env, lpCache->clazz, "size_w", "S");
+ lpCache->size_h = (*env)->GetFieldID(env, lpCache->clazz, "size_h", "S");
+ lpCache->palette = (*env)->GetFieldID(env, lpCache->clazz, "palette", "I");
+ lpCache->accept_text = (*env)->GetFieldID(env, lpCache->clazz, "accept_text", "I");
+ lpCache->dismiss_text = (*env)->GetFieldID(env, lpCache->clazz, "dismiss_text", "I");
+ lpCache->accept_dismiss_text = (*env)->GetFieldID(env, lpCache->clazz, "accept_dismiss_text", "I");
+ lpCache->apply_f = (*env)->GetFieldID(env, lpCache->clazz, "apply_f", "I");
+ lpCache->data = (*env)->GetFieldID(env, lpCache->clazz, "data", "I");
+ lpCache->rgb = (*env)->GetFieldID(env, lpCache->clazz, "rgb", "I");
+ lpCache->dialog = (*env)->GetFieldID(env, lpCache->clazz, "dialog", "I");
+ lpCache->cached = 1;
+}
+
+void getPtColorSelectInfo_tFields(JNIEnv *env, jobject lpObject, PtColorSelectInfo_t *lpStruct, PPtColorSelectInfo_t_FID_CACHE lpCache)
+{
+ lpStruct->flags = (*env)->GetShortField(env, lpObject, lpCache->flags);
+ lpStruct->nselectors = (*env)->GetByteField(env, lpObject, lpCache->nselectors);
+ lpStruct->ncolor_models = (*env)->GetByteField(env, lpObject, lpCache->ncolor_models);
+ lpStruct->color_models = (PgColorModel_t **)(*env)->GetIntField(env, lpObject, lpCache->color_models);
+ lpStruct->selectors = (PtColorSelectorSpec_t *)(*env)->GetIntField(env, lpObject, lpCache->selectors);
+ lpStruct->pos.x = (*env)->GetShortField(env, lpObject, lpCache->pos_x);
+ lpStruct->pos.y = (*env)->GetShortField(env, lpObject, lpCache->pos_y);
+ lpStruct->size.w = (*env)->GetShortField(env, lpObject, lpCache->size_w);
+ lpStruct->size.h = (*env)->GetShortField(env, lpObject, lpCache->size_h);
+ lpStruct->palette.instance = (void *)(*env)->GetIntField(env, lpObject, lpCache->palette);
+ lpStruct->accept_text = (char *)(*env)->GetIntField(env, lpObject, lpCache->accept_text);
+ lpStruct->dismiss_text = (char *)(*env)->GetIntField(env, lpObject, lpCache->dismiss_text);
+ lpStruct->accept_dismiss_text = (char *)(*env)->GetIntField(env, lpObject, lpCache->accept_dismiss_text);
+ lpStruct->apply_f = (void (*))(*env)->GetIntField(env, lpObject, lpCache->apply_f);
+ lpStruct->data = (void *)(*env)->GetIntField(env, lpObject, lpCache->data);
+ lpStruct->rgb = (*env)->GetIntField(env, lpObject, lpCache->rgb);
+ lpStruct->dialog = (PtWidget_t *)(*env)->GetIntField(env, lpObject, lpCache->dialog);
+}
+
+void setPtColorSelectInfo_tFields(JNIEnv *env, jobject lpObject, PtColorSelectInfo_t *lpStruct, PPtColorSelectInfo_t_FID_CACHE lpCache)
+{
+ (*env)->SetShortField(env, lpObject, lpCache->flags, lpStruct->flags);
+ (*env)->SetByteField(env, lpObject, lpCache->nselectors, lpStruct->nselectors);
+ (*env)->SetByteField(env, lpObject, lpCache->ncolor_models, lpStruct->ncolor_models);
+ (*env)->SetIntField(env, lpObject, lpCache->color_models, (jint)lpStruct->color_models);
+ (*env)->SetIntField(env, lpObject, lpCache->selectors, (jint)lpStruct->selectors);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_x, lpStruct->pos.x);
+ (*env)->SetShortField(env, lpObject, lpCache->pos_y, lpStruct->pos.y);
+ (*env)->SetShortField(env, lpObject, lpCache->size_w, lpStruct->size.w);
+ (*env)->SetShortField(env, lpObject, lpCache->size_h, lpStruct->size.h);
+ (*env)->SetIntField(env, lpObject, lpCache->palette, (jint)lpStruct->palette.instance);
+ (*env)->SetIntField(env, lpObject, lpCache->accept_text, (jint)lpStruct->accept_text);
+ (*env)->SetIntField(env, lpObject, lpCache->dismiss_text, (jint)lpStruct->dismiss_text);
+ (*env)->SetIntField(env, lpObject, lpCache->accept_dismiss_text, (jint)lpStruct->accept_dismiss_text);
+ (*env)->SetIntField(env, lpObject, lpCache->apply_f, (jint)lpStruct->apply_f);
+ (*env)->SetIntField(env, lpObject, lpCache->data, (jint)lpStruct->data);
+ (*env)->SetIntField(env, lpObject, lpCache->rgb, lpStruct->rgb);
+ (*env)->SetIntField(env, lpObject, lpCache->dialog, (jint)lpStruct->dialog);
+}
+
+void cachePhRegion_tFids(JNIEnv *env, jobject lpObject, PPhRegion_t_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->clazz = (*env)->GetObjectClass(env, lpObject);
+ lpCache->rid = (*env)->GetFieldID(env, lpCache->clazz, "rid", "I");
+ lpCache->handle = (*env)->GetFieldID(env, lpCache->clazz, "handle", "I");
+ lpCache->owner = (*env)->GetFieldID(env, lpCache->clazz, "owner", "I");
+ lpCache->flags = (*env)->GetFieldID(env, lpCache->clazz, "flags", "I");
+ lpCache->state = (*env)->GetFieldID(env, lpCache->clazz, "state", "S");
+ lpCache->events_sense = (*env)->GetFieldID(env, lpCache->clazz, "events_sense", "I");
+ lpCache->events_opaque = (*env)->GetFieldID(env, lpCache->clazz, "events_opaque", "I");
+ lpCache->origin_x = (*env)->GetFieldID(env, lpCache->clazz, "origin_x", "S");
+ lpCache->origin_y = (*env)->GetFieldID(env, lpCache->clazz, "origin_y", "S");
+ lpCache->parent = (*env)->GetFieldID(env, lpCache->clazz, "parent", "I");
+ lpCache->child = (*env)->GetFieldID(env, lpCache->clazz, "child", "I");
+ lpCache->bro_in_front = (*env)->GetFieldID(env, lpCache->clazz, "bro_in_front", "I");
+ lpCache->bro_behind = (*env)->GetFieldID(env, lpCache->clazz, "bro_behind", "I");
+ lpCache->cursor_color = (*env)->GetFieldID(env, lpCache->clazz, "cursor_color", "I");
+ lpCache->input_group = (*env)->GetFieldID(env, lpCache->clazz, "input_group", "S");
+ lpCache->data_len = (*env)->GetFieldID(env, lpCache->clazz, "data_len", "S");
+ lpCache->cursor_type = (*env)->GetFieldID(env, lpCache->clazz, "cursor_type", "S");
+ lpCache->cached = 1;
+}
+
+void getPhRegion_tFields(JNIEnv *env, jobject lpObject, PhRegion_t *lpStruct, PPhRegion_t_FID_CACHE lpCache)
+{
+ lpStruct->rid = (*env)->GetIntField(env, lpObject, lpCache->rid);
+ lpStruct->handle = (*env)->GetIntField(env, lpObject, lpCache->handle);
+ lpStruct->owner = (*env)->GetIntField(env, lpObject, lpCache->owner);
+ lpStruct->flags = (*env)->GetIntField(env, lpObject, lpCache->flags);
+ lpStruct->state = (*env)->GetShortField(env, lpObject, lpCache->state);
+ lpStruct->events_sense = (*env)->GetIntField(env, lpObject, lpCache->events_sense);
+ lpStruct->events_opaque = (*env)->GetIntField(env, lpObject, lpCache->events_opaque);
+ lpStruct->origin.x = (*env)->GetShortField(env, lpObject, lpCache->origin_x);
+ lpStruct->origin.y = (*env)->GetShortField(env, lpObject, lpCache->origin_y);
+ lpStruct->parent = (*env)->GetIntField(env, lpObject, lpCache->parent);
+ lpStruct->child = (*env)->GetIntField(env, lpObject, lpCache->child);
+ lpStruct->bro_in_front = (*env)->GetIntField(env, lpObject, lpCache->bro_in_front);
+ lpStruct->bro_behind = (*env)->GetIntField(env, lpObject, lpCache->bro_behind);
+ lpStruct->cursor_color = (*env)->GetIntField(env, lpObject, lpCache->cursor_color);
+ lpStruct->input_group = (*env)->GetShortField(env, lpObject, lpCache->input_group);
+ lpStruct->data_len = (*env)->GetShortField(env, lpObject, lpCache->data_len);
+ lpStruct->cursor_type = (*env)->GetShortField(env, lpObject, lpCache->cursor_type);
+}
+
+void setPhRegion_tFields(JNIEnv *env, jobject lpObject, PhRegion_t *lpStruct, PPhRegion_t_FID_CACHE lpCache)
+{
+ (*env)->SetIntField(env, lpObject, lpCache->rid, lpStruct->rid);
+ (*env)->SetIntField(env, lpObject, lpCache->handle, lpStruct->handle);
+ (*env)->SetIntField(env, lpObject, lpCache->owner, lpStruct->owner);
+ (*env)->SetIntField(env, lpObject, lpCache->flags, lpStruct->flags);
+ (*env)->SetShortField(env, lpObject, lpCache->state, lpStruct->state);
+ (*env)->SetIntField(env, lpObject, lpCache->events_sense, lpStruct->events_sense);
+ (*env)->SetIntField(env, lpObject, lpCache->events_opaque, lpStruct->events_opaque);
+ (*env)->SetShortField(env, lpObject, lpCache->origin_x, lpStruct->origin.x);
+ (*env)->SetShortField(env, lpObject, lpCache->origin_y, lpStruct->origin.y);
+ (*env)->SetIntField(env, lpObject, lpCache->parent, lpStruct->parent);
+ (*env)->SetIntField(env, lpObject, lpCache->child, lpStruct->child);
+ (*env)->SetIntField(env, lpObject, lpCache->bro_in_front, lpStruct->bro_in_front);
+ (*env)->SetIntField(env, lpObject, lpCache->bro_behind, lpStruct->bro_behind);
+ (*env)->SetIntField(env, lpObject, lpCache->cursor_color, lpStruct->cursor_color);
+ (*env)->SetShortField(env, lpObject, lpCache->input_group, lpStruct->input_group);
+ (*env)->SetShortField(env, lpObject, lpCache->data_len, lpStruct->data_len);
+ (*env)->SetShortField(env, lpObject, lpCache->cursor_type, lpStruct->cursor_type);
+}
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h
new file mode 100755
index 0000000000..dcc5e20c1b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/structs.h
@@ -0,0 +1,298 @@
+ /**
+ * JNI SWT object field getters and setters declarations for Photon structs
+ */
+
+#ifndef INC_structs_H
+#define INC_structs_H
+
+#include <Ph.h>
+#include <Pt.h>
+#include <photon/PhRender.h>
+
+/* All globals to be declared in globals.h */
+#define FID_CACHE_GLOBALS \
+ PhPoint_t_FID_CACHE PhPoint_tFc; \
+ PhRect_t_FID_CACHE PhRect_tFc; \
+ PhTile_t_FID_CACHE PhTile_tFc; \
+ PtCallbackInfo_t_FID_CACHE PtCallbackInfo_tFc; \
+ PhWindowEvent_t_FID_CACHE PhWindowEvent_tFc; \
+ PhEvent_t_FID_CACHE PhEvent_tFc; \
+ FontQueryInfo_FID_CACHE FontQueryInfoFc; \
+ PhDim_t_FID_CACHE PhDim_tFc; \
+ PhImage_t_FID_CACHE PhImage_tFc; \
+ PhPointerEvent_t_FID_CACHE PhPointerEvent_tFc; \
+ PhKeyEvent_t_FID_CACHE PhKeyEvent_tFc; \
+ PtScrollbarCallback_t_FID_CACHE PtScrollbarCallback_tFc; \
+ PhCursorInfo_t_FID_CACHE PhCursorInfo_tFc; \
+ FontDetails_FID_CACHE FontDetailsFc; \
+ PhArea_t_FID_CACHE PhArea_tFc; \
+ PtFileSelectionInfo_t_FID_CACHE PtFileSelectionInfo_tFc; \
+ PgAlpha_t_FID_CACHE PgAlpha_tFc; \
+ PtTextCallback_t_FID_CACHE PtTextCallback_tFc; \
+ PtTreeItem_t_FID_CACHE PtTreeItem_tFc; \
+ PgMap_t_FID_CACHE PgMap_tFc; \
+ PtColorSelectInfo_t_FID_CACHE PtColorSelectInfo_tFc; \
+ PhRegion_t_FID_CACHE PhRegion_tFc;
+
+/* PhPoint_t struct */
+typedef struct PhPoint_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID x, y;
+} PhPoint_t_FID_CACHE;
+typedef PhPoint_t_FID_CACHE *PPhPoint_t_FID_CACHE;
+
+void cachePhPoint_tFids(JNIEnv *env, jobject lpObject, PPhPoint_t_FID_CACHE lpCache);
+void getPhPoint_tFields(JNIEnv *env, jobject lpObject, PhPoint_t *lpStruct, PPhPoint_t_FID_CACHE lpCache);
+void setPhPoint_tFields(JNIEnv *env, jobject lpObject, PhPoint_t *lpStruct, PPhPoint_t_FID_CACHE lpCache);
+
+/* PhRect_t struct */
+typedef struct PhRect_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID ul_x, ul_y, lr_x, lr_y;
+} PhRect_t_FID_CACHE;
+typedef PhRect_t_FID_CACHE *PPhRect_t_FID_CACHE;
+
+void cachePhRect_tFids(JNIEnv *env, jobject lpObject, PPhRect_t_FID_CACHE lpCache);
+void getPhRect_tFields(JNIEnv *env, jobject lpObject, PhRect_t *lpStruct, PPhRect_t_FID_CACHE lpCache);
+void setPhRect_tFields(JNIEnv *env, jobject lpObject, PhRect_t *lpStruct, PPhRect_t_FID_CACHE lpCache);
+
+typedef struct PhTile_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID rect_ul_x, rect_ul_y, rect_lr_x, rect_lr_y, next;
+} PhTile_t_FID_CACHE;
+typedef PhTile_t_FID_CACHE *PPhTile_t_FID_CACHE;
+
+void cachePhTile_tFids(JNIEnv *env, jobject lpObject, PPhTile_t_FID_CACHE lpCache);
+void getPhTile_tFields(JNIEnv *env, jobject lpObject, PhTile_t *lpStruct, PPhTile_t_FID_CACHE lpCache);
+void setPhTile_tFields(JNIEnv *env, jobject lpObject, PhTile_t *lpStruct, PPhTile_t_FID_CACHE lpCache);
+
+typedef struct PtCallbackInfo_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID reason, reason_subtype, event, cbdata;
+} PtCallbackInfo_t_FID_CACHE;
+typedef PtCallbackInfo_t_FID_CACHE *PPtCallbackInfo_t_FID_CACHE;
+
+void cachePtCallbackInfo_tFids(JNIEnv *env, jobject lpObject, PPtCallbackInfo_t_FID_CACHE lpCache);
+void getPtCallbackInfo_tFields(JNIEnv *env, jobject lpObject, PtCallbackInfo_t *lpStruct, PPtCallbackInfo_t_FID_CACHE lpCache);
+void setPtCallbackInfo_tFields(JNIEnv *env, jobject lpObject, PtCallbackInfo_t *lpStruct, PPtCallbackInfo_t_FID_CACHE lpCache);
+
+typedef struct PhWindowEvent_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID event_f, state_f, rid, pos_x, pos_y, size_w, size_h, event_state, input_group, rsvd0, rsvd1, rsvd2, rsvd3;
+} PhWindowEvent_t_FID_CACHE;
+typedef PhWindowEvent_t_FID_CACHE *PPhWindowEvent_t_FID_CACHE;
+
+void cachePhWindowEvent_tFids(JNIEnv *env, jobject lpObject, PPhWindowEvent_t_FID_CACHE lpCache);
+void getPhWindowEvent_tFields(JNIEnv *env, jobject lpObject, PhWindowEvent_t *lpStruct, PPhWindowEvent_t_FID_CACHE lpCache);
+void setPhWindowEvent_tFields(JNIEnv *env, jobject lpObject, PhWindowEvent_t *lpStruct, PPhWindowEvent_t_FID_CACHE lpCache);
+
+/* PhEvent_t struct */
+typedef struct PhEvent_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID type, subtype, processing_flags, emitter_rid, emitter_handle, collector_rid, collector_handle, input_group, flags, timestamp, translation_x, translation_y, num_rects, data_len;
+} PhEvent_t_FID_CACHE;
+typedef PhEvent_t_FID_CACHE *PPhEvent_t_FID_CACHE;
+
+void cachePhEvent_tFids(JNIEnv *env, jobject lpObject, PPhEvent_t_FID_CACHE lpCache);
+void getPhEvent_tFields(JNIEnv *env, jobject lpObject, PhEvent_t *lpStruct, PPhEvent_t_FID_CACHE lpCache);
+void setPhEvent_tFields(JNIEnv *env, jobject lpObject, PhEvent_t *lpStruct, PPhEvent_t_FID_CACHE lpCache);
+
+/* FontQueryInfo struct */
+typedef struct FontQueryInfo_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID font, desc, size, style, ascender, descender, width, lochar, hichar;
+} FontQueryInfo_FID_CACHE;
+typedef FontQueryInfo_FID_CACHE *PFontQueryInfo_FID_CACHE;
+
+void cacheFontQueryInfoFids(JNIEnv *env, jobject lpObject, PFontQueryInfo_FID_CACHE lpCache);
+void getFontQueryInfoFields(JNIEnv *env, jobject lpObject, FontQueryInfo *lpStruct, PFontQueryInfo_FID_CACHE lpCache);
+void setFontQueryInfoFields(JNIEnv *env, jobject lpObject, FontQueryInfo *lpStruct, PFontQueryInfo_FID_CACHE lpCache);
+
+/* PhDim_t struct */
+typedef struct PhDim_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID w, h;
+} PhDim_t_FID_CACHE;
+typedef PhDim_t_FID_CACHE *PPhDim_t_FID_CACHE;
+
+void cachePhDim_tFids(JNIEnv *env, jobject lpObject, PPhDim_t_FID_CACHE lpCache);
+void getPhDim_tFields(JNIEnv *env, jobject lpObject, PhDim_t *lpStruct, PPhDim_t_FID_CACHE lpCache);
+void setPhDim_tFields(JNIEnv *env, jobject lpObject, PhDim_t *lpStruct, PPhDim_t_FID_CACHE lpCache);
+
+/* PhImage_t struct */
+typedef struct PhImage_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID type, image_tag, bpl, size_w, size_h, palette_tag, colors, alpha, transparent, format, flags, ghost_bpl, spare1, ghost_bitmap, mask_bpl, mask_bm, palette, image;
+} PhImage_t_FID_CACHE;
+typedef PhImage_t_FID_CACHE *PPhImage_t_FID_CACHE;
+
+void cachePhImage_tFids(JNIEnv *env, jobject lpObject, PPhImage_t_FID_CACHE lpCache);
+void getPhImage_tFields(JNIEnv *env, jobject lpObject, PhImage_t *lpStruct, PPhImage_t_FID_CACHE lpCache);
+void setPhImage_tFields(JNIEnv *env, jobject lpObject, PhImage_t *lpStruct, PPhImage_t_FID_CACHE lpCache);
+
+/* PhPointerEvent_t struct */
+typedef struct PhPointerEvent_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID pos_x, pos_y, buttons, button_state, click_count, flags, z, key_mods, zero;
+} PhPointerEvent_t_FID_CACHE;
+typedef PhPointerEvent_t_FID_CACHE *PPhPointerEvent_t_FID_CACHE;
+
+void cachePhPointerEvent_tFids(JNIEnv *env, jobject lpObject, PPhPointerEvent_t_FID_CACHE lpCache);
+void getPhPointerEvent_tFields(JNIEnv *env, jobject lpObject, PhPointerEvent_t *lpStruct, PPhPointerEvent_t_FID_CACHE lpCache);
+void setPhPointerEvent_tFields(JNIEnv *env, jobject lpObject, PhPointerEvent_t *lpStruct, PPhPointerEvent_t_FID_CACHE lpCache);
+
+/* PhKeyEvent_t struct */
+typedef struct PhKeyEvent_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID key_flags, key_mods, key_sym, key_cap, key_scan, key_zero1, key_zero2, pos_x, pos_y, button_state;
+} PhKeyEvent_t_FID_CACHE;
+typedef PhKeyEvent_t_FID_CACHE *PPhKeyEvent_t_FID_CACHE;
+
+void cachePhKeyEvent_tFids(JNIEnv *env, jobject lpObject, PPhKeyEvent_t_FID_CACHE lpCache);
+void getPhKeyEvent_tFields(JNIEnv *env, jobject lpObject, PhKeyEvent_t *lpStruct, PPhKeyEvent_t_FID_CACHE lpCache);
+void setPhKeyEvent_tFields(JNIEnv *env, jobject lpObject, PhKeyEvent_t *lpStruct, PPhKeyEvent_t_FID_CACHE lpCache);
+
+/* PtScrollbarCallback_t struct */
+typedef struct PtScrollbarCallback_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID action, position;
+} PtScrollbarCallback_t_FID_CACHE;
+typedef PtScrollbarCallback_t_FID_CACHE *PPtScrollbarCallback_t_FID_CACHE;
+
+void cachePtScrollbarCallback_tFids(JNIEnv *env, jobject lpObject, PPtScrollbarCallback_t_FID_CACHE lpCache);
+void getPtScrollbarCallback_tFields(JNIEnv *env, jobject lpObject, PtScrollbarCallback_t *lpStruct, PPtScrollbarCallback_t_FID_CACHE lpCache);
+void setPtScrollbarCallback_tFields(JNIEnv *env, jobject lpObject, PtScrollbarCallback_t *lpStruct, PPtScrollbarCallback_t_FID_CACHE lpCache);
+
+/* PhCursorInfo_t struct */
+typedef struct PhCursorInfo_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID pos_x, pos_y, region, ig_region, color, last_press_x, last_press_y, msec, steady_x, steady_y, dragger, drag_boundary_xUL, drag_boundary_yUL, drag_boundary_xLR, drag_boundary_yLR, phantom_rid, type, ig, button_state, click_count, zero10, zero11, zero12, key_mods, zero2;
+} PhCursorInfo_t_FID_CACHE;
+typedef PhCursorInfo_t_FID_CACHE *PPhCursorInfo_t_FID_CACHE;
+
+void cachePhCursorInfo_tFids(JNIEnv *env, jobject lpObject, PPhCursorInfo_t_FID_CACHE lpCache);
+void getPhCursorInfo_tFields(JNIEnv *env, jobject lpObject, PhCursorInfo_t *lpStruct, PPhCursorInfo_t_FID_CACHE lpCache);
+void setPhCursorInfo_tFields(JNIEnv *env, jobject lpObject, PhCursorInfo_t *lpStruct, PPhCursorInfo_t_FID_CACHE lpCache);
+
+/* FontDetails struct */
+typedef struct FontDetails_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID desc, stem, losize, hisize, flags;
+} FontDetails_FID_CACHE;
+typedef FontDetails_FID_CACHE *PFontDetails_FID_CACHE;
+
+void cacheFontDetailsFids(JNIEnv *env, jobject lpObject, PFontDetails_FID_CACHE lpCache);
+void getFontDetailsFields(JNIEnv *env, jobject lpObject, FontDetails *lpStruct, PFontDetails_FID_CACHE lpCache);
+void setFontDetailsFields(JNIEnv *env, jobject lpObject, FontDetails *lpStruct, PFontDetails_FID_CACHE lpCache);
+
+/* PhArea_t struct */
+typedef struct PhArea_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID pos_x, pos_y, size_w, size_h;
+} PhArea_t_FID_CACHE;
+typedef PhArea_t_FID_CACHE *PPhArea_t_FID_CACHE;
+
+void cachePhArea_tFids(JNIEnv *env, jobject lpObject, PPhArea_t_FID_CACHE lpCache);
+void getPhArea_tFields(JNIEnv *env, jobject lpObject, PhArea_t *lpStruct, PPhArea_t_FID_CACHE lpCache);
+void setPhArea_tFields(JNIEnv *env, jobject lpObject, PhArea_t *lpStruct, PPhArea_t_FID_CACHE lpCache);
+
+/* PtFileSelectionInfo_t struct */
+typedef struct PtFileSelectionInfo_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID ret, path, dim, pos, format, fspec, user_data, confirm_display, confirm_selection, new_directory, btn1, btn2, num_args, args, spare;
+} PtFileSelectionInfo_t_FID_CACHE;
+typedef PtFileSelectionInfo_t_FID_CACHE *PPtFileSelectionInfo_t_FID_CACHE;
+
+void cachePtFileSelectionInfo_tFids(JNIEnv *env, jobject lpObject, PPtFileSelectionInfo_t_FID_CACHE lpCache);
+void getPtFileSelectionInfo_tFields(JNIEnv *env, jobject lpObject, PtFileSelectionInfo_t *lpStruct, PPtFileSelectionInfo_t_FID_CACHE lpCache);
+void setPtFileSelectionInfo_tFields(JNIEnv *env, jobject lpObject, PtFileSelectionInfo_t *lpStruct, PPtFileSelectionInfo_t_FID_CACHE lpCache);
+
+/* PgAlpha_t struct */
+typedef struct PgAlpha_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID alpha_op, src_alpha_map_dim_w, src_alpha_map_dim_h, src_alpha_map_bpl, src_alpha_map_bpp, src_alpha_map_map, src_global_alpha, dest_global_alpha;
+} PgAlpha_t_FID_CACHE;
+typedef PgAlpha_t_FID_CACHE *PPgAlpha_t_FID_CACHE;
+
+void cachePgAlpha_tFids(JNIEnv *env, jobject lpObject, PPgAlpha_t_FID_CACHE lpCache);
+void getPgAlpha_tFields(JNIEnv *env, jobject lpObject, PgAlpha_t *lpStruct, PPgAlpha_t_FID_CACHE lpCache);
+void setPgAlpha_tFields(JNIEnv *env, jobject lpObject, PgAlpha_t *lpStruct, PPgAlpha_t_FID_CACHE lpCache);
+
+/* PtTextCallback_t struct */
+typedef struct PtTextCallback_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID start_pos, end_pos, cur_insert, new_insert, length, reserved, text, doit;
+} PtTextCallback_t_FID_CACHE;
+typedef PtTextCallback_t_FID_CACHE *PPtTextCallback_t_FID_CACHE;
+
+void cachePtTextCallback_tFids(JNIEnv *env, jobject lpObject, PPtTextCallback_t_FID_CACHE lpCache);
+void getPtTextCallback_tFields(JNIEnv *env, jobject lpObject, PtTextCallback_t *lpStruct, PPtTextCallback_t_FID_CACHE lpCache);
+void setPtTextCallback_tFields(JNIEnv *env, jobject lpObject, PtTextCallback_t *lpStruct, PPtTextCallback_t_FID_CACHE lpCache);
+
+/* PtTreeItem_t struct */
+typedef struct PtTreeItem_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID list_flags, list_size_w, list_size_h, list_next, list_prev, father, son, brother, dim_w, dim_h, img_set, img_unset, data;
+} PtTreeItem_t_FID_CACHE;
+typedef PtTreeItem_t_FID_CACHE *PPtTreeItem_t_FID_CACHE;
+
+void cachePtTreeItem_tFids(JNIEnv *env, jobject lpObject, PPtTreeItem_t_FID_CACHE lpCache);
+void getPtTreeItem_tFields(JNIEnv *env, jobject lpObject, PtTreeItem_t *lpStruct, PPtTreeItem_t_FID_CACHE lpCache);
+void setPtTreeItem_tFields(JNIEnv *env, jobject lpObject, PtTreeItem_t *lpStruct, PPtTreeItem_t_FID_CACHE lpCache);
+
+/* PgMap_t struct */
+typedef struct PgMap_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID dim_w, dim_h, bpl, bpp, map;
+} PgMap_t_FID_CACHE;
+typedef PgMap_t_FID_CACHE *PPgMap_t_FID_CACHE;
+
+void cachePgMap_tFids(JNIEnv *env, jobject lpObject, PPgMap_t_FID_CACHE lpCache);
+void getPgMap_tFields(JNIEnv *env, jobject lpObject, PgMap_t *lpStruct, PPgMap_t_FID_CACHE lpCache);
+void setPgMap_tFields(JNIEnv *env, jobject lpObject, PgMap_t *lpStruct, PPgMap_t_FID_CACHE lpCache);
+
+/* PtColorSelectInfo_t struct */
+typedef struct PtColorSelectInfo_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID flags, nselectors, ncolor_models, color_models, selectors, pos_x, pos_y, size_w, size_h, palette, accept_text, dismiss_text, accept_dismiss_text, apply_f, data, rgb, dialog;
+ } PtColorSelectInfo_t_FID_CACHE;
+typedef PtColorSelectInfo_t_FID_CACHE *PPtColorSelectInfo_t_FID_CACHE;
+
+void cachePtColorSelectInfo_tFids(JNIEnv *env, jobject lpObject, PPtColorSelectInfo_t_FID_CACHE lpCache);
+void getPtColorSelectInfo_tFields(JNIEnv *env, jobject lpObject, PtColorSelectInfo_t *lpStruct, PPtColorSelectInfo_t_FID_CACHE lpCache);
+void setPtColorSelectInfo_tFields(JNIEnv *env, jobject lpObject, PtColorSelectInfo_t *lpStruct, PPtColorSelectInfo_t_FID_CACHE lpCache);
+
+/* PhRegion_t struct */
+typedef struct PhRegion_t_FID_CACHE {
+ int cached;
+ jclass clazz;
+ jfieldID rid, handle, owner, flags, state, events_sense, events_opaque, origin_x, origin_y, parent, child, bro_in_front, bro_behind, cursor_color, input_group, data_len, cursor_type;
+} PhRegion_t_FID_CACHE;
+typedef PhRegion_t_FID_CACHE *PPhRegion_t_FID_CACHE;
+
+void cachePhRegion_tFids(JNIEnv *env, jobject lpObject, PPhRegion_t_FID_CACHE lpCache);
+void getPhRegion_tFields(JNIEnv *env, jobject lpObject, PhRegion_t *lpStruct, PPhRegion_t_FID_CACHE lpCache);
+void setPhRegion_tFields(JNIEnv *env, jobject lpObject, PhRegion_t *lpStruct, PPhRegion_t_FID_CACHE lpCache);
+
+#endif // INC_structs_H
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c
new file mode 100755
index 0000000000..dedefe1af2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/library/swt.c
@@ -0,0 +1,5896 @@
+/**
+ * SWT OS natives implementation.
+ */
+
+// #define PRINT_FAILED_RCODES
+#define NDEBUG
+
+#include "globals.h"
+#include "structs.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <malloc.h>
+
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_photon_OS_getSharedLibraryMajorVersionNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryMajorVersionNumber\n");
+#endif
+ return SWT_LIBRARY_MAJOR_VERSION;
+}
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_photon_OS_getSharedLibraryMinorVersionNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryMinorVersionNumber\n");
+#endif
+ return SWT_LIBRARY_MINOR_VERSION;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindow
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWindow
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWindow\n");
+#endif
+
+ return (jint)PtWindow;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtList
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtList
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtList\n");
+#endif
+
+ return (jint)PtList;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtLabel
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtLabel
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtLabel\n");
+#endif
+
+ return (jint)PtLabel;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtInit
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtInit
+ (JNIEnv *env, jobject that, jbyteArray name)
+{
+ char *name1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtInit\n");
+#endif
+
+ if (name)
+ name1 = (char *)(*env)->GetByteArrayElements(env, name, NULL);
+
+ result = (jint)PtInit(name1);
+
+ if (name)
+ (*env)->ReleaseByteArrayElements(env, name, (jbyte *)name1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtCreateWidget
+ * Signature: (III[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtCreateWidget
+ (JNIEnv *env, jobject that, jint clazz, jint parent, jint n_args, jintArray args)
+{
+ PtArg_t *args1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtCreateWidget\n");
+#endif
+
+ if (args)
+ args1 = (PtArg_t *)(*env)->GetIntArrayElements(env, args, NULL);
+
+ result = (jint)PtCreateWidget((PtWidgetClassRef_t *)clazz, (PtWidget_t *)parent, n_args, args1);
+
+ if (args)
+ (*env)->ReleaseIntArrayElements(env, args, (jint *)args1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSetResources
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSetResources
+ (JNIEnv *env, jobject that, jint widget, jint n_args, jintArray args)
+{
+ jint *args1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSetResources\n");
+#endif
+
+ if (args)
+ args1 = (*env)->GetIntArrayElements(env, args, NULL);
+
+ result = (jint)PtSetResources((PtWidget_t *)widget, n_args, (PtArg_t *)args1);
+
+ if (args)
+ (*env)->ReleaseIntArrayElements(env, args, args1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtRealizeWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtRealizeWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtRealizeWidget\n");
+#endif
+
+ return (jint)PtRealizeWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAddEventHandler
+ * Signature: (IIII)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAddEventHandler
+ (JNIEnv *env, jobject that, jint widget, jint event_mask, jint callback, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAddEventHandler\n");
+#endif
+
+ PtAddEventHandler((PtWidget_t *)widget, (unsigned long)event_mask, (PtCallbackF_t *)callback, (void *)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetRid
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetRid
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetRid\n");
+#endif
+
+ return (jint)PtWidgetRid((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtMainLoop
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtMainLoop
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtMainLoop\n");
+#endif
+
+ PtMainLoop();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgFlush
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgFlush
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgFlush\n");
+#endif
+
+ return (jint)PgFlush();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgCreateGC
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgCreateGC
+ (JNIEnv *env, jobject that, jint size)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgCreateGC\n");
+#endif
+
+ return (jint)PgCreateGC(size);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetGC
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetGC
+ (JNIEnv *env, jobject that, jint GC)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetGC\n");
+#endif
+
+ return (jint)PgSetGC((PhGC_t *)GC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetRegion
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetRegion
+ (JNIEnv *env, jobject that, jint rid)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetRegion\n");
+#endif
+
+ PgSetRegion(rid);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetFillColor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetFillColor
+ (JNIEnv *env, jobject that, jint color)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetFillColor\n");
+#endif
+
+ return (jint)PgSetFillColor(color);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetStrokeColor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetStrokeColor
+ (JNIEnv *env, jobject that, jint color)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetStrokeColor\n");
+#endif
+
+ return (jint)PgSetStrokeColor(color);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetTextColor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetTextColor
+ (JNIEnv *env, jobject that, jint color)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetTextColor\n");
+#endif
+
+ return (jint)PgSetTextColor(color);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetFont
+ * Signature: ([B)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetFont
+ (JNIEnv *env, jobject that, jbyteArray ff)
+{
+ jbyte *ff1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetFont\n");
+#endif
+
+ if (ff)
+ ff1 = (*env)->GetByteArrayElements(env, ff, NULL);
+
+ PgSetFont(ff1);
+
+ if (ff)
+ (*env)->ReleaseByteArrayElements(env, ff, ff1, JNI_ABORT);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetStrokeDash
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetStrokeDash
+ (JNIEnv *env, jobject that, jbyteArray DashList, jint ListLen, jint DashScale)
+{
+ jbyte *DashList1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetStrokeDash\n");
+#endif
+
+ if (DashList)
+ DashList1 = (*env)->GetByteArrayElements(env, DashList, NULL);
+
+ PgSetStrokeDash(DashList1, ListLen, DashScale);
+
+ if (DashList)
+ (*env)->ReleaseByteArrayElements(env, DashList, DashList1, JNI_ABORT);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetStrokeWidth
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetStrokeWidth
+ (JNIEnv *env, jobject that, jint width)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetStrokeWidth\n");
+#endif
+
+ return (jint)PgSetStrokeWidth(width);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetDrawMode
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetDrawMode
+ (JNIEnv *env, jobject that, jint mode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetDrawMode\n");
+#endif
+
+ return (jint)PgSetDrawMode(mode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetClipping
+ * Signature: (SI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetClipping
+ (JNIEnv *env, jobject that, jshort n, jint rects)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetClipping\n");
+#endif
+
+ PgSetClipping(n, (PhRect_t *)rects);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetPalette
+ * Signature: (IISSII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetPalette
+ (JNIEnv *env, jobject that, jint palette, jint palette_id, jshort first_color, jshort num_colors, jint flags, jint tag)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetPalette\n");
+#endif
+
+ return (jint)PgSetPalette((PgColor_t *)palette, palette_id, first_color, num_colors, flags, tag);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawArc
+ * Signature: (Lorg/eclipse/swt/photon/PhPoint_t;Lorg/eclipse/swt/photon/PhPoint_t;III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawArc
+ (JNIEnv *env, jobject that, jobject center, jobject radii, jint start, jint end, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t center1, *lpCenter1=NULL, radii1, *lpRadii1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawArc\n");
+#endif
+
+ if (center) {
+ lpCenter1 = &center1;
+ cachePhPoint_tFids(env, center, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, center, lpCenter1, &PGLOB(PhPoint_tFc));
+ }
+ if (radii) {
+ lpRadii1 = &radii1;
+ getPhPoint_tFields(env, radii, lpRadii1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PgDrawArc(lpCenter1, lpRadii1, start, end, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawEllipse
+ * Signature: (Lorg/eclipse/swt/photon/PhPoint_t;Lorg/eclipse/swt/photon/PhPoint_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawEllipse
+ (JNIEnv *env, jobject that, jobject center, jobject radii, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t center1, *lpCenter1=NULL, radii1, *lpRadii1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawEllipse\n");
+#endif
+
+ if (center) {
+ lpCenter1 = &center1;
+ cachePhPoint_tFids(env, center, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, center, lpCenter1, &PGLOB(PhPoint_tFc));
+ }
+ if (radii) {
+ lpRadii1 = &radii1;
+ getPhPoint_tFields(env, radii, lpRadii1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PgDrawEllipse(lpCenter1, lpRadii1, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawRoundRect
+ * Signature: (Lorg/eclipse/swt/photon/PhRect_t;Lorg/eclipse/swt/photon/PhPoint_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawRoundRect
+ (JNIEnv *env, jobject that, jobject rect, jobject radii, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+ PhPoint_t radii1, *lpRadii1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawRoundRect\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ if (radii) {
+ lpRadii1 = &radii1;
+ cachePhPoint_tFids(env, radii, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, radii, lpRadii1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PgDrawRoundRect(lpRect1, lpRadii1, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawPolygon
+ * Signature: ([SI;Lorg/eclipse/swt/photon/PhPoint_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawPolygon
+ (JNIEnv *env, jobject that, jshortArray ptr, jint num, jobject pos, jint flags)
+{
+ DECL_GLOB(pGlob)
+ jshort *ptr1=NULL;
+ PhPoint_t pos1, *lpPos1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawPolygon\n");
+#endif
+
+ if (ptr)
+ ptr1 = (*env)->GetShortArrayElements(env, ptr, NULL);
+
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+
+ result = (jint) PgDrawPolygon((PhPoint_t *)ptr1, num, lpPos1, flags);
+
+ if (ptr)
+ (*env)->ReleaseShortArrayElements(env, ptr, ptr1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawILine
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawILine
+ (JNIEnv *env, jobject that, jint x1, jint y1, jint x2, jint y2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawILine\n");
+#endif
+
+ return (jint)PgDrawILine(x1, y1, x2, y2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawIRect
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawIRect
+ (JNIEnv *env, jobject that, jint ulx, jint uly, jint lrx, jint lry, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawIRect\n");
+#endif
+
+ return (jint)PgDrawIRect(ulx, uly, lrx, lry, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetMultiClip
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetMultiClip
+ (JNIEnv *env, jobject that, jint num, jint clip_list)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetMultiClip\n");
+#endif
+
+ return (jint)PgSetMultiClip(num, (PhRect_t *)clip_list);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetUserClip
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetUserClip__I
+ (JNIEnv *env, jobject that, jint ClipRect)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetUserClip\n");
+#endif
+
+ PgSetUserClip((PhRect_t *)ClipRect);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetUserClip
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetUserClip__Lorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv *env, jobject that, jobject ClipRect)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t ClipRect1, *lpClipRect1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetUserClip\n");
+#endif
+
+ if (ClipRect) {
+ lpClipRect1 = &ClipRect1;
+ cachePhRect_tFids(env, ClipRect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, ClipRect, lpClipRect1, &PGLOB(PhRect_tFc));
+ }
+ PgSetUserClip(lpClipRect1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetDrawBufferSize
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetDrawBufferSize
+ (JNIEnv *env, jobject that, jint cmd_buf_len)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetDrawBufferSize\n");
+#endif
+
+ return (jint)PgSetDrawBufferSize(cmd_buf_len);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDestroyGC
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDestroyGC
+ (JNIEnv *env, jobject that, jint GC)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDestroyGC\n");
+#endif
+
+ PgDestroyGC((PhGC_t *)GC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawImage
+ * Signature: (IILorg/eclipse/swt/photon/PhPoint_t;Lorg/eclipse/swt/photon/PhDim_t;II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawImage
+ (JNIEnv *env, jobject that, jint ptr, jint type, jobject pos, jobject size, jint bpl, jint tag)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t pos1, *lpPos1=NULL;
+ PhDim_t size1, *lpSize1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawImage\n");
+#endif
+
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (size) {
+ lpSize1 = &size1;
+ cachePhDim_tFids(env, size, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, size, lpSize1, &PGLOB(PhDim_tFc));
+ }
+ return (jint) PgDrawImage((void *)ptr, type, lpPos1, lpSize1, bpl, tag);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawTImage
+ * Signature: (IILorg/eclipse/swt/photon/PhPoint_t;Lorg/eclipse/swt/photon/PhDim_t;IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawTImage
+ (JNIEnv *env, jobject that, jint ptr, jint type, jobject pos, jobject size, jint bpl, jint tag, jint TransPtr, jint TransBPL)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t pos1, *lpPos1=NULL;
+ PhDim_t size1, *lpSize1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawTImage\n");
+#endif
+
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (size) {
+ lpSize1 = &size1;
+ cachePhDim_tFids(env, size, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, size, lpSize1, &PGLOB(PhDim_tFc));
+ }
+ return (jint) PgDrawTImage((void *)ptr, type, lpPos1, lpSize1, bpl, tag, (void *)TransPtr, TransBPL);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PiCropImage
+ * Signature: (ILorg/eclipse/swt/photon/PhRect_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PiCropImage
+ (JNIEnv *env, jobject that, jint image, jobject bounds, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t bounds1, *lpBounds1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PiCropImage\n");
+#endif
+
+ if (bounds) {
+ lpBounds1 = &bounds1;
+ cachePhRect_tFids(env, bounds, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, bounds, lpBounds1, &PGLOB(PhRect_tFc));
+ }
+ return (jint) PiCropImage((PhImage_t *)image, lpBounds1, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawBitmap
+ * Signature: (IILorg/eclipse/swt/photon/PhPoint_t;Lorg/eclipse/swt/photon/PhDim_t;II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawBitmap
+ (JNIEnv *env, jobject that, jint ptr, jint flags, jobject pos, jobject size, jint bpl, jint tag)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t pos1, *lpPos1=NULL;
+ PhDim_t size1, *lpSize1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawBitmap\n");
+#endif
+
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (size) {
+ lpSize1 = &size1;
+ cachePhDim_tFids(env, size, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, size, lpSize1, &PGLOB(PhDim_tFc));
+ }
+ return (jint) PgDrawBitmap((void *)ptr, flags, lpPos1, (PhPoint_t *)lpSize1, bpl, tag);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawPhImageRectmx
+ * Signature: (Lorg/eclipse/swt/photon/PhPoint_t;ILorg/eclipse/swt/photon/PhRect_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawPhImageRectmx
+ (JNIEnv *env, jobject that, jobject pos, int image, jobject rect, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t pos1, *lpPos1=NULL;
+ PhRect_t rect1, *lpRect1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawPhImageRectmx\n");
+#endif
+
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ return (jint) PgDrawPhImageRectmx(lpPos1, (PhImage_t *)image, lpRect1, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawPhImagemx
+ * Signature: (Lorg/eclipse/swt/photon/PhPoint_t;ILorg/eclipse/swt/photon/PhRect_t;I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawPhImagemx
+ (JNIEnv *env, jobject that, jobject pos, int image, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t pos1, *lpPos1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawPhImagemx\n");
+#endif
+
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PgDrawPhImagemx(lpPos1, (PhImage_t *)image, flags);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhBlit
+ * Signature: (ILorg/eclipse/swt/photon/PhRect_t;ILorg/eclipse/swt/photon/PhPoint_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhBlit
+ (JNIEnv *env, jobject that, jint rid, jobject rect, jobject offset)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+ PhPoint_t offset1, *lpOffset1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhBlit\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ if (offset) {
+ lpOffset1 = &offset1;
+ cachePhPoint_tFids(env, offset, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, offset, lpOffset1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PhBlit((PhRid_t)rid, lpRect1, lpOffset1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhMakeTransBitmap
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhMakeTransBitmap
+ (JNIEnv *env, jobject that, jint image, jint trans_color)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhMakeTransBitmap\n");
+#endif
+
+ return (jint) PhMakeTransBitmap((PhImage_t *)image, (PgColor_t)trans_color);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtEnter
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtEnter
+ (JNIEnv *env, jobject that, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtEnter\n");
+#endif
+
+ return (jint)PtEnter(flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtLeave
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtLeave
+ (JNIEnv *env, jobject that, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtLeave\n");
+#endif
+
+ return (jint)PtLeave(flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtGetResources
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtGetResources
+ (JNIEnv *env, jobject that, jint widget, jint n_args, jintArray args)
+{
+ jint *args1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtGetResources\n");
+#endif
+
+ if (args)
+ args1 = (*env)->GetIntArrayElements(env, args, NULL);
+
+ result = (jint)PtGetResources((PtWidget_t *)widget, n_args, (PtArg_t *)args1);
+
+ if (args)
+ (*env)->ReleaseIntArrayElements(env, args, args1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtDestroyWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtDestroyWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtDestroyWidget\n");
+#endif
+
+ return (jint)PtDestroyWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhEventPeek
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhEventPeek
+ (JNIEnv *env, jobject that, jint buffer, jint size)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhEventPeek\n");
+#endif
+
+ return (jint)PhEventPeek((void *)buffer, size);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhGetMsgSize
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhGetMsgSize
+ (JNIEnv *env, jobject that, jint event_buf)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhGetMsgSize\n");
+#endif
+
+ return (jint)PhGetMsgSize((PhEvent_t *)event_buf);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhGetTile
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhGetTile
+ (JNIEnv *env, jobject that)
+{
+ PhTile_t *tile;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhGetTile\n");
+#endif
+
+ tile = PhGetTile();
+ memset(tile, 0, sizeof(PhTile_t));
+ return (jint)tile;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhTranslateTiles
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhPoint_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhTranslateTiles
+ (JNIEnv *env, jobject that, jint tile, jobject point_add)
+{
+
+ DECL_GLOB(pGlob)
+
+ PhPoint_t point_add1, *lpPoint_add1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhTranslateTiles\n");
+#endif
+
+ if (point_add) {
+ lpPoint_add1= &point_add1;
+ cachePhPoint_tFids(env, point_add, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, point_add, lpPoint_add1, &PGLOB(PhPoint_tFc));
+ }
+ result = (jint)PhTranslateTiles((PhTile_t *)tile, lpPoint_add1);
+
+ if (point_add) {
+ setPhPoint_tFields(env, point_add, lpPoint_add1, &PGLOB(PhPoint_tFc));
+ }
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhDeTranslateTiles
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhDeTranslateTiles
+ (JNIEnv *env, jobject that, jint tile, jint point_sutract)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhDeTranslateTiles\n");
+#endif
+
+ return (jint)PhDeTranslateTiles((PhTile_t *)tile, (PhPoint_t *)point_sutract);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhAddMergeTiles
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhAddMergeTiles
+ (JNIEnv *env, jobject that, jint tiles, jint add_tiles, jintArray added)
+{
+ jint *added1 = NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhAddMergeTiles\n");
+#endif
+
+ if (added)
+ added1 = (*env)->GetIntArrayElements(env, added, NULL);
+
+ result = (jint)PhAddMergeTiles((PhTile_t *)tiles, (PhTile_t *)add_tiles, added1);
+
+ if (added)
+ (*env)->ReleaseIntArrayElements(env, added, added1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhIntersectTilings
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhIntersectTilings
+ (JNIEnv *env, jobject that, jint tile1, jint tile2, jshortArray num_intersect_tiles)
+{
+ jshort *num_intersect_tiles1 = NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhIntersectTilings\n");
+#endif
+
+ if (num_intersect_tiles)
+ num_intersect_tiles1 = (*env)->GetShortArrayElements(env, num_intersect_tiles, NULL);
+
+ result = (jint)PhIntersectTilings((PhTile_t *)tile1, (PhTile_t *)tile2, num_intersect_tiles1);
+
+ if (num_intersect_tiles)
+ (*env)->ReleaseShortArrayElements(env, num_intersect_tiles, num_intersect_tiles1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhCoalesceTiles
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhCoalesceTiles
+ (JNIEnv *env, jobject that, jint tiles)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhCoalesceTiles\n");
+#endif
+
+ return (jint)PhCoalesceTiles((PhTile_t *)tiles);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhMergeTiles
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhMergeTiles
+ (JNIEnv *env, jobject that, jint tiles)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhMergeTiles\n");
+#endif
+
+ return (jint)PhMergeTiles((PhTile_t *)tiles);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhRectUnion
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhRectUnion__II
+ (JNIEnv *env, jobject that, jint rect1, jint rect2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhRectUnion__II\n");
+#endif
+
+ return (jint)PhRectUnion((PhRect_t *)rect1, (PhRect_t *)rect2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhRectIntersect
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhRectIntersect
+ (JNIEnv *env, jobject that, jint rect1, jint rect2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhRectIntersect\n");
+#endif
+
+ return (jint)PhRectIntersect((PhRect_t *)rect1, (PhRect_t *)rect2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipTilings
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipTilings
+ (JNIEnv *env, jobject that, jint tiles, jint clip_tiles, jintArray intersection)
+{
+ jint *intersection1 = NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipTilings\n");
+#endif
+
+ if (intersection)
+ intersection1 = (*env)->GetIntArrayElements(env, intersection, NULL);
+
+ result = (jint)PhClipTilings((PhTile_t *)tiles, (PhTile_t *)clip_tiles, (PhTile_t **)intersection1);
+
+ if (intersection)
+ (*env)->ReleaseIntArrayElements(env, intersection, intersection1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhTilesToRects
+ * Signature: (I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhTilesToRects
+ (JNIEnv *env, jobject that, jint tiles, jintArray num_rects)
+{
+ jint *num_rects1 = NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhTilesToRects\n");
+#endif
+
+ if (num_rects)
+ num_rects1 = (*env)->GetIntArrayElements(env, num_rects, NULL);
+
+ result = (jint)PhTilesToRects((PhTile_t *)tiles, (int *)num_rects1);
+
+ if (num_rects)
+ (*env)->ReleaseIntArrayElements(env, num_rects, num_rects1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhRectsToTiles
+ * Signature: (I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhRectsToTiles
+ (JNIEnv *env, jobject that, jint rects, jint num_rects)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhRectsToTiles\n");
+#endif
+
+ return (jint)PhRectsToTiles((PhRect_t *)rects, num_rects);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhFreeTiles
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PhFreeTiles
+ (JNIEnv *env, jobject that, jint tiles)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhFreeTiles\n");
+#endif
+
+ PhFreeTiles((PhTile_t *)tiles);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhCopyTiles
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhCopyTiles
+ (JNIEnv *env, jobject that, jint tile)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhCopyTiles\n");
+#endif
+
+ return (jint) PhCopyTiles((PhTile_t *)tile);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtEventHandler
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtEventHandler
+ (JNIEnv *env, jobject that, jint event)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtEventHandler\n");
+#endif
+
+ return (jint)PtEventHandler((PhEvent_t *)event);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: malloc
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_malloc
+ (JNIEnv *env, jclass that, jint size)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "malloc\n");
+#endif
+
+ return (jint)calloc(1, (size_t)size);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: free
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_free
+ (JNIEnv *env, jclass that, jint ptr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "free\n");
+#endif
+
+ free((void *)ptr);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhPoint_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhPoint_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhPoint_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhPoint_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhPoint_tFids(env, src, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, src, src1, &PGLOB(PhPoint_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhPoint_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhPoint_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhPoint_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhPoint_tFids(env, dest, &PGLOB(PhPoint_tFc));
+ setPhPoint_tFields(env, dest, dest1, &PGLOB(PhPoint_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhWindowQueryVisible
+ * Signature: (IIILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhWindowQueryVisible
+ (JNIEnv *env, jobject that, jint flag, jint rid, jint input_group, jobject rectangle)
+{
+ DECL_GLOB(pGlob)
+ int result;
+ PhRect_t rect, *lpRect=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhWindowQueryVisible\n");
+#endif
+
+ if (rectangle) {
+ lpRect = &rect;
+ cachePhRect_tFids(env, rectangle, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rectangle, lpRect, &PGLOB(PhRect_tFc));
+ }
+ result =PhWindowQueryVisible(flag, rid, input_group, lpRect);
+ if (rectangle) {
+ setPhRect_tFields(env, rectangle, lpRect, &PGLOB(PhRect_tFc));
+ }
+
+ return (jint) result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__I_3II
+ (JNIEnv *env, jclass that, jint dest, jintArray src, jint count)
+{
+ jint *src1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__I_3II\n");
+#endif
+
+ /* don't do anything if src pointer is NULL */
+ if (src) {
+ src1 = (*env)->GetIntArrayElements(env, src, NULL);
+ memmove((void *)dest, (void *)src1, count);
+ (*env)->ReleaseIntArrayElements(env, src, src1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: ([III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___3III
+ (JNIEnv *env, jclass that, jintArray dest, jint src, jint count)
+{
+ jint *dest1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove___3III\n");
+#endif
+
+ /* don't do anything if dest pointer is NULL */
+ if (dest) {
+ dest1 = (*env)->GetIntArrayElements(env, dest, NULL);
+ memmove((void *)dest1, (void *)src, count);
+ (*env)->ReleaseIntArrayElements(env, dest, dest1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawText
+ * Signature: ([CISSI)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawText
+ (JNIEnv *env, jclass that, jcharArray ptr, jint len, jshort x, jshort y, jint flags)
+{
+ jint result = 0;
+ jchar * ptr1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawText\n");
+#endif
+
+ if (ptr) {
+ PhPoint_t pos;
+
+ pos.x = x;
+ pos.y = y;
+ ptr1 = (*env)->GetCharArrayElements(env, ptr, NULL);
+
+ result = (jint)PgDrawText((char *)ptr1, len, &pos, (int)flags);
+
+ (*env)->ReleaseCharArrayElements(env, ptr, ptr1, JNI_ABORT);
+ }
+
+ return result;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawText
+ * Signature: ([CISSI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawText
+ (JNIEnv *env, jclass that, jbyteArray ptr, jint len, jshort x, jshort y, jint flags)
+{
+ jint result = 0;
+ jbyte * ptr1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawText\n");
+#endif
+
+ /* don't do anything if ptr is NULL */
+ if (ptr) {
+ PhPoint_t pos;
+
+ pos.x = x;
+ pos.y = y;
+ ptr1 = (*env)->GetByteArrayElements(env, ptr, NULL);
+
+ result = (jint)PgDrawText((char *)ptr1, len, &pos, (int)flags);
+
+ (*env)->ReleaseByteArrayElements(env, ptr, ptr1, JNI_ABORT);
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetExtent
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetExtent__II
+ (JNIEnv *env, jobject that, jint widget, jint extent)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetExtent\n");
+#endif
+
+ return (jint)PtWidgetExtent((PtWidget_t *)widget, (PhRect_t *)extent);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetChildBack
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetChildBack
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetChildBack\n");
+#endif
+
+ return (jint)PtWidgetChildBack((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetIsRealized
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetIsRealized
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetIsRealized\n");
+#endif
+
+ return (jint)PtWidgetIsRealized((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetBrotherInFront
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetBrotherInFront
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetBrotherInFront\n");
+#endif
+
+ return (jint)PtWidgetBrotherInFront((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetParent
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetParent
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetParent\n");
+#endif
+
+ return (jint)PtWidgetParent((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhTile_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhTile_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhTile_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhTile_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhTile_tFids(env, src, &PGLOB(PhTile_tFc));
+ getPhTile_tFields(env, src, src1, &PGLOB(PhTile_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhTile_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhTile_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhTile_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhTile_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhTile_tFids(env, dest, &PGLOB(PhTile_tFc));
+ setPhTile_tFields(env, dest, dest1, &PGLOB(PhTile_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PtCallbackInfo_t;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PtCallbackInfo_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PtCallbackInfo_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PtCallbackInfo_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePtCallbackInfo_tFids(env, src, &PGLOB(PtCallbackInfo_tFc));
+ getPtCallbackInfo_tFields(env, src, src1, &PGLOB(PtCallbackInfo_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PtCallbackInfo_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PtCallbackInfo_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PtCallbackInfo_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PtCallbackInfo_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePtCallbackInfo_tFids(env, dest, &PGLOB(PtCallbackInfo_tFc));
+ setPtCallbackInfo_tFields(env, dest, dest1, &PGLOB(PtCallbackInfo_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhWindowEvent_t;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhWindowEvent_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhWindowEvent_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhWindowEvent_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhWindowEvent_tFids(env, src, &PGLOB(PhWindowEvent_tFc));
+ getPhWindowEvent_tFields(env, src, src1, &PGLOB(PhWindowEvent_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhWindowEvent_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhWindowEvent_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhWindowEvent_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhWindowEvent_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhWindowEvent_tFids(env, dest, &PGLOB(PhWindowEvent_tFc));
+ setPhWindowEvent_tFields(env, dest, dest1, &PGLOB(PhWindowEvent_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAddCallback
+ * Signature: (IIII)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAddCallback
+ (JNIEnv *env, jobject that, jint widget, jint callback_type, jint callback, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAddEventHandler\n");
+#endif
+
+ PtAddCallback((PtWidget_t *)widget, (unsigned long)callback_type, (PtCallbackF_t *)callback, (void *)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetChildFront
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetChildFront
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetChildFront\n");
+#endif
+
+ return (jint) PtWidgetChildFront((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetBrotherBehind
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetBrotherBehind
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetBrotherBehind\n");
+#endif
+
+ return (jint) PtWidgetBrotherBehind((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (I[BI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__I_3BI
+ (JNIEnv *env, jclass that, jint dest, jbyteArray src, jint count)
+{
+ jbyte *src1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__I_3BI\n");
+#endif
+
+ /* don't do anything if src pointer is NULL */
+ if (src) {
+ src1 = (*env)->GetByteArrayElements(env, src, NULL);
+ memmove((void *)dest, (void *)src1, count);
+ (*env)->ReleaseByteArrayElements(env, src, src1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___3BII
+ (JNIEnv *env, jclass that, jbyteArray dest, jint src, jint count)
+{
+ jbyte *dest1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove___3BII\n");
+#endif
+
+ /* don't do anything if dest pointer is NULL */
+ if (dest) {
+ dest1 = (*env)->GetByteArrayElements(env, dest, NULL);
+ memmove((void *)dest1, (void *)src, count);
+ (*env)->ReleaseByteArrayElements(env, dest, dest1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindow
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtButton
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtButton\n");
+#endif
+
+ return (jint)PtButton;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhRect_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhRect_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhPoint_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhRect_tFids(env, src, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, src, src1, &PGLOB(PhRect_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhRect_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhPoint_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhRect_tFids(env, dest, &PGLOB(PhRect_tFc));
+ setPhRect_tFields(env, dest, dest1, &PGLOB(PhRect_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtUnrealizeWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtUnrealizeWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtUnrealizeWidget\n");
+#endif
+
+ return (jint)PtUnrealizeWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSyncWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSyncWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSyncWidget\n");
+#endif
+
+ return (jint)PtSyncWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtFlush
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtFlush
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtFlush\n");
+#endif
+
+ return (jint)PtFlush();
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtContainerGiveFocus
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhEvent_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtContainerGiveFocus
+ (JNIEnv *env, jobject that, jint widget, jobject event)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhEvent_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtContainerGiveFocus\n");
+#endif
+
+ if (event) {
+ lpObject = &object;
+ cachePhEvent_tFids(env, event, &PGLOB(PhEvent_tFc));
+ getPhEvent_tFields(env, event, lpObject, &PGLOB(PhEvent_tFc));
+ }
+ result = (jint) PtContainerGiveFocus((PtWidget_t *)widget, lpObject);
+ if (event) {
+ setPhEvent_tFields(env, event, lpObject, &PGLOB(PhEvent_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetToFront
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetToFront
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetToFront\n");
+#endif
+
+ return (jint) PtWidgetToFront((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetToBack
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetToBack
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetToBack\n");
+#endif
+
+ return (jint) PtWidgetToBack((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetInsert
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetInsert
+ (JNIEnv *env, jobject that, jint widget, jint new_sibling, jint behind)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetInsert\n");
+#endif
+
+ return (jint) PtWidgetInsert((PtWidget_t *)widget, (PtWidget_t *)new_sibling, behind);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtDamageExtent
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtDamageExtent
+ (JNIEnv *env, jobject that, jint widget, jobject extent)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhRect_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtContainerGiveFocus\n");
+#endif
+
+ if (extent) {
+ lpObject = &object;
+ cachePhRect_tFids(env, extent, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, extent, lpObject, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PtDamageExtent((PtWidget_t *)widget, lpObject);
+ if (extent) {
+ setPhRect_tFields(env, extent, lpObject, &PGLOB(PhRect_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__III
+ (JNIEnv *env, jobject that, jint dest, jint src, jint size)
+{
+ return (jint)memmove((void *)dest, (void *)src, size);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfQueryFontInfo
+ * Signature: ([BLorg/eclipse/swt/internal/photon/FontQueryInfo;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfQueryFontInfo
+ (JNIEnv *env, jobject that, jbyteArray font, jobject info)
+{
+ DECL_GLOB(pGlob)
+ jbyte *font1=NULL;
+ FontQueryInfo info1, *lpInfo1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfQueryFontInfo\n");
+#endif
+
+ if (font)
+ font1 = (*env)->GetByteArrayElements(env, font, NULL);
+ if (info) {
+ lpInfo1 = &info1;
+ cacheFontQueryInfoFids(env, info, &PGLOB(FontQueryInfoFc));
+ getFontQueryInfoFields(env, info, lpInfo1, &PGLOB(FontQueryInfoFc));
+ }
+
+ result = (jint)PfQueryFontInfo(font1, lpInfo1);
+
+ if (font)
+ (*env)->ReleaseByteArrayElements(env, font, font1, JNI_ABORT);
+ if (info) {
+ setFontQueryInfoFields(env, info, lpInfo1, &PGLOB(FontQueryInfoFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfQueryFonts
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfQueryFonts
+ (JNIEnv *env, jobject that, jint symbol, jint flags, jint list, jint n)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfQueryFonts\n");
+#endif
+
+ return (jint)PfQueryFonts(symbol, flags, (FontDetails *)list, n);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfExtentWideText
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhPoint_t;[B[CI)Lorg/eclipse/swt/internal/photon/PhRect_t;
+ */
+JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_photon_OS_PfExtentWideText
+ (JNIEnv *env, jobject that, jobject extent, jobject pos, jbyteArray font, jcharArray str, jint len)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t extent1, *lpExtent1=NULL;
+ PhPoint_t pos1, *lpPos1=NULL;
+ jbyte *font1=NULL;
+ jchar *str1=NULL;
+ PhRect_t * result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfExtentWideText\n");
+#endif
+
+ if (extent) {
+ lpExtent1 = &extent1;
+ cachePhRect_tFids(env, extent, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, extent, lpExtent1, &PGLOB(PhRect_tFc));
+ }
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (font)
+ font1 = (*env)->GetByteArrayElements(env, font, NULL);
+ if (str)
+ str1 = (*env)->GetCharArrayElements(env, str, NULL);
+
+ result = PfExtentWideText(lpExtent1, lpPos1, font1, str1, len);
+
+ if (extent) {
+ setPhRect_tFields(env, extent, lpExtent1, &PGLOB(PhRect_tFc));
+ }
+ if (pos) {
+ setPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (font)
+ (*env)->ReleaseByteArrayElements(env, font, font1, JNI_ABORT);
+ if (str)
+ (*env)->ReleaseCharArrayElements(env, str, str1, JNI_ABORT);
+
+ return result != NULL ? extent : NULL;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfExtentText
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhPoint_t;[B[BI)Lorg/eclipse/swt/internal/photon/PhRect_t;
+ */
+/*
+JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_photon_OS_PfExtentText
+ (JNIEnv *env, jobject that, jobject extent, jobject pos, jbyteArray font, jbyteArray str, jint len)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t extent1, *lpExtent1=NULL;
+ PhPoint_t pos1, *lpPos1=NULL;
+ jbyte *font1=NULL;
+ jbyte *str1=NULL;
+ PhRect_t * result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfExtentText\n");
+#endif
+
+ if (extent) {
+ lpExtent1 = &extent1;
+ cachePhRect_tFids(env, extent, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, extent, lpExtent1, &PGLOB(PhRect_tFc));
+ }
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (font)
+ font1 = (*env)->GetByteArrayElements(env, font, NULL);
+ if (str)
+ str1 = (*env)->GetByteArrayElements(env, str, NULL);
+
+ result = PfExtentText(lpExtent1, lpPos1, font1, str1, len);
+
+ if (extent) {
+ setPhRect_tFields(env, extent, lpExtent1, &PGLOB(PhRect_tFc));
+ }
+ if (pos) {
+ setPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (font)
+ (*env)->ReleaseByteArrayElements(env, font, font1, JNI_ABORT);
+ if (str)
+ (*env)->ReleaseByteArrayElements(env, str, str1, JNI_ABORT);
+
+ return result != NULL ? extent : NULL;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfExtentText
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhPoint_t;[B[BI)Lorg/eclipse/swt/internal/photon/PhRect_t;
+ */
+JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_photon_OS_PfExtentText
+ (JNIEnv *env, jobject that, jobject extent, jobject pos, int font, int str, jint len)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t extent1, *lpExtent1=NULL;
+ PhPoint_t pos1, *lpPos1=NULL;
+ PhRect_t * result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfExtentText\n");
+#endif
+
+ if (extent) {
+ lpExtent1 = &extent1;
+ cachePhRect_tFids(env, extent, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, extent, lpExtent1, &PGLOB(PhRect_tFc));
+ }
+ if (pos) {
+ lpPos1 = &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+
+ result = PfExtentText(lpExtent1, lpPos1, (char *)font, (char *)str, len);
+
+ if (extent) {
+ setPhRect_tFields(env, extent, lpExtent1, &PGLOB(PhRect_tFc));
+ }
+ if (pos) {
+ setPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+
+ return result != NULL ? extent : NULL;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhDim_t;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhDim_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhDim_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhDim_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhDim_tFids(env, src, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, src, src1, &PGLOB(PhDim_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhDim_t;II)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhDim_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhDim_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhDim_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhDim_tFids(env, dest, &PGLOB(PhDim_tFc));
+ setPhDim_tFields(env, dest, dest1, &PGLOB(PhDim_tFc));
+ }
+
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhImage_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhImage_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhImage_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhImage_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhImage_tFids(env, src, &PGLOB(PhImage_tFc));
+ getPhImage_tFields(env, src, src1, &PGLOB(PhImage_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhImage_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhImage_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhImage_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhImage_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhImage_tFids(env, dest, &PGLOB(PhImage_tFc));
+ setPhImage_tFields(env, dest, dest1, &PGLOB(PhImage_tFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhCreateImage
+ * Signature: (Lorg/eclipse/swt/photon/PhImage_t;SSI[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhCreateImage__Lorg_eclipse_swt_internal_photon_PhImage_1t_2SSI_3III
+ (JNIEnv *env, jobject that, jobject buffer, jshort width, jshort height, jint type, jintArray palette, jint ncolors, jint tag)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ jint *palette1 = NULL;
+ PhImage_t buffer1, *lpBuffer1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhCreateImage\n");
+#endif
+
+ if (buffer) {
+ lpBuffer1 = &buffer1;
+ cachePhImage_tFids(env, buffer, &PGLOB(PhImage_tFc));
+ getPhImage_tFields(env, buffer, lpBuffer1, &PGLOB(PhImage_tFc));
+ }
+ if (palette)
+ palette1 = (*env)->GetIntArrayElements(env, palette, NULL);
+
+ result = (jint)PhCreateImage(lpBuffer1, width, height, type, (PgColor_t *)palette1, ncolors, tag);
+
+ if (buffer) {
+ setPhImage_tFields(env, buffer, lpBuffer1, &PGLOB(PhImage_tFc));
+ }
+ if (palette)
+ (*env)->ReleaseIntArrayElements(env, palette, palette1, JNI_ABORT);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhCreateImage
+ * Signature: (Lorg/eclipse/swt/photon/PhImage_t;SSIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhCreateImage__Lorg_eclipse_swt_internal_photon_PhImage_1t_2SSIIII
+ (JNIEnv *env, jobject that, jobject buffer, jshort width, jshort height, jint type, jint palette, jint ncolors, jint tag)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhImage_t buffer1, *lpBuffer1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhCreateImage\n");
+#endif
+
+ if (buffer) {
+ lpBuffer1 = &buffer1;
+ cachePhImage_tFids(env, buffer, &PGLOB(PhImage_tFc));
+ getPhImage_tFields(env, buffer, lpBuffer1, &PGLOB(PhImage_tFc));
+ }
+
+ result = (jint)PhCreateImage(lpBuffer1, width, height, type, (PgColor_t *)palette, ncolors, tag);
+
+ if (buffer) {
+ setPhImage_tFields(env, buffer, lpBuffer1, &PGLOB(PhImage_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhReleaseImage
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PhReleaseImage
+ (JNIEnv *env, jobject that, jint image)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhReleaseImage\n");
+#endif
+
+ PhReleaseImage((PhImage_t *)image);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PmMemCreateMC
+ * Signature: (ILorg/eclipse/swt/photon/PhDim_t;Lorg/eclipse/swt/photon/PhPoint_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PmMemCreateMC
+ (JNIEnv *env, jobject that, jint image, jobject dim, jobject translation)
+{
+ DECL_GLOB(pGlob)
+ PhDim_t dim1, *lpDim1=NULL;
+ PhPoint_t translation1, *lpTranslation1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PmMemCreateMC\n");
+#endif
+
+ if (dim) {
+ lpDim1 = &dim1;
+ cachePhDim_tFids(env, dim, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, dim, lpDim1, &PGLOB(PhDim_tFc));
+ }
+ if (translation) {
+ lpTranslation1 = &translation1;
+ cachePhPoint_tFids(env, translation, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, translation, lpTranslation1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PmMemCreateMC((PhImage_t *)image, lpDim1, lpTranslation1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PmMemReleaseMC
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PmMemReleaseMC
+ (JNIEnv *env, jobject that, jint mc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PmMemReleaseMC\n");
+#endif
+
+ PmMemReleaseMC((PmMemoryContext_t *)mc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PmMemStart
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PmMemStart
+ (JNIEnv *env, jobject that, jint mc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PmMemStart\n");
+#endif
+
+ return (jint)PmMemStart((PmMemoryContext_t *)mc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PmMemStop
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PmMemStop
+ (JNIEnv *env, jobject that, jint mc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PmMemStop\n");
+#endif
+
+ return (jint)PmMemStop((PmMemoryContext_t *)mc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PmMemFlush
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PmMemFlush
+ (JNIEnv *env, jobject that, jint mc, jint image)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PmMemFlush\n");
+#endif
+
+ return (jint)PmMemFlush((PmMemoryContext_t *)mc, (PhImage_t *)image);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtCreateWidgetClass
+ * Signature: (III[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtCreateWidgetClass
+ (JNIEnv *env, jobject that, jint superclass_ref, jint size, jint n_args, jintArray args)
+{
+ jint *args1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtCreateWidgetClass\n");
+#endif
+
+ if (args)
+ args1 = (*env)->GetIntArrayElements(env, args, NULL);
+
+ result = (jint)PtCreateWidgetClass((PtWidgetClassRef_t *)superclass_ref, size, n_args, (PtArg_t *)args1);
+
+ if (args)
+ (*env)->ReleaseIntArrayElements(env, args, args1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSuperClassDraw
+ * Signature: (III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSuperClassDraw
+ (JNIEnv *env, jobject that, jint wc_ref, jint widget, jint damage)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSuperClassDraw\n");
+#endif
+
+ PtSuperClassDraw((PtWidgetClassRef_t *) wc_ref, (PtWidget_t *)widget, (PhTile_t *)damage);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtToggleButton
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtToggleButton
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtToggleButton\n");
+#endif
+
+ return (jint)PtToggleButton;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtOnOffButton
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtOnOffButton
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtOnOffButton\n");
+#endif
+
+ return (jint)PtOnOffButton;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtOnOffButton
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtComboBox
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtComboBox\n");
+#endif
+
+ return (jint)PtComboBox;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtText
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtText
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtText\n");
+#endif
+
+ return (jint)PtText;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtMultiText
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtMultiText
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtMultiText\n");
+#endif
+
+ return (jint)PtMultiText;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtMenu
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtMenu
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtMenu\n");
+#endif
+
+ return (jint)PtMenu;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtMenuBar
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtMenuBar
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtMenuBar\n");
+#endif
+
+ return (jint)PtMenuBar;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtMenuButton
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtMenuButton
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtMenuButton\n");
+#endif
+
+ return (jint)PtMenuButton;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtScrollbar
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtScrollbar
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtScrollbar\n");
+#endif
+
+ return (jint)PtScrollbar;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSeparator
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSeparator
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSeparator\n");
+#endif
+
+ return (jint)PtSeparator;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListAddItems
+ * Signature: (I[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListAddItems
+ (JNIEnv *env, jobject that, jint widget, jintArray items, jint item_count, jint position)
+{
+ jint *items1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListAddItems\n");
+#endif
+
+ if (items)
+ items1 = (*env)->GetIntArrayElements(env, items, NULL);
+
+ result = (jint)PtListAddItems((PtWidget_t *)widget, (void *)items1, item_count, position);
+
+ if (items)
+ (*env)->ReleaseIntArrayElements(env, items, items1, 0);
+
+ return result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListUnselectPos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListUnselectPos
+ (JNIEnv *env, jobject that, jint widget, jint pos)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListUnselectPos\n");
+#endif
+
+ PtListUnselectPos((PtWidget_t *)widget, pos);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (I[SI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__I_3SI
+ (JNIEnv *env, jclass that, jint dest, jintArray src, jint count)
+{
+ jshort *src1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__I_3SI\n");
+#endif
+
+ /* don't do anything if src pointer is NULL */
+ if (src) {
+ src1 = (*env)->GetShortArrayElements(env, src, NULL);
+ memmove((void *)dest, (void *)src1, count);
+ (*env)->ReleaseShortArrayElements(env, src, src1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: ([SII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove___3SII
+ (JNIEnv *env, jclass that, jintArray dest, jint src, jint count)
+{
+ jshort *dest1;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove___3SII\n");
+#endif
+
+ /* don't do anything if dest pointer is NULL */
+ if (dest) {
+ dest1 = (*env)->GetShortArrayElements(env, dest, NULL);
+ memmove((void *)dest1, (void *)src, count);
+ (*env)->ReleaseShortArrayElements(env, dest, dest1, 0);
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: strlen
+ * Signature: (II)V
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_photon_OS_strlen
+ (JNIEnv *env, jobject that, jint string)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "strlen\n");
+#endif
+
+ return (jint) strlen((char *) string);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListDeleteItemPos
+ * Signature: (III)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListDeleteItemPos
+ (JNIEnv *env, jobject that, jint widget, jint item_count, jint position)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListDeleteItemPos\n");
+#endif
+
+ PtListDeleteItemPos((PtWidget_t *)widget, item_count, position);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListDeleteAllItems
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListDeleteAllItems
+ (JNIEnv *env, jobject that, jint widget)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListDeleteAllItems\n");
+#endif
+
+ PtListDeleteAllItems((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListSelectPos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListSelectPos
+ (JNIEnv *env, jobject that, jint widget, jint pos)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListSelectPos\n");
+#endif
+
+ PtListSelectPos((PtWidget_t *)widget, pos);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListReplaceItemPos
+ * Signature: (I[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListReplaceItemPos
+ (JNIEnv *env, jobject that, jint widget, jintArray items, jint item_count, jint position)
+{
+ jint *items1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListReplaceItemPos\n");
+#endif
+
+ if (items)
+ items1 = (*env)->GetIntArrayElements(env, items, NULL);
+
+ result = (jint)PtListReplaceItemPos((PtWidget_t *)widget, (void *)items1, item_count, position);
+
+ if (items)
+ (*env)->ReleaseIntArrayElements(env, items, items1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListGotoPos
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListGotoPos
+ (JNIEnv *env, jobject that, jint widget, jint pos)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListGotoPos\n");
+#endif
+
+ PtListGotoPos((PtWidget_t *)widget, pos);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtListItemPos
+ * Signature: (I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtListItemPos
+ (JNIEnv *env, jobject that, jint widget, jbyteArray item)
+{
+ char *item1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtListItemPos\n");
+#endif
+
+ if (item)
+ item1 = (char *)(*env)->GetByteArrayElements(env, item, NULL);
+
+ result = PtListItemPos((PtWidget_t *)widget, item1);
+
+ if (item)
+ (*env)->ReleaseByteArrayElements(env, item, (jbyte *)item1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTextModifyText
+ * Signature: (IIII[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTextModifyText__IIII_3BI
+ (JNIEnv *env, jobject that, jint widget, jint start, jint end, jint insert_pos, jbyteArray text, jint length)
+{
+ char *text1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTextModifyText\n");
+#endif
+
+ if (text)
+ text1 = (char *)(*env)->GetByteArrayElements(env, text, NULL);
+
+ result = (jint)PtTextModifyText((PtWidget_t *)widget, start, end, insert_pos, text1, length);
+
+ if (text)
+ (*env)->ReleaseByteArrayElements(env, text, (jbyte *)text1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTextModifyText
+ * Signature: (IIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTextModifyText__IIIIII
+ (JNIEnv *env, jobject that, jint widget, jint start, jint end, jint insert_pos, jint text, jint length)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTextModifyText\n");
+#endif
+
+ return (jint)PtTextModifyText((PtWidget_t *)widget, start, end, insert_pos, (char *)text, length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTextGetSelection
+ * Signature: (I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTextGetSelection
+ (JNIEnv *env, jobject that, jint widget, jintArray start, jintArray end)
+{
+ int *start1=NULL, *end1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTextGetSelection\n");
+#endif
+
+ if (start)
+ start1 = (int *)(*env)->GetIntArrayElements(env, start, NULL);
+ if (end)
+ end1 = (int *)(*env)->GetIntArrayElements(env, end, NULL);
+
+ result = (jint)PtTextGetSelection((PtWidget_t *)widget, start1, end1);
+
+ if (start)
+ (*env)->ReleaseIntArrayElements(env, start, (jint *)start1, 0);
+ if (end)
+ (*env)->ReleaseIntArrayElements(env, end, (jint *)end1, 0);
+
+ return result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTextSetSelection
+ * Signature: (I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTextSetSelection
+ (JNIEnv *env, jobject that, jint widget, jintArray start, jintArray end)
+{
+ int *start1=NULL, *end1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTextSetSelection\n");
+#endif
+
+ if (start)
+ start1 = (int *)(*env)->GetIntArrayElements(env, start, NULL);
+ if (end)
+ end1 = (int *)(*env)->GetIntArrayElements(env, end, NULL);
+
+ result = (jint)PtTextSetSelection((PtWidget_t *)widget, start1, end1);
+
+ if (start)
+ (*env)->ReleaseIntArrayElements(env, start, (jint *)start1, 0);
+ if (end)
+ (*env)->ReleaseIntArrayElements(env, end, (jint *)end1, 0);
+
+ return result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtPositionMenu
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtPositionMenu
+ (JNIEnv *env, jobject that, jint widget, jobject event)
+{
+ DECL_GLOB(pGlob)
+ PhEvent_t object, *lpObject=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtPositionMenu\n");
+#endif
+ if (event) {
+ lpObject = &object;
+ cachePhEvent_tFids(env, event, &PGLOB(PhEvent_tFc));
+ getPhEvent_tFields(env, event, lpObject, &PGLOB(PhEvent_tFc));
+ }
+ PtPositionMenu((PtWidget_t *)widget, lpObject);
+ if (event) {
+ setPhEvent_tFields(env, event, lpObject, &PGLOB(PhEvent_tFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtReParentWidget
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtReParentWidget
+ (JNIEnv *env, jobject that, jint widget, jint parent)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtReParentWidget\n");
+#endif
+
+ return (jint) PtReParentWidget((PtWidget_t *)widget, (PtWidget_t *)parent);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtForwardWindowEvent
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhWindowEvent_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtForwardWindowEvent
+ (JNIEnv *env, jobject that, jobject event)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhWindowEvent_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtForwardWindowEvent\n");
+#endif
+
+ if (event) {
+ lpObject = &object;
+ cachePhWindowEvent_tFids(env, event, &PGLOB(PhWindowEvent_tFc));
+ getPhWindowEvent_tFields(env, event, lpObject, &PGLOB(PhWindowEvent_tFc));
+ }
+ result = (jint) PtForwardWindowEvent(lpObject);
+ if (event) {
+ setPhWindowEvent_tFields(env, event, lpObject, &PGLOB(PhWindowEvent_tFc));
+ }
+
+ return result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetOffset
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhPoint_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetOffset
+ (JNIEnv *env, jobject that, jint widget, jobject offset)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhPoint_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetOffset\n");
+#endif
+
+ if (offset) {
+ lpObject = &object;
+ cachePhPoint_tFids(env, offset, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, offset, lpObject, &PGLOB(PhPoint_tFc));
+ }
+ result = (jint) PtWidgetOffset((PtWidget_t *)widget, lpObject);
+ if (offset) {
+ setPhPoint_tFields(env, offset, lpObject, &PGLOB(PhPoint_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtRemoveCallback
+ * Signature: (IIII)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtRemoveCallback
+ (JNIEnv *env, jobject that, jint widget, jint callback_type, jint callback, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtRemoveCallback\n");
+#endif
+
+ PtRemoveCallback((PtWidget_t *)widget, (unsigned long)callback_type, (PtCallbackF_t *)callback, (void *)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindow
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtScrollContainer
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtScrollContainer\n");
+#endif
+
+ return (jint)PtScrollContainer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetCanvas
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetCanvas__II
+ (JNIEnv *env, jobject that, jint widget, jint canvas_rect)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetCanvas\n");
+#endif
+
+ return (jint) PtWidgetCanvas((PtWidget_t *)widget, (PhRect_t *)canvas_rect);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetCanvas
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetCanvas__ILorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv *env, jobject that, jint widget, jobject canvas_rect)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhRect_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetCanvas\n");
+#endif
+
+ if (canvas_rect) {
+ lpObject = &object;
+ cachePhRect_tFids(env, canvas_rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, canvas_rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PtWidgetCanvas((PtWidget_t *)widget, lpObject);
+ if (canvas_rect) {
+ setPhRect_tFields(env, canvas_rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtLabelWidgetCanvas
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtLabelWidgetCanvas__ILorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv *env, jobject that, jint widget, jobject canvas_rect)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhRect_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtLabelWidgetCanvas\n");
+#endif
+
+ if (canvas_rect) {
+ lpObject = &object;
+ cachePhRect_tFids(env, canvas_rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, canvas_rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PtLabelWidgetCanvas((PtWidget_t *)widget, lpObject);
+ if (canvas_rect) {
+ setPhRect_tFields(env, canvas_rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetClass
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetClass
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetClass\n");
+#endif
+
+ return (jint) PtWidgetClass ((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhPointerEvent_t;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhPointerEvent_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhPointerEvent_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhPointerEvent_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhPointerEvent_tFids(env, src, &PGLOB(PhPointerEvent_tFc));
+ getPhPointerEvent_tFields(env, src, src1, &PGLOB(PhPointerEvent_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhPointerEvent_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhPointerEvent_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhPointerEvent_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhPointerEvent_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhPointerEvent_tFids(env, dest, &PGLOB(PhPointerEvent_tFc));
+ setPhPointerEvent_tFields(env, dest, dest1, &PGLOB(PhPointerEvent_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhGetData
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhGetData
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhGetData\n");
+#endif
+
+ return (jint)PhGetData((PhEvent_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhGetRects
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhGetRects
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhGetRects\n");
+#endif
+
+ return (jint)PhGetRects((PhEvent_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhEvent_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhEvent_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhEvent_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhEvent_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhEvent_tFids(env, dest, &PGLOB(PhEvent_tFc));
+ setPhEvent_tFields(env, dest, dest1, &PGLOB(PhEvent_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtExtentWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtExtentWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtExtentWidget\n");
+#endif
+
+ return (jint)PtExtentWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtExtentWidgetFamily
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtExtentWidgetFamily
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtExtentWidgetFamily\n");
+#endif
+
+ return (jint)PtExtentWidgetFamily((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtGetAbsPosition
+ * Signature: ([S[S)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtGetAbsPosition
+ (JNIEnv *env, jobject that, jint widget, jshortArray x, jshortArray y)
+{
+ jshort *x1=NULL, *y1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtGetAbsPosition\n");
+#endif
+
+ if (x)
+ x1 = (*env)->GetShortArrayElements(env, x, NULL);
+ if (y)
+ y1 = (*env)->GetShortArrayElements(env, y, NULL);
+
+ PtGetAbsPosition((PtWidget_t *)widget, x1, y1);
+
+ if (x)
+ (*env)->ReleaseShortArrayElements(env, x, x1, 0);
+ if (y)
+ (*env)->ReleaseShortArrayElements(env, y, y1, 0);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSetAreaFromExtent
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhArea_t;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSetAreaFromExtent
+ (JNIEnv *env, jobject that, jint widget, jobject extent, jobject area)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhRect_t object1, *lpObject1=NULL;
+ PhArea_t object2, *lpObject2=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSetAreaFromExtent\n");
+#endif
+
+ if (extent) {
+ lpObject1 = &object1;
+ cachePhRect_tFids(env, extent, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, extent, lpObject1, &PGLOB(PhRect_tFc));
+ }
+ if (area) {
+ lpObject2 = &object2;
+ cachePhArea_tFids(env, area, &PGLOB(PhArea_tFc));
+ getPhArea_tFields(env, area, lpObject2, &PGLOB(PhArea_tFc));
+ }
+ result = (jint) PtSetAreaFromExtent((PtWidget_t *)widget, lpObject1, (PhArea_t *)lpObject2);
+ if (extent) {
+ setPhRect_tFields(env, extent, lpObject1, &PGLOB(PhRect_tFc));
+ }
+ if (area) {
+ setPhArea_tFields(env, area, lpObject2, &PGLOB(PhArea_tFc));
+ }
+
+ return result;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSetAreaFromWidgetCanvas
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhArea_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSetAreaFromWidgetCanvas
+ (JNIEnv *env, jobject that, jint widget, jobject extent, jobject area)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhRect_t object1, *lpObject1=NULL;
+ PhArea_t object2, *lpObject2=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSetAreaFromWidgetCanvas\n");
+#endif
+
+ if (extent) {
+ lpObject1 = &object1;
+ cachePhRect_tFids(env, extent, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, extent, lpObject1, &PGLOB(PhRect_tFc));
+ }
+ if (area) {
+ lpObject2 = &object2;
+ cachePhArea_tFids(env, area, &PGLOB(PhArea_tFc));
+ getPhArea_tFields(env, area, lpObject2, &PGLOB(PhArea_tFc));
+ }
+ result = (jint) PtSetAreaFromWidgetCanvas((PtWidget_t *)widget, lpObject1, lpObject2);
+ if (extent) {
+ setPhRect_tFields(env, extent, lpObject1, &PGLOB(PhRect_tFc));
+ }
+ if (area) {
+ setPhArea_tFields(env, area, lpObject2, &PGLOB(PhArea_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhKeyEvent_t;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhKeyEvent_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhKeyEvent_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhKeyEvent_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhKeyEvent_tFids(env, src, &PGLOB(PhKeyEvent_tFc));
+ getPhKeyEvent_tFields(env, src, src1, &PGLOB(PhKeyEvent_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhKeyEvent_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhKeyEvent_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PhKeyEvent_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhKeyEvent_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhKeyEvent_tFids(env, dest, &PGLOB(PhKeyEvent_tFc));
+ setPhKeyEvent_tFields(env, dest, dest1, &PGLOB(PhKeyEvent_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhTo8859_1
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhTo8859_11
+ (JNIEnv *env, jobject that, jint event)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhTo8859_1\n");
+#endif
+
+ return (jint)PhTo8859_1((PhKeyEvent_t *)event);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhKeyToMb_1
+ * Signature: ([BI)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhKeyToMb
+ (JNIEnv *env, jobject that, jbyteArray buffer, jint event)
+{
+ jbyte *buffer1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhKeyToMb\n");
+#endif
+
+ if (buffer)
+ buffer1 = (*env)->GetByteArrayElements(env, buffer, NULL);
+
+ result = PhKeyToMb(buffer1, (PhKeyEvent_t *)event);
+
+ if (buffer)
+ (*env)->ReleaseByteArrayElements(env, buffer, buffer1, 0);
+
+ return result;
+}
+*/
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PtScrollbarCallback_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PtScrollbarCallback_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PtScrollbarCallback_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhPoint_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePtScrollbarCallback_tFids(env, src, &PGLOB(PtScrollbarCallback_tFc));
+ getPtScrollbarCallback_tFields(env, src, src1, &PGLOB(PtScrollbarCallback_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PtScrollbarCallback_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PtScrollbarCallback_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PtScrollbarCallback_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhPoint_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePtScrollbarCallback_tFids(env, dest, &PGLOB(PtScrollbarCallback_tFc));
+ setPtScrollbarCallback_tFields(env, dest, dest1, &PGLOB(PtScrollbarCallback_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSetParentWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSetParentWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSetParentWidget\n");
+#endif
+
+ return (jint)PtSetParentWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtFrameSize
+ * Signature: (II[I[I[I[I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtFrameSize
+ (JNIEnv *env, jobject that, jint render, jint border_size, jintArray left_border, jintArray top_border, jintArray right_border, jintArray bottom_border)
+{
+ int *left_border1=NULL;
+ int *top_border1=NULL;
+ int *right_border1=NULL;
+ int *bottom_border1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtFrameSize\n");
+#endif
+
+ if (left_border)
+ left_border1 = (*env)->GetIntArrayElements(env, left_border, NULL);
+ if (top_border)
+ top_border1 = (*env)->GetIntArrayElements(env, top_border, NULL);
+ if (right_border)
+ right_border1 = (*env)->GetIntArrayElements(env, right_border, NULL);
+ if (bottom_border)
+ bottom_border1 = (*env)->GetIntArrayElements(env, bottom_border, NULL);
+
+ PtFrameSize (render, border_size, left_border1, top_border1, right_border1, bottom_border1);
+
+ if (left_border)
+ (*env)->ReleaseIntArrayElements(env, left_border, left_border1, 0);
+ if (top_border)
+ (*env)->ReleaseIntArrayElements(env, top_border, top_border1, 0);
+ if (right_border)
+ (*env)->ReleaseIntArrayElements(env, right_border, right_border1, 0);
+ if (bottom_border)
+ (*env)->ReleaseIntArrayElements(env, bottom_border, bottom_border1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtCreateAppContext
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtCreateAppContext
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtCreateAppContext\n");
+#endif
+
+ return (jint)PtCreateAppContext();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppProcessEvent ()
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppProcessEvent
+ (JNIEnv *env, jobject that, jint app_context)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppProcessEvent \n");
+#endif
+
+ PtAppProcessEvent ((PtAppContext_t)app_context);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppAddWorkProc
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppAddWorkProc
+ (JNIEnv *env, jobject that, jint app_context, jint work_func, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppAddWorkProc\n");
+#endif
+
+ return (jint)PtAppAddWorkProc ((PtAppContext_t)app_context, (PtWorkProc_t) work_func, (void *)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppRemoveWorkProc()
+ * Signature: (II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppRemoveWorkProc
+ (JNIEnv *env, jobject that, jint app_context, jint WorkProc_id)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppRemoveWorkProc\n");
+#endif
+
+ PtAppRemoveWorkProc((PtAppContext_t)app_context, (PtWorkProcId_t *) WorkProc_id);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetExtent
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetExtent__ILorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv *env, jobject that, jint widget, jobject rect)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetExtent\n");
+#endif
+
+ if (rect) {
+ lpRect = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PtWidgetExtent((PtWidget_t *) widget, lpRect);
+ if (rect) {
+ setPhRect_tFields(env, rect, lpRect, &PGLOB(PhRect_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetArea
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhArea_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetArea
+ (JNIEnv *env, jobject that, jint widget, jobject area)
+{
+ DECL_GLOB(pGlob)
+ PhArea_t area1, *lpArea=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetArea\n");
+#endif
+
+ if (area) {
+ lpArea = &area1;
+ cachePhArea_tFids(env, area, &PGLOB(PhArea_tFc));
+ getPhArea_tFields(env, area, lpArea, &PGLOB(PhArea_tFc));
+ }
+ result = (jint) PtWidgetArea((PtWidget_t *) widget, lpArea);
+ if (area) {
+ setPhArea_tFields(env, area, lpArea, &PGLOB(PhArea_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhQueryCursor
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhCursorInfo_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhQueryCursor
+ (JNIEnv *env, jobject that, jshort ig, jobject buf)
+{
+ DECL_GLOB(pGlob)
+ PhCursorInfo_t buf1, *lpBuf1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhQueryCursor\n");
+#endif
+
+ if (buf) {
+ lpBuf1 = &buf1;
+ cachePhCursorInfo_tFids(env, buf, &PGLOB(PhCursorInfo_tFc));
+ getPhCursorInfo_tFields(env, buf, lpBuf1, &PGLOB(PhCursorInfo_tFc));
+ }
+ result = (jint) PhQueryCursor(ig, lpBuf1);
+ if (buf) {
+ setPhCursorInfo_tFields(env, buf, lpBuf1, &PGLOB(PhCursorInfo_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhInputGroup
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhInputGroup
+ (JNIEnv *env, jobject that, jint event)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhInputGroup\n");
+#endif
+
+ return (jint) PhInputGroup ((PhEvent_t *) event);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtContainer
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtContainer
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtContainer\n");
+#endif
+
+ return (jint)PtContainer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtScrollArea
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtScrollArea
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtScrollArea\n");
+#endif
+
+ return (jint)PtScrollArea;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAddClassStyle
+ * Signature: (II)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAddClassStyle
+ (JNIEnv *env, jobject that, jint wclass, jint style)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAddClassStyle\n");
+#endif
+
+ return (jint)PtAddClassStyle((PtWidgetClassRef_t *)wclass, (PtWidgetClassStyle_t *)style);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtClippedBlit
+ * Signature: (IILorg/eclipse/swt/photon/PhPoint_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtClippedBlit
+ (JNIEnv *env, jobject that, jint widget, jint src, jobject delta, jint clip)
+{
+ DECL_GLOB(pGlob)
+ PhPoint_t delta1, *lpDelta1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtClippedBlit\n");
+#endif
+ if (delta) {
+ lpDelta1 = &delta1;
+ cachePhPoint_tFids(env, delta, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, delta, lpDelta1, &PGLOB(PhPoint_tFc));
+ }
+
+ return (jint)PtClippedBlit((PtWidget_t *)widget, (PhTile_t *)src, lpDelta1, (PhTile_t *)clip);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/FontDetails;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_FontDetails_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ FontDetails object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_FontDetails_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cacheFontDetailsFids(env, src, &PGLOB(FontDetailsFc));
+ getFontDetailsFields(env, src, src1, &PGLOB(FontDetailsFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/FontDetails;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_FontDetails_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ FontDetails object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_FontDetails_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cacheFontDetailsFids(env, dest, &PGLOB(FontDetailsFc));
+ setFontDetailsFields(env, dest, dest1, &PGLOB(FontDetailsFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhArea_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PhArea_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhArea_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PhArea_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePhArea_tFids(env, src, &PGLOB(PhArea_tFc));
+ getPhArea_tFields(env, src, src1, &PGLOB(PhArea_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhArea_t;II)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PhArea_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PhArea_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PhArea_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePhArea_tFids(env, dest, &PGLOB(PhArea_tFc));
+ setPhArea_tFields(env, dest, dest1, &PGLOB(PhArea_tFc));
+ }
+
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtFileSelection
+ * Signature: (ILorg/eclipse/swt/photon/PhPoint_t;[B[B[B[B[BLorg/eclipse/swt/photon/PtFileSelectionInfo_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtFileSelection
+ (JNIEnv *env, jobject that, jint widget, jobject pos, jbyteArray title, jbyteArray root_dir, jbyteArray file_spec, jbyteArray btn1, jbyteArray btn2, jbyteArray format, jobject info, jint flags)
+{
+ DECL_GLOB(pGlob)
+
+ PhPoint_t pos1, *lpPos1=NULL;
+ PtFileSelectionInfo_t info1, *lpInfo1=NULL;
+
+ char *title1=NULL;
+ char *root_dir1=NULL;
+ char *file_spec1=NULL;
+ char *btn11=NULL;
+ char *btn21=NULL;
+ char *format1=NULL;
+
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtFileSelection\n");
+#endif
+
+ if (pos) {
+ lpPos1= &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (info) {
+ memset (&info1, 0, sizeof (PtFileSelectionInfo_t));
+ lpInfo1= &info1;
+ cachePtFileSelectionInfo_tFids(env, info, &PGLOB(PtFileSelectionInfo_tFc));
+ getPtFileSelectionInfo_tFields(env, info, lpInfo1, &PGLOB(PtFileSelectionInfo_tFc));
+ }
+ if (title) title1 = (*env)->GetByteArrayElements(env, title, NULL);
+ if (root_dir) root_dir1 = (*env)->GetByteArrayElements(env, root_dir, NULL);
+ if (file_spec) file_spec1 = (*env)->GetByteArrayElements(env, file_spec, NULL);
+ if (btn1) btn11 = (*env)->GetByteArrayElements(env, btn1, NULL);
+ if (btn2) btn21 = (*env)->GetByteArrayElements(env, btn2, NULL);
+ if (format) format1 = (*env)->GetByteArrayElements(env, format, NULL);
+
+ result = (jint) PtFileSelection ((PtWidget_t *)widget, lpPos1, title1, root_dir1, file_spec1, btn11, btn21, format1, lpInfo1, flags);
+
+ if (pos) {
+ setPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (info) {
+ setPtFileSelectionInfo_tFields(env, info, lpInfo1, &PGLOB(PtFileSelectionInfo_tFc));
+ }
+ if (title) (*env)->ReleaseByteArrayElements(env, title, title1, 0);
+ if (root_dir) (*env)->ReleaseByteArrayElements(env, root_dir, root_dir1, 0);
+ if (file_spec) (*env)->ReleaseByteArrayElements(env, file_spec, file_spec1, 0);
+ if (btn1) (*env)->ReleaseByteArrayElements(env, btn1, btn11, 0);
+ if (btn2) (*env)->ReleaseByteArrayElements(env, btn2, btn21, 0);
+ if (format) (*env)->ReleaseByteArrayElements(env, format, format1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetPreferredSize
+ * Signature: (ILorg/eclipse/swt/photon/PhDim_t;)Lorg/eclipse/swt/photon/PhDim_t;
+ */
+JNIEXPORT jobject JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetPreferredSize
+ (JNIEnv *env, jobject that, jint widget, jobject dim)
+{
+ DECL_GLOB(pGlob)
+ PhDim_t dim1, *result, *lpDim1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetPreferredSize\n");
+#endif
+
+ if (dim) {
+ lpDim1 = &dim1;
+ cachePhDim_tFids(env, dim, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, dim, lpDim1, &PGLOB(PhDim_tFc));
+ }
+ result = PtWidgetPreferredSize((PtWidget_t *)widget, lpDim1);
+ if (dim) {
+ setPhDim_tFields(env, dim, lpDim1, &PGLOB(PhDim_tFc));
+ }
+ return result == NULL ? NULL : dim;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppCreatePulse
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppCreatePulse
+ (JNIEnv *env, jobject that, jint app, jint priority)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppCreatePulse\n");
+#endif
+
+ return (jint)PtAppCreatePulse((PtAppContext_t)app, priority);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppAddInput
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppAddInput
+ (JNIEnv *env, jobject that, jint app_context, jint pid, jint input_func, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppAddInput\n");
+#endif
+
+ return (jint)PtAppAddInput((PtAppContext_t)app_context, (pid_t)pid, (PtInputCallbackProc_t)input_func, (void *)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppRemoveInput
+ * Signature: (II)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppRemoveInput
+ (JNIEnv *env, jobject that, jint app_context, jint input_id)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppRemoveInput\n");
+#endif
+
+ PtAppRemoveInput((PtAppContext_t)app_context, (PtInputId_t *)input_id);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppDeletePulse
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppDeletePulse
+ (JNIEnv *env, jobject that, jint app, jint pulse_pid)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppDeletePulse\n");
+#endif
+
+ return (jint)PtAppDeletePulse((PtAppContext_t)app, (pid_t)pulse_pid);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAppPulseTrigger
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAppPulseTrigger
+ (JNIEnv *env, jobject that, jint app, jint pulse)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAppPulseTrigger\n");
+#endif
+
+ return (jint)PtAppPulseTrigger((PtAppContext_t)app, (pid_t)pulse);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtContainerFindFocus
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtContainerFindFocus
+ (JNIEnv *env, jobject that, jint family_member)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtContainerFindFocus\n");
+#endif
+
+ return (jint)PtContainerFindFocus((PtWidget_t *)family_member);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtIsFocused
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtIsFocused
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtIsFocused\n");
+#endif
+
+ return (jint)PtIsFocused((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindowFocus
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWindowFocus
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWindowFocus\n");
+#endif
+
+ return (jint)PtWindowFocus((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindowToFront
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWindowToFront
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWindowToFront\n");
+#endif
+
+ PtWindowToFront((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindowToBack
+ * Signature: (I)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWindowToBack
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWindowToBack\n");
+#endif
+
+ PtWindowToBack((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtFindDisjoint
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtFindDisjoint
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtFindDisjoint\n");
+#endif
+
+ return (jint) PtFindDisjoint((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardCopyString
+ * Signature: (SI)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardCopyString__SI
+ (JNIEnv *env, jobject that, jshort ig, jint string)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardCopyString\n");
+#endif
+
+ return (jint) PhClipboardCopyString(ig, (char *)string);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardCopyString
+ * Signature: (S[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardCopyString__S_3B
+ (JNIEnv *env, jclass that, jshort ig, jbyteArray string)
+{
+ jbyte *string1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardCopyString\n");
+#endif
+
+ if (string)
+ string1 = (*env)->GetByteArrayElements(env, string, NULL);
+
+ result = (jint)PhClipboardCopyString(ig, (char *)string1);
+
+ if (string)
+ (*env)->ReleaseByteArrayElements(env, string, string1, 0);
+
+ return result;
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhClipboardPasteString
+ * Signature: (S)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhClipboardPasteString
+ (JNIEnv *env, jobject that, jshort ig)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhClipboardPasteString\n");
+#endif
+
+ return (jint) PhClipboardPasteString(ig);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtBlockAllWindows
+ * Signature: (ISI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtBlockAllWindows
+ (JNIEnv *env, jobject that, jint skip, jshort cursor, jint cursor_color)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtBlockAllWindows\n");
+#endif
+
+ return (jint) PtBlockAllWindows((PtWidget_t *)skip, cursor, (PgColor_t)cursor_color);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtUnblockWindows
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtUnblockWindows
+ (JNIEnv *env, jobject that, jint bl)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtUnblockWindows\n");
+#endif
+
+ PtUnblockWindows((PtBlockedList_t *)bl);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtNextTopLevelWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtNextTopLevelWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtNextTopLevelWidget\n");
+#endif
+
+ return (jint) PtNextTopLevelWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWindowGetState
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWindowGetState
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWindowGetState\n");
+#endif
+
+ return (jint) PtWindowGetState((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAddHotkeyHandler
+ * Signature: (IIISII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAddHotkeyHandler
+ (JNIEnv *env, jobject that, jint widget, jint key_sym_cap, jint key_mods, jshort flags, jint data, jint callback)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAddHotkeyHandler\n");
+#endif
+
+ PtAddHotkeyHandler((PtWidget_t *)widget, key_sym_cap, key_mods, flags, (void *)data, (PtCallbackF_t *)callback);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtRemoveHotkeyHandler
+ * Signature: (IIISII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtRemoveHotkeyHandler
+ (JNIEnv *env, jobject that, jint widget, jint key_sym_cap, jint key_mods, jshort flags, jint data, jint callback)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtRemoveHotkeyHandler\n");
+#endif
+
+ PtRemoveHotkeyHandler((PtWidget_t *)widget, key_sym_cap, key_mods, flags, (void *)data, (PtCallbackF_t *)callback);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PgAlpha_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PgAlpha_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ /* Some fields of the structure are not represented in Java.
+ * Make the are set to zero.
+ */
+ PgAlpha_t object = {0}, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PgAlpha_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePgAlpha_tFids(env, src, &PGLOB(PgAlpha_tFc));
+ getPgAlpha_tFields(env, src, src1, &PGLOB(PgAlpha_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PgAlpha_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PgAlpha_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ /* Some fields of the structure are not represented in Java.
+ * Make the are set to zero.
+ */
+ PgAlpha_t object = {0}, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PgAlpha_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePgAlpha_tFids(env, dest, &PGLOB(PgAlpha_tFc));
+ setPgAlpha_tFields(env, dest, dest1, &PGLOB(PgAlpha_tFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetAlpha
+ * Signature: (IIIBB)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetAlpha
+ (JNIEnv *env, jobject that, jint alpha_op, jobject src_alpha_map, jint src_alpha_gradient, jbyte src_global_alpha, jbyte dst_global_alpha)
+{
+ DECL_GLOB(pGlob)
+ PgMap_t map1, *lpMap1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetAlpha\n");
+#endif
+
+ if (src_alpha_map) {
+ lpMap1 = &map1;
+ cachePgMap_tFids(env, src_alpha_map, &PGLOB(PgMap_tFc));
+ getPgMap_tFields(env, src_alpha_map, lpMap1, &PGLOB(PgMap_tFc));
+ }
+ PgSetAlpha(alpha_op, lpMap1, (PgGradient_t *)src_alpha_gradient, (char unsigned)src_global_alpha, (char unsigned)dst_global_alpha);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgSetAlpha
+ * Signature: (IIIBB)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgSetAlpha
+ (JNIEnv *env, jobject that, jint alpha_op, jint src_alpha_map, jint src_alpha_gradient, jbyte src_global_alpha, jbyte dst_global_alpha)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgSetAlpha\n");
+#endif
+
+ PgSetAlpha(alpha_op, (PgMap_t *)src_alpha_map, (PgGradient_t *)src_alpha_gradient, (char unsigned)src_global_alpha, (char unsigned)dst_global_alpha);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgAlphaOn
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgAlphaOn
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgAlphaOn\n");
+#endif
+
+ PgAlphaOn();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgAlphaOff
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgAlphaOff
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgAlphaOff\n");
+#endif
+
+ PgAlphaOff();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PtTextCallback_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PtTextCallback_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PtTextCallback_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PtTextCallback_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePtTextCallback_tFids(env, src, &PGLOB(PtTextCallback_tFc));
+ getPtTextCallback_tFields(env, src, src1, &PGLOB(PtTextCallback_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PtTextCallback_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PtTextCallback_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PtTextCallback_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PtTextCallback_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePtTextCallback_tFids(env, dest, &PGLOB(PtTextCallback_tFc));
+ setPtTextCallback_tFields(env, dest, dest1, &PGLOB(PtTextCallback_tFc));
+ }
+
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhInitDrag
+ * Signature: (IILorg/eclipse/swt/photon/PhRect_t;Lorg/eclipse/swt/photon/PhRect_t;ILorg/eclipse/swt/photon/PhDim_t;Lorg/eclipse/swt/photon/PhDim_t;Lorg/eclipse/swt/photon/PhDim_t;Lorg/eclipse/swt/photon/PhPoint_t;[I;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhInitDrag
+ (JNIEnv *env, jobject that, jint rid, jint flags, jobject rect, jobject boundary, jint input_group, jobject min, jobject max, jobject step, jobject ptrpos, jshortArray cursor)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, rect2, *lpRect1=NULL, *lpRect2=NULL;
+ PhDim_t dim1, dim2, dim3, *lpDim1=NULL, *lpDim2=NULL, *lpDim3=NULL;
+ PhPoint_t point1, *lpPoint1=NULL;
+ jshort *cursor1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhInitDrag\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ if (boundary) {
+ lpRect2 = &rect2;
+ cachePhRect_tFids(env, boundary, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, boundary, lpRect2, &PGLOB(PhRect_tFc));
+ }
+ if (min) {
+ lpDim1 = &dim1;
+ cachePhDim_tFids(env, min, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, min, lpDim1, &PGLOB(PhDim_tFc));
+ }
+ if (max) {
+ lpDim2 = &dim2;
+ cachePhDim_tFids(env, max, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, max, lpDim2, &PGLOB(PhDim_tFc));
+ }
+ if (step) {
+ lpDim3 = &dim3;
+ cachePhDim_tFids(env, step, &PGLOB(PhDim_tFc));
+ getPhDim_tFields(env, step, lpDim3, &PGLOB(PhDim_tFc));
+ }
+ if (ptrpos) {
+ lpPoint1 = &point1;
+ cachePhPoint_tFids(env, ptrpos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, ptrpos, lpPoint1, &PGLOB(PhPoint_tFc));
+ }
+ if (cursor)
+ cursor1 = (*env)->GetShortArrayElements(env, cursor, NULL);
+
+ result = (jint) PhInitDrag(rid, flags, lpRect1, lpRect2, input_group, lpDim1, lpDim2, lpDim3, lpPoint1, (PhCursorDescription_t *)cursor1);
+
+ if (cursor)
+ (*env)->ReleaseShortArrayElements(env, cursor, cursor1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtProgress
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtProgress
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtProgress\n");
+#endif
+
+ return (jint)PtProgress;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtPanelGroup
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtPanelGroup
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtPanelGroup\n");
+#endif
+
+ return (jint)PtPanelGroup;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhAreaToRect
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhArea_t;)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PhAreaToRect
+ (JNIEnv *env, jobject that, jobject area, jobject rect)
+{
+ DECL_GLOB(pGlob)
+ PhArea_t object1, *lpObject1=NULL;
+ PhRect_t object2, *lpObject2=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhAreaToRect\n");
+#endif
+
+ if (area) {
+ lpObject1 = &object1;
+ cachePhArea_tFids(env, area, &PGLOB(PhArea_tFc));
+ getPhArea_tFields(env, area, lpObject1, &PGLOB(PhArea_tFc));
+ }
+ if (rect) {
+ lpObject2 = &object2;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpObject2, &PGLOB(PhRect_tFc));
+ }
+ PhAreaToRect(lpObject1, lpObject2);
+ if (area) {
+ setPhArea_tFields(env, area, lpObject1, &PGLOB(PhArea_tFc));
+ }
+ if (rect) {
+ setPhRect_tFields(env, rect, lpObject2, &PGLOB(PhRect_tFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtCalcCanvas
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtCalcCanvas__ILorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv *env, jobject that, jint widget, jobject canvas_rect)
+{
+ DECL_GLOB(pGlob)
+ jint result;
+ PhRect_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtCalcCanvas\n");
+#endif
+
+ if (canvas_rect) {
+ lpObject = &object;
+ cachePhRect_tFids(env, canvas_rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, canvas_rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PtCalcCanvas((PtWidget_t *)widget, lpObject);
+ if (canvas_rect) {
+ setPhRect_tFields(env, canvas_rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtValidParent
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtValidParent
+ (JNIEnv *env, jobject that, jint widget, jint class_ref)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtValidParent\n");
+#endif
+
+ return (jint)PtValidParent((PtWidget_t *)widget, (PtWidgetClassRef_t *) class_ref);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtCalcBorder
+ * Signature: (ILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtCalcBorder__ILorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv *env, jobject that, jint widget, jobject rect)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t object, *lpObject=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtCalcBorder\n");
+#endif
+
+ if (rect) {
+ lpObject = &object;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+ PtCalcBorder((PtWidget_t *)widget, lpObject);
+ if (rect) {
+ setPhRect_tFields(env, rect, lpObject, &PGLOB(PhRect_tFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtPane
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtPane
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtPane\n");
+#endif
+
+ return (jint)PtPane;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTree
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTree
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTree\n");
+#endif
+
+ return (jint)PtTree;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeAllocItem
+ * Signature: (I[BSS)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeAllocItem
+ (JNIEnv *env, jobject that, jint widget, jbyteArray str, jshort set_img, jshort unset_img)
+{
+ PtTreeItem_t *result;
+ jbyte *str1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeAllocItem\n");
+#endif
+ if (str)
+ str1 = (*env)->GetByteArrayElements(env, str, NULL);
+
+ result = PtTreeAllocItem((PtWidget_t *)widget, str1, set_img, unset_img);
+
+ if (str)
+ (*env)->ReleaseByteArrayElements(env, str, str1, JNI_ABORT);
+
+ return (jint) result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeModifyItem
+ * Signature: (II[BSS)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeModifyItem
+ (JNIEnv *env, jobject that, jint widget, jint item, jbyteArray str, jshort set_img, jshort unset_img)
+{
+ PtTreeItem_t *result;
+ jbyte *str1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeModifyItem\n");
+#endif
+ if (str)
+ str1 = (*env)->GetByteArrayElements(env, str, NULL);
+
+ result = PtTreeModifyItem((PtWidget_t *)widget, (PtTreeItem_t *) item, str1, set_img, unset_img);
+
+ if (str)
+ (*env)->ReleaseByteArrayElements(env, str, str1, JNI_ABORT);
+
+ return (jint) result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeModifyItemString
+ * Signature: (II[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeModifyItemString
+ (JNIEnv *env, jobject that, jint widget, jint item, jbyteArray str)
+{
+ PtTreeItem_t *result;
+ jbyte *str1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeModifyItemString\n");
+#endif
+ if (str)
+ str1 = (*env)->GetByteArrayElements(env, str, NULL);
+
+ result = PtTreeModifyItemString((PtWidget_t *)widget, (PtTreeItem_t *) item, str1);
+
+ if (str)
+ (*env)->ReleaseByteArrayElements(env, str, str1, JNI_ABORT);
+
+ return (jint) result;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeAddFirst
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeAddFirst
+ (JNIEnv *env, jobject that, jint widget, jint item, jint parent)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeAddFirst\n");
+#endif
+
+ return (jint)PtTreeAddFirst((PtWidget_t *)widget, (PtTreeItem_t *) item, (PtTreeItem_t *) parent);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeAddAfter
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeAddAfter
+ (JNIEnv *env, jobject that, jint widget, jint item, jint brother)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeAddAfter\n");
+#endif
+
+ return (jint)PtTreeAddAfter((PtWidget_t *)widget, (PtTreeItem_t *) item, (PtTreeItem_t *) brother);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeRemoveItem
+ * Signature: (II)
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeRemoveItem
+ (JNIEnv *env, jobject that, jint widget, jint item)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeRemoveItem\n");
+#endif
+
+ PtTreeRemoveItem((PtWidget_t *)widget, (PtTreeItem_t *) item);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeRootItem
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeRootItem
+ (JNIEnv *env, jobject that, jint tree)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeRootItem\n");
+#endif
+
+ return (jint) PtTreeRootItem((PtWidget_t *)tree);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PtTreeItem_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PtTreeItem_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PtTreeItem_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PtTreeItem_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePtTreeItem_tFids(env, src, &PGLOB(PtTreeItem_tFc));
+ getPtTreeItem_tFields(env, src, src1, &PGLOB(PtTreeItem_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PtTreeItem_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PtTreeItem_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PtTreeItem_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PtTreeItem_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePtTreeItem_tFids(env, dest, &PGLOB(PtTreeItem_tFc));
+ setPtTreeItem_tFields(env, dest, dest1, &PGLOB(PtTreeItem_tFc));
+ }
+
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeClearSelection
+ * Signature: (I)
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeClearSelection
+ (JNIEnv *env, jobject that, jint tree)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeClearSelection\n");
+#endif
+
+ PtTreeClearSelection((PtWidget_t *)tree);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeSelect
+ * Signature: (II)
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeSelect
+ (JNIEnv *env, jobject that, jint widget, jint item)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeSelect\n");
+#endif
+
+ PtTreeSelect((PtWidget_t *)widget, (PtTreeItem_t *) item);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeExpand
+ * Signature: (III)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeExpand
+ (JNIEnv *env, jobject that, jint widget, jint item, jint event)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeExpand\n");
+#endif
+
+ return PtTreeExpand((PtWidget_t *)widget, (PtTreeItem_t *) item, (PhEvent_t *) event);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeCollapse
+ * Signature: (III)I
+ */
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeCollapse
+ (JNIEnv *env, jobject that, jint widget, jint item, jint event)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeCollapse\n");
+#endif
+
+ return PtTreeCollapse((PtWidget_t *)widget, (PtTreeItem_t *) item, (PhEvent_t *) event);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTreeFreeAllItems
+ * Signature: (I)
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTreeFreeAllItems
+ (JNIEnv *env, jobject that, jint tree)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTreeFreeAllItems \n");
+#endif
+
+ PtTreeFreeAllItems ((PtWidget_t *)tree);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (ILorg/eclipse/swt/internal/photon/PgMap_t;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__ILorg_eclipse_swt_internal_photon_PgMap_1t_2I
+ (JNIEnv *env, jobject that, jint dest, jobject src, jint count)
+{
+ DECL_GLOB(pGlob)
+
+ PgMap_t object, *src1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__ILorg_eclipse_swt_internal_photon_PgMap_1t_2I\n");
+#endif
+
+ if (src) {
+ src1=&object;
+ cachePgMap_tFids(env, src, &PGLOB(PgMap_tFc));
+ getPgMap_tFields(env, src, src1, &PGLOB(PgMap_tFc));
+ }
+ memmove((void *)dest, (void *)src1, count);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: memmove
+ * Signature: (Lorg/eclipse/swt/internal/photon/PgMap_t;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_memmove__Lorg_eclipse_swt_internal_photon_PgMap_1t_2II
+ (JNIEnv *env, jobject that, jobject dest, jint src, jint count)
+{
+ DECL_GLOB(pGlob)
+ PgMap_t object, *dest1=NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "memmove__Lorg_eclipse_swt_internal_photon_PgMap_1t_2II\n");
+#endif
+
+ memmove((void *)&object, (void *)src, count);
+ if (dest) {
+ dest1=&object;
+ cachePgMap_tFids(env, dest, &PGLOB(PgMap_tFc));
+ setPgMap_tFields(env, dest, dest1, &PGLOB(PgMap_tFc));
+ }
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtDamageWidget
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtDamageWidget
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtDamageWidget\n");
+#endif
+
+ return (jint)PtDamageWidget((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtBlit
+ * Signature: (ILorg/eclipse/swt/photon/PhRect_t;ILorg/eclipse/swt/photon/PhPoint_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtBlit
+ (JNIEnv *env, jobject that, jint widget, jobject rect, jobject offset)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+ PhPoint_t offset1, *lpOffset1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtBlit\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ if (offset) {
+ lpOffset1 = &offset1;
+ cachePhPoint_tFids(env, offset, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, offset, lpOffset1, &PGLOB(PhPoint_tFc));
+ }
+ return (jint) PtBlit((PtWidget_t *)widget, lpRect1, lpOffset1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtContainerHold
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtContainerHold
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtContainerHold\n");
+#endif
+
+ return (jint)PtContainerHold((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtContainerRelease
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtContainerRelease
+ (JNIEnv *env, jobject that, jint widget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtContainerRelease\n");
+#endif
+
+ return (jint)PtContainerRelease((PtWidget_t *)widget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtFontSelection
+ * Signature: (ILorg/eclipse/swt/photon/PhPoint_t;[B[BII[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtFontSelection
+ (JNIEnv *env, jobject that, jint parent, jobject pos, jbyteArray title, jbyteArray font, jint symbol, jint flags, jbyteArray sample)
+{
+ DECL_GLOB(pGlob)
+
+ PhPoint_t pos1, *lpPos1=NULL;
+
+ char *title1=NULL;
+ char *font1=NULL;
+ char *sample1=NULL;
+
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtFontSelection\n");
+#endif
+
+ if (pos) {
+ lpPos1= &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (title) title1 = (*env)->GetByteArrayElements(env, title, NULL);
+ if (font) font1 = (*env)->GetByteArrayElements(env, font, NULL);
+ if (sample) sample1 = (*env)->GetByteArrayElements(env, sample, NULL);
+
+ result = (jint) PtFontSelection ((PtWidget_t *)parent, lpPos1, title1, font1, symbol, flags, sample1);
+
+ if (pos) {
+ setPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (title) (*env)->ReleaseByteArrayElements(env, title, title1, 0);
+ if (font) (*env)->ReleaseByteArrayElements(env, font, font1, 0);
+ if (sample) (*env)->ReleaseByteArrayElements(env, sample, sample1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfGenerateFontName
+ * Signature: ([BII[B)[B
+ */
+JNIEXPORT jbyteArray JNICALL Java_org_eclipse_swt_internal_photon_OS_PfGenerateFontName
+ (JNIEnv *env, jobject that, jbyteArray pkucDescription, jint kuiFlags, jint kuiSize, jbyteArray pucBuff)
+{
+ char *pkucDescription1=NULL;
+ char *pucBuff1=NULL;
+
+ uchar_t *result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfGenerateFontName\n");
+#endif
+
+ if (pkucDescription) pkucDescription1 = (*env)->GetByteArrayElements(env, pkucDescription, NULL);
+ if (pucBuff) pucBuff1 = (*env)->GetByteArrayElements(env, pucBuff, NULL);
+
+ result = PfGenerateFontName(pkucDescription1, kuiFlags, kuiSize, pucBuff1);
+
+ if (pkucDescription) (*env)->ReleaseByteArrayElements(env, pkucDescription, pkucDescription1, 0);
+ if (pucBuff) (*env)->ReleaseByteArrayElements(env, pucBuff, pucBuff1, 0);
+
+ return result == NULL ? NULL : pucBuff;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfFindFont
+ * Signature: ([BII)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfFindFont
+ (JNIEnv *env, jobject that, jbyteArray pkucDescription, jint kulFlags, jint kulSize)
+{
+ char *pkucDescription1=NULL;
+
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfFindFont\n");
+#endif
+
+ if (pkucDescription) pkucDescription1 = (*env)->GetByteArrayElements(env, pkucDescription, NULL);
+
+ result = (jint)PfFindFont(pkucDescription1, kulFlags, kulSize);
+
+ if (pkucDescription) (*env)->ReleaseByteArrayElements(env, pkucDescription, pkucDescription1, 0);
+
+ return result;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfFreeFont
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfFreeFont
+ (JNIEnv *env, jobject that, jint ptsID)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfFreeFont\n");
+#endif
+
+ return PfFreeFont((FontID *)ptsID);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfFontDescription
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfFontDescription
+ (JNIEnv *env, jobject that, jint ptsID)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfFontDescription\n");
+#endif
+
+ return (jint)PfFontDescription((FontID *)ptsID);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfFontFlags
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfFontFlags
+ (JNIEnv *env, jobject that, jint ptsID)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfFontFlags\n");
+#endif
+
+ return PfFontFlags((FontID *)ptsID);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfFontSize
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfFontSize
+ (JNIEnv *env, jobject that, jint ptsID)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfFontSize\n");
+#endif
+
+ return PfFontSize((FontID *)ptsID);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PfConvertFontID
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PfConvertFontID
+ (JNIEnv *env, jobject that, jint ptsID)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PfConvertFontID\n");
+#endif
+
+ return (jint)PfConvertFontID((FontID *)ptsID);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtToolbar
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtToolbar
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtToolbar\n");
+#endif
+
+ return (jint)PtToolbar;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtColorSelGroup
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtColorSelGroup
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtColorSelGroup\n");
+#endif
+
+ return (jint)PtColorSelGroup;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtColorPatch
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtColorPatch
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtColorPatch\n");
+#endif
+
+ return (jint)PtColorPatch;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtColorPalette
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtColorPalette
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtColorPalette\n");
+#endif
+
+ return (jint)PtColorPalette;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtGroup
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtGroup
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtGroup\n");
+#endif
+
+ return (jint)PtGroup;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: Pg_CM_RGB
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_Pg_1CM_1RGB
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Pg_CM_RGB\n");
+#endif
+
+ return (jint)Pg_CM_RGB;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: Pg_CM_HSB
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_Pg_1CM_1HSB
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Pg_CM_HSB\n");
+#endif
+
+ return (jint)Pg_CM_HSB;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: Pg_CM_HLS
+ * Signature: ()I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_Pg_1CM_1HLS
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Pg_CM_HLS\n");
+#endif
+
+ return (jint)Pg_CM_HLS;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhRectUnion
+ * Signature: (Lorg/eclipse/swt/internal/photon/PhRect_t;Lorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhRectUnion__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhRect_1t_2
+ (JNIEnv * env, jobject that, jobject rect1, jobject rect2)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect11, *lpRect11=NULL;
+ PhRect_t rect21, *lpRect21=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhRectUnion__Lorg_eclipse_swt_internal_photon_PhRect_1t_2Lorg_eclipse_swt_internal_photon_PhRect_1t_2\n");
+#endif
+
+ if (rect1) {
+ lpRect11 = &rect11;
+ cachePhRect_tFids(env, rect1, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect1, lpRect11, &PGLOB(PhRect_tFc));
+ }
+ if (rect2) {
+ lpRect21 = &rect21;
+ cachePhRect_tFids(env, rect2, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect2, lpRect21, &PGLOB(PhRect_tFc));
+ }
+ result = PhRectUnion(lpRect11, lpRect21);
+ if (rect1) {
+ setPhRect_tFields(env, rect1, lpRect11, &PGLOB(PhRect_tFc));
+ }
+ if (rect2) {
+ setPhRect_tFields(env, rect2, lpRect21, &PGLOB(PhRect_tFc));
+ }
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtRegion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtRegion
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtRegion\n");
+#endif
+
+ return (jint)PtRegion;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAddFilterCallback
+ * Signature: (IIII)I
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAddFilterCallback
+ (JNIEnv *env, jobject that, jint widget, jint callback_type, jint callback, jint data)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAddFilterCallback\n");
+#endif
+
+ PtAddFilterCallback((PtWidget_t *)widget, (unsigned long)callback_type, (PtCallbackF_t *)callback, (void *)data);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtTimer
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtTimer
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtTimer\n");
+#endif
+
+ return (jint)PtTimer;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtHit
+ * Signature: (IILorg/eclipse/swt/internal/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtHit
+ (JNIEnv * env, jobject that, jint container, jint n, jobject rect)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtHit\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PtHit ((PtWidget_t *) container, n, lpRect1);
+ if (rect) {
+ setPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtColorSelect
+ * Signature: (I[BLorg/eclipse/swt/internal/photon/PtColorSelectInfo_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtColorSelect
+ (JNIEnv *env, jobject that, jint parent, jbyteArray title, jobject info)
+{
+ DECL_GLOB(pGlob)
+ PtColorSelectInfo_t info1, *lpInfo1=NULL;
+ jbyte *title1=NULL;
+ jint result;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtColorSelect\n");
+#endif
+
+ if (title) title1 = (*env)->GetByteArrayElements(env, title, NULL);
+ if (info) {
+ lpInfo1 = &info1;
+ cachePtColorSelectInfo_tFids(env, info, &PGLOB(PtColorSelectInfo_tFc));
+ getPtColorSelectInfo_tFields(env, info, lpInfo1, &PGLOB(PtColorSelectInfo_tFc));
+ }
+ result = PtColorSelect((PtWidget_t *)parent, (char *)title1, lpInfo1);
+ if (title) (*env)->ReleaseByteArrayElements(env, title, title1, 0);
+ if (info) {
+ setPtColorSelectInfo_tFields(env, info, lpInfo1, &PGLOB(PtColorSelectInfo_tFc));
+ }
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgDrawArrow
+ * Signature: (Lorg/eclipse/swt/photon/PhRect_t;SII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgDrawArrow
+ (JNIEnv *env, jobject that, jobject rect, jshort unknown, jint color, jint flags)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgDrawArrow\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ PgDrawArrow(lpRect1, unknown, (PgColor_t)color, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtWidgetIsClassMember
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtWidgetIsClassMember
+ (JNIEnv *env, jobject that, jint widget, jint clazz)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtWidgetIsClassMember\n");
+#endif
+
+ return (jint)PtWidgetIsClassMember((PtWidget_t *)widget, (PtWidgetClassRef_t *)clazz);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtBeep
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtBeep
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtBeep\n");
+#endif
+
+ return (jint)PtBeep();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtAlert
+ * Signature: (ILorg/eclipse/swt/photon/PhPoint_t;[BI[B[BII[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtAlert
+ (JNIEnv *env, jobject that, jint parent, jobject pos, jbyteArray title, int image, jbyteArray message,
+ jbyteArray msgFont, int btnCount, jintArray buttons, jintArray btnFonts,
+ int defBtn, int escBtn, int flags)
+{
+ DECL_GLOB(pGlob)
+
+ PhPoint_t pos1, *lpPos1=NULL;
+
+ char *title1=NULL;
+ char *message1=NULL;
+ char *msgFont1=NULL;
+ jint *buttons1=NULL;
+ jint *btnFonts1=NULL;
+
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtAlert\n");
+#endif
+
+ if (pos) {
+ lpPos1= &pos1;
+ cachePhPoint_tFids(env, pos, &PGLOB(PhPoint_tFc));
+ getPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (title) title1 = (*env)->GetByteArrayElements(env, title, NULL);
+ if (message) message1 = (*env)->GetByteArrayElements(env, message, NULL);
+ if (msgFont) msgFont1 = (*env)->GetByteArrayElements(env, msgFont, NULL);
+ if (buttons) buttons1 = (*env)->GetIntArrayElements(env, buttons, NULL);
+ if (btnFonts) btnFonts1 = (*env)->GetIntArrayElements(env, btnFonts, NULL);
+
+ result = (jint) PtAlert ((PtWidget_t *)parent, lpPos1, title1, (PhImage_t *)image, message1, msgFont1, btnCount, (char const**)buttons1, (char const**)btnFonts1, defBtn, escBtn, flags);
+
+ if (pos) {
+ setPhPoint_tFields(env, pos, lpPos1, &PGLOB(PhPoint_tFc));
+ }
+ if (title) (*env)->ReleaseByteArrayElements(env, title, title1, 0);
+ if (msgFont) (*env)->ReleaseByteArrayElements(env, msgFont, msgFont1, 0);
+ if (message) (*env)->ReleaseByteArrayElements(env, message, message1, 0);
+ if (buttons) (*env)->ReleaseIntArrayElements(env, buttons, buttons1, 0);
+ if (btnFonts) (*env)->ReleaseIntArrayElements(env, btnFonts, btnFonts1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PtSlider
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PtSlider
+ (JNIEnv *env, jobject that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtSlider\n");
+#endif
+
+ return (jint)PtSlider;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PiDuplicateImage
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PiDuplicateImage
+ (JNIEnv *env, jobject that, jint image, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PiDuplicateImage\n");
+#endif
+
+ return (jint)PiDuplicateImage ((PhImage_t *)image, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhMakeGhostBitmap
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhMakeGhostBitmap
+ (JNIEnv *env, jobject that, jint image)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhMakeGhostBitmap\n");
+#endif
+
+ return (jint) PhMakeGhostBitmap((PhImage_t *)image);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgReadScreen
+ * Signature: (Lorg/eclipse/swt/photon/PhRect_t;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgReadScreen
+ (JNIEnv *env, jobject that, jobject rect, jint buffer)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgReadScreen\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ return (jint) PgReadScreen(lpRect1, (void *) buffer);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgReadScreenSize
+ * Signature: (Lorg/eclipse/swt/photon/PhRect_t;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgReadScreenSize
+ (JNIEnv *env, jobject that, jobject rect)
+{
+ DECL_GLOB(pGlob)
+ PhRect_t rect1, *lpRect1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgReadScreenSize\n");
+#endif
+
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ return (jint) PgReadScreenSize(lpRect1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgShmemDestroy
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgShmemDestroy
+ (JNIEnv *env, jobject that, jint addr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgShmemDestroy\n");
+#endif
+
+ return (jint) PgShmemDestroy((void *)addr);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgShmemDetach
+ * Signature: (I)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgShmemDetach
+ (JNIEnv *env, jobject that, jint addr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgShmemDetach\n");
+#endif
+
+ return (jint) PgShmemDetach((void *)addr);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgShmemCreate
+ * Signature: (I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PgShmemCreate
+ (JNIEnv *env, jobject that, jint size, jbyteArray name)
+{
+ jint result;
+ char *name1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgShmemCreate\n");
+#endif
+
+ if (name) name1 = (*env)->GetByteArrayElements(env, name, NULL);
+ result = (jint) PgShmemCreate(size, name1);
+ if (name) (*env)->ReleaseByteArrayElements(env, name, name1, 0);
+
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PgShmemCleanup
+ * Signature: ()V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_photon_OS_PgShmemCleanup
+ (JNIEnv *env, jobject that, jint addr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PgShmemCleanup\n");
+#endif
+
+ PgShmemCleanup();
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PhRegionQuery
+ * Signature: (ILorg/eclipse/swt/photon/PhRegion_t;Lorg/eclipse/swt/photon/PhRect_t;II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PhRegionQuery
+ (JNIEnv *env, jobject that, jint rid, jobject region, jobject rect, jint data, jint data_len)
+{
+ DECL_GLOB(pGlob)
+ PhRegion_t region1, *lpRegion1=NULL;
+ PhRect_t rect1, *lpRect1=NULL;
+ jint result;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PhRegionQuery\n");
+#endif
+
+ if (region) {
+ lpRegion1 = &region1;
+ cachePhRegion_tFids(env, region, &PGLOB(PhRegion_tFc));
+ getPhRegion_tFields(env, region, lpRegion1, &PGLOB(PhRegion_tFc));
+ }
+ if (rect) {
+ lpRect1 = &rect1;
+ cachePhRect_tFids(env, rect, &PGLOB(PhRect_tFc));
+ getPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ result = (jint) PhRegionQuery((PhRid_t)rid, lpRegion1, lpRect1, (void *) data, data_len);
+ if (region) {
+ setPhRegion_tFields(env, region, lpRegion1, &PGLOB(PhRegion_tFc));
+ }
+ if (rect) {
+ setPhRect_tFields(env, rect, lpRect1, &PGLOB(PhRect_tFc));
+ }
+ return result;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_photon_OS
+ * Method: PiGetPixelRGB
+ * Signature: (II)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_photon_OS_PiGetPixelRGB
+ (JNIEnv *env, jobject that, jint image, jint x, jint y, jintArray value)
+{
+ jint result;
+ jint *value1 = NULL;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PiGetPixelRGB\n");
+#endif
+
+ if (value) value1 = (*env)->GetIntArrayElements(env, value, NULL);
+
+ result = (jint)PiGetPixelRGB ((PhImage_t *)image, x, y, (PgColor_t *)value1);
+
+ if (value) (*env)->ReleaseIntArrayElements(env, value, value1, 0);
+
+ return result;
+}
+*/ \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/libswt0104.so b/bundles/org.eclipse.swt/Eclipse SWT/photon/libswt0104.so
new file mode 100755
index 0000000000..031b391dec
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/libswt0104.so
Binary files differ
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
new file mode 100755
index 0000000000..f737dbd2df
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Color.java
@@ -0,0 +1,99 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+
+public final class Color {
+
+ /**
+ * the handle to the OS color resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this color was created
+ */
+ Device device;
+
+Color() {
+}
+
+public Color (Device device, int red, int green, int blue) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, red, green, blue);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Color (Device device, RGB rgb) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, rgb.red, rgb.green, rgb.blue);
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose() {
+ if (handle == -1) return;
+
+ handle = -1;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Color)) return false;
+ Color color = (Color) object;
+ return device == color.device && (handle & 0xFFFFFF) == (color.handle & 0xFFFFFF);
+}
+
+public int getBlue () {
+ return handle & 0xFF;
+}
+
+public int getGreen () {
+ return (handle & 0xFF00) >> 8;
+}
+
+public int getRed () {
+ return (handle & 0xFF0000) >> 16;
+}
+
+public RGB getRGB () {
+ return new RGB((handle & 0xFF0000) >> 16, (handle & 0xFF00) >> 8, handle & 0xFF);
+}
+
+public int hashCode () {
+ return handle;
+}
+
+void init(Device device, 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.device = device;
+ handle = (blue & 0xFF) | ((green & 0xFF) << 8) | ((red & 0xFF) << 16);
+}
+
+public boolean isDisposed() {
+ return handle == -1;
+}
+
+public String toString () {
+ return "Color {" + getRed() + ", " + getGreen() + ", " + getBlue() + "}";
+}
+
+public static Color photon_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Color color = new Color();
+ color.handle = handle;
+ color.device = device;
+ return color;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
new file mode 100755
index 0000000000..dae177eaca
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Cursor.java
@@ -0,0 +1,112 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class Cursor {
+
+ /**
+ * the type to the OS cursor resource
+ * (Warning: This field is platform dependent)
+ */
+ public int type;
+
+ /**
+ * the handle to the OS cursor resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this cursor was created
+ */
+ Device device;
+
+Cursor() {
+}
+
+public Cursor(Device device, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ switch (style) {
+ case SWT.CURSOR_ARROW: type = OS.Ph_CURSOR_POINTER; break;
+ case SWT.CURSOR_WAIT: type = OS.Ph_CURSOR_CLOCK; break;
+ case SWT.CURSOR_HAND: type = OS.Ph_CURSOR_FINGER; break;
+ case SWT.CURSOR_CROSS: type = OS.Ph_CURSOR_CROSSHAIR; break;
+ case SWT.CURSOR_APPSTARTING: type = OS.Ph_CURSOR_POINT_WAIT; break;
+ case SWT.CURSOR_HELP: type = OS.Ph_CURSOR_QUESTION_POINT; break;
+ case SWT.CURSOR_SIZEALL: type = OS.Ph_CURSOR_MOVE; break;
+ case SWT.CURSOR_SIZENESW: type = OS.Ph_CURSOR_MOVE; break;
+ case SWT.CURSOR_SIZENS: type = OS.Ph_CURSOR_DRAG_VERTICAL; break;
+ case SWT.CURSOR_SIZENWSE: type = OS.Ph_CURSOR_MOVE; break;
+ case SWT.CURSOR_SIZEWE: type = OS.Ph_CURSOR_DRAG_HORIZONTAL; break;
+ case SWT.CURSOR_SIZEN: type = OS.Ph_CURSOR_DRAG_TOP; break;
+ case SWT.CURSOR_SIZES: type = OS.Ph_CURSOR_DRAG_BOTTOM; break;
+ case SWT.CURSOR_SIZEE: type = OS.Ph_CURSOR_DRAG_RIGHT; break;
+ case SWT.CURSOR_SIZEW: type = OS.Ph_CURSOR_DRAG_LEFT; break;
+ case SWT.CURSOR_SIZENE: type = OS.Ph_CURSOR_DRAG_TR; break;
+ case SWT.CURSOR_SIZESE: type = OS.Ph_CURSOR_DRAG_BR; break;
+ case SWT.CURSOR_SIZESW: type = OS.Ph_CURSOR_DRAG_BL; break;
+ case SWT.CURSOR_SIZENW: type = OS.Ph_CURSOR_DRAG_TL; break;
+ case SWT.CURSOR_UPARROW: type = OS.Ph_CURSOR_FINGER; break;
+ case SWT.CURSOR_IBEAM: type = OS.Ph_CURSOR_INSERT; break;
+ case SWT.CURSOR_NO: type = OS.Ph_CURSOR_DONT; break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ handle = type;
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ type = OS.Ph_CURSOR_BITMAP;
+ SWT.error(SWT.ERROR_NOT_IMPLEMENTED);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose () {
+ if (handle == 0) return;
+ if (type == OS.Ph_CURSOR_BITMAP && handle != 0) {
+ /* BITMAP cursors are not implemented yet */
+ }
+ type = handle = 0;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+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;
+}
+
+public int hashCode () {
+ return handle ^ type;
+}
+
+public boolean isDisposed() {
+ return type == 0;
+}
+
+public static Cursor photon_new(Device device, int type, int handle) {
+ if (device == null) device = Device.getDevice();
+ Cursor cursor = new Cursor();
+ cursor.type = type;
+ cursor.handle = handle;
+ cursor.device = device;
+ return cursor;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
new file mode 100755
index 0000000000..3d48ea467a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Device.java
@@ -0,0 +1,253 @@
+package org.eclipse.swt.graphics;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+
+public abstract class Device implements Drawable {
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ public boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ boolean disposed;
+
+public Device(DeviceData data) {
+ create (data);
+ init ();
+ if (data != null) {
+ debug = data.debug;
+ tracking = data.tracking;
+ }
+ if (tracking) {
+ errors = new Error [128];
+ objects = new Object [128];
+ }
+}
+
+/**
+ * Temporary code.
+ */
+static Device getDevice () {
+ Device device = null;
+ try {
+ Class clazz = Class.forName ("org.eclipse.swt.widgets.Display");
+ java.lang.reflect.Method method = clazz.getMethod("getCurrent", new Class[0]);
+ device = (Device) method.invoke(clazz, new Object[0]);
+ if (device == null) {
+ method = clazz.getMethod("getDefault", new Class[0]);
+ device = (Device)method.invoke(clazz, new Object[0]);
+ }
+ } catch (Throwable e) {};
+ return device;
+}
+
+protected void checkDevice () {
+ if (disposed) SWT.error(SWT.ERROR_DEVICE_DISPOSED);
+}
+
+protected void create (DeviceData data) {
+}
+
+protected void destroy () {
+}
+
+public void dispose () {
+ if (isDisposed()) return;
+ checkDevice ();
+ release ();
+ destroy ();
+ disposed = true;
+ if (tracking) {
+ objects = null;
+ errors = null;
+ }
+}
+
+void dispose_Object (Object object) {
+ for (int i=0; i<objects.length; i++) {
+ if (objects [i] == object) {
+ objects [i] = null;
+ errors [i] = null;
+ return;
+ }
+ }
+}
+
+public Rectangle getBounds () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle (rect.ul_x, rect.ul_y, width, height);
+}
+
+public Rectangle getClientArea () {
+ return getBounds ();
+}
+
+public int getDepth () {
+ checkDevice ();
+ //NOT DONE
+ return 32;
+}
+
+public DeviceData getDeviceData () {
+ checkDevice();
+ DeviceData data = new DeviceData ();
+ data.debug = debug;
+ data.tracking = tracking;
+ int count = 0, length = 0;
+ if (tracking) 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++;
+ }
+ }
+ return data;
+}
+
+public Point getDPI () {
+ checkDevice ();
+ //NOT DONE
+ return new Point (96, 96);
+}
+
+public FontData [] getFontList (String faceName, boolean scalable) {
+ checkDevice ();
+ int flags = OS.PHFONT_FIXED | OS.PHFONT_PROP | OS.PFFONT_DONT_SHOW_LEGACY;
+ flags |= scalable ? OS.PHFONT_SCALABLE : OS.PHFONT_BITMAP;
+ int nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_FONTS, flags, 0, 0);
+ if (nfonts <= 0) return new FontData[0];
+
+ int list_ptr = OS.malloc(nfonts * FontDetails.sizeof);
+ nfonts = OS.PfQueryFonts(OS.PHFONT_ALL_FONTS, flags, list_ptr, nfonts);
+ int ptr = list_ptr;
+ int nFds = 0;
+ FontData[] fds = new FontData[faceName != null ? 4 : nfonts];
+ FontDetails details = new FontDetails();
+ for (int i = 0; i < nfonts; i++) {
+ OS.memmove(details, ptr, FontDetails.sizeof);
+ String name = new String(Converter.mbcsToWcs(null, details.desc)).trim();
+ if (faceName == null || faceName.equalsIgnoreCase(name)) {
+ int size;
+ if (details.losize == 0 && details.hisize == 0) size = 9; // This value was taken from the PhAB editor
+ else size = details.losize;
+ flags = details.flags & ~(OS.PHFONT_INFO_PROP | OS.PHFONT_INFO_FIXED);
+ while (flags != 0) {
+ int style;
+ if ((flags & OS.PHFONT_INFO_PLAIN) != 0) {
+ style = SWT.NORMAL;
+ flags &= ~OS.PHFONT_INFO_PLAIN;
+ } else if ((flags & OS.PHFONT_INFO_BOLD) != 0) {
+ style = SWT.BOLD;
+ flags &= ~OS.PHFONT_INFO_BOLD;
+ } else if ((flags & OS.PHFONT_INFO_ITALIC) != 0) {
+ style = SWT.ITALIC;
+ flags &= ~OS.PHFONT_INFO_ITALIC;
+ } else if ((flags & OS.PHFONT_INFO_BLDITC) != 0) {
+ style = SWT.BOLD | SWT.ITALIC;
+ flags &= ~OS.PHFONT_INFO_BLDITC;
+ } else break;
+ if (nFds == fds.length) {
+ FontData[] newFds = new FontData[fds.length + nfonts];
+ System.arraycopy(fds, 0, newFds, 0, nFds);
+ fds = newFds;
+ }
+ fds[nFds++] = new FontData(name, size, style);
+ }
+ }
+ ptr += FontDetails.sizeof;
+ }
+ OS.free(list_ptr);
+
+ if (nFds == fds.length) return fds;
+
+ FontData[] result = new FontData[nFds];
+ System.arraycopy(fds, 0, result, 0, nFds);
+ return result;
+}
+
+public Color getSystemColor (int id) {
+ checkDevice ();
+ int color = 0x000000;
+ switch (id) {
+ case SWT.COLOR_BLACK: color = 0x000000; break;
+ case SWT.COLOR_DARK_RED: color = 0x800000; break;
+ case SWT.COLOR_DARK_GREEN: color = 0x008000; break;
+ case SWT.COLOR_DARK_YELLOW: color = 0x808000; break;
+ case SWT.COLOR_DARK_BLUE: color = 0x000080; break;
+ case SWT.COLOR_DARK_MAGENTA: color = 0x800080; break;
+ case SWT.COLOR_DARK_CYAN: color = 0x008080; break;
+ case SWT.COLOR_GRAY: color = 0x808080; break;
+ case SWT.COLOR_DARK_GRAY: color = 0x404040; break;
+ case SWT.COLOR_RED: color = 0xFF0000; break;
+ case SWT.COLOR_GREEN: color = 0x00FF00; break;
+ case SWT.COLOR_YELLOW: color = 0xFFFF00; break;
+ case SWT.COLOR_BLUE: color = 0x0000FF; break;
+ case SWT.COLOR_MAGENTA: color = 0xFF00FF; break;
+ case SWT.COLOR_CYAN: color = 0x00FFFF; break;
+ case SWT.COLOR_WHITE: color = 0xFFFFFF; break;
+ }
+ return Color.photon_new (this, color);
+}
+
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.photon_new (this, Font.DefaultFont);
+}
+
+public boolean getWarnings () {
+ checkDevice ();
+ return false;
+}
+
+protected void init () {
+}
+
+public abstract int internal_new_GC (GCData data);
+
+public abstract void internal_dispose_GC (int handle, GCData data);
+
+public boolean isDisposed () {
+ return disposed;
+}
+
+void new_Object (Object object) {
+ 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;
+}
+
+protected void release () {
+}
+
+public void setWarnings (boolean warnings) {
+ checkDevice ();
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
new file mode 100755
index 0000000000..f971a60537
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/DeviceData.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class DeviceData {
+ /*
+ * Debug fields - may not be honoured
+ * on some SWT platforms.
+ */
+ public boolean debug;
+ public boolean tracking;
+ public Error [] errors;
+ public Object [] objects;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
new file mode 100755
index 0000000000..de23742eed
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Font.java
@@ -0,0 +1,107 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class Font {
+
+ /**
+ * the handle to the OS font resource
+ * (Warning: This field is platform dependent)
+ */
+ public byte[] handle;
+
+ /**
+ * the device where this font was created
+ */
+ Device device;
+
+ static final byte[] DefaultFontName = {(byte)'h', (byte)'e', (byte)'l', (byte)'v'};
+ static final byte[] DefaultFont = {(byte)'h', (byte)'e', (byte)'l', (byte)'v', (byte)'1', (byte)'2'};
+
+Font() {
+}
+
+public Font(Device device, FontData fd) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, fd.getName(), fd.getHeight(), fd.getStyle(), fd.stem);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Font(Device device, String name, int height, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, name, height, style, null);
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose() {
+ if (handle == null) return;
+
+ handle = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+public boolean equals(Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Font)) return false;
+ byte[] h = ((Font)object).handle;
+ if (h == handle) return true;
+ if (h == null || handle == null) return false;
+ if (h.length != handle.length) return false;
+ for (int i = 0; i < handle.length; i++) {
+ if (handle[i] != h[i]) return false;
+ }
+ return true;
+}
+
+public FontData[] getFontData() {
+ return new FontData[]{new FontData(handle)};
+}
+
+public int hashCode () {
+ if (handle == null) return 0;
+ return handle.hashCode();
+}
+
+public boolean isDisposed() {
+ return handle == null;
+}
+
+void init(Device device, String name, int height, int style, byte[] stem) {
+ if (height < 0) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (stem != null) {
+ handle = stem;
+ } else {
+ byte[] description = (name == null) ? null : Converter.wcsToMbcs(null, name, true);
+ int osStyle = 0;
+ if ((style & SWT.BOLD) != 0) osStyle |= OS.PF_STYLE_BOLD;
+ if ((style & SWT.ITALIC) != 0) osStyle |= OS.PF_STYLE_ITALIC;
+ byte[] buffer = new byte[OS.MAX_FONT_TAG];
+ handle = OS.PfGenerateFontName(description, osStyle, height, buffer);
+ if (handle == null) handle = OS.PfGenerateFontName(DefaultFontName, osStyle, height, buffer);
+ }
+ if (handle == null) handle = DefaultFont;
+ FontQueryInfo info = new FontQueryInfo();
+ if (OS.PfQueryFontInfo(handle, info) == 0) handle = info.font;
+}
+
+public static Font photon_new(Device device, byte[] stem) {
+ if (device == null) device = Device.getDevice();
+ Font font = new Font();
+ font.init(device, null, 0, 0, stem);
+ return font;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
new file mode 100755
index 0000000000..b7e0fe27ce
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontData.java
@@ -0,0 +1,188 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class FontData {
+
+ /**
+ * the font name
+ * (Warning: This field is platform dependent)
+ */
+ String name;
+
+ /**
+ * the font height
+ * (Warning: This field is platform dependent)
+ */
+ int height;
+
+ /**
+ * the font style
+ * (Warning: This field is platform dependent)
+ */
+ int style;
+
+ /**
+ * A Photon stem
+ * (Warning: This field is platform dependent)
+ */
+ public byte[] stem;
+
+FontData(byte[] stem) {
+ FontQueryInfo info = new FontQueryInfo();
+ if (OS.PfQueryFontInfo(stem, info) == 0) {
+ this.stem = info.font;
+ name = new String(Converter.mbcsToWcs(null, info.desc)).trim();
+ if ((info.style & OS.PHFONT_INFO_PLAIN) != 0) style = SWT.NORMAL;
+ else if ((info.style & OS.PHFONT_INFO_BOLD) != 0) style = SWT.BOLD;
+ else if ((info.style & OS.PHFONT_INFO_ITALIC) != 0) style = SWT.ITALIC;
+ else if ((info.style & OS.PHFONT_INFO_BLDITC) != 0) style = SWT.BOLD | SWT.ITALIC;
+ else style = SWT.NORMAL;
+ /*
+ * For some reason, sometimes PfQueryFontInfo does not
+ * set the size of the font. In that case, the size is
+ * parsed from the stem.
+ */
+ if (info.size != 0) {
+ height = info.size;
+ } else {
+ String fontName = new String(Converter.mbcsToWcs(null, this.stem)).trim();
+ int end = fontName.length();
+ for (int i = end - 1; i >= 0; i--) {
+ if (Character.isDigit(fontName.charAt(i))) break;
+ end--;
+ }
+ int start = end;
+ for (int i = end - 1; i >= 0; i--) {
+ if (!Character.isDigit(fontName.charAt(i))) break;
+ start--;
+ }
+ try {
+ height = Integer.parseInt(fontName.substring(start, end));
+ } catch (NumberFormatException e) {}
+ }
+ } else {
+ this.stem = stem;
+ }
+}
+
+public FontData() {
+ this("", 12, SWT.NORMAL);
+}
+
+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);
+
+ 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);
+ int height = 0;
+ try {
+ height = Integer.parseInt(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("PHOTON") && version2.equals("1")) {
+ return;
+ }
+}
+
+public FontData(String name, int height, int style) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontData)) return false;
+ FontData data = (FontData)object;
+ return name == name && height == data.height && style == data.style;
+}
+
+public int getHeight() {
+ return height;
+}
+
+public String getName() {
+ return name;
+}
+
+public int getStyle() {
+ return style;
+}
+
+public int hashCode () {
+ return name.hashCode() ^ height ^ style;
+}
+
+public void setHeight(int height) {
+ this.height = height;
+}
+
+public void setName(String name) {
+ this.name = name;
+}
+
+public void setStyle(int style) {
+ this.style = style;
+}
+
+public String toString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("1|");
+ buffer.append(getName());
+ buffer.append("|");
+ buffer.append(getHeight());
+ buffer.append("|");
+ buffer.append(getStyle());
+ buffer.append("|");
+ buffer.append("PHOTON|1|");
+ return buffer.toString();
+}
+
+public static FontData photon_new(byte[] stem) {
+ return new FontData(stem);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
new file mode 100755
index 0000000000..6943cd42d9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/FontMetrics.java
@@ -0,0 +1,78 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+
+public final class FontMetrics {
+
+ /**
+ * A Photon FontQueryInfo struct
+ * (Warning: This field is platform dependent)
+ */
+ FontQueryInfo handle;
+
+FontMetrics() {
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof FontMetrics)) return false;
+ FontQueryInfo info = ((FontMetrics)object).handle;
+ if (info == handle) return true;
+ if (info == null || handle == null) return false;
+ if (handle.size == info.size &&
+ handle.style == info.style &&
+ handle.ascender == info.ascender &&
+ handle.descender == info.descender &&
+ handle.width == info.width &&
+ handle.lochar == info.lochar &&
+ handle.hichar == info.hichar &&
+ handle.desc.length == info.desc.length &&
+ handle.font.length == info.font.length)
+ {
+ for (int i = handle.font.length - 1; i >= 0; i--) {
+ if (handle.font[i] != info.font[i]) return false;
+ }
+ return true;
+ }
+ return false;
+}
+
+public int getAscent() {
+ return -handle.ascender;
+}
+
+public int getAverageCharWidth() {
+ return handle.width / 2;
+}
+
+public int getDescent() {
+ return handle.descender;
+}
+
+public int getHeight() {
+ return -handle.ascender + handle.descender;
+}
+
+public int getLeading() {
+ return 0;
+}
+
+public int hashCode() {
+ if (handle == null) return 0;
+ return handle.size ^ handle.style ^ handle.ascender ^
+ handle.descender ^ handle.width ^
+ handle.lochar ^ handle.hichar ^ handle.font.hashCode() ^
+ handle.desc.hashCode();
+}
+
+public static FontMetrics photon_new(FontQueryInfo handle) {
+ FontMetrics fontMetrics = new FontMetrics();
+ fontMetrics.handle = handle;
+ return fontMetrics;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
new file mode 100755
index 0000000000..9c79ad0715
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GC.java
@@ -0,0 +1,1407 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class GC {
+ /**
+ * The handle to the OS device context.
+ * Warning: This field is platform dependent.
+ */
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+ static final int DefaultBack = 0xffffff;
+ static final int DefaultFore = 0x000000;
+ static final byte[][] DashList = {
+ { }, // SWT.LINE_SOLID
+ { 10, 4 }, // SWT.LINE_DASH
+ { 2, 2 }, // SWT.LINE_DOT
+ { 10, 4, 2, 4 }, // SWT.LINE_DASHDOT
+ { 10, 4, 2, 4, 2, 4 } // SWT.LINE_DASHDOTDOT
+ };
+ // Photon Draw Buffer Size for off screen drawing.
+ static int DrawBufferSize = 48 * 1024;
+
+GC() {
+}
+
+public GC(Drawable drawable) {
+ int flags = OS.PtEnter(0);
+ try {
+ if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ GCData data = new GCData ();
+ int hDC = drawable.internal_new_GC (data);
+ Device device = data.device;
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ data.device = device;
+ init (drawable, data, hDC);
+ if (device.tracking) device.new_Object(this);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void copyArea(Image image, int x, int y) {
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ int flags = OS.PtEnter(0);
+ try {
+ Rectangle bounds = image.getBounds();
+ int memImage = 0;
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x; rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + bounds.width - 1); rect.lr_y = (short)(y + bounds.height - 1);
+ boolean sharedMem = true;
+ int rid = data.rid;
+ int widget = data.widget;
+ if (rid == OS.Ph_DEV_RID) {
+ memImage = OS.PgShmemCreate(OS.PgReadScreenSize(rect), null);
+ if (memImage != 0) memImage = OS.PgReadScreen(rect, memImage);
+ } else if (widget != 0) {
+ short [] widget_x = new short [1], widget_y = new short [1];
+ OS.PtGetAbsPosition(widget, widget_x, widget_y);
+ rect.ul_x += widget_x[0];
+ rect.ul_y += widget_y[0];
+ rect.lr_x += widget_y[0];
+ rect.lr_y += widget_y[0];
+ memImage = OS.PgShmemCreate(OS.PgReadScreenSize(rect), null);
+ if (memImage != 0) memImage = OS.PgReadScreen(rect, memImage);
+ } else if (data.image != null) {
+ memImage = OS.PiCropImage(data.image.handle, rect, 0);
+ sharedMem = false;
+ }
+ if (memImage == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, memImage, PhImage_t.sizeof);
+ PhPoint_t trans = new PhPoint_t();
+ PhPoint_t pos = new PhPoint_t();
+ PhDim_t scale = new PhDim_t();
+ scale.w = (short)bounds.width;
+ scale.h = (short)bounds.height;
+ int mc = OS.PmMemCreateMC(image.handle, scale, trans);
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ if (phImage.palette != 0) OS.PgSetPalette(phImage.palette, 0, (short)0, (short)phImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phImage.image, phImage.type, pos, scale, phImage.bpl, 0);
+ if (phImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, image.handle);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ if (sharedMem) {
+ OS.PgShmemDestroy(memImage);
+ } else {
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(memImage, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(memImage);
+ OS.free(memImage);
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void copyArea(int x, int y, int width, int height, int destX, int destY) {
+ if (width == 0 || height == 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+
+ int flags = OS.PtEnter(0);
+ try {
+ boolean overlaps = (destX < x + width) && (destY < y + height) &&
+ (destX + width > x) && (destY + height > y);
+ int widget = data.widget;
+ Image image = data.image;
+ if (image != null) {
+ int drawImage = image.handle;
+ PhImage_t phDrawImage = new PhImage_t();
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ if (overlaps) {
+ PhPoint_t trans = new PhPoint_t();
+ PhDim_t scale = new PhDim_t();
+ scale.w = (short)width;
+ scale.h = (short)height;
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)-x;
+ pos.y = (short)-y;
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phDrawImage.size_w, x + width);
+ dim.h = (short)Math.min(phDrawImage.size_h, y + height);
+ /* Feature on Photon - It is only possible to draw on images of
+ type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int type = OS.Pg_IMAGE_PALETTE_BYTE;
+ if ((phDrawImage.type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_DIRECT) {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ }
+ int memImage = OS.PhCreateImage(null, (short)width, (short)height, type, phDrawImage.palette, phDrawImage.colors, 0);
+ int mc = OS.PmMemCreateMC(memImage, scale, trans);
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(phDrawImage.palette, 0, (short)0, (short)phDrawImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phDrawImage.image, phDrawImage.type, pos, dim, phDrawImage.bpl, 0);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, memImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ x = (short)0;
+ y = (short)0;
+ drawImage = memImage;
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ phDrawImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(drawImage, phDrawImage, PhImage_t.sizeof);
+ }
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)(destX - x);
+ pos.y = (short)(destY - y);
+ PhRect_t clip = new PhRect_t();
+ clip.ul_x = (short)destX;
+ clip.ul_y = (short)destY;
+ clip.lr_x = (short)(destX + width - 1);
+ clip.lr_y = (short)(destY + height - 1);
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phDrawImage.size_w, x + width);
+ dim.h = (short)Math.min(phDrawImage.size_h, y + height);
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgSetUserClip(clip);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(phDrawImage.palette, 0, (short)0, (short)phDrawImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phDrawImage.image, phDrawImage.type, pos, dim, phDrawImage.bpl, 0);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PgSetUserClip(null);
+ unsetGC(prevContext);
+ if (drawImage != image.handle) {
+ OS.PhReleaseImage(drawImage);
+ OS.free(drawImage);
+ }
+ } else if (widget != 0) {
+ int rid = OS.PtWidgetRid(widget);
+ if (rid == 0) return;
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x;
+ rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + width - 1);
+ rect.lr_y = (short)(y + height - 1);
+ PhPoint_t delta = new PhPoint_t();
+ delta.x = (short)deltaX;
+ delta.y = (short)deltaY;
+ int clipRects = data.clipRects;
+ if (clipRects == 0) {
+ OS.PhBlit(rid, rect, delta);
+ } else {
+ int dest = OS.PhGetTile();
+ OS.memmove(dest, rect, PhRect_t.sizeof);
+ OS.PhTranslateTiles(dest, delta);
+ int clip = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
+ int dest_tiles = OS.PhIntersectTilings(dest, clip, new short[1]);
+ OS.PhFreeTiles(clip);
+ OS.PhFreeTiles(dest);
+ PhPoint_t inverseDelta = new PhPoint_t();
+ inverseDelta.x = (short)(-delta.x);
+ inverseDelta.y = (short)(-delta.y);
+ OS.PhTranslateTiles(dest_tiles, inverseDelta);
+ int[] src_rects_count = new int[1];
+ int src_rects = OS.PhTilesToRects(dest_tiles, src_rects_count);
+ OS.PhFreeTiles(dest_tiles);
+ PhRect_t src_rect = new PhRect_t();
+ for (int i = 0; i<src_rects_count[0]; i++) {
+ OS.memmove(src_rect, src_rects + (i * PhRect_t.sizeof), PhRect_t.sizeof);
+ OS.PhBlit(rid, src_rect, delta);
+ }
+ OS.free(src_rects);
+ }
+ if (!overlaps) {
+ OS.PtDamageExtent (widget, rect);
+ } else {
+ int src = OS.PhGetTile();
+ int dest = OS.PhGetTile();
+ OS.memmove(src, rect, PhRect_t.sizeof);
+ OS.memmove(dest, rect, PhRect_t.sizeof);
+ OS.PhTranslateTiles(dest, delta);
+ int damage_tile = OS.PhClipTilings(src, dest, null);
+ int[] damage_rects_count = new int[1];
+ int damage_rects = OS.PhTilesToRects(damage_tile, damage_rects_count);
+ OS.PhFreeTiles(dest);
+ OS.PhFreeTiles(damage_tile);
+ for (int i=0; i<damage_rects_count[0]; i++) {
+ OS.memmove(rect, damage_rects + (i * PhRect_t.sizeof), PhRect_t.sizeof);
+ OS.PtDamageExtent (widget, rect);
+ }
+ OS.free(damage_rects);
+ }
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void dispose() {
+ int flags = OS.PtEnter(0);
+ try {
+ if (handle == 0) return;
+
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ }
+ Image image = data.image;
+ if (image != null) image.memGC = null;
+
+ /*
+ * Dispose the HDC.
+ */
+ Device device = data.device;
+ drawable.internal_dispose_GC(handle, data);
+ drawable = null;
+ handle = 0;
+ data.image = null;
+ data.font = null;
+ data.rid = data.widget = data.topWidget = 0;
+ if (device.tracking) device.dispose_Object(this);
+ data.device = null;
+ data = null;
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (startAngle > 0) {
+ if (endAngle > 0) {
+ //No need to modify start angle.
+ endAngle += startAngle;
+ } else {
+ int newStartAngle;
+ int newStopAngle = startAngle;
+ if (startAngle > Math.abs(endAngle)) {
+ newStartAngle = startAngle - Math.abs(endAngle);
+ } else {
+ newStartAngle = startAngle + 360 - Math.abs(endAngle);
+ }
+ startAngle = newStartAngle;
+ endAngle = newStopAngle;
+ }
+ } else {
+ if (endAngle > 0) {
+ endAngle = endAngle + startAngle;
+ startAngle = 360 - Math.abs(startAngle);
+ } else {
+ int newStopAngle = 360 + startAngle;
+ startAngle = newStopAngle - Math.abs(endAngle);
+ endAngle = newStopAngle;
+ }
+ }
+
+ startAngle = (int) (startAngle * 65536 / 360);
+ endAngle = (int) (endAngle * 65536 / 360);
+
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)(x + (width / 2));
+ center.y = (short)(y + (height / 2));
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(width / 2);
+ radii.y = (short)(height / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawArc(center, radii, startAngle, endAngle, OS.Pg_ARC | OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawFocus (int x, int y, int width, int height) {
+ drawRectangle(x, y, width, height);
+}
+
+public void drawImage(Image image, int x, int y) {
+ if (image == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ drawImage(image, 0, 0, -1, -1, x, y, -1, -1, true);
+}
+
+public void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ 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);
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, false);
+}
+void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ int flags = OS.PtEnter(0);
+ try {
+ int drawImage = image.handle;
+ if (drawImage == 0) return;
+ PhImage_t phDrawImage = new PhImage_t();
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ int imgWidth = phDrawImage.size_w;
+ int imgHeight = phDrawImage.size_h;
+ 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);
+ }
+ }
+ if (srcWidth != destWidth || srcHeight != destHeight) {
+ drawImage = scaleImage(image, phDrawImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight);
+ srcX = (short)0;
+ srcY = (short)0;
+ srcWidth = (short)destWidth;
+ srcHeight = (short)destHeight;
+ OS.memmove(phDrawImage, drawImage, PhImage_t.sizeof);
+ }
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)(destX - srcX);
+ pos.y = (short)(destY - srcY);
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phDrawImage.size_w, srcX + srcWidth);
+ dim.h = (short)Math.min(phDrawImage.size_h, srcY + srcHeight);
+ PhRect_t clip = new PhRect_t();
+ clip.ul_x = (short)destX;
+ clip.ul_y = (short)destY;
+ clip.lr_x = (short)(destX + destWidth - 1);
+ clip.lr_y = (short)(destY + destHeight - 1);
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgSetUserClip(clip);
+ if (phDrawImage.palette != 0) OS.PgSetPalette(phDrawImage.palette, 0, (short)0, (short)phDrawImage.colors, OS.Pg_PALSET_SOFT, 0);
+ if (phDrawImage.alpha != 0) {
+ drawImageAlpha(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ } else if (image.transparentPixel != -1) {
+ drawImageTransparent(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ } else if (phDrawImage.mask_bm != 0) {
+ drawImageMask(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ } else {
+ drawImage(image, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, phDrawImage, drawImage, pos, dim);
+ }
+ if (phDrawImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PgSetUserClip(null);
+ unsetGC(prevContext);
+ if (drawImage != image.handle) {
+ phDrawImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(drawImage, phDrawImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(drawImage);
+ OS.free(drawImage);
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+void drawImageAlpha(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ PgAlpha_t phAlpha = new PgAlpha_t();
+ OS.memmove(phAlpha, phImage.alpha, PgAlpha_t.sizeof);
+ if ((phAlpha.alpha_op & OS.Pg_ALPHA_OP_SRC_GLOBAL) != 0) {
+ OS.PgSetAlpha(phAlpha.alpha_op, null, 0, phAlpha.src_global_alpha, phAlpha.dest_global_alpha);
+ OS.PgAlphaOn();
+ OS.PgDrawImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0);
+ OS.PgAlphaOff();
+ return;
+ }
+
+ /*
+ * Feature/Bug in Photon - When drawing images with alpha blending
+ * enabled, there is a limitation in the size of the alpha map.
+ * This limitation is probably related to the draw buffer size and
+ * it seems to be worse when drawing to a memory context. The
+ * fix/workaround is to draw the image line by line.
+ */
+ PgMap_t imageMap = new PgMap_t();
+ OS.memmove(imageMap, phImage.alpha + 4, PgMap_t.sizeof);
+ PgMap_t lineMap = new PgMap_t();
+ lineMap.dim_w = imageMap.dim_w;
+ lineMap.dim_h = 1;
+ /*
+ * Feature in Photon - The alpha map set in a graphics context by
+ * PgSetAlpha is freed when the graphics context is destroyed.
+ */
+ lineMap.map = OS.malloc(lineMap.dim_w);
+ OS.PgSetAlpha(phAlpha.alpha_op, lineMap, 0, phAlpha.src_global_alpha, phAlpha.dest_global_alpha);
+ OS.PgAlphaOn();
+ pos.y = (short)(destY);
+ int end = dim.h;
+ dim.h = (short)1;
+ for (int y=srcY; y<end; y+=lineMap.dim_h) {
+ OS.memmove(lineMap.map, imageMap.map + (imageMap.dim_w * y), lineMap.dim_w);
+ /*
+ * Bug in Photon - When drawing an image to a memory context created by
+ * PmMemCreateMC at a negative position, the alpha map is not offset.
+ */
+ if (data.image != null && pos.x < 0) {
+ OS.memmove(lineMap.map, lineMap.map - pos.x, lineMap.dim_w + pos.x);
+ }
+ OS.PgDrawImage(phImage.image + (phImage.bpl * y), phImage.type, pos, dim, phImage.bpl, 0);
+ /*
+ * Flushing is necessary in order to change the alpha map.
+ */
+ if (data.image != null) OS.PmMemFlush(handle, data.image.handle);
+ else OS.PgFlush();
+ pos.y += lineMap.dim_h;
+ }
+ OS.PgAlphaOff();
+}
+void drawImageTransparent(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ /* Generate the mask if necessary */
+ if (phImage.mask_bm == 0) {
+ createMask(imgHandle, phImage.type, image.transparentPixel);
+ OS.memmove(phImage, imgHandle, PhImage_t.sizeof);
+ }
+ OS.PgDrawTImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0, phImage.mask_bm, phImage.mask_bpl);
+ /* Destroy the mask if there is a GC created on the image */
+ if (image.memGC != null && image.handle == imgHandle) {
+ OS.free(phImage.mask_bm);
+ phImage.mask_bm = 0;
+ phImage.mask_bpl = 0;
+ OS.memmove(imgHandle, phImage, PhImage_t.sizeof);
+ }
+}
+void drawImageMask(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ OS.PgDrawTImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0, phImage.mask_bm, phImage.mask_bpl);
+}
+void drawImage(Image image, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, PhImage_t phImage, int imgHandle, PhPoint_t pos, PhDim_t dim) {
+ OS.PgDrawImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0);
+}
+static void createMask(int image, int type, int transparent) {
+ if ((type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_PALETTE) {
+ transparent = (transparent & 0xFF) | OS.Pt_INDEX_COLOR;
+ } else {
+ switch (type) {
+ case OS.Pg_IMAGE_DIRECT_888:
+ transparent = ((transparent & 0xFF) << 16) | (transparent & 0xFF00) | ((transparent & 0xFF0000) >> 16);
+ break;
+ case OS.Pg_IMAGE_DIRECT_8888:
+ transparent = ((transparent & 0xFF00) << 8) | ((transparent & 0xFF0000) >> 8) | ((transparent & 0xFF000000) >> 24);
+ break;
+ case OS.Pg_IMAGE_DIRECT_565:
+ transparent = ((transparent & 0xF800) << 8) | ((transparent & 0x7E0) << 5) | ((transparent & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_555:
+ transparent = ((transparent & 0x7C00) << 9) | ((transparent & 0x3E0) << 6) | ((transparent & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_444:
+ transparent = ((transparent & 0xF00) << 12) | ((transparent & 0xF0) << 8) | ((transparent & 0xF) << 4);
+ break;
+ }
+ }
+ OS.PhMakeTransBitmap(image, transparent);
+}
+static int scaleImage(Image image, PhImage_t phImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight) {
+ PhPoint_t trans = new PhPoint_t();
+ PhDim_t scale = new PhDim_t();
+ scale.w = (short)srcWidth;
+ scale.h = (short)srcHeight;
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = (short)-srcX;
+ pos.y = (short)-srcY;
+ PhDim_t dim = new PhDim_t();
+ dim.w = (short)Math.min(phImage.size_w, srcX + srcWidth);
+ dim.h = (short)Math.min(phImage.size_h, srcY + srcHeight);
+ /*
+ * Feature on Photon - It is only possible to draw on images of
+ * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int type = OS.Pg_IMAGE_PALETTE_BYTE;
+ if ((phImage.type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_DIRECT) {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ }
+ /* Scale the image */
+ int memImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, type, phImage.palette, phImage.colors, 0);
+ if (memImage == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int mc = OS.PmMemCreateMC(memImage, scale, trans);
+ if (mc == 0) {
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ if (phImage.palette != 0) OS.PgSetPalette(phImage.palette, 0, (short)0, (short)phImage.colors, OS.Pg_PALSET_SOFT, 0);
+ OS.PgDrawImage(phImage.image, phImage.type, pos, dim, phImage.bpl, 0);
+ if (phImage.palette != 0) OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+ OS.PmMemFlush(mc, memImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+
+ PhImage_t phMemImage = new PhImage_t();
+ OS.memmove(phMemImage, memImage, PhImage_t.sizeof);
+ if (image.transparentPixel != -1) {
+ /* Generate the mask if it was created originally */
+ if (phImage.mask_bm != 0) {
+ createMask(memImage, phImage.type, image.transparentPixel);
+ }
+ } else if (phImage.mask_bm != 0) {
+ /* Scale the mask */
+ int[] palette = new int[2];
+ palette[0] = 0x000000;
+ palette[1] = 0xffffff;
+ int palettePtr = OS.malloc(palette.length * 4);
+ OS.memmove(palettePtr, palette, palette.length * 4);
+ /*
+ * Feature on Photon - It is only possible to draw on images of
+ * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+ */
+ int maskImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);
+ if (maskImage == 0) {
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ mc = OS.PmMemCreateMC(maskImage, scale, trans);
+ if (mc == 0) {
+ Image.destroyImage(maskImage);
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.PmMemStart(mc);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ OS.PgSetFillColor(palette[0]);
+ OS.PgSetTextColor(palette[1]);
+ OS.PgDrawBitmap(phImage.mask_bm, OS.Pg_BACK_FILL, pos, dim, phImage.mask_bpl, 0);
+ OS.PmMemFlush(mc, maskImage);
+ OS.PmMemStop(mc);
+ OS.PmMemReleaseMC(mc);
+ OS.free(palettePtr);
+
+ /* Transfer the mask to the scaled image */
+ OS.PhMakeTransBitmap(maskImage, 0 | OS.Pt_INDEX_COLOR);
+ PhImage_t phMaskImage = new PhImage_t();
+ OS.memmove(phMaskImage, maskImage, PhImage_t.sizeof);
+ phMemImage.mask_bm = phMaskImage.mask_bm;
+ phMemImage.mask_bpl = phMaskImage.mask_bpl;
+ OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
+
+ /* Release the temporary image but not the mask data */
+ phMaskImage.mask_bm = 0;
+ phMaskImage.mask_bpl = 0;
+ phMaskImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(maskImage, phMaskImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(maskImage);
+ OS.free(maskImage);
+ } else if (phImage.alpha != 0) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ OS.memmove(alpha, phImage.alpha, PgAlpha_t.sizeof);
+ int alphaPtr = OS.malloc(PgAlpha_t.sizeof);
+ if (alphaPtr == 0) {
+ Image.destroyImage(memImage);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+
+ /* Scale alpha data */
+ if (alpha.src_alpha_map_map != 0) {
+// int[] palette = new int[256];
+// for (int i = 0; i < palette.length; i++) {
+// palette[i] = i;
+// }
+// int palettePtr = OS.malloc(palette.length * 4);
+// OS.memmove(palettePtr, palette, palette.length * 4);
+// /*
+// * Feature on Photon - It is only possible to draw on images of
+// * type Pg_IMAGE_PALETTE_BYTE and Pg_IMAGE_DIRECT_888.
+// */
+// int alphaImage = OS.PhCreateImage(null, (short)destWidth, (short)destHeight, OS.Pg_IMAGE_PALETTE_BYTE, palettePtr, palette.length, 0);
+// if (alphaImage == 0) {
+// Image.destroyImage(memImage);
+// SWT.error(SWT.ERROR_NO_HANDLES);
+// }
+// mc = OS.PmMemCreateMC(alphaImage, scale, trans);
+// if (mc == 0) {
+// Image.destroyImage(alphaImage);
+// Image.destroyImage(memImage);
+// SWT.error(SWT.ERROR_NO_HANDLES);
+// }
+// OS.PmMemStart(mc);
+// OS.PgSetPalette(palettePtr, 0, (short)0, (short)palette.length, OS.Pg_PALSET_SOFT, 0);
+// OS.PgDrawImage(alpha.src_alpha_map_map, OS.Pg_IMAGE_PALETTE_BYTE, pos, dim, alpha.src_alpha_map_bpl, 0);
+// OS.PgSetPalette(0, 0, (short)0, (short)-1, 0, 0);
+// OS.PmMemFlush(mc, alphaImage);
+// OS.PmMemStop(mc);
+// OS.PmMemReleaseMC(mc);
+// OS.free(palettePtr);
+//
+// /* Transfer the image to the scaled image alpha data*/
+// PhImage_t phAlphaImage = new PhImage_t();
+// OS.memmove(phAlphaImage, alphaImage, PhImage_t.sizeof);
+// alpha.src_alpha_map_dim_w = (short)phAlphaImage.bpl;
+// alpha.src_alpha_map_dim_h = (short)phAlphaImage.size_h;
+// alpha.src_alpha_map_map = phAlphaImage.image;
+//
+// /* Release the temporary image but not the image data */
+// phAlphaImage.image = 0;
+// phAlphaImage.bpl = 0;
+// phAlphaImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+// OS.memmove(alphaImage, phAlphaImage, PhImage_t.sizeof);
+// OS.PhReleaseImage(alphaImage);
+// OS.free(alphaImage);
+
+ // The code above can not be used because it generates an image with
+ // scanline padding. It seems that Photon does not accept
+ // padding in src_alpha_map, even though there is a field to specify
+ // the number of bytes per line - src_alpha_map_map_bpl.
+ byte[] srcAlphaData = new byte[alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h];
+ OS.memmove(srcAlphaData, alpha.src_alpha_map_map, srcAlphaData.length);
+ byte[] destAlphaData = new byte[destWidth * destHeight];
+ ImageData.stretch8(srcAlphaData, alpha.src_alpha_map_dim_w, 0, 0, srcWidth, srcHeight, destAlphaData, destWidth, 0, 0, destWidth, destHeight, null, false, false);
+ int ptr = OS.malloc(destAlphaData.length);
+ OS.memmove(ptr, destAlphaData, destAlphaData.length);
+ alpha.src_alpha_map_dim_w = (short)destWidth;
+ alpha.src_alpha_map_dim_h = (short)destHeight;
+ alpha.src_alpha_map_map = ptr;
+ }
+
+ OS.memmove(alphaPtr, alpha, PgAlpha_t.sizeof);
+ phMemImage.alpha = alphaPtr;
+ OS.memmove(memImage, phMemImage, PhImage_t.sizeof);
+ }
+ return memImage;
+}
+
+public void drawLine (int x1, int y1, int x2, int y2) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawILine(x1, y1, x2, y2);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawOval (int x, int y, int width, int height) {
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)x; center.y = (short)y;
+ PhPoint_t radii = new PhPoint_t();
+ // Don't subtract one, so that the bottom/right edges are drawn
+ radii.x = (short)(x + width); radii.y = (short)(y + height);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawEllipse(center, radii, OS.Pg_DRAW_STROKE | OS.Pg_EXTENT_BASED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawPolygon(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ short[] points = new short[pointArray.length];
+ for (int i = pointArray.length - 1; i >= 0; i--) {
+ points[i] = (short)pointArray[i];
+ }
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_STROKE | OS.Pg_CLOSED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawPolyline(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ short[] points = new short[pointArray.length];
+ for (int i = pointArray.length - 1; i >= 0; i--) {
+ points[i] = (short)pointArray[i];
+ }
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = 0; pos.y = 0;
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawPolygon(points, pointArray.length / 2, pos, OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawRectangle (int x, int y, int width, int height) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ // Don't subtract one, so that the bottom/right edges are drawn
+ OS.PgDrawIRect(x, y, x + width, y + height, OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ drawRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x; rect.ul_y = (short)y;
+ // Don't subtract one, so that the bottom/right edges are drawn
+ rect.lr_x = (short)(x + width); rect.lr_y = (short)(y + height);
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(arcWidth / 2); radii.y = (short)(arcHeight / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawRoundRect(rect, radii, OS.Pg_DRAW_STROKE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawString (String string, int x, int y) {
+ drawString(string, x, y, false);
+}
+
+public void drawString (String string, int x, int y, boolean isTransparent) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ int drawFlags = OS.Pg_TEXT_LEFT | OS.Pg_TEXT_TOP;
+ if (!isTransparent) drawFlags |= OS.Pg_BACK_FILL;
+ byte[] buffer = Converter.wcsToMbcs(null, string, false);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawText(buffer, buffer.length, (short)x, (short)y, drawFlags);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void drawText (String string, int x, int y) {
+ drawText(string, x, y, false);
+}
+
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ drawString(string, x, y, isTransparent);;
+}
+
+public boolean equals (Object object) {
+ return (object == this) || ((object instanceof GC) && (handle == ((GC)object).handle));
+}
+
+public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ if (startAngle > 0) {
+ if (endAngle > 0) {
+ //No need to modify start angle.
+ endAngle += startAngle;
+ } else {
+ int newStartAngle;
+ int newStopAngle = startAngle;
+ if (startAngle > Math.abs(endAngle)) {
+ newStartAngle = startAngle - Math.abs(endAngle);
+ } else {
+ newStartAngle = startAngle + 360 - Math.abs(endAngle);
+ }
+ startAngle = newStartAngle;
+ endAngle = newStopAngle;
+ }
+ } else {
+ if (endAngle > 0) {
+ endAngle = endAngle + startAngle;
+ startAngle = 360 - Math.abs(startAngle);
+ } else {
+ int newStopAngle = 360 + startAngle;
+ startAngle = newStopAngle - Math.abs(endAngle);
+ endAngle = newStopAngle;
+ }
+ }
+
+ startAngle = (int) (startAngle * 65536 / 360);
+ endAngle = (int) (endAngle * 65536 / 360);
+
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)(x + (width / 2));
+ center.y = (short)(y + (height / 2));
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(width / 2);
+ radii.y = (short)(height / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawArc(center, radii, startAngle, endAngle, OS.Pg_ARC_PIE | OS.Pg_DRAW_FILL);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillOval (int x, int y, int width, int height) {
+ PhPoint_t center = new PhPoint_t();
+ center.x = (short)x; center.y = (short)y;
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(x + width);
+ if (width != 2) radii.x--;
+ radii.y = (short)(y + height);
+ if (height != 2) radii.y--;
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawEllipse(center, radii, OS.Pg_DRAW_FILL | OS.Pg_EXTENT_BASED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillPolygon(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+
+ short[] points = new short[pointArray.length];
+ for (int i = pointArray.length - 1; i >= 0; i--) {
+ points[i] = (short)pointArray[i];
+ }
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawPolygon(points, pointArray.length / 2, new PhPoint_t(), OS.Pg_DRAW_FILL | OS.Pg_CLOSED);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillRectangle (int x, int y, int width, int height) {
+ if (width == 0 || height == 0) return;
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawIRect(x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_FILL);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void fillRectangle (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ fillRectangle (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x; rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + width - 1); rect.lr_y = (short)(y + height - 1);
+ PhPoint_t radii = new PhPoint_t();
+ radii.x = (short)(arcWidth / 2); radii.y = (short)(arcHeight / 2);
+
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ setGCClipping();
+ OS.PgDrawRoundRect(rect, radii, OS.Pg_DRAW_FILL);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public int getAdvanceWidth(char ch) {
+ return getCharWidth(ch);
+}
+
+public Color getBackground() {
+ return Color.photon_new(data.device, data.background);
+}
+
+public int getCharWidth(char ch) {
+ String string = new String(new char[] {ch});
+ Point point = stringExtent(string);
+ return point.x;
+}
+
+public Rectangle getClipping() {
+ int flags = OS.PtEnter(0);
+ try {
+ PhRect_t rect = new PhRect_t();
+ int rid = data.rid;
+ int widget = data.widget;
+ Image image = data.image;
+ if (rid == OS.Ph_DEV_RID) {
+ OS.PhRegionQuery (rid, null, rect, 0, 0);
+ } else if (widget != 0) {
+ OS.PtWidgetCanvas(widget, rect);
+ } else if (image != null) {
+ PhImage_t img = new PhImage_t();
+ OS.memmove(img, image.handle, PhImage_t.sizeof);
+ rect.lr_x = (short)(img.size_w - 1);
+ rect.lr_y = (short)(img.size_h - 1);
+ }
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ int clipRectsCount = data.clipRectsCount;
+ int clip_ptr = OS.malloc(PhRect_t.sizeof);
+ OS.memmove(clip_ptr, clipRects, PhRect_t.sizeof);
+ for (int i = 1; i < clipRectsCount; i++) {
+ OS.PhRectUnion (clip_ptr, clipRects + (i * 4));
+ }
+ int rect_ptr = OS.malloc(PhRect_t.sizeof);
+ OS.memmove(rect_ptr, rect, PhRect_t.sizeof);
+ boolean intersect = OS.PhRectIntersect(rect_ptr, clip_ptr) != 0;
+ OS.memmove(rect, rect_ptr, PhRect_t.sizeof);
+ OS.free(rect_ptr);
+ OS.free(clip_ptr);
+ if (!intersect) return new Rectangle(0, 0, 0, 0);
+ }
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle(rect.ul_x, rect.ul_y, width, height);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void getClipping (Region region) {
+ if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.PtEnter(0);
+ try {
+ if (region.handle != 0 && region.handle != Region.EMPTY_REGION) {
+ OS.PhFreeTiles(region.handle);
+ }
+ int clipRects = data.clipRects;
+ if (clipRects != 0) {
+ region.handle = OS.PhRectsToTiles(clipRects, data.clipRectsCount);
+ } else {
+ region.handle = OS.PhGetTile();
+ PhRect_t rect = new PhRect_t ();
+ int rid = data.rid;
+ int widget = data.widget;
+ Image image = data.image;
+ if (rid == OS.Ph_DEV_RID) {
+ OS.PhRegionQuery (rid, null, rect, 0, 0);
+ } else if (widget != 0) {
+ OS.PtWidgetCanvas(widget, rect);
+ } else if (image != null) {
+ PhImage_t img = new PhImage_t();
+ OS.memmove(img, image.handle, PhImage_t.sizeof);
+ rect.lr_x = (short)(img.size_w - 1);
+ rect.lr_y = (short)(img.size_h - 1);
+ }
+ OS.memmove(region.handle, rect, PhRect_t.sizeof);
+ }
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public Font getFont () {
+ return Font.photon_new(data.device, data.font);
+}
+
+public FontMetrics getFontMetrics() {
+ FontQueryInfo info = new FontQueryInfo();
+ OS.PfQueryFontInfo(data.font, info);
+ return FontMetrics.photon_new(info);
+}
+
+public Color getForeground() {
+ return Color.photon_new(data.device, data.foreground);
+}
+
+public int getLineStyle() {
+ return data.lineStyle;
+}
+
+public int getLineWidth() {
+ return data.lineWidth;
+}
+
+public boolean getXORMode() {
+ return data.xorMode;
+}
+
+public int hashCode () {
+ return handle;
+}
+
+
+void init(Drawable drawable, GCData data, int context) {
+ int prevContext;
+ Image image = data.image;
+ if (image == null) {
+ prevContext = OS.PgSetGC(context);
+ } else {
+ prevContext = OS.PmMemStart(context);
+ OS.PgSetDrawBufferSize(DrawBufferSize);
+ }
+
+ if (data.foreground == -1) data.foreground = DefaultFore;
+ OS.PgSetStrokeColor(data.foreground);
+ OS.PgSetTextColor(data.foreground);
+ if (data.background == -1) data.background = DefaultBack;
+ OS.PgSetFillColor(data.background);
+ if (data.font == null) data.font = Font.DefaultFont;
+ OS.PgSetFont(data.font);
+
+ if (image == null) {
+ OS.PgSetGC(prevContext);
+ } else {
+ image.memGC = this;
+ OS.PmMemStop(context);
+
+
+ /*
+ * Destroy the mask when it is generated from a transparent
+ * pixel since drawing on the image might change the mask.
+ */
+ if (image.transparentPixel != -1) {
+ PhImage_t phImage = new PhImage_t ();
+ OS.memmove(phImage, image.handle, PhImage_t.sizeof);
+ if (phImage.mask_bm != 0) {
+ OS.free(phImage.mask_bm);
+ phImage.mask_bm = 0;
+ phImage.mask_bpl = 0;
+ OS.memmove(image.handle, phImage, PhImage_t.sizeof);
+ }
+ }
+ }
+ this.drawable = drawable;
+ this.data = data;
+ handle = context;
+}
+
+public boolean isClipped() {
+ return data.clipRects != 0;
+}
+
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+public void setBackground (Color color) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ int backColor = color == null ? DefaultBack : color.handle;
+ OS.PgSetFillColor(backColor);
+ data.background = backColor;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setClipping (int x, int y, int width, int height) {
+ int flags = OS.PtEnter(0);
+ try {
+ int clipRects = data.clipRects;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ clipRects = OS.malloc(PhRect_t.sizeof);
+ int clipRectsCount = 1;
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x;
+ rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + width - 1);
+ rect.lr_y = (short)(y + height - 1);
+ OS.memmove(clipRects, rect, PhRect_t.sizeof);
+ int prevContext = setGC();
+ OS.PgSetMultiClip(clipRectsCount, clipRects);
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setClipping (Rectangle rect) {
+ if (rect == null) {
+ int flags = OS.PtEnter(0);
+ try {
+ int clipRects = data.clipRects;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ data.clipRects = data.clipRectsCount = 0;
+ int prevContext = setGC();
+ OS.PgSetMultiClip(0, 0);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+ } else
+ setClipping (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void setClipping (Region region) {
+ int flags = OS.PtEnter(0);
+ try {
+ int clipRects = data.clipRects;
+ int clipRectsCount = data.clipRectsCount;
+ if (clipRects != 0)
+ OS.free(clipRects);
+ if (region == null || region.handle == 0) {
+ clipRects = clipRectsCount = 0;
+ } else if (region.handle == Region.EMPTY_REGION) {
+ clipRects = OS.malloc(PhRect_t.sizeof);
+ clipRectsCount = 1;
+ } else {
+ int[] clip_rects_count = new int[1];
+ clipRects = OS.PhTilesToRects(region.handle, clip_rects_count);
+ clipRectsCount = clip_rects_count[0];
+ }
+ int prevContext = setGC();
+ OS.PgSetMultiClip(clipRectsCount, clipRects);
+ data.clipRects = clipRects;
+ data.clipRectsCount = clipRectsCount;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setFont (Font font) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ byte[] newFont = font == null ? Font.DefaultFont : font.handle;
+ OS.PgSetFont(newFont);
+ data.font = newFont;
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setForeground (Color color) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ int foreColor = color == null ? DefaultFore : color.handle;
+ data.foreground = foreColor;
+ OS.PgSetStrokeColor(foreColor);
+ OS.PgSetTextColor(foreColor);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setLineStyle(int lineStyle) {
+ byte[] dashList;
+ switch (lineStyle) {
+ case SWT.LINE_SOLID: dashList = DashList[0]; break;
+ case SWT.LINE_DASH: dashList = DashList[1]; break;
+ case SWT.LINE_DOT: dashList = DashList[2]; break;
+ case SWT.LINE_DASHDOT: dashList = DashList[3]; break;
+ case SWT.LINE_DASHDOTDOT: dashList = DashList[4]; break;
+ default:
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ return;
+ }
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ data.lineStyle = lineStyle;
+ OS.PgSetStrokeDash(dashList, dashList.length, 0x10000);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public void setLineWidth(int lineWidth) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ data.lineWidth = lineWidth;
+ OS.PgSetStrokeWidth(lineWidth);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+int setGC() {
+ if (data.image != null) return OS.PmMemStart(handle);
+ else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) return OS.PgSetGC(handle);
+ else return 0;
+}
+
+void setGCClipping() {
+ int rid = data.rid;
+ int widget = data.widget;
+ int topWidget = data.topWidget;
+ if (rid == OS.Ph_DEV_RID) OS.PgSetRegion(rid);
+ else if (widget != 0) OS.PgSetRegion(OS.PtWidgetRid(widget));
+ else if (data.image != null) return;
+
+ // NOTE: PgSetRegion resets the clipping rectangle to the full size of
+ // the region.
+ OS.PgSetMultiClip(data.clipRectsCount, data.clipRects);
+
+ if (widget == 0) return;
+
+ int child_tile = 0;
+ int widget_tile = OS.PhGetTile(); // NOTE: PhGetTile native initializes the tile
+
+ // Get the rectangle of all siblings in front of the widget
+ int temp_widget = topWidget;
+ while ((temp_widget = OS.PtWidgetBrotherInFront(temp_widget)) != 0) {
+ if (OS.PtWidgetIsRealized(temp_widget)) {
+ int tile = OS.PhGetTile();
+ if (child_tile == 0) child_tile = tile;
+ else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
+ OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
+ }
+ }
+ // Translate the siblings rectangles to the widget's coordinates
+ OS.PtWidgetCanvas(topWidget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(child_tile, widget_tile); // NOTE: widget_tile->rect.ul
+
+ // Get the rectangle of the widget's children
+ temp_widget = OS.PtWidgetChildBack(widget);
+ while (temp_widget != 0) {
+ if (OS.PtWidgetIsRealized(temp_widget)) {
+ int tile = OS.PhGetTile();
+ if (child_tile == 0) child_tile = tile;
+ else child_tile = OS.PhAddMergeTiles(tile, child_tile, null);
+ OS.PtWidgetExtent(temp_widget, tile); // NOTE: tile->rect
+ }
+ temp_widget = OS.PtWidgetBrotherInFront(temp_widget);
+ }
+
+ // Get the widget's rectangle
+ OS.PtWidgetCanvas(widget, widget_tile); // NOTE: widget_tile->rect
+ OS.PhDeTranslateTiles(widget_tile, widget_tile); // NOTE: widget_tile->rect.ul
+
+ // Clip the widget's rectangle from the child/siblings rectangle's
+ int clip_rects;
+ int[] clip_rects_count = new int[1];
+ if (child_tile != 0) {
+ int clip_tile = OS.PhClipTilings(widget_tile, child_tile, null);
+ clip_rects = OS.PhTilesToRects(clip_tile, clip_rects_count);
+ OS.PhFreeTiles(child_tile);
+ OS.PhFreeTiles(clip_tile);
+ } else {
+ clip_rects = OS.PhTilesToRects(widget_tile, clip_rects_count);
+ OS.PhFreeTiles(widget_tile);
+ }
+
+ // PgSetClipping sets the clipping to the full region when the count is zero
+ if (clip_rects_count[0] == 0) {
+ clip_rects_count[0] = 1;
+ OS.free(clip_rects);
+ clip_rects = OS.malloc(PhRect_t.sizeof);
+ }
+ OS.PgSetClipping((short)clip_rects_count[0], clip_rects);
+ OS.free(clip_rects);
+}
+
+public void setXORMode(boolean xor) {
+ int flags = OS.PtEnter(0);
+ try {
+ int prevContext = setGC();
+ data.xorMode = xor;
+ if (xor) OS.PgSetDrawMode(OS.Pg_DRAWMODE_XOR);
+ else OS.PgSetDrawMode(OS.Pg_DRAWMODE_OPAQUE);
+ unsetGC(prevContext);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+}
+
+public Point stringExtent(String string) {
+ if (string == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ PhRect_t rect = new PhRect_t();
+ int size = string.length();
+ char[] buffer = new char[size];
+ string.getChars(0, size, buffer, 0);
+
+ int flags = OS.PtEnter(0);
+ try {
+ OS.PfExtentWideText(rect, null, data.font, buffer, size * 2);
+ } finally {
+ if (flags >= 0) OS.PtLeave(flags);
+ }
+
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Point(width, height);
+}
+
+public Point textExtent(String string) {
+ return stringExtent(string);
+}
+
+void unsetGC(int prevContext) {
+ Image image = data.image;
+ if (image != null) {
+ OS.PmMemFlush(handle, image.handle);
+ OS.PmMemStop(handle);
+ } else if (data.rid == OS.Ph_DEV_RID || data.widget != 0) {
+ OS.PgSetGC(prevContext);
+// OS.PgFlush();
+ }
+}
+
+public static GC photon_new(Drawable drawable, GCData data) {
+ GC gc = new GC();
+ int context = drawable.internal_new_GC(data);
+ gc.init(drawable, data, context);
+ return gc;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
new file mode 100755
index 0000000000..f021841ba1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/GCData.java
@@ -0,0 +1,23 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+
+public final class GCData {
+ public Device device;
+ public Image image;
+ public int rid;
+ public int widget, topWidget;
+ public int foreground = -1;
+ public int background = -1;
+ public byte[] font;
+ public boolean xorMode;
+ public int lineStyle = SWT.LINE_SOLID;
+ public int lineWidth = 1;
+ public int clipRectsCount;
+ public int clipRects;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
new file mode 100755
index 0000000000..01f00d8053
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Image.java
@@ -0,0 +1,612 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import java.io.*;
+
+public final class Image implements Drawable {
+
+ /**
+ * specifies whether the receiver is a bitmap or an icon
+ * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>)
+ */
+ public int type;
+
+ /**
+ * the OS resource of the image
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this image was created
+ */
+ Device device;
+
+ /**
+ * specifies the transparent pixel
+ * (Warning: This field is platform dependent)
+ */
+ int transparentPixel = -1;
+
+ /**
+ * the GC which is drawing on the image
+ * (Warning: This field is platform dependent)
+ */
+ GC memGC;
+
+ /**
+ * specifies the default scanline padding
+ * (Warning: This field is platform dependent)
+ */
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+Image () {
+}
+
+public Image(Device device, int width, int height) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, width, height);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image(Device device, Image srcImage, int flag) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ switch (flag) {
+ case SWT.IMAGE_COPY:
+ case SWT.IMAGE_DISABLE:
+ this.type = srcImage.type;
+ int imageHandle = srcImage.handle;
+ if (imageHandle != 0) {
+ imageHandle = OS.PiDuplicateImage (imageHandle, 0);
+ if (imageHandle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhImage_t phImage = new PhImage_t();
+ if (flag == SWT.IMAGE_COPY) {
+ /*
+ * Bug in Photon - The image returned by PiDuplicateImage
+ * has the same mask_bm as the original image.
+ */
+ OS.memmove (phImage, imageHandle, PhImage_t.sizeof);
+ if (phImage.mask_bm != 0) {
+ int length = phImage.mask_bpl * phImage.size_h;
+ int ptr = OS.malloc (length);
+ OS.memmove(ptr, phImage.mask_bm, length);
+ phImage.mask_bm = ptr;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ /*
+ * Bug in Photon - The image returned by PiDuplicateImage
+ * has the same alpha as the original image.
+ */
+ if (phImage.alpha != 0) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ OS.memmove(alpha, phImage.alpha, PgAlpha_t.sizeof);
+ if (alpha.src_alpha_map_map != 0) {
+ int length = alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h;
+ int ptr = OS.malloc(length);
+ OS.memmove(ptr, alpha.src_alpha_map_map, length);
+ }
+ int ptr = OS.malloc(PgAlpha_t.sizeof);
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ phImage.alpha = ptr;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ transparentPixel = srcImage.transparentPixel;
+ } else {
+ OS.PhMakeGhostBitmap(imageHandle);
+ OS.memmove (phImage, imageHandle, PhImage_t.sizeof);
+ phImage.mask_bm = phImage.ghost_bitmap;
+ phImage.mask_bpl = phImage.ghost_bpl;
+ phImage.ghost_bitmap = 0;
+ phImage.ghost_bpl = 0;
+ phImage.alpha = 0;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ }
+ handle = imageHandle;
+ if (device.tracking) device.new_Object(this);
+ return;
+ case SWT.IMAGE_GRAY:
+ Rectangle r = srcImage.getBounds();
+ ImageData data = srcImage.getImageData();
+ PaletteData palette = data.palette;
+ ImageData newData = data;
+ if (!palette.isDirect) {
+ /* Convert the palette entries to gray. */
+ RGB [] rgbs = palette.getRGBs();
+ for (int i=0; i<rgbs.length; i++) {
+ if (data.transparentPixel != i) {
+ RGB color = rgbs [i];
+ int red = color.red;
+ int green = color.green;
+ int blue = color.blue;
+ int intensity = (red+red+green+green+green+green+green+blue) >> 3;
+ color.red = color.green = color.blue = intensity;
+ }
+ }
+ newData.palette = new PaletteData(rgbs);
+ } else {
+ /* Create a 8 bit depth image data with a gray palette. */
+ RGB[] rgbs = new RGB[256];
+ for (int i=0; i<rgbs.length; i++) {
+ rgbs[i] = new RGB(i, i, i);
+ }
+ newData = new ImageData(r.width, r.height, 8, new PaletteData(rgbs));
+ newData.maskData = data.maskData;
+ newData.maskPad = data.maskPad;
+
+ /* Convert the pixels. */
+ int[] scanline = new int[r.width];
+ 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 y=0; y<r.height; y++) {
+ int offset = y * newData.bytesPerLine;
+ data.getPixels(0, y, r.width, scanline, 0);
+ for (int x=0; x<r.width; x++) {
+ int pixel = scanline[x];
+ int red = pixel & redMask;
+ red = (redShift < 0) ? red >>> -redShift : red << redShift;
+ int green = pixel & greenMask;
+ green = (greenShift < 0) ? green >>> -greenShift : green << greenShift;
+ int blue = pixel & blueMask;
+ blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift;
+ newData.data[offset++] =
+ (byte)((red+red+green+green+green+green+green+blue) >> 3);
+ }
+ }
+ }
+ init (device, newData);
+ if (device.tracking) device.new_Object(this);
+ return;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
+public Image(Device device, Rectangle bounds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, bounds.width, bounds.height);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image(Device device, ImageData data) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, data);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image(Device device, ImageData source, ImageData mask) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 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);
+ }
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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(device, image);
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image (Device device, InputStream stream) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new ImageData(stream));
+ if (device.tracking) device.new_Object(this);
+}
+
+public Image (Device device, String filename) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new ImageData(filename));
+ if (device.tracking) device.new_Object(this);
+}
+
+public void dispose () {
+ if (handle == 0) return;
+ destroyImage(handle);
+ handle = 0;
+ memGC = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = null;
+}
+
+public boolean equals (Object object) {
+ if (object == this) return true;
+ if (!(object instanceof Image)) return false;
+ Image image = (Image) object;
+ return device == image.device && handle == image.handle;
+}
+
+public Color getBackground() {
+ if (transparentPixel == -1) return null;
+
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int color = 0;
+ if ((phImage.type & OS.Pg_IMAGE_CLASS_MASK) == OS.Pg_IMAGE_CLASS_PALETTE) {
+ int phPalette = phImage.palette;
+ if (phPalette == 0 || transparentPixel > phImage.colors) return null;
+ int[] pgColor = new int[1];
+ OS.memmove(pgColor, phPalette + (transparentPixel * 4), 4);
+ color = pgColor[0];
+ } else {
+ switch (phImage.type) {
+ case OS.Pg_IMAGE_DIRECT_888:
+ color = ((transparentPixel & 0xFF) << 16) | (transparentPixel & 0xFF00) | ((transparentPixel & 0xFF0000) >> 16);
+ break;
+ case OS.Pg_IMAGE_DIRECT_8888:
+ color = ((transparentPixel & 0xFF00) << 8) | ((transparentPixel & 0xFF0000) >> 8) | ((transparentPixel & 0xFF000000) >> 24);
+ break;
+ case OS.Pg_IMAGE_DIRECT_565:
+ color = ((transparentPixel & 0xF800) << 8) | ((transparentPixel & 0x7E0) << 5) | ((transparentPixel & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_555:
+ color = ((transparentPixel & 0x7C00) << 9) | ((transparentPixel & 0x3E0) << 6) | ((transparentPixel & 0x1F) << 3);
+ break;
+ case OS.Pg_IMAGE_DIRECT_444:
+ color = ((transparentPixel & 0xF00) << 12) | ((transparentPixel & 0xF0) << 8) | ((transparentPixel & 0xF) << 4);
+ break;
+ default:
+ return null;
+ }
+ }
+ return Color.photon_new(device, color);
+}
+
+public Rectangle getBounds() {
+ if (handle == 0) return new Rectangle(0, 0, 0, 0);
+ PhImage_t image = new PhImage_t();
+ OS.memmove(image, handle, PhImage_t.sizeof);
+ return new Rectangle(0, 0, image.size_w, image.size_h);
+}
+
+public ImageData getImageData() {
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int depth = 0;
+ PaletteData palette = null;
+ switch (phImage.type) {
+ case OS.Pg_IMAGE_DIRECT_555:
+ depth = 16;
+ palette = new PaletteData(0x7C00,0x3E0,0x1F);
+ break;
+ case OS.Pg_IMAGE_DIRECT_565:
+ depth = 16;
+ palette = new PaletteData(0xF800,0x7E0,0x1F);
+ break;
+ case OS.Pg_IMAGE_DIRECT_444:
+ depth = 16;
+ palette = new PaletteData(0xF00,0xF0,0xF);
+ break;
+ case OS.Pg_IMAGE_DIRECT_888:
+ depth = 24;
+ palette = new PaletteData(0xFF,0xFF00,0xFF0000);
+ break;
+ case OS.Pg_IMAGE_DIRECT_8888:
+ depth = 32;
+ palette = new PaletteData(0xFF00,0xFF0000,0xFF000000);
+ break;
+ case -1:
+ depth = 1;
+ palette = new PaletteData(new RGB[] {new RGB(0,0,0), new RGB(255,255,255)});
+ break;
+ case OS.Pg_IMAGE_PALETTE_NIBBLE:
+ case OS.Pg_IMAGE_PALETTE_BYTE:
+ depth = phImage.type == OS.Pg_IMAGE_PALETTE_BYTE ? 8 : 4;
+ RGB[] rgbs = new RGB[phImage.colors];
+ int[] colors = new int[phImage.colors];
+ OS.memmove(colors, phImage.palette, colors.length * 4);
+ for (int i = 0; i < rgbs.length; i++) {
+ int rgb = colors[i];
+ rgbs[i] = new RGB((rgb & 0xFF0000) >> 16, (rgb & 0xFF00) >> 8, rgb & 0xFF);
+ }
+ palette = new PaletteData(rgbs);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+
+ int calcBpl, scanLinePad, bpl = phImage.bpl;
+ int width = phImage.size_w, height = phImage.size_h;
+ int dataBytesPerLine = (width * depth + 7) / 8;
+ for (scanLinePad = 1; scanLinePad < 128; scanLinePad++) {
+ calcBpl = (dataBytesPerLine + (scanLinePad - 1)) / scanLinePad * scanLinePad;
+ if (bpl == calcBpl) break;
+ }
+ byte[] data = new byte[height * bpl];
+ OS.memmove(data, phImage.image, data.length);
+
+ ImageData imageData = new ImageData(width, height, depth, palette, scanLinePad, data);
+
+ if (transparentPixel != -1) {
+ imageData.transparentPixel = transparentPixel;
+ } else if (phImage.mask_bm != 0) {
+ imageData.maskData = new byte[height * phImage.mask_bpl];
+ OS.memmove(imageData.maskData, phImage.mask_bm, imageData.maskData.length);
+ imageData.maskPad = 4;
+ } else if (phImage.alpha != 0) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ OS.memmove(alpha, phImage.alpha, PgAlpha_t.sizeof);
+ imageData.alpha = alpha.src_global_alpha;
+ if ((alpha.alpha_op & OS.Pg_ALPHA_OP_SRC_MAP) != 0 && alpha.src_alpha_map_map != 0) {
+ int length = alpha.src_alpha_map_dim_w * alpha.src_alpha_map_dim_h;
+ imageData.alphaData = new byte[length];
+ OS.memmove(imageData.alphaData, alpha.src_alpha_map_map, length);
+ }
+ }
+
+ return imageData;
+}
+
+public int hashCode () {
+ return handle;
+}
+
+void init(Device device, int width, int height) {
+ if (width <= 0 | height <= 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.device = device;
+ this.type = SWT.BITMAP;
+
+ handle = OS.PhCreateImage(null, (short)width, (short)height, OS.Pg_IMAGE_DIRECT_888, 0, 0, 0);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+void init(Device device, ImageData i) {
+ if (i == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+
+ /* Photon does not support 1 & 2-bit images. Convert to 4-bit image. */
+ if (i.depth == 1 || i.depth == 2) {
+ ImageData img = new ImageData(i.width, i.height, 4, i.palette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, ImageData.MSB_FIRST, 0, 0, i.width, i.height, null, null, null, -1, null, 0,
+ img.data, img.depth, img.bytesPerLine, ImageData.MSB_FIRST, 0, 0, img.width, img.height, null, null, null,
+ false, false);
+ img.transparentPixel = i.transparentPixel;
+ img.maskPad = i.maskPad;
+ img.maskData = i.maskData;
+ img.alpha = i.alpha;
+ img.alphaData = i.alphaData;
+ i = img;
+ }
+
+ int type = 0;
+ int[] phPalette = null;
+ if (!i.palette.isDirect) {
+ switch (i.depth) {
+ case 4: type = OS.Pg_IMAGE_PALETTE_NIBBLE; break;
+ case 8: type = OS.Pg_IMAGE_PALETTE_BYTE; break;
+ default: SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ RGB[] rgbs = i.palette.getRGBs();
+ phPalette = new int[rgbs.length];
+ for (int j=0; j<rgbs.length; j++) {
+ RGB rgb = rgbs[j];
+ phPalette[j] = ((rgb.red & 0xFF) << 16) | ((rgb.green & 0xFF) << 8) | (rgb.blue & 0xFF);
+ }
+ } else {
+ PaletteData newPalette = null;
+ PaletteData palette = i.palette;
+ int redMask = palette.redMask;
+ int greenMask = palette.greenMask;
+ int blueMask = palette.blueMask;
+ int order = ImageData.MSB_FIRST;
+ switch (i.depth) {
+ case 16:
+ order = ImageData.LSB_FIRST;
+ if (redMask == 0x7C00 && greenMask == 0x3E0 && blueMask == 0x1F) {
+ type = OS.Pg_IMAGE_DIRECT_555;
+ } else if (redMask == 0xF800 && greenMask == 0x7E0 && blueMask == 0x1F) {
+ type = OS.Pg_IMAGE_DIRECT_565;
+ } else if (redMask == 0xF00 && greenMask == 0xF0 && blueMask == 0xF) {
+ type = OS.Pg_IMAGE_DIRECT_444;
+ } else {
+ type = OS.Pg_IMAGE_DIRECT_565;
+ newPalette = new PaletteData(0xF800, 0x7E0, 0x1F);
+ }
+ break;
+ case 24:
+ if (redMask == 0xFF && greenMask == 0xFF00 && blueMask == 0xFF0000) {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ } else {
+ type = OS.Pg_IMAGE_DIRECT_888;
+ newPalette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ }
+ break;
+ case 32:
+ if (redMask == 0xFF00 && greenMask == 0xFF0000 && blueMask == 0xFF000000) {
+ type = OS.Pg_IMAGE_DIRECT_8888;
+ } else {
+ type = OS.Pg_IMAGE_DIRECT_8888;
+ newPalette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ }
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ if (newPalette != null) {
+ ImageData img = new ImageData(i.width, i.height, i.depth, newPalette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, order, 0, 0, i.width, i.height, redMask, greenMask, blueMask, -1, null, 0,
+ img.data, img.depth, img.bytesPerLine, order, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,
+ false, false);
+ if (i.transparentPixel != -1) {
+ img.transparentPixel = newPalette.getPixel(palette.getRGB(i.transparentPixel));
+ }
+ img.maskPad = i.maskPad;
+ img.maskData = i.maskData;
+ img.alpha = i.alpha;
+ img.alphaData = i.alphaData;
+ i = img;
+ }
+ }
+ int handle = OS.malloc(PhImage_t.sizeof);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ PhImage_t phImage = new PhImage_t();
+ phImage.type = type;
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ int size = i.data.length;
+ int ptr = OS.malloc(size);
+ if (ptr == 0) {
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, i.data, size);
+ phImage.image = ptr;
+ phImage.size_w = (short)i.width;
+ phImage.size_h = (short)i.height;
+ phImage.bpl = i.bytesPerLine;
+ if (phPalette != null) {
+ size = phPalette.length * 4;
+ ptr = OS.malloc(size);
+ if (ptr == 0) {
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, phPalette, size);
+ phImage.palette = ptr;
+ phImage.colors = phPalette.length;
+ }
+ if (i.getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ this.type = SWT.ICON;
+ int maskBpl = (i.width * 1 + 7) / 8;
+ maskBpl = (maskBpl + (i.maskPad - 1)) / i.maskPad * i.maskPad;
+ size = maskBpl * i.height;
+ ptr = OS.malloc(size);
+ if (ptr == 0) {
+ if (phImage.palette != 0) OS.free(phImage.palette);
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, i.maskData, size);
+ phImage.mask_bm = ptr;
+ phImage.mask_bpl = maskBpl;
+ } else {
+ this.type = SWT.BITMAP;
+ if (i.transparentPixel != -1) {
+ /*
+ * The PhImage_t field transparent can not used to store the
+ * transparent pixel because it is overwritten when a GC is
+ * created on the image.
+ */
+ transparentPixel = i.transparentPixel;
+ } else if (i.alpha != -1 || i.alphaData != null) {
+ PgAlpha_t alpha = new PgAlpha_t();
+ alpha.alpha_op = i.alpha != -1 ? OS.Pg_ALPHA_OP_SRC_GLOBAL : OS.Pg_ALPHA_OP_SRC_MAP;
+ alpha.alpha_op |= OS.Pg_BLEND_SRC_SRC_ALPHA | OS.Pg_BLEND_DST_ONE_MINUS_SRC_ALPHA;
+ alpha.src_global_alpha = (byte)i.alpha;
+ if (i.alpha == -1 && i.alphaData != null) {
+ ptr = OS.malloc(i.alphaData.length);
+ if (ptr == 0) {
+ if (phImage.palette != 0) OS.free(phImage.palette);
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, i.alphaData, i.alphaData.length);
+ alpha.src_alpha_map_dim_w = (short)i.width;
+ alpha.src_alpha_map_dim_h = (short)i.height;
+ alpha.src_alpha_map_map = ptr;
+ }
+ ptr = OS.malloc(PgAlpha_t.sizeof);
+ if (ptr == 0) {
+ if (alpha.src_alpha_map_map != 0) OS.free(alpha.src_alpha_map_map);
+ if (phImage.palette != 0) OS.free(phImage.palette);
+ OS.free(phImage.image);
+ OS.free(handle);
+ SWT.error(SWT.ERROR_NO_HANDLES);
+ }
+ OS.memmove(ptr, alpha, PgAlpha_t.sizeof);
+ phImage.alpha = ptr;
+ }
+ }
+ OS.memmove(handle, phImage, PhImage_t.sizeof);
+ this.handle = handle;
+}
+
+public int internal_new_GC (GCData data) {
+ /*
+ * Create a new GC that can draw into the image.
+ * Only supported for bitmaps.
+ */
+ if (type != SWT.BITMAP || memGC != null) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ PhDim_t dim = new PhDim_t();
+ dim.w = phImage.size_w;
+ dim.h = phImage.size_h;
+ PhPoint_t trans = new PhPoint_t();
+ int pmMC = OS.PmMemCreateMC(handle, dim, trans);
+ if (pmMC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ data.device = device;
+ data.image = this;
+ return pmMC;
+}
+
+public void internal_dispose_GC (int pmMC, GCData data) {
+ OS.PmMemReleaseMC(pmMC);
+}
+
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+public void setBackground(Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (transparentPixel == -1) return;
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, handle, PhImage_t.sizeof);
+ int phPalette = phImage.palette;
+ if (phPalette == 0 || transparentPixel > phImage.colors) return;
+ int[] pgColor = new int[]{ color.handle };
+ OS.memmove(phPalette + (transparentPixel * 4), pgColor, 4);
+}
+
+static void destroyImage(int image) {
+ if (image == 0) return;
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove(phImage, image, PhImage_t.sizeof);
+ phImage.flags = OS.Ph_RELEASE_IMAGE_ALL;
+ OS.memmove(image, phImage, PhImage_t.sizeof);
+ OS.PhReleaseImage(image);
+ OS.free(image);
+}
+
+public static Image photon_new(Device device, int type, int handle) {
+ if (device == null) device = Device.getDevice();
+ Image image = new Image();
+ image.type = type;
+ image.handle = handle;
+ image.device = device;
+ return image;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
new file mode 100755
index 0000000000..2b058dfc7c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/graphics/Region.java
@@ -0,0 +1,153 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+
+public final class Region {
+
+ /**
+ * the OS resource for the region
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ static int EMPTY_REGION = -1;
+
+public Region () {
+ handle = EMPTY_REGION;
+}
+Region(int handle) {
+ this.handle = handle;
+}
+
+
+public void add (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle == 0) return;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ tile.rect_ul_x = (short)rect.x;
+ tile.rect_ul_y = (short)rect.y;
+ tile.rect_lr_x = (short)(rect.x + rect.width - 1);
+ tile.rect_lr_y = (short)(rect.y + rect.height - 1);
+ OS.memmove(tile_ptr, tile, PhTile_t.sizeof);
+ if (handle == EMPTY_REGION) handle = tile_ptr;
+ else handle = OS.PhAddMergeTiles (handle, tile_ptr, null);
+}
+
+public void add (Region region) {
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (handle == 0) return;
+ if (region.handle == 0 || region.handle == EMPTY_REGION) return;
+ int copy = OS.PhCopyTiles(region.handle);
+ if (handle == EMPTY_REGION) handle = copy;
+ else handle = OS.PhAddMergeTiles (handle, copy, null);
+}
+
+public boolean contains (int x, int y) {
+ if (handle == 0 || handle == EMPTY_REGION) return false;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ tile.rect_ul_x = tile.rect_lr_x = (short)x;
+ tile.rect_ul_y = tile.rect_lr_y = (short)y;
+ OS.memmove(tile_ptr, tile, PhTile_t.sizeof);
+ int intersection = OS.PhIntersectTilings (tile_ptr, handle, null);
+ boolean result = intersection != 0;
+ OS.PhFreeTiles(tile_ptr);
+ OS.PhFreeTiles(intersection);
+ return result;
+}
+
+public boolean contains (Point pt) {
+ if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return contains(pt.x, pt.y);
+}
+
+public void dispose () {
+ if (handle == 0) return;
+ if (handle != EMPTY_REGION) OS.PhFreeTiles (handle);
+ handle = 0;
+}
+
+public boolean equals (Object object) {
+ if (this == object) return true;
+ if (!(object instanceof Region)) return false;
+ int rgn = ((Region)object).handle;
+ return handle == rgn;
+}
+
+public Rectangle getBounds() {
+ if (handle == 0 || handle == EMPTY_REGION) return new Rectangle(0, 0, 0, 0);
+ PhTile_t tile = new PhTile_t();
+ int temp_tile;
+ int rect_ptr = OS.malloc(PhRect_t.sizeof);
+ OS.memmove(rect_ptr, handle, PhRect_t.sizeof);
+ OS.memmove(tile, handle, PhTile_t.sizeof);
+ while ((temp_tile = tile.next) != 0) {
+ OS.PhRectUnion (rect_ptr, temp_tile);
+ OS.memmove(tile, temp_tile, PhTile_t.sizeof);
+ }
+ PhRect_t rect = new PhRect_t();
+ OS.memmove(rect, rect_ptr, PhRect_t.sizeof);
+ OS.free(rect_ptr);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle(rect.ul_x, rect.ul_y, width, height);
+}
+
+public int hashCode () {
+ return handle;
+}
+
+public boolean intersects (int x, int y, int width, int height) {
+ if (handle == 0 || handle == EMPTY_REGION) return false;
+ int tile_ptr = OS.PhGetTile();
+ PhTile_t tile = new PhTile_t();
+ tile.rect_ul_x = (short)x;
+ tile.rect_ul_y = (short)y;
+ tile.rect_lr_x = (short)(x + width - 1);
+ tile.rect_lr_y = (short)(y + height - 1);
+ OS.memmove(tile_ptr, tile, PhTile_t.sizeof);
+ int intersection = OS.PhIntersectTilings (tile_ptr, handle, null);
+ boolean result = intersection != 0;
+ OS.PhFreeTiles(tile_ptr);
+ OS.PhFreeTiles(intersection);
+ return result;
+}
+
+public boolean intersects (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return intersects(rect.x, rect.y, rect.width, rect.height);
+}
+
+public boolean isDisposed() {
+ return handle == 0;
+}
+
+public boolean isEmpty () {
+ return getBounds().isEmpty();
+
+}
+
+public static Region photon_new(int handle) {
+ return new Region(handle);
+}
+/*
+public static void printTile(int tile_ptr, String msg) {
+ if (tile_ptr == 0) return;
+ PhTile_t tile = new PhTile_t();
+ int temp_tile = tile_ptr;
+ int count = 0;
+ do {
+ OS.memmove(tile, temp_tile, PhTile_t.sizeof);
+ System.out.println(msg + "-" + count++ + " address=" + temp_tile + " x1=" + tile.rect_ul_x + " y1=" + tile.rect_ul_y + " x2=" + tile.rect_lr_x + " y2=" + tile.rect_lr_y);
+ temp_tile = tile.next;
+ } while (temp_tile != 0);
+}
+*/
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
new file mode 100755
index 0000000000..682f69081f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/Converter.java
@@ -0,0 +1,71 @@
+package org.eclipse.swt.internal;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public final class Converter {
+ public static final byte [] NullByteArray = new byte [1];
+ public static final char [] NullCharArray = new char [1];
+ public static final byte [] EmptyByteArray = new byte [0];
+ public static final char [] EmptyCharArray = new char [0];
+public static String defaultCodePage () {
+ /*
+ | ptr cp |
+ DefaultCodePage == nil ifFalse: [^DefaultCodePage].
+ cp := ''. "$NON-NLS$"
+ (ptr := OSStringZ address: (NlLanginfo callWith: 49)) isNull
+ ifFalse: [cp := String copyFromOSMemory: ptr].
+ cp isEmpty ifFalse: [
+ IsSunOS ifTrue: [
+ (cp size > 3 and: [(cp copyFrom: 1 to: 3) = 'ISO'])
+ ifTrue: [cp := cp copyFrom: 4 to: cp size]].
+ ^DefaultCodePage := cp].
+ IsAIX ifTrue: [^DefaultCodePage := 'ISO8859-1'].
+ IsSunOS ifTrue: [^DefaultCodePage := '8859-1'].
+ ^DefaultCodePage := 'iso8859_1'
+ */
+ return null;
+}
+static boolean is7BitAscii (byte [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if ((buffer [i] & 0xFF) > 0x7F) return false;
+ }
+ return true;
+}
+static boolean is7BitAscii (char [] buffer) {
+ for (int i=0; i<buffer.length; i++) {
+ if (buffer [i] > 0x7F) return false;
+ }
+ return true;
+}
+public static char [] mbcsToWcs (String codePage, byte [] buffer) {
+ //SLOW AND BOGUS
+ return new String (buffer).toCharArray ();
+}
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, String string) {
+ return wcsToMbcs (codePage, string, false);
+}
+public static byte [] wcsToMbcs (String codePage, String string, boolean terminate) {
+ //SLOW AND BOGUS
+ int count = string.length ();
+ if (terminate) count++;
+ char [] buffer = new char [count];
+ string.getChars (0, string.length (), buffer, 0);
+ return wcsToMbcs (codePage, buffer, false);
+}
+/* TEMPORARY CODE */
+public static byte [] wcsToMbcs (String codePage, char [] buffer) {
+ return wcsToMbcs (codePage, buffer, false);
+}
+public static byte [] wcsToMbcs (String codePage, char [] buffer, boolean terminate) {
+ //SLOW AND BOGUS
+ if (!terminate) return new String (buffer).getBytes ();
+ byte [] buffer1 = new String (buffer).getBytes ();
+ byte [] buffer2 = new byte [buffer1.length + 1];
+ System.arraycopy (buffer1, 0, buffer2, 0, buffer1.length);
+ return buffer2;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
new file mode 100755
index 0000000000..adcae07101
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontDetails.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class FontDetails {
+ public byte[] desc = new byte[OS.MAX_DESC_LENGTH];
+ public byte[] stem = new byte[OS.MAX_FONT_TAG];
+ public short losize;
+ public short hisize;
+ public short flags;
+ public static final int sizeof = 128;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
new file mode 100755
index 0000000000..af0556407a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/FontQueryInfo.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class FontQueryInfo {
+ public byte[] font = new byte[OS.MAX_FONT_TAG];
+ public byte[] desc = new byte[OS.MAX_DESC_LENGTH];
+ public short size;
+ public short style;
+ public short ascender;
+ public short descender;
+ public short width;
+ public int lochar;
+ public int hichar;
+ public static final int sizeof = 140;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
new file mode 100755
index 0000000000..0ecedcc7b1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/OS.java
@@ -0,0 +1,2893 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+
+public class OS {
+
+ /* Load the SWT library. */
+ static {
+ Callback.loadLibrary ();
+ }
+
+/**** BEGIN MANUALLY ADDED/FIXED ***/
+ public static final int Pt_SET_DRAW_F = 1507348;
+ public static final int Pt_ARG_ORIENTATION = ( 21 * 1000 + 5 );
+ public static final int Pt_ARG_SCROLL_POSITION = ( 21 * 1000 + 4 );
+ public static final int Pt_ARG_MAXIMUM = ( 21 * 1000 + 3 );
+ public static final int Pt_ARG_MINIMUM = ( 21 * 1000 + 2 );
+ public static final int Pt_ARG_WIDTH = ( 1 * 1000 + 23 );
+ public static final int Pt_ARG_HEIGHT = ( 1 * 1000 + 24 );
+// public static final int Pt_ARG_STYLE = ( 2 * 1000 + 18 );
+// public static final int Ph_USE_TRANSPARENCY = 0x80;
+ public static final int Ph_RELEASE_IMAGE_ALL = 0x1F;
+
+ public static final int Pt_TOP_ETCH = 0x00000001;
+ public static final int Pt_BOTTOM_ETCH = 0x00000002;
+ public static final int Pt_LEFT_ETCH = 0x00000004;
+ public static final int Pt_RIGHT_ETCH = 0x00000008;
+ public static final int Pt_TOP_OUTLINE = 0x00000010;
+ public static final int Pt_BOTTOM_OUTLINE = 0x00000020;
+ public static final int Pt_LEFT_OUTLINE = 0x00000040;
+ public static final int Pt_RIGHT_OUTLINE = 0x00000080;
+// public static final int Pt_TOP_BEVEL = 0x00000100;
+// public static final int Pt_BOTTOM_BEVEL = 0x00000200;
+// public static final int Pt_LEFT_BEVEL = 0x00000400;
+// public static final int Pt_RIGHT_BEVEL = 0x00000800;
+ public static final int Pt_TOP_INLINE = 0x00001000;
+ public static final int Pt_BOTTOM_INLINE = 0x00002000;
+ public static final int Pt_LEFT_INLINE = 0x00004000;
+ public static final int Pt_RIGHT_INLINE = 0x00008000;
+// public static final int Pt_FLAT_FILL = 0x00010000;
+// public static final int Pt_FULL_BORDERS = 0x00020000;
+// public static final int Pt_FULL_BEVELS = 0x00020000;
+ public static final int Pt_HORIZONTAL_GRADIENT = 0x00040000;
+// public static final int Pt_REVERSE_GRADIENT = 0x00080000;
+ public static final int Pt_STATIC_GRADIENT = 0x00100000;
+// public static final int Pt_STATIC_BORDERS = 0x00200000;
+// public static final int Pt_STATIC_BEVELS = 0x00200000;
+// public static final int Pt_STATIC_BORDER_COLORS = 0x00400000;
+// public static final int Pt_STATIC_BEVEL_COLORS = 0x00400000;
+// public static final int Pt_BASIC_ARMED = 0x80000000;
+// public static final int Pt_BASIC_RO_FLAGS = 0x80000000;
+// public static final int Pt_TOP_LEFT_ETCH = (Pt_TOP_ETCH | Pt_LEFT_ETCH);
+// public static final int Pt_BOTTOM_RIGHT_ETCH = (Pt_BOTTOM_ETCH | Pt_RIGHT_ETCH);
+// public static final int Pt_ALL_ETCHED = (Pt_TOP_LEFT_ETCH | Pt_BOTTOM_RIGHT_ETCH);
+ public static final int Pt_ALL_ETCHES = (Pt_TOP_ETCH | Pt_BOTTOM_ETCH | Pt_LEFT_ETCH | Pt_RIGHT_ETCH );
+// public static final int Pt_TOP_LEFT_OUTLINE = (Pt_TOP_OUTLINE | Pt_LEFT_OUTLINE);
+// public static final int Pt_BOTTOM_RIGHT_OUTLINE = (Pt_BOTTOM_OUTLINE | Pt_RIGHT_OUTLINE );
+ public static final int Pt_ALL_OUTLINES = (Pt_TOP_OUTLINE | Pt_BOTTOM_OUTLINE | Pt_LEFT_OUTLINE | Pt_RIGHT_OUTLINE);
+// public static final int Pt_TOP_LEFT_INLINE = (Pt_TOP_INLINE | Pt_LEFT_INLINE);
+// public static final int Pt_BOTTOM_RIGHT_INLINE = (Pt_BOTTOM_INLINE | Pt_RIGHT_INLINE );
+ public static final int Pt_ALL_INLINES = (Pt_TOP_INLINE | Pt_BOTTOM_INLINE | Pt_LEFT_INLINE | Pt_RIGHT_INLINE);
+// public static final int Pt_TOP_LEFT_BEVEL = (Pt_TOP_BEVEL | Pt_LEFT_BEVEL);
+// public static final int Pt_BOTTOM_RIGHT_BEVEL = (Pt_BOTTOM_BEVEL | Pt_RIGHT_BEVEL );
+// public static final int Pt_ALL_BEVELS = (Pt_TOP_BEVEL | Pt_BOTTOM_BEVEL | Pt_LEFT_BEVEL | Pt_RIGHT_BEVEL);
+// public static final int Pt_ALL_TOP = (Pt_TOP_ETCH | Pt_TOP_OUTLINE | Pt_TOP_BEVEL | Pt_TOP_INLINE);
+// public static final int Pt_ALL_BOTTOM = (Pt_BOTTOM_ETCH | Pt_BOTTOM_OUTLINE | Pt_BOTTOM_BEVEL | Pt_BOTTOM_INLINE);
+// public static final int Pt_ALL_LEFT = (Pt_LEFT_ETCH | Pt_LEFT_OUTLINE | Pt_LEFT_BEVEL | Pt_LEFT_INLINE);
+// public static final int Pt_ALL_RIGHT = (Pt_RIGHT_ETCH | Pt_RIGHT_OUTLINE | Pt_RIGHT_BEVEL | Pt_RIGHT_INLINE);
+// public static final int Pt_ALL = (Pt_ALL_TOP | Pt_ALL_BOTTOM | Pt_ALL_LEFT | Pt_ALL_RIGHT);
+
+ public static final int NAME_MAX = 255;
+ public static final int PATH_MAX = 1024;
+ public static final int Pt_FSR_NO_FCHECK = 0x000100;
+// public static final int Pt_FSR_NO_FSPEC = 0x000200;
+// public static final int Pt_FSR_NO_UP_BUTTON = 0x000400;
+// public static final int Pt_FSR_NO_NEW = 0x000800;
+// public static final int Pt_FSR_NO_NEW_BUTTON = 0x001000;
+ public static final int Pt_FSR_NO_SELECT_FILES = 0x002000;
+ public static final int Pt_FSR_SELECT_DIRS = 0x004000;
+// public static final int Pt_FSR_CREATE_PATH = 0x008000;
+// public static final int Pt_FSR_NO_CONFIRM_CREATE_PATH = 0x010000;
+// public static final int Pt_FSR_NO_DELETE = 0x020000;
+// public static final int Pt_FSR_NO_CONFIRM_DELETE = 0x040000;
+// public static final int Pt_FSR_RECURSIVE_DELETE = 0x080000;
+// public static final int Pt_FSR_CONFIRM_EXISTING = 0x100000;
+// public static final int Pt_FSR_CENTER = 0x200000;
+
+ public static final int Pt_ARG_BEVEL_WIDTH = ( 1 * 1000 + 1 );
+ public static final int Pt_ARG_INLINE_COLOR = ( 2 * 1000 + 23 );
+ public static final int Pt_ARG_OUTLINE_COLOR = ( 2 * 1000 + 22 );
+ public static final int Pt_ARG_LIGHT_FILL_COLOR = ( 2 * 1000 + 24 );
+ public static final int Pt_ARG_DARK_FILL_COLOR = ( 2 * 1000 + 25 );
+ public static final int Pt_ARG_DARK_BEVEL_COLOR = ( 2 * 1000 + 6 );
+ public static final int Pt_ARG_LIGHT_BEVEL_COLOR = ( 2 * 1000 + 0 );
+ public static final int Pt_ARG_BEVEL_COLOR = ( 2 * 1000 + 21 );
+
+ public static final int Pt_INDEX_COLOR = 0x2000000;
+
+// public static final int Pg_ALPHA_VALID = 0x80000000;
+// public static final int Pg_ALPHA_OP_TEST = 0x00010000;
+// public static final int Pg_ALPHA_OP_DEST_GLOBAL = 0x00020000;
+ public static final int Pg_ALPHA_OP_SRC_GLOBAL = 0x00040000;
+ public static final int Pg_ALPHA_OP_SRC_MAP = 0x00080000;
+// public static final int Pg_ALPHA_OP_SRC_GRADIENT = 0x00100000;
+// public static final int Pg_BLEND_SRC_ZERO = 0x0000; // (0,0,0,0)
+// public static final int Pg_BLEND_SRC_ONE = 0x0100; // (1,1,1,1)
+// public static final int Pg_BLEND_SRC_DST_COLOR = 0x0200; // (Ad,Rd,Gd,Bd)
+// public static final int Pg_BLEND_SRC_ONE_MINUS_DST_ALPHA = 0x0300; // (1,1,1,1)-(Ad,Rd,Gd,Bd)
+ public static final int Pg_BLEND_SRC_SRC_ALPHA = 0x0400; // (As,As,As,As)
+// public static final int Pg_BLEND_SRC_ONE_MINUS_SRC_ALPHA = 0x0500; // (1,1,1,1)-(As,As,As,As)
+// public static final int Pg_BLEND_SRC_DST_ALPHA = 0x0600; // (Ad,Ad,Ad,Ad)
+// public static final int Pg_BLEND_ONE_MINUS_DST_ALPHA = 0x0700; // (1,1,1,1)-(Ad,Ad,Ad,Ad)
+// public static final int Pg_BLEND_DST_ZERO = 0x00; // (0,0,0,0)
+// public static final int Pg_BLEND_DST_ONE = 0x01; // (1,1,1,1)
+// public static final int Pg_BLEND_DST_SRC_COLOR = 0x02; // (As,Rs,Gs,Bs)
+// public static final int Pg_BLEND_DST_ONE_MINUS_SRC = 0x03; // (1,1,1,1)-(As,Rs,Gs,Bs)
+// public static final int Pg_BLEND_DST_SRC_ALPHA = 0x04; // (As,As,As,As)
+ public static final int Pg_BLEND_DST_ONE_MINUS_SRC_ALPHA = 0x05; // (1,1,1,1)-(As,As,As,As)
+// public static final int Pg_BLEND_DST_DST_ALPHA = 0x06; // (Ad,Ad,Ad,Ad)
+// public static final int Pg_BLEND_DST_ONE_MINUS_DST_ALPHA = 0x07; // (1,1,1,1)-(Ad,Ad,Ad,Ad)
+
+// public static final int Pt_ARG_PG_FLAGS = 64 * 1000 + 0;
+// public static final int Pt_ARG_PG_CURRENT = 64 * 1000 + 1;
+ public static final int Pt_ARG_PG_PANEL_TITLES = 64 * 1000 + 2;
+// public static final int Pt_ARG_PG_CONTAINERS = 64 * 1000 + 3;
+// public static final int Pt_ARG_PG_SELECTION_MODE = 64 * 1000 + 4;
+ public static final int Pt_ARG_PG_CURRENT_INDEX = 64 * 1000 + 5;
+// public static final int Pt_ARG_PG_OVERLAP_THRESHOLD = 64 * 1000 + 6;
+// public static final int Pt_ARG_PG_DEFAULT_TAB_COLOR = 64 * 1000 + 7;
+ public static final int Pt_CB_PG_PANEL_SWITCHING = 64 * 1000 + 10;
+ public static final int Pt_PG_INVALID = 65535;
+
+ public static final int Pt_ARG_TITLE = 10 * 1000 + 7;
+ public static final int Pt_ARG_TITLE_FONT = 10 * 1000 + 8;
+ public static final int Pt_SHOW_TITLE = 0x00000100;
+ public static final int Pt_ETCH_TITLE_AREA = 0x00000200;
+ public static final int Pt_GRADIENT_TITLE_AREA = 0x00000400;
+
+ public static final int PF_STYLE_BOLD = 0x1;
+ public static final int PF_STYLE_ITALIC = 0x2;
+
+ public static final int PFFONT_DONT_SHOW_LEGACY = 0x40;
+
+// public static final int Pt_ARG_CS_COLOR = ( 150 * 1000 + 1 );
+// public static final int Pt_ARG_CS_COLOR_MODELS = ( 150 * 1000 + 2 );
+// public static final int Pt_ARG_CS_PALETTE = ( 150 * 1000 + 4 );
+
+ public static final int Ph_WM_RENDER_COLLAPSE = 0x00004000;
+
+ public static final int Pt_ARG_LABEL_IMAGE = ( 3 * 1000 + 1 );
+
+ public static final int Pt_ARG_TOOLBAR_FLAGS = ( 61 * 1000 + 0 );
+ public static final int Pt_ARG_TOOLBAR_SPACING = ( 61 * 1000 + 1 );
+ public static final int Pt_TOOLBAR_ITEM_SEPARATORS = 0x0020;
+
+ public static final int Pt_COLORSELECT_MODAL = 0x4;
+ public static final int Pt_COLORSELECT_ACCEPT = 0x8000;
+
+ public static final int Pt_PROCESS = 0;
+// public static final int Pt_IGNORE = 1;
+// public static final int Pt_CONSUME = 2;
+ public static final int Pt_CB_FILTER = ( 1 * 1000 + 26 );
+
+/*** END MANUALLY ADDED/FIXED ***/
+
+//public static final int Aw_ARG_ONOFF_STATE = ( 5 * 1000 + 1 );
+//public static final int Aw_CB_ONOFF_NEW_VALUE = ( 5 * 1000 + 0 );
+//public static final int DEV_CTRL_DEVICE_LAYER = 1;
+//public static final int DEV_CTRL_INPUT = 1;
+//public static final int DEV_CTRL_LAYER_MASK = 0xf0000000;
+//public static final int DEV_CTRL_OUTPUT = 2;
+//public static final int DEV_CTRL_PROTOCOL_LAYER = 2;
+//public static final int DEV_CTRL_SWITCH_MASK = 0x0f000000;
+//public static final int DEV_CTRL_TRANSLATE = 4;
+//public static final int DEV_CTRL_TYPE_MASK = 0x000000ff;
+//public static final int IsBorder = 0x00000200;
+//public static final int IsColorMode = 0x00010000;
+//public static final int IsColors = 0x04000000;
+//public static final int IsCopies = 0x00008000;
+//public static final int IsDither = 0x00400000;
+//public static final int IsDuplex = 0x00200000;
+//public static final int IsInkType = 0x01000000;
+//public static final int IsIntensity = 0x00800000;
+//public static final int IsMargins = 0x00000100;
+//public static final int IsOrientation = 0x00020000;
+//public static final int IsPageRange = 0x10000000;
+//public static final int IsPaperCollate = 0x00100000;
+//public static final int IsPaperSize = 0x00000040;
+//public static final int IsPaperSource = 0x00040000;
+//public static final int IsPaperType = 0x00080000;
+//public static final int IsPrinterDpi = 0x00000010;
+//public static final int IsScale = 0x00004000;
+//public static final int IsSrcColors = 0x02000000;
+//public static final int IsSrcDim = 0x00000001;
+//public static final int IsSrcDpi = 0x00001000;
+//public static final int IsSrcOff = 0x00000004;
+//public static final int KEY_CAP_VALID = 0x00000080;
+//public static final int KEY_DEAD = 0x40000000;
+//public static final int KEY_DEAD_FLAG = 0x80;
+//public static final int KEY_DOWN = 0x00000001;
+//public static final int KEY_MASK = 0x03ff;
+//public static final int KEY_NOSYM_FLAG = 0x40;
+//public static final int KEY_OEM_CAP = 0x80000000;
+//public static final int KEY_REPEAT = 0x00000002;
+//public static final int KEY_SCAN_VALID = 0x00000020;
+//public static final int KEY_SYM_VALID = 0x00000040;
+//public static final int KEYBOARD_CTRL_ATTR_MASK = 0x000f0000;
+//public static final int KEYBOARD_CTRL_DELAY = 0x00001000;
+//public static final int KEYBOARD_CTRL_DISPLAY = 0x00000400;
+//public static final int KEYBOARD_CTRL_DISPLAY_OFF = 0x00020000;
+//public static final int KEYBOARD_CTRL_DISPLAY_ON = 0x00010000;
+//public static final int KEYBOARD_CTRL_FILENAME = 0x00002000;
+//public static final int KEYBOARD_CTRL_LAYER = 0x00040000;
+//public static final int KEYBOARD_CTRL_LAYER_MASK = DEV_CTRL_LAYER_MASK;
+//public static final int KEYBOARD_CTRL_OFF = 0x00000200;
+//public static final int KEYBOARD_CTRL_ON = 0x00000100;
+//public static final int KEYBOARD_CTRL_RATE = 0x00000800;
+//public static final int KEYBOARD_CTRL_SWITCH_MASK = DEV_CTRL_SWITCH_MASK;
+//public static final int KEYBOARD_CTRL_TYPE_MASK = (DEV_CTRL_TYPE_MASK << 8);
+//public static final int KEYCAP = 0x0400;
+//public static final int KEYCODE_PC_KEYS = 0xF000;
+//public static final int KEYCODE_CAPS_LOCK = (KEYCODE_PC_KEYS + 0xe5);
+//public static final int KEYCODE_DELETE = (KEYCODE_PC_KEYS + 0xff);
+//public static final int KEYCODE_DOWN = (KEYCODE_PC_KEYS + 0x54);
+//public static final int KEYCODE_END = (KEYCODE_PC_KEYS + 0x57);
+//public static final int KEYCODE_ESCAPE = (KEYCODE_PC_KEYS + 0x1b);
+//public static final int KEYCODE_F1 = (KEYCODE_PC_KEYS + 0xbe);
+//public static final int KEYCODE_F10 = (KEYCODE_PC_KEYS + 0xc7);
+//public static final int KEYCODE_F11 = (KEYCODE_PC_KEYS + 0xc8);
+//public static final int KEYCODE_F12 = (KEYCODE_PC_KEYS + 0xc9);
+//public static final int KEYCODE_F2 = (KEYCODE_PC_KEYS + 0xbf);
+//public static final int KEYCODE_F3 = (KEYCODE_PC_KEYS + 0xc0);
+//public static final int KEYCODE_F4 = (KEYCODE_PC_KEYS + 0xc1);
+//public static final int KEYCODE_F5 = (KEYCODE_PC_KEYS + 0xc2);
+//public static final int KEYCODE_F6 = (KEYCODE_PC_KEYS + 0xc3);
+//public static final int KEYCODE_F7 = (KEYCODE_PC_KEYS + 0xc4);
+//public static final int KEYCODE_F8 = (KEYCODE_PC_KEYS + 0xc5);
+//public static final int KEYCODE_F9 = (KEYCODE_PC_KEYS + 0xc6);
+//public static final int KEYCODE_HOME = (KEYCODE_PC_KEYS + 0x50);
+//public static final int KEYCODE_INSERT = (KEYCODE_PC_KEYS + 0x63);
+//public static final int KEYCODE_KP_DELETE = (KEYCODE_PC_KEYS + 0xae);
+//public static final int KEYCODE_KP_DIVIDE = (KEYCODE_PC_KEYS + 0xaf);
+//public static final int KEYCODE_KP_DOWN = (KEYCODE_PC_KEYS + 0xb2);
+//public static final int KEYCODE_KP_END = (KEYCODE_PC_KEYS + 0xb1);
+//public static final int KEYCODE_KP_ENTER = (KEYCODE_PC_KEYS + 0x8d);
+//public static final int KEYCODE_KP_FIVE = (KEYCODE_PC_KEYS + 0xb5);
+//public static final int KEYCODE_KP_HOME = (KEYCODE_PC_KEYS + 0xb7);
+//public static final int KEYCODE_KP_INSERT = (KEYCODE_PC_KEYS + 0xb0);
+//public static final int KEYCODE_KP_LEFT = (KEYCODE_PC_KEYS + 0xb4);
+//public static final int KEYCODE_KP_MINUS = (KEYCODE_PC_KEYS + 0xad);
+//public static final int KEYCODE_KP_MULTIPLY = (KEYCODE_PC_KEYS + 0xaa);
+//public static final int KEYCODE_KP_PG_DOWN = (KEYCODE_PC_KEYS + 0xb3);
+//public static final int KEYCODE_KP_PG_UP = (KEYCODE_PC_KEYS + 0xb9);
+//public static final int KEYCODE_KP_PLUS = (KEYCODE_PC_KEYS + 0xab);
+//public static final int KEYCODE_KP_RIGHT = (KEYCODE_PC_KEYS + 0xb6);
+//public static final int KEYCODE_KP_UP = (KEYCODE_PC_KEYS + 0xb8);
+//public static final int KEYCODE_LEFT = (KEYCODE_PC_KEYS + 0x51);
+//public static final int KEYCODE_LEFT_ALT = (KEYCODE_PC_KEYS + 0xe9);
+//public static final int KEYCODE_LEFT_CTRL = (KEYCODE_PC_KEYS + 0xe3);
+//public static final int KEYCODE_LEFT_HYPER = (KEYCODE_PC_KEYS + 0xed);
+//public static final int KEYCODE_LEFT_SHIFT = (KEYCODE_PC_KEYS + 0xe1);
+//public static final int KEYCODE_MENU = (KEYCODE_PC_KEYS + 0x67);
+//public static final int KEYCODE_NUM_LOCK = (KEYCODE_PC_KEYS + 0x7f);
+//public static final int KEYCODE_PAUSE = (KEYCODE_PC_KEYS + 0x13);
+//public static final int KEYCODE_PG_DOWN = (KEYCODE_PC_KEYS + 0x56);
+//public static final int KEYCODE_PG_UP = (KEYCODE_PC_KEYS + 0x55);
+//public static final int KEYCODE_PRINT = (KEYCODE_PC_KEYS + 0x61);
+//public static final int KEYCODE_RETURN = (KEYCODE_PC_KEYS + 0x0d);
+//public static final int KEYCODE_RIGHT = (KEYCODE_PC_KEYS + 0x53);
+//public static final int KEYCODE_RIGHT_ALT = (KEYCODE_PC_KEYS + 0xea);
+//public static final int KEYCODE_RIGHT_CTRL = (KEYCODE_PC_KEYS + 0xe4);
+//public static final int KEYCODE_RIGHT_HYPER = (KEYCODE_PC_KEYS + 0xee);
+//public static final int KEYCODE_RIGHT_SHIFT = (KEYCODE_PC_KEYS + 0xe2);
+//public static final int KEYCODE_SCROLL_LOCK = (KEYCODE_PC_KEYS + 0x14);
+//public static final int KEYCODE_SYSREQ = (KEYCODE_PC_KEYS + 0x6a);
+//public static final int KEYCODE_TAB = (KEYCODE_PC_KEYS + 0x09);
+//public static final int KEYCODE_UP = (KEYCODE_PC_KEYS + 0x52);
+//public static final int KEYCOMPOSE_CODE = 0x0000;
+//public static final int KEYCOMPOSE_LAST = 0x8000;
+//public static final int KEYCOMPOSE_SIZE = 0x3fff;
+//public static final int KEYCOMPOSE_TABLE = 0x4000;
+//public static final int KEYGRP_MAX = 15;
+//public static final int KEYIND_CAPS_LOCK = 0x04;
+//public static final int KEYIND_NUM_LOCK = 0x02;
+//public static final int KEYIND_SCROLL_LOCK = 0x01;
+//public static final int KEYINDICATOR_MAX = 7;
+//public static final int KEYMAP_COMPOSE = 5;
+//public static final int KEYMAP_EXTENDED_MAP = 1;
+//public static final int KEYMAP_GEOMETRY = 7;
+//public static final int KEYMAP_GROUPS = 2;
+//public static final int KEYMAP_INDICATORS = 6;
+//public static final int KEYMAP_KEYS = 3;
+//public static final int KEYMAP_MAGIC = 0x2044424b;
+//public static final int KEYMAP_MODIFIERS = 4;
+//public static final int KEYMAP_NAME = 0;
+//public static final int KEYMODBIT_ALT = 2;
+//public static final int KEYMODBIT_ALT_LOCK = 10;
+//public static final int KEYMODBIT_ALTGR = 3;
+//public static final int KEYMODBIT_ALTGR_LOCK = 11;
+//public static final int KEYMODBIT_CAPS_LOCK = 16;
+//public static final int KEYMODBIT_CTRL = 1;
+//public static final int KEYMODBIT_CTRL_LOCK = 9;
+//public static final int KEYMODBIT_MASK = 0x3f;
+//public static final int KEYMODBIT_MOD6 = 5;
+//public static final int KEYMODBIT_MOD6_LOCK = 13;
+//public static final int KEYMODBIT_MOD7 = 6;
+//public static final int KEYMODBIT_MOD7_LOCK = 14;
+//public static final int KEYMODBIT_MOD8 = 7;
+//public static final int KEYMODBIT_MOD8_LOCK = 15;
+//public static final int KEYMODBIT_NUM_LOCK = 17;
+//public static final int KEYMODBIT_SCROLL_LOCK = 18;
+//public static final int KEYMODBIT_SHIFT = 0;
+//public static final int KEYMODBIT_SHIFT_LOCK = 8;
+//public static final int KEYMODBIT_SHL3 = 4;
+//public static final int KEYMODBIT_SHL3_LOCK = 12;
+//public static final int KEYMOD = 0x0800;
+//public static final int KEYMOD_ALT = (1 << KEYMODBIT_ALT);
+//public static final int KEYMOD_ALT_LOCK = (1 << KEYMODBIT_ALT_LOCK);
+//public static final int KEYMOD_ALTGR = (1 << KEYMODBIT_ALTGR);
+//public static final int KEYMOD_ALTGR_LOCK = (1 << KEYMODBIT_ALTGR_LOCK);
+//public static final int KEYMOD_AND = 0x80;
+//public static final int KEYMOD_CAPS_LOCK = (1 << KEYMODBIT_CAPS_LOCK);
+//public static final int KEYMOD_CTRL = (1 << KEYMODBIT_CTRL);
+//public static final int KEYMOD_CTRL_LOCK = (1 << KEYMODBIT_CTRL_LOCK);
+//public static final int KEYMOD_DOWN = 0x40;
+//public static final int KEYMOD_MOD6 = (1 << KEYMODBIT_MOD6);
+//public static final int KEYMOD_MOD6_LOCK = (1 << KEYMODBIT_MOD6_LOCK);
+//public static final int KEYMOD_MOD7 = (1 << KEYMODBIT_MOD7);
+//public static final int KEYMOD_MOD7_LOCK = (1 << KEYMODBIT_MOD7_LOCK);
+//public static final int KEYMOD_MOD8 = (1 << KEYMODBIT_MOD8);
+//public static final int KEYMOD_MOD8_LOCK = (1 << KEYMODBIT_MOD8_LOCK);
+//public static final int KEYMOD_NUM_LOCK = (1 << KEYMODBIT_NUM_LOCK);
+//public static final int KEYMOD_OR = 0x00;
+//public static final int KEYMOD_PRESS = 0xc0;
+//public static final int KEYMOD_RELEASE = 0x80;
+//public static final int KEYMOD_SCROLL_LOCK = (1 << KEYMODBIT_SCROLL_LOCK);
+//public static final int KEYMOD_SHIFT = (1 << KEYMODBIT_SHIFT);
+//public static final int KEYMOD_SHIFT_LOCK = (1 << KEYMODBIT_SHIFT_LOCK);
+//public static final int KEYMOD_SHL3 = (1 << KEYMODBIT_SHL3);
+//public static final int KEYMOD_SHL3_LOCK = (1 << KEYMODBIT_SHL3_LOCK);
+//public static final int KEYMOD_UP = 0x00;
+//public static final int MAX_FONT_TAG = 80;
+//public static final int NAME_MAX = 48;
+//public static final int NUMERIC_BUF = 40;
+//public static final int PaperCollateAAABBBCCC = 0x0002;
+//public static final int PaperCollateABCABCABC = 0x0001;
+//public static final int PaperCollateDefault = 0x0000;
+//public static final int PaperSourceAuto = 0x0001;
+//public static final int PaperSourceDefault = 0x0000;
+//public static final int PaperSourceEnvelope = 0x0005;
+//public static final int PaperSourceLower = 0x0003;
+//public static final int PaperSourceManual = 0x0004;
+//public static final int PaperSourceManualEnv = 0x0006;
+//public static final int PaperSourceUpper = 0x0002;
+//public static final int PaperTypeDefault = 0x0000;
+//public static final int PaperTypeDraftQuality = 0x0003;
+//public static final int PaperTypeEnvelope = 0x0005;
+//public static final int PaperTypeHighQuality = 0x0002;
+//public static final int PaperTypeNormal = 0x0001;
+//public static final int PaperTypeTransparency = 0x0004;
+//public static final int PaperTypeTShirt = 0x0006;
+//public static final int PFR_STATS = 0x02;
+//public static final int Pg_DRAW_ARC = 0x44;
+//public static final int Pg_DRAW_BEVELBOX = 0x45;
+//public static final int Pg_DRAW_BEZIER = 0x47;
+//public static final int Pg_DRAW_BITBLIT = 0x46;
+//public static final int Pg_DRAW_BITBLT = 0x46;
+//public static final int Pg_DRAW_BITBLT_CHROMA = 0x4A;
+//public static final int Pg_DRAW_BITMAP = 0x44;
+//public static final int Pg_DRAW_ELLIPSE = 0x43;
+ public static final int Pg_DRAW_FILL = 0x20;
+ public static final int Pg_DRAW_STROKE = 0x10;
+//public static final int Pg_DRAW_FILL_STROKE = (Pg_DRAW_FILL | Pg_DRAW_STROKE);
+//public static final int Pg_DRAW_GETIMAGE = 0x4F;
+//public static final int Pg_DRAW_GRADIENT = 0xD2;
+//public static final int Pg_DRAW_GRID = 0x47;
+//public static final int Pg_DRAW_IMAGE = 0x45;
+//public static final int Pg_DRAW_LINE = 0x42;
+//public static final int Pg_DRAW_POINT = 0x40;
+//public static final int Pg_DRAW_POINT_ARRAY = 0x41;
+//public static final int Pg_DRAW_POLYGON = 0x40;
+//public static final int Pg_DRAW_RECT = 0x41;
+//public static final int Pg_DRAW_RRECT = 0x42;
+//public static final int Pg_DRAW_SPAN = 0x46;
+//public static final int Pg_DRAW_STROKE_FILL = Pg_DRAW_FILL_STROKE;
+//public static final int Pg_DRAW_TEXT = 0x43;
+//public static final int Pg_DRAW_TREND = 0x48;
+//public static final int Pg_DRAW_VECTOR = 0x49;
+ public static final int Pg_ARC = (0x20 << 8);
+//public static final int Pg_ARC_CHORD = (0x00 << 8);
+ public static final int Pg_ARC_PIE = (0x10 << 8);
+//public static final int Pg_ARC_FILL = Pg_DRAW_FILL;
+//public static final int Pg_ARC_FILL_CHORD = Pg_DRAW_STROKE | Pg_ARC_CHORD;
+//public static final int Pg_ARC_FILL_PIE = Pg_DRAW_FILL | Pg_ARC_PIE;
+//public static final int Pg_ARC_STROKE = Pg_DRAW_STROKE;
+//public static final int Pg_ARC_STROKE_ARC = Pg_DRAW_STROKE | Pg_ARC;
+//public static final int Pg_ARC_STROKE_CHORD = Pg_DRAW_STROKE | Pg_ARC_CHORD;
+//public static final int Pg_ARC_STROKE_PIE = Pg_DRAW_STROKE | Pg_ARC_PIE;
+ public static final int Pg_BACK_FILL = (0x01 << 8);
+//public static final int Pg_BEVEL_ADOWN = 0xE000;
+//public static final int Pg_BEVEL_ALEFT = 0x2000;
+//public static final int Pg_BEVEL_ARIGHT = 0x6000;
+//public static final int Pg_BEVEL_ARROW = 0x2000;
+//public static final int Pg_BEVEL_AUP = 0xA000;
+//public static final int Pg_BEVEL_CLIP = 0x8000;
+//public static final int Pg_BEVEL_JOIN = 0x02;
+//public static final int Pg_BEVEL_MAX = 15;
+//public static final int Pg_BEVEL_ROUND = 0xC000;
+//public static final int Pg_BEVEL_SET = 0x1000;
+//public static final int Pg_BEVEL_SQUARE = 0x0000;
+//public static final int Pg_BEVEL_TYPE_MASK = 0xE000;
+public static final int Pg_BITMAP_BACKFILL = 0xFE;
+public static final int Pg_BITMAP_TRANSPARENT = 0xFF;
+//public static final int Pg_BUTT_CAP = 0x00;
+//public static final int Pg_BUTT_JOIN = 0x04;
+//public static final int Pg_CAH_INLINE_OFF_SIZE = 0x00000040;
+//public static final int Pg_CAH_RECORD_SIZE_MASK = 0x0000003F;
+//public static final int Pg_CAH_RELAY_TAGGED = 0x00002000;
+//public static final int Pg_CAH_SHMEM_LIMIT = 0x00000100;
+//public static final int Pg_CAH_SHMEM_NAME = 0x00000080;
+//public static final int Pg_CAH_SHMEM_OFFSET = 0x00000200;
+//public static final int Pg_CAH_SRCE_OFFSET = 0x00000800;
+//public static final int Pg_CAH_SRCE_SIZE = 0x00001000;
+//public static final int Pg_CAH_SRCE_TAG = 0x00000400;
+//public static final int Pg_CENTER_BASED = (0x00 << 8);
+//public static final int Pg_CHROMA_DEST_KEY = 0x00000001;
+//public static final int Pg_CHROMA_DEST_MATCH = 1;
+//public static final int Pg_CHROMA_DRAW = 0;
+//public static final int Pg_CHROMA_NODRAW = 2;
+//public static final int Pg_CHROMA_NOT_DST_KEY = 0x00000003;
+//public static final int Pg_CHROMA_NOT_SRC_KEY = 0x00000002;
+//public static final int Pg_CHROMA_SRC_KEY = 0x00000000;
+//public static final int Pg_CHROMA_SRC_MATCH = 0;
+//public static final int Pg_CLIPTEST_CURSOR_HIDE = 0x0020;
+ public static final int Pg_CLOSED = (0x10 << 8);
+//public static final int Pg_CMD_CAH_COUNT_1 = 0x00010000;
+//public static final int Pg_CMD_CAH_COUNT_2 = 0x00020000;
+//public static final int Pg_CMD_CAH_COUNT_3 = 0x00030000;
+//public static final int Pg_CMD_CAH_COUNT_MASK = 0x00030000;
+//public static final int Pg_CMD_CAH_COUNT_UNIT = 0x00010000;
+//public static final int Pg_CMD_CMD_SIZE_MASK = 0xFFFC0000;
+ public static final int Pg_TRANSPARENT = 0xFFFFFFFF;
+//public static final int Pg_INVERT_COLOR = 0xFFFFFFFE;
+//public static final int Pg_CURSOR_SHOW = 0x0080;
+//public static final int Pg_DASH_INVERT = 0x40;
+//public static final int Pg_DASH_SLOPE_ADJ = 0x80;
+//public static final int Pg_DELETE_CURSOR = 0x80;
+//public static final int Pg_DLL_CMDS = 0xD0;
+//public static final int Pg_DO_EXTENT = 0x0002;
+//public static final int Pg_DOUBLE_UNDERLINE = 0x10;
+//public static final int Pg_DRAWMODE_AND = 2;
+//public static final int Pg_DRAWMODE_ANDINV = 6;
+//public static final int Pg_DRAWMODE_ANDREV = 0xA;
+//public static final int Pg_DRAWMODE_CLEAR = 8;
+//public static final int Pg_DRAWMODE_COPYINV = 4;
+//public static final int Pg_DRAWMODE_INVERT = 0xD;
+//public static final int Pg_DRAWMODE_NAND = 0xF;
+//public static final int Pg_DRAWMODE_NOP = 9;
+//public static final int Pg_DRAWMODE_NOR = 0xE;
+ public static final int Pg_DRAWMODE_OPAQUE = 0;
+//public static final int Pg_DRAWMODE_OR = 3;
+//public static final int Pg_DRAWMODE_ORINV = 7;
+//public static final int Pg_DRAWMODE_ORREV = 0xB;
+//public static final int Pg_DRAWMODE_SET = 0xC;
+//public static final int Pg_DRAWMODE_XNOR = 5;
+ public static final int Pg_DRAWMODE_XOR = 1;
+//public static final int Pg_ENABLE_CHROMA = 0x00000004;
+//public static final int Pg_END_OF_DRAW = 0x00;
+//public static final int Pg_ENDIAN_TEST = 0xD5;
+//public static final int Pg_EXPOSE_SOURCE = (0x02 << 8);
+ public static final int Pg_EXTENT_BASED = (0x01 << 8);
+//public static final int Pg_GHOST = 0x01000000;
+ public static final int Pg_IMAGE_PALETTE_BYTE = 0x10;
+//public static final int Pg_IMAGE_BYTE_PALETTE = Pg_IMAGE_PALETTE_BYTE;
+//public static final int Pg_IMAGE_CLASS_BLEND = 0x08;
+ public static final int Pg_IMAGE_CLASS_DIRECT = 0x20;
+//public static final int Pg_IMAGE_CLASS_GRADIENT = 0x18;
+ public static final int Pg_IMAGE_CLASS_MASK = 0x38;
+ public static final int Pg_IMAGE_CLASS_PALETTE = 0x10;
+//public static final int Pg_IMAGE_DBLEND_LONG = 0x0B;
+//public static final int Pg_IMAGE_DBLEND_SHORT = 0x0A;
+ public static final int Pg_IMAGE_DIRECT_444 = 0x24;
+ public static final int Pg_IMAGE_DIRECT_555 = 0x23;
+ public static final int Pg_IMAGE_DIRECT_565 = 0x22;
+ public static final int Pg_IMAGE_DIRECT_888 = 0x21;
+ public static final int Pg_IMAGE_DIRECT_8888 = 0x20;
+//public static final int Pg_IMAGE_GBLEND_BYTE = 0x08;
+//public static final int Pg_IMAGE_GBLEND_NIBBLE = 0x09;
+//public static final int Pg_IMAGE_GRADIENT_BYTE = 0x18;
+//public static final int Pg_IMAGE_GRADIENT_NIBBLE = 0x19;
+ public static final int Pg_IMAGE_PALETTE_NIBBLE = 0x11;
+//public static final int Pg_IMAGE_NIBBLE_PALETTE = Pg_IMAGE_PALETTE_NIBBLE;
+//public static final int Pg_ITEST_CURSOR_HIDE = 0x0010;
+//public static final int Pg_MITER_JOIN = 0x00;
+//public static final int Pg_MOVE_DISPLAY = 0x4D;
+//public static final int Pg_OVRFN_EQ = 5;
+//public static final int Pg_OVRFN_FALSE = 0;
+//public static final int Pg_OVRFN_GE = 2;
+//public static final int Pg_OVRFN_GT = 7;
+//public static final int Pg_OVRFN_LE = 6;
+//public static final int Pg_OVRFN_LT = 3;
+//public static final int Pg_OVRFN_NE = 4;
+//public static final int Pg_OVRFN_TRUE = 1;
+//public static final int Pg_PALSET_FORCE_EXPOSE = 0x80;
+//public static final int Pg_PALSET_GLOBAL = 0x03;
+//public static final int Pg_PALSET_HARD = 0x01;
+//public static final int Pg_PALSET_HARDINACTIVE = 0x05;
+//public static final int Pg_PALSET_HARDLOCKED = 0x02;
+ public static final int Pg_PALSET_SOFT = 0x00;
+//public static final int Pg_PALSET_TYPEMASK = 0x0F;
+//public static final int Pg_POINT_CAP = 0x03;
+//public static final int Pg_RELATIVE = (0x01 << 8);
+//public static final int Pg_REPBM_ALTERNATE = (0x10 <<16);
+//public static final int Pg_POLY_FILL = Pg_DRAW_FILL;
+//public static final int Pg_POLY_RELATIVE = Pg_RELATIVE;
+//public static final int Pg_POLY_STROKE = Pg_DRAW_STROKE;
+//public static final int Pg_POLY_STROKE_CLOSED = Pg_DRAW_STROKE | Pg_CLOSED;
+//public static final int Pg_PRINTER_CMD = 0xF1;
+//public static final int Pg_QROUND_JOIN = 0x03;
+//public static final int Pg_REL_POLY_FILL = (Pg_POLY_FILL | Pg_POLY_RELATIVE);
+//public static final int Pg_REL_POLY_STROKE = (Pg_POLY_STROKE | Pg_POLY_RELATIVE);
+//public static final int Pg_REL_POLY_STROKE_CLOSED = (Pg_POLY_STROKE_CLOSED | Pg_POLY_RELATIVE);
+//public static final int Pg_ROUND_CAP = 0x01;
+//public static final int Pg_ROUND_JOIN = 0x01;
+//public static final int Pg_SET = 1;
+//public static final int Pg_SET_AUX_CLIP = 0x07;
+//public static final int Pg_SET_CURSOR_BITMAP = 0x83;
+//public static final int Pg_SET_CURSOR_CHAR = 0x82;
+//public static final int Pg_SET_CURSOR_POSITION = 0x81;
+//public static final int Pg_SET_DEFAULT_STATE = 0x01;
+//public static final int Pg_SET_DRAG_CURSOR = 0x84;
+//public static final int Pg_SET_DRAW_MODE = 0x02;
+//public static final int Pg_SET_FILL_COLOR = 0x20;
+//public static final int Pg_SET_FILL_DITHER = 0x22;
+//public static final int Pg_SET_FILL_TRANSP = 0x23;
+//public static final int Pg_SET_FILL_XOR_COLOR = 0x21;
+//public static final int Pg_SET_PALETTE = 0x08;
+//public static final int Pg_SET_PLANE_MASK = 0x03;
+//public static final int Pg_SET_ROTATION = 0x0B;
+//public static final int Pg_SET_SCALE = 0x0A;
+//public static final int Pg_SET_STROKE_CAP = 0x15;
+//public static final int Pg_SET_STROKE_COLOR = 0x10;
+//public static final int Pg_SET_STROKE_DASH = 0x17;
+//public static final int Pg_SET_STROKE_DITHER = 0x12;
+//public static final int Pg_SET_STROKE_JOIN = 0x16;
+//public static final int Pg_SET_STROKE_TRANSP = 0x13;
+//public static final int Pg_SET_STROKE_WIDTH = 0x14;
+//public static final int Pg_SET_STROKE_XOR_COLOR = 0x11;
+//public static final int Pg_SET_TEXT_COLOR = 0x30;
+//public static final int Pg_SET_TEXT_DITHER = 0x32;
+//public static final int Pg_SET_TEXT_FONT = 0x34;
+//public static final int Pg_SET_TEXT_TRANSP = 0x33;
+//public static final int Pg_SET_TEXT_UNDERLINE = 0x35;
+//public static final int Pg_SET_TEXT_XOR_COLOR = 0x31;
+//public static final int Pg_SET_TRANSLATION = 0x09;
+//public static final int Pg_SET_USER_CLIP = 0x06;
+//public static final int Pg_SETGAMMA_CBlack = 0x0004;
+//public static final int Pg_SETGAMMA_CFactor = 0x0002;
+//public static final int Pg_SETGAMMA_CWhite = 0x0008;
+//public static final int Pg_SETGAMMA_Factor = 0x0001;
+//public static final int Pg_SMART_BLIT = (0x01 << 8);
+//public static final int Pg_SQUARE_CAP = 0x02;
+//public static final int Pg_STRETCH_BLT = 0x00000008;
+//public static final int Pg_SWAP_DISPLAY = 0xD4;
+//public static final int Pg_SYNC = 0xD3;
+//public static final int Pg_TARGET_STREAM = 0xD1;
+//public static final int Pg_TEST_BITMAP = 2;
+//public static final int Pg_TEST_FILL = (Pg_DRAW_FILL);
+//public static final int Pg_TEST_FILL_STROKE = (Pg_DRAW_FILL | Pg_DRAW_STROKE);
+//public static final int Pg_TEST_STROKE = (Pg_DRAW_STROKE);
+//public static final int Pg_TEST_TEXT = 1;
+//public static final int Pg_TEXT_AREA = (0x08 << 8);
+//public static final int Pg_TEXT_BOTTOM = (0x80 << 8);
+ public static final int Pg_TEXT_LEFT = (0x10 << 8);
+//public static final int Pg_TEXT_RIGHT = (0x20 << 8);
+ public static final int Pg_TEXT_TOP = (0x40 << 8);
+//public static final int Pg_TEXT_CENTER = ( Pg_TEXT_LEFT | Pg_TEXT_RIGHT );
+//public static final int Pg_TEXT_MIDDLE = ( Pg_TEXT_TOP | Pg_TEXT_BOTTOM );
+//public static final int Pg_TEXT_SIZE_HINT = (0x02 << 8);
+ public static final int Pg_TEXT_UTF2CHAR = (0x04 << 8);
+ public static final int Pg_TEXT_WIDECHAR = (Pg_TEXT_UTF2CHAR);
+//public static final int Pg_TREND_HORIZ = 0x00;
+//public static final int Pg_TREND_VERT = 0x01;
+//public static final int Pg_UNSET = 0;
+//public static final int Pg_WAIT_VSYNC = 0x00000010;
+//public static final int Pg_XADDR_INLINE = 1;
+//public static final int Pg_XADDR_SHMEM = 0;
+//public static final int Pgrs_RelBehind = 0x0002;
+//public static final int Pgrs_RelInFront = 0x0001;
+//public static final int Pgrs_RelParent = 0x0000;
+//public static final int PgrsI_CreatedShmem = 0x0001;
+//public static final int Pgv_C_ByteFlag = 0x00000800;
+//public static final int Pgv_C_ByteIndex = 0x00000600;
+//public static final int Pgv_C_Direct = 0x00000400;
+//public static final int Pgv_C_DStrokePen = 0x00000200;
+//public static final int Pgv_C_MASK = 0x00000E00;
+//public static final int Pgv_C_StrokePen = 0x00000000;
+//public static final int Pgv_O_FixedLine = 0x00000000;
+//public static final int Pgv_O_MASK = 0x03000000;
+//public static final int Pgv_O_Variable = 0x01000000;
+//public static final int Pgv_OP_Glyph = 0x80;
+//public static final int Pgv_OP_Line = 0x01;
+//public static final int Pgv_OP_NOP = 0x00;
+//public static final int Pgv_OP_Point = 0x02;
+//public static final int Pgv_P_Color = 0x00200000;
+//public static final int Pgv_P_MASK = 0x00F00000;
+//public static final int Pgv_P_Simple = 0x00100000;
+//public static final int Pgv_T_MASK = 0x00003000;
+//public static final int Pgv_T_PostTrans = 0x00002000;
+//public static final int Pgv_T_PreTrans = 0x00001000;
+//public static final int Pgv_T_ZTrans = 0x00004000;
+//public static final int Pgv_X_Char = 0x00000002;
+//public static final int Pgv_X_LFixed = 0x00000004;
+//public static final int Pgv_X_MASK = 0x00000007;
+//public static final int Pgv_X_Short = 0x00000003;
+//public static final int Pgv_X_UseDelta = 0x00000001;
+//public static final int Pgv_Y_Char = (Pgv_X_Char << 3);
+//public static final int Pgv_Y_LFixed = (Pgv_X_LFixed << 3);
+//public static final int Pgv_Y_MASK = (Pgv_X_MASK << 3);
+//public static final int Pgv_Y_Short = (Pgv_X_Short << 3);
+//public static final int Pgv_Y_UseDelta = (Pgv_X_UseDelta << 3);
+//public static final int Pgv_Z_Char = (Pgv_X_Char << 6);
+//public static final int Pgv_Z_LFixed = (Pgv_X_LFixed << 6);
+//public static final int Pgv_Z_MASK = (Pgv_X_MASK << 6);
+//public static final int Pgv_Z_Short = (Pgv_X_Short << 6);
+//public static final int Pgv_Z_UseDelta = (Pgv_X_UseDelta << 6);
+//public static final int Ph_ACTIVATE_DC = 0;
+//public static final int Ph_AUDIO_REGION = 0x00000100;
+//public static final int Ph_AUXPTR_REGION = 0x00000080;
+//public static final int Ph_BACK_EVENT = 0x0002;
+//public static final int Ph_BAUD_CONSOLE = 100000000;
+//public static final int Ph_BAUD_NETWORK = 10000000;
+//public static final int Ph_BAUD_SLOW = 100000;
+//public static final int Ph_BLIT_REGION = 0x00008000;
+//public static final int Ph_BLOCK_OVERFLOW = 0x00000001;
+ public static final int Ph_BUTTON_ADJUST = 0x0002;
+ public static final int Ph_BUTTON_MENU = 0x0001;
+ public static final int Ph_BUTTON_SELECT = 0x0004;
+// public static final int Ph_BUTTON_1 = Ph_BUTTON_MENU;
+// public static final int Ph_BUTTON_2 = Ph_BUTTON_ADJUST;
+// public static final int Ph_BUTTON_3 = Ph_BUTTON_SELECT;
+//public static final int Ph_CAPTURE_EXPOSE = 4;
+//public static final int Ph_CLIPBOARD_MAX_TYPES = 5;
+//public static final int Ph_COMPOUND_REPLY = 0x00000020;
+//public static final int Ph_CURSOR_BACK = 2;
+//public static final int Ph_CURSOR_BIG_POINTER = 0xE902;
+ public static final int Ph_CURSOR_BITMAP = 0xFB;
+ public static final int Ph_CURSOR_CLOCK = 0xE908;
+ public static final int Ph_CURSOR_CROSSHAIR = 0xE906;
+//public static final int Ph_CURSOR_DEFAULT_COLOR = 0xFFFFE0;
+ public static final int Ph_CURSOR_DONT = 0xE90A;
+//public static final int Ph_CURSOR_DRAG_BACKDIAG = 0xE914;
+ public static final int Ph_CURSOR_DRAG_BL = 0xE916;
+ public static final int Ph_CURSOR_DRAG_BOTTOM = 0xE910;
+ public static final int Ph_CURSOR_DRAG_BR = 0xE914;
+//public static final int Ph_CURSOR_DRAG_FOREDIAG = 0xE916;
+ public static final int Ph_CURSOR_DRAG_HORIZONTAL = 0xE912;
+ public static final int Ph_CURSOR_DRAG_LEFT = 0xE912;
+ public static final int Ph_CURSOR_DRAG_RIGHT = 0xE912;
+ public static final int Ph_CURSOR_DRAG_TL = 0xE914;
+ public static final int Ph_CURSOR_DRAG_TOP = 0xE910;
+ public static final int Ph_CURSOR_DRAG_TR = 0xE916;
+ public static final int Ph_CURSOR_DRAG_VERTICAL = 0xE910;
+ public static final int Ph_CURSOR_FINGER = 0xE90C;
+//public static final int Ph_CURSOR_FRONT = 1;
+ public static final int Ph_CURSOR_INHERIT = 0x00;
+ public static final int Ph_CURSOR_INSERT = 0xE90E;
+//public static final int Ph_CURSOR_LONG_WAIT = 0xE91A;
+//public static final int Ph_CURSOR_MANUAL_CONTROL = 0xFF;
+ public static final int Ph_CURSOR_MOVE = 0xE904;
+//public static final int Ph_CURSOR_NO_INHERIT = 0x01;
+//public static final int Ph_CURSOR_NOINPUT = 0xE90A;
+//public static final int Ph_CURSOR_NONE = 0xFD;
+//public static final int Ph_CURSOR_PASTE = 0xE91E;
+ public static final int Ph_CURSOR_POINT_WAIT = 0xE918;
+ public static final int Ph_CURSOR_POINTER = 0xE900;
+ public static final int Ph_CURSOR_QUESTION_POINT = 0xE91C;
+//public static final int Ph_CURSOR_SET = 0x01000000;
+//public static final int Ph_CURSOR_WAIT = 0xE908;
+//public static final int Ph_DEACTIVATE_DC = 1;
+//public static final int Ph_DESTROYING_DC = 2;
+ public static final int Ph_DEV_RID = 1;
+//public static final int Ph_DIRECTED_FOCUS = 0x0004;
+//public static final int Ph_DONE_DRAW = 0x8000;
+//public static final int Ph_DRAG_ABSOLUTE = 0x0080;
+//public static final int Ph_DRAG_CURSOR_EXACT = 0x0400;
+//public static final int Ph_DRAG_DRAW_RECT = 0x0100;
+//public static final int Ph_DRAG_DRAW_RECT_INITIAL = 0x0200;
+ public static final int Ph_DRAG_KEY_MOTION = 0x0020;
+ public static final int Ph_DRAG_NOBUTTON = 0x0040;
+ public static final int Ph_DRAG_TRACK = 0x0010;
+//public static final int Ph_DRAW_TO_MEMORY_CONTEXT = 2;
+//public static final int Ph_DRAW_TO_PHOTON = 0;
+//public static final int Ph_DRAW_TO_PRINT_CONTEXT = 1;
+//public static final int Ph_DRAW_TO_SERVICE = 3;
+//public static final int Ph_DYNAMIC_BUFFER = 0x00000010;
+//public static final int Ph_EMIT_TOWARD = 0x0001;
+//public static final int Ph_ESCAPE_COUNT_MASK = 0x000F;
+//public static final int Ph_EV_ADMIN_FILE_SENT = 1;
+//public static final int Ph_EV_ADMIN_SEND_FILE = 0;
+//public static final int Ph_EV_AMIN = 0x00000100;
+//public static final int Ph_EV_AUDIO = 0x00100000;
+//public static final int Ph_EV_BLIT = 0x00000800;
+ public static final int Ph_EV_BOUNDARY = 0x00000020;
+ public static final int Ph_EV_BUT_PRESS = 0x00000002;
+ public static final int Ph_EV_BUT_RELEASE = 0x00000004;
+//public static final int Ph_EV_BUT_REPEAT = 0x00004000;
+//public static final int Ph_EV_CONFIG = 3;
+//public static final int Ph_EV_COVERED = 0x00000400;
+//public static final int Ph_EV_DND_ACK = 4;
+//public static final int Ph_EV_DND_CANCEL = 1;
+//public static final int Ph_EV_DND_COMPLETE = 7;
+//public static final int Ph_EV_DND_DELIVERED = 8;
+//public static final int Ph_EV_DND_DROP = 6;
+//public static final int Ph_EV_DND_ENTER = 2;
+//public static final int Ph_EV_DND_INIT = 0;
+//public static final int Ph_EV_DND_LEAVE = 3;
+//public static final int Ph_EV_DND_MOTION = 5;
+//public static final int Ph_EV_DNDROP = 0x00200000;
+ public static final int Ph_EV_DRAG = 0x00000200;
+//public static final int Ph_EV_DRAG_BOUNDARY = 5;
+//public static final int Ph_EV_DRAG_COMPLETE = 2;
+//public static final int Ph_EV_DRAG_INIT = 0;
+//public static final int Ph_EV_DRAG_KEY_EVENT = 3;
+ public static final int Ph_EV_DRAG_MOTION_EVENT = 4;
+//public static final int Ph_EV_DRAG_MOVE = 1;
+//public static final int Ph_EV_DRAG_START = 6;
+//public static final int Ph_EV_DRAW = 0x00000080;
+//public static final int Ph_EV_EXPOSE = 0x00000040;
+//public static final int Ph_EV_FEP = 4;
+//public static final int Ph_EV_INFO = 0x00080000;
+//public static final int Ph_EV_INVALIDATE_FONTINFO = 1;
+//public static final int Ph_EV_INVALIDATE_SYSINFO = 0;
+ public static final int Ph_EV_KEY = 0x00000001;
+//public static final int Ph_EV_KEY_NORMAL = 0;
+//public static final int Ph_EV_KEYBOARD_CTRL = 3;
+//public static final int Ph_EV_LB_SYSTEM = 0x00020000;
+//public static final int Ph_EV_MOTION_NORMAL = 0;
+//public static final int Ph_EV_MOTION_STEADY = 1;
+//public static final int Ph_EV_NEW_TIMEZONE = 2;
+//public static final int Ph_EV_POINTER_CTRL = 2;
+//public static final int Ph_EV_PRINTER = 5;
+ public static final int Ph_EV_PTR_ENTER = 0;
+ public static final int Ph_EV_PTR_ENTER_FROM_CHILD = 4;
+//public static final int Ph_EV_PTR_ENTER_FROM_PARENT = 0;
+ public static final int Ph_EV_PTR_LEAVE = 1;
+ public static final int Ph_EV_PTR_LEAVE_TO_CHILD = 5;
+//public static final int Ph_EV_PTR_LEAVE_TO_PARENT = 1;
+ public static final int Ph_EV_PTR_MOTION_BUTTON = 0x00000010;
+ public static final int Ph_EV_PTR_MOTION_NOBUTTON = 0x00000008;
+//public static final int Ph_EV_PTR_RECT_ENTER = 0x10;
+//public static final int Ph_EV_PTR_RECT_LEAVE = 0x11;
+//public static final int Ph_EV_PTR_STEADY = 2;
+//public static final int Ph_EV_PTR_TRANSIENT_ENTER = 8;
+//public static final int Ph_EV_PTR_TRANSIENT_LEAVE = 9;
+//public static final int Ph_EV_PTR_UNSTEADY = 3;
+ public static final int Ph_EV_PTR_MOTION = ( Ph_EV_PTR_MOTION_NOBUTTON | Ph_EV_PTR_MOTION_BUTTON );
+//public static final int Ph_EV_PTR_ALL = ( Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_PTR_MOTION | Ph_EV_BUT_REPEAT );
+//public static final int Ph_EV_RAW = 0x00008000;
+//public static final int Ph_EV_RAW_AUXPTR = 2;
+//public static final int Ph_EV_RAW_KEY = 0;
+//public static final int Ph_EV_RAW_PTR = 1;
+//public static final int Ph_EV_RELEASE_ENDCLICK = 2;
+//public static final int Ph_EV_RELEASE_OUTBOUND = 3;
+ public static final int Ph_EV_RELEASE_PHANTOM = 1;
+//public static final int Ph_EV_RELEASE_REAL = 0;
+//public static final int Ph_EV_REMOTE_WM = 1;
+//public static final int Ph_EV_SERVICE = 0x00040000;
+//public static final int Ph_EV_SYSTEM = 0x00001000;
+ public static final int Ph_EV_TIMER = 0x00010000;
+//public static final int Ph_EV_WIDGET_SENSE = ( Ph_EV_KEY | Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_DRAG | Ph_EV_BOUNDARY );
+//public static final int Ph_EV_WIDGET_OPAQUE = ( Ph_EV_WIDGET_SENSE | Ph_EV_PTR_ALL | Ph_EV_KEY );
+//public static final int Ph_EV_WIN_SENSE = ( Ph_EV_KEY | Ph_EV_BUT_PRESS | Ph_EV_BUT_RELEASE | Ph_EV_EXPOSE | Ph_EV_DRAG | Ph_EV_TIMER );
+//public static final int Ph_EV_WIN_OPAQUE = ( Ph_EV_WIN_SENSE | Ph_EV_PTR_ALL | Ph_EV_BOUNDARY | Ph_EV_DRAW | Ph_EV_COVERED | Ph_EV_KEY | Ph_EV_BUT_REPEAT );
+//public static final int Ph_EV_WM = 0x00002000;
+//public static final int _Ph_REGION_OPEN = 0;
+//public static final int _Ph_REGION_SET = 1;
+//public static final int _Ph_REGION_CLOSE = 2;
+//public static final int _Ph_REGION_WM_BASE = 8;
+//public static final int Ph_EV_WM_CLOSE = _Ph_REGION_CLOSE;
+//public static final int Ph_EV_WM_CONFIG = (_Ph_REGION_WM_BASE+3);
+//public static final int Ph_EV_WM_CONSWITCH = (_Ph_REGION_WM_BASE+5);
+//public static final int Ph_EV_WM_EVENT = (_Ph_REGION_WM_BASE+0);
+//public static final int Ph_EV_WM_MENUREAD = (_Ph_REGION_WM_BASE+6);
+//public static final int Ph_EV_WM_OPEN = _Ph_REGION_OPEN;
+//public static final int Ph_EV_WM_SET = _Ph_REGION_SET;
+//public static final int Ph_EV_WM_TASKEVENT = (_Ph_REGION_WM_BASE+4);
+//public static final int Ph_EV_WM_TRANSPORT = (_Ph_REGION_WM_BASE+2);
+//public static final int Ph_EV_WM_VISIBLE = (_Ph_REGION_WM_BASE+1);
+//public static final int Ph_EV_ICON_OPAQUE = ( Ph_EV_WM | Ph_EV_EXPOSE | Ph_EV_DRAW );
+//public static final int Ph_EV_ICON_SENSE = ( Ph_EV_WM | Ph_EV_EXPOSE );
+//public static final int Ph_EVENT_ABSOLUTE = 0x0004;
+//public static final int Ph_EVENT_DIRECT = 0x0010;
+//public static final int Ph_EVENT_INCLUSIVE = 0x0008;
+ public static final int Ph_EVENT_MSG = 1;
+//public static final int Ph_EVENT_NO_RECT = 0x0002;
+//public static final int Ph_EVENT_REDIRECTED = 0x0020;
+//public static final int Ph_EVENT_RSRV1 = 0x8000;
+//public static final int Ph_EXPOSE_FAMILY = 0x00002000;
+//public static final int Ph_EXPOSE_REGION = 0x00004000;
+//public static final int Ph_FAKE_EVENT = 0x0001;
+//public static final int Ph_FEP_ACTIVATE = 0x00000003;
+//public static final int Ph_FEP_BROADCAST = 0x00000000;
+//public static final int Ph_FEP_CHINESE = 0x00000002;
+//public static final int Ph_FEP_DEACTIVATE = 0x00000004;
+//public static final int Ph_FEP_DEREGISTER = 1;
+//public static final int Ph_FEP_JAPANESE = 0x00000001;
+//public static final int Ph_FEP_KOREAN = 0x00000003;
+//public static final int Ph_FEP_NORECT = 0x00000002;
+//public static final int Ph_FEP_RECT = 0x00000001;
+//public static final int Ph_FEP_REGISTER = 0;
+//public static final int Ph_FOCUS_BRANCH = 0x0008;
+//public static final int Ph_FOLLOW_IG_SIZE = 0x00200000;
+//public static final int Ph_FORCE_BOUNDARY = 0x00400000;
+//public static final int Ph_FORCE_FRONT = 0x00100000;
+//public static final int Ph_GCAP_BLIT = 0x00000001;
+//public static final int Ph_GCAP_DIRECTCOLOR = 0x00000100;
+//public static final int Ph_GCAP_DRAW_OFFSCREEN = 0x00004000;
+//public static final int Ph_GCAP_FRAME_READ = 0x00001000;
+//public static final int Ph_GCAP_FutureSupported = 0xFF000000;
+//public static final int Ph_GCAP_LOCALHW = 0x00000040;
+//public static final int Ph_GCAP_MASKED_BLIT = 0x00000002;
+//public static final int Ph_GCAP_NONINTERLACED = 0x00000400;
+//public static final int Ph_GCAP_PALETTE = 0x00000008;
+//public static final int Ph_GCAP_PHINDOWS = 0x00000020;
+//public static final int Ph_GCAP_RELAY = 0x00000010;
+//public static final int Ph_GCAP_SHMEM = 0x00000004;
+//public static final int Ph_GCAP_SHMEM_FLUSH = 0x00002000;
+//public static final int Ph_GCAP_TEXT_AREA = 0x00000800;
+//public static final int Ph_GCAP_VIDEO_READABLE = 0x00000200;
+//public static final int Ph_GEN_INFO_BANDWIDTH = 0x000000001;
+//public static final int Ph_GEN_INFO_CAPABILITIES = 0x000000002;
+//public static final int Ph_GEN_INFO_NUM_GFX = 0x000000004;
+//public static final int Ph_GEN_INFO_NUM_IG = 0x000000020;
+//public static final int Ph_GEN_INFO_NUM_KBD = 0x000000008;
+//public static final int Ph_GEN_INFO_NUM_PTR = 0x000000010;
+//public static final int Ph_GFX_BANDWIDTH = 0x00000001;
+//public static final int Ph_GFX_CAPABILITIES = 0x00000002;
+//public static final int Ph_GFX_COLOR_BITS = 0x00000004;
+//public static final int Ph_GFX_POSSIBILITIES = 0x00000008;
+//public static final int Ph_GFXD_DITHERSTROKE = 0x00000008;
+//public static final int Ph_GFXD_HARDROT = 0x00000002;
+//public static final int Ph_GFXD_SCALEING = 0x00000004;
+//public static final int Ph_GFXD_VPANNING = 0x00000001;
+//public static final int Ph_GFXG_DMANDOR = 0x00000020;
+//public static final int Ph_GFXG_DMEXTENDED = 0x00000040;
+//public static final int Ph_GFXG_DMXOR = 0x00000010;
+//public static final int Ph_GFXG_HWBITBLT = 0x00000002;
+//public static final int Ph_GFXG_HWBITBLT_CHROMA = 0x00000080;
+//public static final int Ph_GFXG_HWBITBLT_STRETCH = 0x00000100;
+//public static final int Ph_GFXG_HWCURSOR = 0x00000001;
+//public static final int Ph_GFXG_MASKBLIT = 0x00000004;
+//public static final int Ph_GFXG_OFFSCREENMEM = 0x00000008;
+//public static final int Ph_GFXV_DIRECT = 0x00000010;
+//public static final int Ph_GFXV_MONOCHROME = 0x00000001;
+//public static final int Ph_GFXV_NONINTERLACED = 0x00002000;
+//public static final int Ph_GFXV_OVERLAY = 0x00000020;
+//public static final int Ph_GFXV_PALETTE16 = 0x00000002;
+//public static final int Ph_GFXV_PALETTE256 = 0x00000004;
+//public static final int Ph_GFXV_VIDEO_READABLE = 0x00001000;
+//public static final int Ph_GFXVAL_BITPOS = 0x00400000;
+//public static final int Ph_GFXVAL_BPL = 0x00100000;
+//public static final int Ph_GFXVAL_BPP = 0x00200000;
+//public static final int Ph_GFXVAL_CARDSUBTYPE = 0x00000020;
+//public static final int Ph_GFXVAL_CARDTYPE = 0x00000010;
+//public static final int Ph_GFXVAL_COPT = 0x00000008;
+//public static final int Ph_GFXVAL_DACSIZE = 0x00800000;
+//public static final int Ph_GFXVAL_DOPT = 0x00000002;
+//public static final int Ph_GFXVAL_GOPT = 0x00000004;
+//public static final int Ph_GFXVAL_NCURSOR = 0x00001000;
+//public static final int Ph_GFXVAL_NPALETTE = 0x00002000;
+//public static final int Ph_GFXVAL_POINTBS = 0x00004000;
+//public static final int Ph_GFXVAL_PRES = 0x00000100;
+//public static final int Ph_GFXVAL_VOPT = 0x00000001;
+//public static final int Ph_GFXVAL_VRAMSIZE = 0x00000800;
+//public static final int Ph_GFXVAL_VRES = 0x00000200;
+//public static final int Ph_GFXVAL_WORKSPACES = 0x00008000;
+//public static final int Ph_GRAFX_REGION = 0x00000004;
+//public static final int Ph_GRAPHIC_EXPOSE = 2;
+//public static final int Ph_INFO_CTRL_BUF_GC = 6;
+//public static final int Ph_INFO_CTRL_DFLT_GC = 5;
+//public static final int Ph_INFO_CTRL_FD = 0;
+//public static final int Ph_INFO_CTRL_GC = 4;
+//public static final int Ph_INFO_CTRL_GIN = 3;
+//public static final int Ph_INFO_CTRL_PROXY = 1;
+//public static final int Ph_INFO_CTRL_REM_PROXY = 2;
+//public static final int Ph_INLINE_SHMEM_OBJECTS = 0x00000001;
+//public static final int Ph_INPUTGROUP_REGION = 0x00000040;
+//public static final int Ph_KBD_CAPABILITIES = 0x00000001;
+//public static final int Ph_KBD_REGION = 0x00000010;
+//public static final int Ph_LIB_VERSION = 114;
+//public static final int Ph_MAX_FONT_LEN = 16;
+//public static final int Ph_NO_COMPRESSION = 0x00800000;
+//public static final int Ph_NO_HOLD = 0x00000008;
+//public static final int Ph_NO_PROXY = 0x00000004;
+//public static final int Ph_NORMAL_DRAW = 0x0000;
+//public static final int Ph_NORMAL_EXPOSE = 0;
+//public static final int Ph_NOT_CUAKEY = 0x10;
+//public static final int Ph_NOT_HOTKEY = 0x20;
+//public static final int Ph_PRINT_REGION = 0x00000020;
+//public static final int Ph_PRINTER_EXPOSE = 1;
+//public static final int Ph_PROC_ARMED = 0x0002;
+//public static final int Ph_PROC_BLOCKED = 0x0004;
+//public static final int Ph_PROC_CATCH_UP = 0x0010;
+//public static final int Ph_PROC_DYNAMIC_BUF = 0x0020;
+//public static final int Ph_PROC_HELD = 0x0008;
+//public static final int Ph_PROC_VIRTUAL = 0x0001;
+//public static final int Ph_PTR_CAPABILITIES = 0x00000001;
+//public static final int Ph_PTR_FLAG_PROG = 0x04;
+//public static final int Ph_PTR_FLAG_Z_ABS = 0x02;
+//public static final int Ph_PTR_FLAG_Z_MASK = 0x03;
+//public static final int Ph_PTR_FLAG_Z_NONE = 0x00;
+//public static final int Ph_PTR_FLAG_Z_PRESSURE = 0x03;
+//public static final int Ph_PTR_FLAG_Z_REL = 0x01;
+//public static final int Ph_PTR_RAW_FLAG_NO_BUTTONS = 0x01;
+//public static final int Ph_PTR_RAW_FLAG_XY_REL = 0x02;
+//public static final int Ph_PTR_REGION = 0x00000008;
+//public static final int Ph_QUERY_DC_GRAFX_INFO = 0x80000000;
+//public static final int Ph_QUERY_EXACT = 0x0100;
+ public static final int Ph_QUERY_GRAPHICS = 0x0004;
+//public static final int Ph_QUERY_IG_POINTER = 0x1000;
+//public static final int Ph_QUERY_IG_REGION = 0x2000;
+//public static final int Ph_QUERY_INPUT_GROUP = 0x0040;
+//public static final int Ph_QUERY_MEMORY_GRAFX_INFO = 0x80000000;
+//public static final int Ph_RDATA_CLIPBOARD = 0x000A;
+//public static final int Ph_RDATA_CURSOR = 0x0002;
+//public static final int Ph_RDATA_GFXDETAIL = 0x0008;
+//public static final int Ph_RDATA_GFXINFO = 0x0004;
+//public static final int Ph_RDATA_IG = 0x0003;
+//public static final int Ph_RDATA_INPMGRINFO = 0x0009;
+//public static final int Ph_RDATA_KBDINFO = 0x0005;
+//public static final int Ph_RDATA_PTRINFO = 0x0006;
+//public static final int Ph_RDATA_USER = 0xFFFF;
+//public static final int Ph_RDATA_WINDOW = 0x0001;
+//public static final int Ph_RDATA_WMCONFIG = 0x0007;
+//public static final int Ph_RECT_BOUNDARY = 0x02000000;
+//public static final int Ph_REGION_BEHIND = 0x00000200;
+//public static final int Ph_REGION_CURSOR = 0x00001000;
+//public static final int Ph_REGION_DATA = 0x00000800;
+//public static final int Ph_REGION_EV_OPAQUE = 0x00000008;
+//public static final int Ph_REGION_EV_OPAQUE_AND = 0x00010000;
+//public static final int Ph_REGION_EV_OPAQUE_OR = 0x00040000;
+//public static final int Ph_REGION_EV_OPAQUE_SET = 0x00000008;
+//public static final int Ph_REGION_EV_SENSE = 0x00000010;
+//public static final int Ph_REGION_EV_SENSE_AND = 0x00020000;
+//public static final int Ph_REGION_EV_SENSE_OR = 0x00080000;
+//public static final int Ph_REGION_EV_SENSE_SET = 0x00000010;
+//public static final int Ph_REGION_FLAGS = 0x00000004;
+//public static final int Ph_REGION_HANDLE = 0x00000002;
+//public static final int Ph_REGION_IN_FRONT = 0x00000100;
+//public static final int Ph_REGION_INPUT_GROUP = 0x00008000;
+//public static final int Ph_REGION_ORIGIN = 0x00000040;
+//public static final int Ph_REGION_OWNER = 0x00000001;
+//public static final int Ph_REGION_PARENT = 0x00000080;
+//public static final int Ph_REGION_RECT = 0x00000400;
+//public static final int Ph_REGION_STATE = 0x00000020;
+//public static final int Ph_REGION_TYPE_MASK = 0x000FFFFF;
+//public static final int Ph_RELEASE_GHOST_BITMAP = 0x08;
+//public static final int Ph_RELEASE_IMAGE = 0x01;
+//public static final int Ph_RELEASE_IMAGE_ALL = 0x0F;
+//public static final int Ph_RELEASE_PALETTE = 0x02;
+//public static final int Ph_RELEASE_TRANSPARENCY_MASK = 0x04;
+ public static final int Ph_RESIZE_MSG = 3;
+//public static final int Ph_RIDQUERY_IG_POINTER = 0x1000;
+//public static final int Ph_RIDQUERY_TOWARD = 0x2000;
+//public static final int Ph_ROOT_RID = 0;
+//public static final int Ph_START_DRAW = 0x4000;
+//public static final int Ph_SUPRESS_PARENT_CLIP = 0x00000004;
+//public static final int Ph_SYNC_GCS = 0x00000008;
+//public static final int Ph_SYSTEM_CON_SWITCHABS = 0x0101;
+//public static final int Ph_SYSTEM_CON_SWITCHREL = 0x0102;
+//public static final int Ph_SYSTEM_GRAPHIC_ROTATE = 0x0201;
+//public static final int Ph_SYSTEM_GRAPHIC_ZOOM = 0x0202;
+//public static final int Ph_SYSTEM_MOUSE_ACCEL = 0x0342;
+//public static final int Ph_SYSTEM_MOUSE_DCLICK = 0x0341;
+//public static final int Ph_SYSTEM_NEWMANAGER = 0x0002;
+//public static final int Ph_SYSTEM_PTR_REGION_CHANGE = 0x0301;
+//public static final int Ph_SYSTEM_REGION_CHANGE = 0x0004;
+//public static final int Ph_SYSTEM_ROTATE = 0x0003;
+//public static final int Ph_SYSTEM_SHUTDOWN = 0x0001;
+//public static final int Ph_TEXT_EXTENTS = 0x00000002;
+ public static final int Ph_TRACK_BOTTOM = 0x0008;
+ public static final int Ph_TRACK_LEFT = 0x0001;
+ public static final int Ph_TRACK_RIGHT = 0x0002;
+ public static final int Ph_TRACK_TOP = 0x0004;
+ public static final int Ph_TRACK_DRAG = (Ph_TRACK_LEFT|Ph_TRACK_RIGHT|Ph_TRACK_TOP|Ph_TRACK_BOTTOM);
+//public static final int Ph_TYPE_SPECIFIC = 0x0FF0;
+//public static final int Ph_USER_RSRVD_BITS = 0xF000;
+//public static final int Ph_WINDOW_REGION = 0x00000001;
+//public static final int Ph_WM_ALL_FLAGS = 0x00003F3D;
+//
+//public static final int Ph_WM_BACKDROP = 0x00001000;
+ public static final int Ph_WM_CLOSE = 0x00000001;
+//public static final int Ph_WM_CONSWITCH = 0x00000080;
+//public static final int Ph_WM_EVSTATE_DEICONIFY = 1;
+//public static final int Ph_WM_EVSTATE_FFRONT = 0;
+//public static final int Ph_WM_EVSTATE_FFRONT_DISABLE = 1;
+ public static final int Ph_WM_EVSTATE_FOCUS = 0;
+ public static final int Ph_WM_EVSTATE_FOCUSLOST = 1;
+ public static final int Ph_WM_EVSTATE_HIDE = 0;
+// public static final int Ph_WM_EVSTATE_ICONIFY = 0;
+//public static final int Ph_WM_EVSTATE_INVERSE = 1;
+//public static final int Ph_WM_EVSTATE_MENU = 0;
+//public static final int Ph_WM_EVSTATE_MENU_FINISH = 1;
+//public static final int Ph_WM_EVSTATE_PERFORM = 0;
+ public static final int Ph_WM_EVSTATE_UNHIDE = 1;
+//public static final int Ph_WM_FFRONT = 0x00010000;
+ public static final int Ph_WM_FOCUS = 0x00000004;
+ public static final int Ph_WM_HELP = 0x00002000;
+ public static final int Ph_WM_HIDE = 0x00000040;
+ public static final int Ph_WM_ICON = 0x00000400;
+ public static final int Ph_WM_MAX = 0x00000800;
+//public static final int Ph_WM_MENU = 0x00000008;
+ public static final int Ph_WM_MOVE = 0x00000200;
+//public static final int Ph_WM_RENDER_ASAPP = 0x00000000;
+//public static final int Ph_WM_RENDER_ASICON = 0x00000001;
+//public static final int Ph_WM_RENDER_ASMASK = 0x0000000F;
+ public static final int Ph_WM_RENDER_BORDER = 0x00000010;
+//public static final int Ph_WM_RENDER_CLOSE = 0x00000200;
+//public static final int Ph_WM_RENDER_HELP = 0x00000400;
+ public static final int Ph_WM_RENDER_MAX = 0x00002000;
+ public static final int Ph_WM_RENDER_MENU = 0x00000100;
+ public static final int Ph_WM_RENDER_MIN = 0x00001000;
+//public static final int Ph_WM_RENDER_MOVE = 0x00000040;
+ public static final int Ph_WM_RENDER_RESIZE = 0x00000020;
+//public static final int Ph_WM_RENDER_RETURN = 0x00008000;
+ public static final int Ph_WM_RENDER_TITLE = 0x00000080;
+ public static final int Ph_WM_RESIZE = 0x00000100;
+ public static final int Ph_WM_RESTORE = 0x00008000;
+//public static final int Ph_WM_SET_CHILD_COUNT = 0x0200;
+//public static final int Ph_WM_SET_CONVERSE_LINK = 0x8000;
+//public static final int Ph_WM_SET_FLAGS = 0x0001;
+//public static final int Ph_WM_SET_FRAME_ATTRIB = 0x0400;
+//public static final int Ph_WM_SET_FRONT_WINDOW = 0x0800;
+//public static final int Ph_WM_SET_ICON_POS = 0x0040;
+//public static final int Ph_WM_SET_ICON_SIZE = 0x0020;
+//public static final int Ph_WM_SET_ICON_TITLE = 0x0010;
+//public static final int Ph_WM_SET_LINK = 0x0080;
+//public static final int Ph_WM_SET_RELATION = 0x0100;
+//public static final int Ph_WM_SET_RENDER = 0x0004;
+//public static final int Ph_WM_SET_STATE = 0x0002;
+//public static final int Ph_WM_SET_TITLE = 0x0008;
+//public static final int Ph_WM_STATE_ISALTKEY = 0x00000200;
+//public static final int Ph_WM_STATE_ISBACKDROP = 0x00000004;
+//public static final int Ph_WM_STATE_ISBLOCKED = 0x00000008;
+ public static final int Ph_WM_STATE_ISFOCUS = 0x00008000;
+//public static final int Ph_WM_STATE_ISFRONT = 0x00000100;
+ public static final int Ph_WM_STATE_ISHIDDEN = 0x00000001;
+//public static final int Ph_WM_STATE_ISICON = 0x00000080;
+ public static final int Ph_WM_STATE_ISICONIFIED = 0x00000040;
+//public static final int Ph_WM_STATE_ISMASK = 0x0000FFFF;
+ public static final int Ph_WM_STATE_ISMAX = 0x00000002;
+//public static final int Ph_WM_STATE_ISMAXING = 0x00004000;
+//public static final int Ph_WM_STATE_ISNORMAL = 0x00000000;
+//public static final int Ph_WM_STATE_ISPDM = 0x00000020;
+//public static final int Ph_WM_STATE_ISREMOTE = 0x00000400;
+//public static final int Ph_WM_STATE_ISTASKBAR = 0x00000010;
+//public static final int Ph_WM_SUPERSELECT = ~0;
+//public static final int Ph_WM_TASKBAR = 0x00004000;
+//public static final int Ph_WM_TERMINATE = 0x00000002;
+//public static final int Ph_WM_TOBACK = 0x00000020;
+//public static final int Ph_WM_TOFRONT = 0x00000010;
+//public static final int Ph_WND_MGR_REGION = 0x00000002;
+//public static final int PHF_STATS = 0x01;
+ public static final int PHFONT_ALL_FONTS = 0x33;
+ public static final int PHFONT_ALL_SYMBOLS = (-1);
+ public static final int PHFONT_BITMAP = 0x02;
+ public static final int PHFONT_FIXED = 0x20;
+ public static final int PHFONT_INFO_BLDITC = 0x08;
+ public static final int PHFONT_INFO_BOLD = 0x02;
+ public static final int PHFONT_INFO_FIXED = 0x10;
+ public static final int PHFONT_INFO_ITALIC = 0x04;
+ public static final int PHFONT_INFO_PLAIN = 0x01;
+ public static final int PHFONT_INFO_PROP = 0x20;
+//public static final int PHFONT_LOAD_IMAGES = 0x02;
+//public static final int PHFONT_LOAD_METRICS = 0x01;
+//public static final int PHFONT_MSG_ANTIALIAS = 12;
+//public static final int PHFONT_MSG_CEXTENT1 = 6;
+//public static final int PHFONT_MSG_CEXTENT2 = 14;
+//public static final int PHFONT_MSG_DYNAMIC_LOAD = 0x1000;
+//public static final int PHFONT_MSG_DYNAMIC_UNLOAD = 0x1001;
+//public static final int PHFONT_MSG_EXTENT = 5;
+//public static final int PHFONT_MSG_FEXTENT = 18;
+//public static final int PHFONT_MSG_FEXTENT_WIDE = 26;
+//public static final int PHFONT_MSG_FRENDER = 19;
+//public static final int PHFONT_MSG_FRENDER2 = 20;
+//public static final int PHFONT_MSG_FRENDER_WIDE = 25;
+//public static final int PHFONT_MSG_FRENDER_WIDE2 = 27;
+//public static final int PHFONT_MSG_GLYPH = 9;
+//public static final int PHFONT_MSG_LIST = 3;
+//public static final int PHFONT_MSG_LOAD = 2;
+//public static final int PHFONT_MSG_LOCAL1 = 10;
+//public static final int PHFONT_MSG_LOCAL2 = 11;
+//public static final int PHFONT_MSG_LOCAL2_V20 = 31;
+//public static final int PHFONT_MSG_QUERY = 4;
+//public static final int PHFONT_MSG_RENDER = 7;
+//public static final int PHFONT_MSG_RENDER2 = 13;
+//public static final int PHFONT_MSG_SHMEM = 8;
+//public static final int PHFONT_MSG_STAT_PFR = 29;
+//public static final int PHFONT_MSG_STAT_PHF = 28;
+//public static final int PHFONT_MSG_STAT_TTF = 30;
+//public static final int PHFONT_MSG_WEXTENT = 15;
+//public static final int PHFONT_MSG_WRENDER = 16;
+//public static final int PHFONT_MSG_WRENDER2 = 17;
+ public static final int PHFONT_PROP = 0x10;
+ public static final int PHFONT_SCALABLE = 0x01;
+//
+ public static final int Pk_KF_Key_Down = 0x00000001;
+ public static final int Pk_KF_Key_Repeat = 0x00000002;
+ public static final int Pk_KF_Scan_Valid = 0x00000020;
+ public static final int Pk_KF_Sym_Valid = 0x00000040;
+ public static final int Pk_KF_Cap_Valid = 0x00000080;
+//public static final int Pk_KF_Compose = 0x40000000;
+ public static final int Pk_KM_Shift = 0x00000001;
+ public static final int Pk_KM_Ctrl = 0x00000002;
+ public static final int Pk_KM_Alt = 0x00000004;
+//public static final int Pk_KM_AltGr = 0x00000008;
+//public static final int Pk_KM_Shl3 = 0x00000010;
+//
+//public static final int Pk_KM_Shift_Lock = 0x00000100;
+//public static final int Pk_KM_Ctrl_Lock = 0x00000200;
+//public static final int Pk_KM_Alt_Lock = 0x00000400;
+//public static final int Pk_KM_AltGr_Lock = 0x00000800;
+//
+//public static final int Pk_KM_Caps_Lock = 0x00010000;
+//public static final int Pk_KM_Num_Lock = 0x00020000;
+//public static final int Pk_KM_Scroll_Lock = 0x00040000;
+//
+//
+ public static final int Pk_BackSpace = 0xF008; /* back space, back char */
+ public static final int Pk_Tab = 0xF009;
+ public static final int Pk_Linefeed = 0xF00A; /* Linefeed, LF */
+ public static final int Pk_Clear = 0xF00B;
+ public static final int Pk_Return = 0xF00D; /* Return, enter */
+ public static final int Pk_Pause = 0xF013; /* Pause, hold */
+ public static final int Pk_Scroll_Lock = 0xF014;
+ public static final int Pk_Escape = 0xF01B;
+ public static final int Pk_Delete = 0xF0FF; /* Delete, rubout */
+//
+//public static final int Pk_Multi_key = 0xF020; /* Multi-key character compose */
+//
+//public static final int Pk_Kanji = 0xF021; /* Kanji, Kanji convert */
+//public static final int Pk_Muhenkan = 0xF022; /* Cancel Conversion */
+//public static final int Pk_Henkan_Mode = 0xF023; /* Start/Stop Conversion */
+//public static final int Pk_Henkan = 0xF023; /* Alias for Henkan_Mode */
+//public static final int Pk_Romaji = 0xF024; /* to Romaji */
+//public static final int Pk_Hiragana = 0xF025; /* to Hiragana */
+//public static final int Pk_Katakana = 0xF026; /* to Katakana */
+//public static final int Pk_Hiragana_Katakana = 0xF027; /* Hiragana/Katakana toggle */
+//public static final int Pk_Zenkaku = 0xF028; /* to Zenkaku */
+//public static final int Pk_Hankaku = 0xF029; /* to Hankaku */
+//public static final int Pk_Zenkaku_Hankaku = 0xF02A; /* Zenkaku/Hankaku toggle */
+//public static final int Pk_Touroku = 0xF02B; /* Add to Dictionary */
+//public static final int Pk_Massyo = 0xF02C; /* Delete from Dictionary */
+//public static final int Pk_Kana_Lock = 0xF02D; /* Kana Lock */
+//public static final int Pk_Kana_Shift = 0xF02E; /* Kana Shift */
+//public static final int Pk_Eisu_Shift = 0xF02F; /* Alphanumeric Shift */
+//public static final int Pk_Eisu_toggle = 0xF030; /* Alphanumeric toggle */
+//
+ public static final int Pk_Home = 0xF050;
+ public static final int Pk_Left = 0xF051; /* Move left, left arrow */
+ public static final int Pk_Up = 0xF052; /* Move up, up arrow */
+ public static final int Pk_Right = 0xF053; /* Move right, right arrow */
+ public static final int Pk_Down = 0xF054; /* Move down, down arrow */
+ public static final int Pk_Prior = 0xF055; /* Prior, previous */
+ public static final int Pk_Pg_Up = 0xF055; /* Prior, previous */
+ public static final int Pk_Next = 0xF056; /* Next */
+ public static final int Pk_Pg_Down = 0xF056; /* Next */
+ public static final int Pk_End = 0xF057; /* EOL */
+//public static final int Pk_Begin = 0xF058; /* BOL */
+//
+//public static final int Pk_Select = 0xF060; /* Select, mark */
+//public static final int Pk_Print = 0xF061;
+//public static final int Pk_Execute = 0xF062; /* Execute, run, do */
+ public static final int Pk_Insert = 0xF063; /* Insert, insert here */
+//public static final int Pk_Undo = 0xF065; /* Undo, oops */
+//public static final int Pk_Redo = 0xF066; /* redo, again */
+//public static final int Pk_Menu = 0xF067;
+//public static final int Pk_Find = 0xF068; /* Find, search */
+//public static final int Pk_Cancel = 0xF069; /* Cancel, stop, abort, exit */
+//public static final int Pk_Help = 0xF06A; /* Help, ? */
+//public static final int Pk_Break = 0xF06B;
+//public static final int Pk_Mode_switch = 0xF07E; /* Character set switch */
+//public static final int Pk_script_switch = 0xF07E; /* Alias for mode_switch */
+//public static final int Pk_Num_Lock = 0xF07F;
+//
+//public static final int Pk_KP_Space = 0xF080; /* space */
+//public static final int Pk_KP_Tab = 0xF089;
+//public static final int Pk_KP_Enter = 0xF08D; /* enter */
+//public static final int Pk_KP_F1 = 0xF091; /* PF1, KP_A, ... */
+//public static final int Pk_KP_F2 = 0xF092;
+//public static final int Pk_KP_F3 = 0xF093;
+//public static final int Pk_KP_F4 = 0xF094;
+//public static final int Pk_KP_Equal = 0xF0BD; /* equals */
+//public static final int Pk_KP_Multiply = 0xF0AA;
+//public static final int Pk_KP_Add = 0xF0AB;
+//public static final int Pk_KP_Separator = 0xF0AC; /* separator, often comma */
+//public static final int Pk_KP_Subtract = 0xF0AD;
+//public static final int Pk_KP_Decimal = 0xF0AE;
+//public static final int Pk_KP_Divide = 0xF0AF;
+//
+//public static final int Pk_KP_0 = 0xF0B0;
+//public static final int Pk_KP_1 = 0xF0B1;
+//public static final int Pk_KP_2 = 0xF0B2;
+//public static final int Pk_KP_3 = 0xF0B3;
+//public static final int Pk_KP_4 = 0xF0B4;
+//public static final int Pk_KP_5 = 0xF0B5;
+//public static final int Pk_KP_6 = 0xF0B6;
+//public static final int Pk_KP_7 = 0xF0B7;
+//public static final int Pk_KP_8 = 0xF0B8;
+//public static final int Pk_KP_9 = 0xF0B9;
+//
+ public static final int Pk_F1 = 0xF0BE;
+ public static final int Pk_F2 = 0xF0BF;
+ public static final int Pk_F3 = 0xF0C0;
+ public static final int Pk_F4 = 0xF0C1;
+ public static final int Pk_F5 = 0xF0C2;
+ public static final int Pk_F6 = 0xF0C3;
+ public static final int Pk_F7 = 0xF0C4;
+ public static final int Pk_F8 = 0xF0C5;
+ public static final int Pk_F9 = 0xF0C6;
+ public static final int Pk_F10 = 0xF0C7;
+ public static final int Pk_F11 = 0xF0C8;
+ public static final int Pk_F12 = 0xF0C9;
+//
+ public static final int Pk_Shift_L = 0xF0E1; /* Left shift */
+ public static final int Pk_Shift_R = 0xF0E2; /* Right shift */
+ public static final int Pk_Control_L = 0xF0E3; /* Left control */
+ public static final int Pk_Control_R = 0xF0E4; /* Right control */
+//public static final int Pk_Caps_Lock = 0xF0E5; /* Caps lock */
+//public static final int Pk_Shift_Lock = 0xF0E6; /* Shift lock */
+//
+//public static final int Pk_Meta_L = 0xF0E7; /* Left meta */
+//public static final int Pk_Meta_R = 0xF0E8; /* Right meta */
+ public static final int Pk_Alt_L = 0xF0E9; /* Left alt */
+ public static final int Pk_Alt_R = 0xF0EA; /* Right alt */
+//
+//public static final int Pm_CONTEXT_FLUSHED = 0x00000001;
+//public static final int Pm_IMAGE_CONTEXT = 1;
+//public static final int Pm_PHS_CONTEXT = 0;
+//public static final int POINTER_CTRL_ATTR_MASK = 0x00000f00;
+//public static final int POINTER_CTRL_BUTTONS = 0x00000010;
+//public static final int POINTER_CTRL_DEVMATRIX = 0x00000200;
+//public static final int POINTER_CTRL_FILENAME = 0x00000080;
+//public static final int POINTER_CTRL_GAIN = 0x00000004;
+//public static final int POINTER_CTRL_GETCTRL = 0x00000000;
+//public static final int POINTER_CTRL_GETMATRIX = 0x00000040;
+//public static final int POINTER_CTRL_LAYER = 0x00000800;
+//public static final int POINTER_CTRL_LAYER_MASK = DEV_CTRL_LAYER_MASK;
+//public static final int POINTER_CTRL_OFF = 0x00000002;
+//public static final int POINTER_CTRL_ON = 0x00000001;
+//public static final int POINTER_CTRL_SCRNMATRIX = 0x00000400;
+//public static final int POINTER_CTRL_SETMATRIX = 0x00000020;
+//public static final int POINTER_CTRL_SWAP = 0x00000100;
+//public static final int POINTER_CTRL_SWITCH_MASK = DEV_CTRL_SWITCH_MASK;
+//public static final int POINTER_CTRL_THRESHOLD = 0x00000008;
+//public static final int POINTER_CTRL_TYPE_MASK = DEV_CTRL_TYPE_MASK;
+//public static final int Pp_DOCUMENT_COMPLETE = 0x00000001;
+//public static final int Pp_LANDSCAPE = 1;
+//public static final int Pp_LANDSCAPE_TSHIRT = 3;
+//public static final int Pp_PAGE_COMPLETE = 0x00000002;
+//public static final int Pp_PORTRAIT = 0;
+//public static final int Pp_TSHIRT = 2;
+//public static final int Pt_ALIGN_BOTTOM = 0x20;
+//public static final int Pt_ALIGN_CENTER = 0x2;
+//public static final int Pt_ALIGN_LEFT = 0x40;
+//public static final int Pt_ALIGN_RIGHT = 0x80;
+//public static final int Pt_ALIGN_TOP = 0x10;
+//public static final int Pt_ALL_BUTTONS = 0x00800000;
+ public static final int Pt_ALWAYS = 0x01;
+//public static final int Pt_ANCHORS_INVALID = 0x40000000;
+ public static final int Pt_ANCHORS_LOCKED = 0x04000000;
+//public static final int Pt_ARC_CHORD = Pg_ARC_CHORD;
+//public static final int Pt_ARC_CURVE = Pg_ARC;
+//public static final int Pt_ARC_PIE = Pg_ARC_PIE;
+//public static final int Pt_ARG_ACCEL_FONT = ( 7 * 1000 + 1 );
+ public static final int Pt_ARG_ACCEL_KEY = ( 3 * 1000 + 18 );
+ public static final int Pt_ARG_ACCEL_TEXT = ( 7 * 1000 + 0 );
+ public static final int Pt_ARG_ANCHOR_FLAGS = ( 10 * 1000 + 1 );
+//public static final int Pt_ARG_ANCHOR_OFFSETS = ( 10 * 1000 + 0 );
+//public static final int Pt_ARG_ARC_END = ( 26 * 1000 + 0 );
+//public static final int Pt_ARG_ARC_START = ( 26 * 1000 + 1 );
+//public static final int Pt_ARG_ARC_TYPE = ( 26 * 1000 + 2 );
+ public static final int Pt_ARG_AREA = ( 1 * 1000 + 0 );
+//public static final int Pt_ARG_ARM_COLOR = ( 6 * 1000 + 0 );
+//public static final int Pt_ARG_ARM_DATA = ( 6 * 1000 + 1 );
+//public static final int Pt_ARG_ARM_FILL = ( 6 * 1000 + 2 );
+//public static final int Pt_ARG_BALLOON_COLOR = ( 3 * 1000 + 20 );
+//public static final int Pt_ARG_BALLOON_FILL_COLOR = ( 3 * 1000 + 19 );
+ public static final int Pt_ARG_BALLOON_POSITION = ( 3 * 1000 + 16 );
+//public static final int Pt_ARG_BANDWIDTH_THRESHOLD = ( 2 * 1000 + 17 );
+ public static final int Pt_ARG_BASIC_FLAGS = ( 2 * 1000 + 15 );
+//public static final int Pt_ARG_BEZIER_FLAGS = ( 42 * 1000 + 1 );
+//public static final int Pt_ARG_BITMAP_BALLOON = ( 20 * 1000 + 9 );
+//public static final int Pt_ARG_BITMAP_BALLOON_COLOR = ( 20 * 1000 + 11 );
+//public static final int Pt_ARG_BITMAP_BALLOON_FILL_COLOR = ( 20 * 1000 + 10 );
+//public static final int Pt_ARG_BITMAP_BALLOON_POSITION = ( 20 * 1000 + 8 );
+//public static final int Pt_ARG_BITMAP_COLORS = ( 20 * 1000 + 0 );
+//public static final int Pt_ARG_BITMAP_CURSOR = ( 1 * 1000 + 17 );
+//public static final int Pt_ARG_BITMAP_DATA = ( 20 * 1000 + 1 );
+//public static final int Pt_ARG_BITMAP_FLAGS = ( 20 * 1000 + 7 );
+//public static final int Pt_ARG_BITMAP_TEXT = ( 20 * 1000 + 2 );
+//public static final int Pt_ARG_BKGD_BRT_FROM = ( 14 * 1000 + 0 );
+//public static final int Pt_ARG_BKGD_BRT_TO = ( 14 * 1000 + 1 );
+//public static final int Pt_ARG_BKGD_HUE_FROM = ( 14 * 1000 + 2 );
+//public static final int Pt_ARG_BKGD_HUE_TO = ( 14 * 1000 + 3 );
+//public static final int Pt_ARG_BKGD_IMAGE = ( 14 * 1000 + 15 );
+//public static final int Pt_ARG_BKGD_MIX = ( 14 * 1000 + 4 );
+//public static final int Pt_ARG_BKGD_ORIENTATION = ( 14 * 1000 + 5 );
+//public static final int Pt_ARG_BKGD_PIX_HEIGHT = ( 14 * 1000 + 8 );
+//public static final int Pt_ARG_BKGD_PIX_WIDTH = ( 14 * 1000 + 9 );
+//public static final int Pt_ARG_BKGD_PIXCOLORS = ( 14 * 1000 + 6 );
+//public static final int Pt_ARG_BKGD_PIXMAP = ( 14 * 1000 + 7 );
+//public static final int Pt_ARG_BKGD_SAT_FROM = ( 14 * 1000 + 10 );
+//public static final int Pt_ARG_BKGD_SAT_TO = ( 14 * 1000 + 11 );
+//public static final int Pt_ARG_BKGD_SPACING = ( 14 * 1000 + 16 );
+//public static final int Pt_ARG_BKGD_STEPS = ( 14 * 1000 + 12 );
+//public static final int Pt_ARG_BKGD_TILE = ( 14 * 1000 + 13 );
+//public static final int Pt_ARG_BKGD_TYPE = ( 14 * 1000 + 14 );
+//public static final int Pt_ARG_BMP_SET_BG_COLOR = ( 20 * 1000 + 3 );
+//public static final int Pt_ARG_BMP_SET_BG_FILL = ( 20 * 1000 + 4 );
+ public static final int Pt_ARG_BORDER_WIDTH = ( 1 * 1000 + 1 );
+//public static final int Pt_ARG_BOT_BORDER_COLOR = ( 2 * 1000 + 0 );
+ public static final int Pt_ARG_BUTTON_TYPE = ( 7 * 1000 + 2 );
+//public static final int Pt_ARG_CALENDAR_COLOR1 = ( 56 * 1000 + 2 );
+//public static final int Pt_ARG_CALENDAR_COLOR2 = ( 56 * 1000 + 4 );
+//public static final int Pt_ARG_CALENDAR_COLOR3 = ( 56 * 1000 + 6 );
+//public static final int Pt_ARG_CALENDAR_COLOR4 = ( 56 * 1000 + 8 );
+//public static final int Pt_ARG_CALENDAR_COLOR5 = ( 56 * 1000 + 10 );
+//public static final int Pt_ARG_CALENDAR_DATE = ( 56 * 1000 + 0 );
+//public static final int Pt_ARG_CALENDAR_FLAGS = ( 56 * 1000 + 14 );
+//public static final int Pt_ARG_CALENDAR_FONT1 = ( 56 * 1000 + 1 );
+//public static final int Pt_ARG_CALENDAR_FONT2 = ( 56 * 1000 + 3 );
+//public static final int Pt_ARG_CALENDAR_FONT3 = ( 56 * 1000 + 5 );
+//public static final int Pt_ARG_CALENDAR_FONT4 = ( 56 * 1000 + 7 );
+//public static final int Pt_ARG_CALENDAR_FONT5 = ( 56 * 1000 + 9 );
+//public static final int Pt_ARG_CALENDAR_HIGHLIGHT = ( 56 * 1000 + 15 );
+//public static final int Pt_ARG_CALENDAR_MONTH_BTN_COLOR = ( 56 * 1000 + 19 );
+//public static final int Pt_ARG_CALENDAR_MONTH_NAMES = ( 56 * 1000 + 13 );
+//public static final int Pt_ARG_CALENDAR_SEL_COLOR = ( 56 * 1000 + 11 );
+//public static final int Pt_ARG_CALENDAR_TIME_T = ( 56 * 1000 + 17 );
+//public static final int Pt_ARG_CALENDAR_WDAY_NAMES = ( 56 * 1000 + 12 );
+//public static final int Pt_ARG_CALENDAR_YEAR_BTN_COLOR = ( 56 * 1000 + 18 );
+//public static final int Pt_ARG_CBOX_BUTTON_BORDER_WIDTH = ( 31 * 1000 + 15 );
+//public static final int Pt_ARG_CBOX_BUTTON_BOT_BORDER_COLOR = ( 31 * 1000 + 17 );
+//public static final int Pt_ARG_CBOX_BUTTON_COLOR = ( 31 * 1000 + 18 );
+//public static final int Pt_ARG_CBOX_BUTTON_TOP_BORDER_COLOR = ( 31 * 1000 + 16 );
+//public static final int Pt_ARG_CBOX_BUTTON_WIDTH = ( 31 * 1000 + 6 );
+ public static final int Pt_ARG_CBOX_FLAGS = ( 31 * 1000 + 0 );
+ public static final int Pt_ARG_CBOX_MAX_VISIBLE_COUNT = ( 31 * 1000 + 19);
+//public static final int Pt_ARG_CBOX_SEL_ITEM = ( 31 * 1000 + 1 );
+ public static final int Pt_ARG_CBOX_SELECTION_ITEM = ( 31 * 1000 + 1 );
+//public static final int Pt_ARG_CLIENT_FLAGS = ( 99 * 1000 + 7 );
+//public static final int Pt_ARG_CLIENT_NAME = ( 99 * 1000 + 4 );
+//public static final int Pt_ARG_CLIENT_REPLY_LEN = ( 99 * 1000 + 2 );
+//public static final int Pt_ARG_CLIENT_SEND = ( 99 * 1000 + 1 );
+//public static final int Pt_ARG_CLIENT_SERVER = ( 99 * 1000 + 0 );
+//public static final int Pt_ARG_CLOCK_FACE_COLOR = (57 * 1000 +6);
+//public static final int Pt_ARG_CLOCK_FACE_OUTLINE_COLOR = (57 * 1000 +5);
+//public static final int Pt_ARG_CLOCK_FLAGS = (57 * 1000 +1);
+//public static final int Pt_ARG_CLOCK_FONT = (57 * 1000 +17);
+//public static final int Pt_ARG_CLOCK_HOUR = (57 * 1000 +2);
+//public static final int Pt_ARG_CLOCK_HOUR_COLOR = (57 * 1000 +7);
+//public static final int Pt_ARG_CLOCK_HOUR_OFFSET = (57 * 1000 +14);
+//public static final int Pt_ARG_CLOCK_MINUTE = (57 * 1000 +3);
+//public static final int Pt_ARG_CLOCK_MINUTE_COLOR = (57 * 1000 +8);
+//public static final int Pt_ARG_CLOCK_MINUTE_OFFSET = (57 * 1000 +15);
+//public static final int Pt_ARG_CLOCK_SECOND = (57 * 1000 +4);
+//public static final int Pt_ARG_CLOCK_SECOND_COLOR = (57 * 1000 +9);
+//public static final int Pt_ARG_CLOCK_SECOND_OFFSET = (57 * 1000 +16);
+//public static final int Pt_ARG_CLOCK_SEP1 = (57 * 1000 +10);
+//public static final int Pt_ARG_CLOCK_SEP1_COLOR = (57 * 1000 +12);
+//public static final int Pt_ARG_CLOCK_SEP2 = (57 * 1000 +11);
+//public static final int Pt_ARG_CLOCK_SEP2_COLOR = (57 * 1000 +13);
+//public static final int Pt_ARG_CLOCK_TYPE = (57 * 1000 +0);
+ public static final int Pt_ARG_COLOR = ( 2 * 1000 + 1 );
+//public static final int Pt_ARG_COLUMNS = ( 4 * 1000 + 1 );
+ public static final int Pt_ARG_CONTAINER_FLAGS = ( 10 * 1000 + 5 );
+//public static final int Pt_ARG_CURRENT_FRAME = ( 101 * 1000 + 3 );
+//public static final int Pt_ARG_CURSOR_COLOR = ( 1 * 1000 + 3 );
+//public static final int Pt_ARG_CURSOR_OFFSET = ( 4 * 1000 + 19);
+ public static final int Pt_ARG_CURSOR_POSITION = ( 4 * 1000 + 3 );
+ public static final int Pt_ARG_CURSOR_TYPE = ( 1 * 1000 + 2 );
+//public static final int Pt_ARG_DASH_LIST = ( 25 * 1000 + 0 );
+//public static final int Pt_ARG_DASH_SCALE = ( 25 * 1000 + 8 );
+//public static final int Pt_ARG_DATA = ( 1 * 1000 + 4 );
+//public static final int Pt_ARG_DB_IMAGE_TYPE = ( 48 * 1000 + 0 );
+//public static final int Pt_ARG_DB_MEMORY_CONTEXT_TYPE = ( 48 * 1000 + 1 );
+//public static final int Pt_ARG_DEFAULT_ACTION = ( 18 * 1000 + 0 );
+ public static final int Pt_ARG_DIM = ( 1 * 1000 + 5 );
+//public static final int Pt_ARG_DIRECTION = ( 29 * 1000 + 0 );
+//public static final int Pt_ARG_DIVIDER_FLAGS = ( 44 * 1000 + 1 );
+//public static final int Pt_ARG_DIVIDER_OFFSET = ( 44 * 1000 + 4 );
+//public static final int Pt_ARG_DIVIDER_SIZES = ( 44 * 1000 + 2 );
+//public static final int Pt_ARG_EDIT_MASK = ( 4 * 1000 + 4 );
+//public static final int Pt_ARG_EFLAGS = ( 1 * 1000 + 18 );
+//public static final int Pt_ARG_EXTENDED_SHIFT = 20;
+//public static final int Pt_ARG_EXTENDED_TYPES_MASK = 0x00300000;
+ public static final int Pt_ARG_FILL_COLOR = ( 2 * 1000 + 2 );
+//public static final int Pt_ARG_FILL_PATTERN = ( 2 * 1000 + 3 );
+ public static final int Pt_ARG_FLAGS = ( 1 * 1000 + 6 );
+//public static final int Pt_ARG_FOCUS = ( 10 * 1000 + 2 );
+//public static final int Pt_ARG_FONT_DISPLAY = (38 * 1000 + 5);
+//public static final int Pt_ARG_FONT_FLAGS = (38 * 1000 + 3);
+//public static final int Pt_ARG_FONT_NAME = (38 * 1000 + 0);
+//public static final int Pt_ARG_FONT_SAMPLE = (38 * 1000 + 1);
+//public static final int Pt_ARG_FONT_SYMBOL = (38 * 1000 + 2);
+//public static final int Pt_ARG_FRAME_DATA = ( 101 * 1000 + 0 );
+//public static final int Pt_ARG_FRAME_INTERVAL = ( 101 * 1000 + 2 );
+//public static final int Pt_ARG_FS_FILE_SPEC = ( 47 * 1000 + 5 );
+//public static final int Pt_ARG_FS_FLAGS = ( 47 * 1000 + 2 );
+//public static final int Pt_ARG_FS_FORMAT = ( 47 * 1000 + 5 );
+//public static final int Pt_ARG_FS_IMAGES = ( 47 * 1000 + 1 );
+//public static final int Pt_ARG_FS_REFRESH = ( 47 * 1000 + 3 );
+//public static final int Pt_ARG_FS_ROOT_DIR = ( 47 * 1000 + 0 );
+//public static final int Pt_ARG_FS_TIMER_INITIAL = ( 47 * 1000 + 4 );
+//public static final int Pt_ARG_GAUGE_FLAGS = ( 21 * 1000 + 0 );
+//public static final int Pt_ARG_GAUGE_FONT = ( 21 * 1000 + 1 );
+//public static final int Pt_ARG_GAUGE_H_ALIGN = ( 21 * 1000 + 8 );
+ public static final int Pt_ARG_GAUGE_MAXIMUM = ( 21 * 1000 + 3 );
+ public static final int Pt_ARG_GAUGE_MINIMUM = ( 21 * 1000 + 2 );
+ public static final int Pt_ARG_GAUGE_ORIENTATION = ( 21 * 1000 + 5 );
+//public static final int Pt_ARG_GAUGE_V_ALIGN = ( 21 * 1000 + 9 );
+ public static final int Pt_ARG_GAUGE_VALUE = ( 21 * 1000 + 4 );
+//public static final int Pt_ARG_GAUGE_VALUE_PREFIX = ( 21 * 1000 + 6 );
+//public static final int Pt_ARG_GAUGE_VALUE_SUFFIX = ( 21 * 1000 + 7 );
+//public static final int Pt_ARG_GRAPHIC_FLAGS = ( 25 * 1000 + 1 );
+//public static final int Pt_ARG_GRID_HORIZONTAL = ( 43 * 1000 + 0 );
+//public static final int Pt_ARG_GRID_VERTICAL = ( 43 * 1000 + 1 );
+ public static final int Pt_ARG_GROUP_FLAGS = ( 11 * 1000 + 0 );
+ public static final int Pt_ARG_GROUP_HORZ_ALIGN = ( 11 * 1000 + 1 );
+//public static final int Pt_ARG_GROUP_ORIENTATION = ( 11 * 1000 + 2 );
+//public static final int Pt_ARG_GROUP_ROWS_COLS = ( 11 * 1000 + 5 );
+ public static final int Pt_ARG_GROUP_SPACING = ( 11 * 1000 + 3 );
+//public static final int Pt_ARG_GROUP_SPACING_X = ( 11 * 1000 + 6 );
+//public static final int Pt_ARG_GROUP_SPACING_Y = ( 11 * 1000 + 7 );
+ public static final int Pt_ARG_GROUP_VERT_ALIGN = ( 11 * 1000 + 4 );
+//public static final int Pt_ARG_HELP_TOPIC = ( 1 * 1000 + 15 );
+//public static final int Pt_ARG_HIGHLIGHT_COLOR = ( 4 * 1000 + 15 );
+//public static final int Pt_ARG_HIGHLIGHT_ROUNDNESS = ( 2 * 1000 + 14 );
+ public static final int Pt_ARG_HORIZONTAL_ALIGNMENT = ( 3 * 1000 + 0 );
+//public static final int Pt_ARG_HTML_BORDER_WIDTH = ( 45 * 1000 + 26 );
+//public static final int Pt_ARG_HTML_CURSOR_BUSY = ( 45 * 1000 + 11 );
+//public static final int Pt_ARG_HTML_CURSOR_DEFAULT = ( 45 * 1000 + 9 );
+//public static final int Pt_ARG_HTML_CURSOR_LINK = ( 45 * 1000 + 10 );
+//public static final int Pt_ARG_HTML_FILL_COLOR = ( 45 * 1000 + 27 );
+//public static final int Pt_ARG_HTML_FLAGS = ( 45 * 1000 + 31 );
+//public static final int Pt_ARG_HTML_H1_FONT = ( 45 * 1000 + 2 );
+//public static final int Pt_ARG_HTML_H2_FONT = ( 45 * 1000 + 3 );
+//public static final int Pt_ARG_HTML_H3_FONT = ( 45 * 1000 + 4 );
+//public static final int Pt_ARG_HTML_H4_FONT = ( 45 * 1000 + 5 );
+//public static final int Pt_ARG_HTML_H5_FONT = ( 45 * 1000 + 6 );
+//public static final int Pt_ARG_HTML_H6_FONT = ( 45 * 1000 + 7 );
+//public static final int Pt_ARG_HTML_INCREMENT = ( 45 * 1000 + 32 );
+//public static final int Pt_ARG_HTML_LINK_COLOR = ( 45 * 1000 + 8 );
+//public static final int Pt_ARG_HTML_PAGE_BM = ( 45 * 1000 + 24 );
+//public static final int Pt_ARG_HTML_PAGE_H = ( 45 * 1000 + 20 );
+//public static final int Pt_ARG_HTML_PAGE_INCREMENT = ( 45 * 1000 + 33 );
+//public static final int Pt_ARG_HTML_PAGE_LM = ( 45 * 1000 + 25 );
+//public static final int Pt_ARG_HTML_PAGE_N = ( 45 * 1000 + 35 );
+//public static final int Pt_ARG_HTML_PAGE_RM = ( 45 * 1000 + 23 );
+//public static final int Pt_ARG_HTML_PAGE_TM = ( 45 * 1000 + 22 );
+//public static final int Pt_ARG_HTML_PAGE_W = ( 45 * 1000 + 21 );
+//public static final int Pt_ARG_HTML_PAGE_X = ( 45 * 1000 + 18 );
+//public static final int Pt_ARG_HTML_PAGE_Y = ( 45 * 1000 + 19 );
+//public static final int Pt_ARG_HTML_PAGES = ( 45 * 1000 + 34 );
+//public static final int Pt_ARG_HTML_SCROLL_COLOR = ( 45 * 1000 + 28 );
+//public static final int Pt_ARG_HTML_SCROLL_FILL_COLOR = ( 45 * 1000 + 29 );
+//public static final int Pt_ARG_HTML_SCROLL_HORIZONTAL = ( 45 * 1000 + 13 );
+//public static final int Pt_ARG_HTML_SCROLL_VERTICAL = ( 45 * 1000 + 12 );
+//public static final int Pt_ARG_HTML_SCROLL_WIDTH = ( 45 * 1000 + 14 );
+//public static final int Pt_ARG_HTML_TEXT_FONT = ( 45 * 1000 + 1 );
+//public static final int Pt_ARG_HTML_URL = ( 45 * 1000 + 0 );
+//public static final int Pt_ARG_ICON_FLAGS = ( 18 * 1000 + 1 );
+//public static final int Pt_ARG_ICON_POS = ( 18 * 1000 + 2 );
+//public static final int Pt_ARG_ICON_WINDOW = ( 18 * 1000 + 3 );
+//public static final int Pt_ARG_IMAGEAREA_FLAGS = ( 103 * 1000 + 8 );
+//public static final int Pt_ARG_IMAGEAREA_GRID_COLOR = ( 103 * 1000 + 14 );
+//public static final int Pt_ARG_IMAGEAREA_GRID_THRESHOLD = ( 103 * 1000 + 13 );
+//public static final int Pt_ARG_IMAGEAREA_IMAGE = ( 103 * 1000 + 0 );
+//public static final int Pt_ARG_IMAGEAREA_LEFT = ( 103 * 1000 + 6 );
+//public static final int Pt_ARG_IMAGEAREA_SELECTION = ( 103 * 1000 + 12 );
+//public static final int Pt_ARG_IMAGEAREA_TOP = ( 103 * 1000 + 5 );
+//public static final int Pt_ARG_IMAGEAREA_ZOOM = ( 103 * 1000 + 7 );
+//public static final int Pt_ARG_IMAGETREE_COLUMNS = ( 49 * 1000 + 2 );
+//public static final int Pt_ARG_IN_EXDATA = 0x00100000;
+//public static final int Pt_ARG_IN_WDATA = 0x00200000;
+ public static final int Pt_ARG_INCREMENT = ( 29 * 1000 + 1 );
+//public static final int Pt_ARG_INDICATOR_COLOR = ( 9 * 1000 + 0 );
+//public static final int Pt_ARG_INDICATOR_DEPTH = ( 9 * 1000 + 6 );
+//public static final int Pt_ARG_INDICATOR_HEIGHT = ( 9 * 1000 + 8 );
+ public static final int Pt_ARG_INDICATOR_TYPE = ( 9 * 1000 + 2 );
+//public static final int Pt_ARG_INDICATOR_WIDTH = ( 9 * 1000 + 7 );
+ public static final int Pt_ARG_ITEMS = ( 23 * 1000 + 1 );
+//public static final int Pt_ARG_LABEL_BALLOON = ( 3 * 1000 + 17 );
+//public static final int Pt_ARG_LABEL_DATA = ( 3 * 1000 + 1 );
+//public static final int Pt_ARG_LABEL_FLAGS = ( 3 * 1000 + 2 );
+ public static final int Pt_ARG_LABEL_TYPE = ( 3 * 1000 + 3 );
+//public static final int Pt_ARG_LINE_CAP = ( 25 * 1000 + 4 );
+//public static final int Pt_ARG_LINE_JOIN = ( 25 * 1000 + 3 );
+//public static final int Pt_ARG_LINE_SPACING = ( 3 * 1000 + 21 );
+//public static final int Pt_ARG_LINE_WIDTH = ( 25 * 1000 + 2 );
+//public static final int Pt_ARG_LIST_BALLOON = ( 23 * 1000 + 31 );
+//public static final int Pt_ARG_LIST_COLUMN_ATTR = ( 23 * 1000 + 28 );
+//public static final int Pt_ARG_LIST_COLUMN_POS = ( 23 * 1000 + 27 );
+//public static final int Pt_ARG_LIST_FLAGS = ( 23 * 1000 + 2 );
+ public static final int Pt_ARG_LIST_FONT = ( 23 * 1000 + 3 );
+ public static final int Pt_ARG_LIST_ITEM_COUNT = ( 23 * 1000 + 14 );
+//public static final int Pt_ARG_LIST_SB_RES = ( 23 * 1000 + 25 );
+//public static final int Pt_ARG_LIST_SCROLL_RATE = ( 23 * 1000 + 26 );
+ public static final int Pt_ARG_LIST_SEL_COUNT = ( 23 * 1000 + 15 );
+//public static final int Pt_ARG_LIST_SPACING = ( 23 * 1000 + 4 );
+ public static final int Pt_ARG_LIST_TOTAL_HEIGHT = ( 23 * 1000 + 16 );
+ public static final int Pt_ARG_MARGIN_BOTTOM = ( 3 * 1000 + 4 );
+//public static final int Pt_ARG_MARGIN_HEIGHT = ( 2 * 1000 + 4 );
+ public static final int Pt_ARG_MARGIN_LEFT = ( 3 * 1000 + 5 );
+ public static final int Pt_ARG_MARGIN_RIGHT = ( 3 * 1000 + 6 );
+ public static final int Pt_ARG_MARGIN_TOP = ( 3 * 1000 + 7 );
+ public static final int Pt_ARG_MARGIN_WIDTH = ( 2 * 1000 + 5 );
+//public static final int Pt_ARG_MAX_HEIGHT = ( 18 * 1000 + 4 );
+ public static final int Pt_ARG_MAX_LENGTH = ( 4 * 1000 + 5 );
+//public static final int Pt_ARG_MAX_WIDTH = ( 18 * 1000 + 5 );
+ public static final int Pt_ARG_MENU_FLAGS = ( 19 * 1000 + 0 );
+//public static final int Pt_ARG_MENU_SPACING = ( 19 * 1000 + 1 );
+//public static final int Pt_ARG_MENU_TEXT_FONT = ( 19 * 1000 + 2 );
+//public static final int Pt_ARG_MENU_TITLE = ( 19 * 1000 + 3 );
+//public static final int Pt_ARG_MENU_TITLE_FONT = ( 19 * 1000 + 4 );
+//public static final int Pt_ARG_MENUBAR_FLAGS = ( 37 * 1000 + 0 );
+//public static final int Pt_ARG_MIN_HEIGHT = ( 18 * 1000 + 6 );
+//public static final int Pt_ARG_MIN_SLIDER_SIZE = ( 29 * 1000 + 11 );
+//public static final int Pt_ARG_MIN_WIDTH = ( 18 * 1000 + 7 );
+//public static final int Pt_ARG_MLTITXT_FLAGS = ( 5 * 1000 + 2 );
+//public static final int Pt_ARG_MODE_ALLOC = 0x000A0000;
+//public static final int Pt_ARG_MODE_ARRAY = 0x000C0000;
+//public static final int Pt_ARG_MODE_BOOLEAN = 0x00080000;
+//public static final int Pt_ARG_MODE_CHAR = 0x00010000;
+//public static final int Pt_ARG_MODE_CHAR_FLAGS = 0x00040000;
+//public static final int Pt_ARG_MODE_LONG = 0x00030000;
+//public static final int Pt_ARG_MODE_INT = Pt_ARG_MODE_LONG;
+//public static final int Pt_ARG_MODE_LINKED = 0x000D0000;
+//public static final int Pt_ARG_MODE_LONG_FLAGS = 0x00060000;
+//public static final int Pt_ARG_MODE_MASK = 0x000F0000;
+//public static final int Pt_ARG_MODE_PTR = 0x00070000;
+//public static final int Pt_ARG_MODE_SHORT = 0x00020000;
+//public static final int Pt_ARG_MODE_SHORT_FLAGS = 0x00050000;
+//public static final int Pt_ARG_MODE_STRALLOC = 0x000B0000;
+//public static final int Pt_ARG_MODE_STRING = 0x000B0000;
+//public static final int Pt_ARG_MODE_STRUCT = 0x00090000;
+//public static final int Pt_ARG_MODE_VARIABLE = 0x00090000;
+//public static final int Pt_ARG_MODIFY_ITEMS = ( 23 * 1000 + 29 );
+//public static final int Pt_ARG_MSG_BUTTON1 = ( 32 * 1000 + 4 );
+//public static final int Pt_ARG_MSG_BUTTON2 = ( 32 * 1000 + 5 );
+//public static final int Pt_ARG_MSG_BUTTON3 = ( 32 * 1000 + 6 );
+//public static final int Pt_ARG_MSG_DEFAULT = ( 32 * 1000 + 7 );
+//public static final int Pt_ARG_MSG_ESCAPE = ( 32 * 1000 + 2 );
+//public static final int Pt_ARG_MSG_FLAGS = ( 32 * 1000 + 11 );
+//public static final int Pt_ARG_MSG_FONT = ( 32 * 1000 + 3 );
+//public static final int Pt_ARG_MSG_TEXT = ( 32 * 1000 + 1 );
+//public static final int Pt_ARG_MSG_TITLE = ( 32 * 1000 + 0 );
+//public static final int Pt_ARG_MULTITEXT_BOTTOM_LINE = ( 5 * 1000 + 8 );
+//public static final int Pt_ARG_MULTITEXT_FLAGS = ( 5 * 1000 + 15 );
+ public static final int Pt_ARG_MULTITEXT_LINE_SPACING = ( 5 * 1000 + 3 );
+ public static final int Pt_ARG_MULTITEXT_NUM_LINES = ( 5 * 1000 + 6 );
+//public static final int Pt_ARG_MULTITEXT_NUM_LINES_VISIBLE = ( 5 * 1000 + 5 );
+//public static final int Pt_ARG_MULTITEXT_QUERY_CHARACTER = ( 5 * 1000 + 11 );
+ public static final int Pt_ARG_MULTITEXT_QUERY_LINE = ( 5 * 1000 + 10 );
+//public static final int Pt_ARG_MULTITEXT_RANGE_ATTRIBUTES = ( 5 * 1000 + 0 );
+//public static final int Pt_ARG_MULTITEXT_ROWS = ( 5 * 1000 + 12 );
+//public static final int Pt_ARG_MULTITEXT_SEGMENTS = ( 5 * 1000 + 4 );
+//public static final int Pt_ARG_MULTITEXT_TABS = ( 5 * 1000 + 13 );
+ public static final int Pt_ARG_MULTITEXT_TOP_LINE = ( 5 * 1000 + 7 );
+ public static final int Pt_ARG_MULTITEXT_WRAP_FLAGS = ( 5 * 1000 + 1 );
+//public static final int Pt_ARG_MULTITEXT_X_SCROLL_POS = ( 5 * 1000 + 9 );
+//public static final int Pt_ARG_MULTITEXT_Y_SCROLL_POS = ( 5 * 1000 + 7 );
+//public static final int Pt_ARG_NUM_FRAMES = ( 101 * 1000 + 1 );
+//public static final int Pt_ARG_NUMERIC_FLAGS = ( 53 * 1000 + 1 );
+//public static final int Pt_ARG_NUMERIC_INCREMENT = ( 53 * 1000 + 3 );
+//public static final int Pt_ARG_NUMERIC_MAX = ( 53 * 1000 + 6 );
+//public static final int Pt_ARG_NUMERIC_MIN = ( 53 * 1000 + 5 );
+//public static final int Pt_ARG_NUMERIC_PRECISION = ( 53 * 1000 + 16 );
+//public static final int Pt_ARG_NUMERIC_PREFIX = ( 53 * 1000 + 7 );
+//public static final int Pt_ARG_NUMERIC_SPACING = ( 53 * 1000 + 17 );
+//public static final int Pt_ARG_NUMERIC_SUFFIX = ( 53 * 1000 + 8 );
+//public static final int Pt_ARG_NUMERIC_TEXT_BORDER = ( 53 * 1000 + 9 );
+//public static final int Pt_ARG_NUMERIC_TEXT_BOT_BORDER_COLOR = ( 53 * 1000 + 14 );
+//public static final int Pt_ARG_NUMERIC_TEXT_COLOR = ( 53 * 1000 + 11 );
+//public static final int Pt_ARG_NUMERIC_TEXT_FILL_COLOR = ( 53 * 1000 + 12 );
+//public static final int Pt_ARG_NUMERIC_TEXT_FLAGS = ( 53 * 1000 + 19 );
+//public static final int Pt_ARG_NUMERIC_TEXT_FONT = ( 53 * 1000 + 10 );
+//public static final int Pt_ARG_NUMERIC_TEXT_TOP_BORDER_COLOR = ( 53 * 1000 + 13 );
+//public static final int Pt_ARG_NUMERIC_UPDOWN_BORDER_WIDTH = ( 53 * 1000 + 18 );
+//public static final int Pt_ARG_NUMERIC_UPDOWN_WIDTH = ( 53 * 1000 + 2 );
+//public static final int Pt_ARG_NUMERIC_VALUE = ( 53 * 1000 + 4 );
+//public static final int Pt_ARG_OFFSET = ( 7 * 1000 + 3 );
+//public static final int Pt_ARG_OFFSET_MASK = 0x0000FFFF;
+//public static final int Pt_ARG_ONOFF_STATE = ( 8 * 1000 + 0 );
+//public static final int Pt_ARG_ORIGIN = ( 25 * 1000 + 5 );
+ public static final int Pt_ARG_PAGE_INCREMENT = ( 29 * 1000 + 5 );
+//public static final int Pt_ARG_PANE_FLAGS = ( 12 * 1000 + 0 );
+//public static final int Pt_ARG_PANE_RECT = ( 12 * 1000 + 1 );
+//public static final int Pt_ARG_POINTS = ( 25 * 1000 + 6 );
+//public static final int Pt_ARG_POLYGON_FLAGS = ( 27 * 1000 + 1 );
+ public static final int Pt_ARG_POS = ( 1 * 1000 + 7 );
+//public static final int Pt_ARG_PRINT_CONTEXT = (46 * 1000 + 0);
+//public static final int Pt_ARG_PRINT_FLAGS = (46 * 1000 + 1);
+//public static final int Pt_ARG_PS_ALL_PAGES_LABEL = (46 * 1000 + 12);
+//public static final int Pt_ARG_PS_COLLATE_METHOD_LABEL = (46 * 1000 + 6);
+//public static final int Pt_ARG_PS_COPIES_LABEL = (46 * 1000 + 10);
+//public static final int Pt_ARG_PS_FILENAME_LABEL = (46 * 1000 + 16);
+//public static final int Pt_ARG_PS_LOCATION_LABEL = (46 * 1000 + 7);
+//public static final int Pt_ARG_PS_NUM_COPIES_LABEL = (46 * 1000 + 5);
+//public static final int Pt_ARG_PS_PAGES_LABEL = (46 * 1000 + 13);
+//public static final int Pt_ARG_PS_PRINT_RANGE_LABEL = (46 * 1000 + 9);
+//public static final int Pt_ARG_PS_PRINTER_LABEL = (46 * 1000 + 8);
+//public static final int Pt_ARG_PS_PROPERTIES_LABEL = (46 * 1000 + 11);
+//public static final int Pt_ARG_PS_SEL_TITLE = (46 * 1000 + 4);
+//public static final int Pt_ARG_PS_SELECTION_LABEL = (46 * 1000 + 15);
+//public static final int Pt_ARG_PS_TOFILE_LABEL = (46 * 1000 + 14);
+//public static final int Pt_ARG_RAW_CALLBACKS = ( 1 * 1000 + 11 );
+//public static final int Pt_ARG_RAW_CONNECT_F = ( 24 * 1000 + 1 );
+//public static final int Pt_ARG_RAW_DRAW_F = ( 24 * 1000 + 0 );
+//public static final int Pt_ARG_RAW_EXTENT_F = ( 24 * 1000 + 2 );
+//public static final int Pt_ARG_RAW_INIT_F = ( 24 * 1000 + 3 );
+//public static final int Pt_ARG_RECT_ROUNDNESS = ( 28 * 1000 + 0 );
+//public static final int Pt_ARG_REGION_CURSOR = ( 1 * 1000 + 2 );
+//public static final int Pt_ARG_REGION_CURSOR_COLOR = ( 1 * 1000 + 3 );
+//public static final int Pt_ARG_REGION_DATA = ( 15 * 1000 + 9 );
+//public static final int Pt_ARG_REGION_FIELDS = ( 15 * 1000 + 2 );
+//public static final int Pt_ARG_REGION_FLAGS = ( 15 * 1000 + 3 );
+//public static final int Pt_ARG_REGION_HANDLE = ( 15 * 1000 + 4 );
+//public static final int Pt_ARG_REGION_INFRONT = ( 15 * 1000 + 10 );
+//public static final int Pt_ARG_REGION_INPUT_GROUP = ( 15 * 1000 + 11 );
+ public static final int Pt_ARG_REGION_OPAQUE = ( 15 * 1000 + 5 );
+//public static final int Pt_ARG_REGION_OWNER = ( 15 * 1000 + 6 );
+//public static final int Pt_ARG_REGION_PARENT = ( 15 * 1000 + 7 );
+ public static final int Pt_ARG_REGION_SENSE = ( 15 * 1000 + 8 );
+ public static final int Pt_ARG_RESIZE_FLAGS = ( 1 * 1000 + 8 );
+//public static final int Pt_ARG_SCROLL_AREA_FLAGS = ( 13 * 1000 + 12 );
+//public static final int Pt_ARG_SCROLL_AREA_INCREMENT_X = ( 13 * 1000 + 0 );
+//public static final int Pt_ARG_SCROLL_AREA_INCREMENT_Y = ( 13 * 1000 + 1 );
+ public static final int Pt_ARG_SCROLL_AREA_MAX_X = ( 13 * 1000 + 2 );
+ public static final int Pt_ARG_SCROLL_AREA_MAX_Y = ( 13 * 1000 + 3 );
+//public static final int Pt_ARG_SCROLL_AREA_POS_X = ( 13 * 1000 + 5 );
+//public static final int Pt_ARG_SCROLL_AREA_POS_Y = ( 13 * 1000 + 4 );
+//public static final int Pt_ARG_SCROLLBAR = ( 23 * 1000 + 11 );
+//public static final int Pt_ARG_SCROLLBAR_FLAGS = ( 29 * 1000 + 9 );
+ public static final int Pt_ARG_SCROLLBAR_WIDTH = ( 23 * 1000 + 5 );
+ public static final int Pt_ARG_SCROLLBAR_X_DISPLAY = ( 13 * 1000 + 6 );
+//public static final int Pt_ARG_SCROLLBAR_X_HEIGHT = ( 13 * 1000 + 7 );
+ public static final int Pt_ARG_SCROLLBAR_Y_DISPLAY = ( 13 * 1000 + 8 );
+//public static final int Pt_ARG_SCROLLBAR_Y_WIDTH = ( 13 * 1000 + 9 );
+//public static final int Pt_ARG_SEL_INDEXES = ( 23 * 1000 + 6 );
+//public static final int Pt_ARG_SEL_MODE = ( 23 * 1000 + 7 );
+//public static final int Pt_ARG_SELECT_SHIFT = ( 3 * 1000 + 9 );
+ public static final int Pt_ARG_SELECTION_FILL_COLOR = ( 23 * 1000 + 12 );
+ public static final int Pt_ARG_SELECTION_INDEXES = ( 23 * 1000 + 6 );
+ public static final int Pt_ARG_SELECTION_MODE = ( 23 * 1000 + 7 );
+ public static final int Pt_ARG_SELECTION_RANGE = ( 4 * 1000 + 12 );
+ public static final int Pt_ARG_SELECTION_TEXT_COLOR = ( 23 * 1000 + 13 );
+ public static final int Pt_ARG_SEP_FLAGS = ( 30 * 1000 + 0 );
+//public static final int Pt_ARG_SEP_ORIENTATION = ( 30 * 1000 + 1 );
+ public static final int Pt_ARG_SEP_TYPE = ( 30 * 1000 + 2 );
+//public static final int Pt_ARG_SERVER_CONNECTION = ( 98 * 1000 + 6 );
+//public static final int Pt_ARG_SERVER_NAME = ( 98 * 1000 + 7 );
+//public static final int Pt_ARG_SERVER_SEND = ( 98 * 1000 + 2 );
+//public static final int Pt_ARG_SET_BITMAP_COLORS = ( 20 * 1000 + 5 );
+//public static final int Pt_ARG_SET_BITMAP_DATA = ( 20 * 1000 + 6 );
+//public static final int Pt_ARG_SET_COLOR = ( 9 * 1000 + 3 );
+//public static final int Pt_ARG_SET_FILL = ( 9 * 1000 + 4 );
+//public static final int Pt_ARG_SHOW_ARROWS = ( 29 * 1000 + 6 );
+//public static final int Pt_ARG_SIZE_MASK = 0xFFC00000;
+//public static final int Pt_ARG_SIZE_SHIFT = 22;
+//public static final int Pt_ARG_SLIDER_FLAGS = ( 22 * 1000 + 0 );
+//public static final int Pt_ARG_SLIDER_HANDLE_HEIGHT = ( 22 * 1000 + 8 );
+//public static final int Pt_ARG_SLIDER_HANDLE_WIDTH = ( 22 * 1000 + 7 );
+//public static final int Pt_ARG_SLIDER_IMAGE = ( 22 * 1000 + 9 );
+//public static final int Pt_ARG_SLIDER_INCREMENT = ( 22 * 1000 + 1 );
+//public static final int Pt_ARG_SLIDER_LABEL_BR = ( 22 * 1000 + 3 );
+//public static final int Pt_ARG_SLIDER_LABEL_BR_COL = ( 22 * 1000 + 5 );
+//public static final int Pt_ARG_SLIDER_LABEL_TL = ( 22 * 1000 + 2 );
+//public static final int Pt_ARG_SLIDER_LABEL_TL_COL = ( 22 * 1000 + 4 );
+//public static final int Pt_ARG_SLIDER_MULTIPLE = ( 22 * 1000 + 6 );
+//public static final int Pt_ARG_SLIDER_ORIENTATION = ( 22 * 1000 + 19 );
+ public static final int Pt_ARG_SLIDER_SIZE = ( 29 * 1000 + 7 );
+//public static final int Pt_ARG_SLIDER_TICK_MAJOR_COL = ( 22 * 1000 + 10 );
+//public static final int Pt_ARG_SLIDER_TICK_MAJOR_DIV = ( 22 * 1000 + 13 );
+//public static final int Pt_ARG_SLIDER_TICK_MAJOR_LEN = ( 22 * 1000 + 14 );
+//public static final int Pt_ARG_SLIDER_TICK_MINOR_COL = ( 22 * 1000 + 11 );
+//public static final int Pt_ARG_SLIDER_TICK_MINOR_DIV = ( 22 * 1000 + 12 );
+//public static final int Pt_ARG_SLIDER_TICK_MINOR_LEN = ( 22 * 1000 + 15 );
+//public static final int Pt_ARG_SLIDER_TROUGH_COL = ( 22 * 1000 + 18 );
+//public static final int Pt_ARG_SLIDER_TROUGH_SIZE = ( 22 * 1000 + 16 );
+//public static final int Pt_ARG_SPACING = ( 9 * 1000 + 5 );
+//public static final int Pt_ARG_TAB_FLAGS = ( 58 * 1000 + 0 );
+//public static final int Pt_ARG_TEMPLATE_1 = ( 5001 * 1000 + 0 );
+//public static final int Pt_ARG_TEMPLATE_2 = ( 5001 * 1000 + 1 );
+//public static final int Pt_ARG_TEXT_CURSOR_WIDTH = ( 4 * 1000 + 18 );
+ public static final int Pt_ARG_TEXT_FLAGS = ( 4 * 1000 + 8 );
+ public static final int Pt_ARG_TEXT_FONT = ( 3 * 1000 + 10 );
+//public static final int Pt_ARG_TEXT_HIGHLIGHT_BACKGROUND_COLOR = ( 4 * 1000 + 17 );
+//public static final int Pt_ARG_TEXT_HIGHLIGHT_TEXT_COLOR = ( 4 * 1000 + 16 );
+ public static final int Pt_ARG_TEXT_STRING = ( 3 * 1000 + 11 );
+//public static final int Pt_ARG_TEXT_SUBSTRING = ( 4 * 1000 + 13 );
+ public static final int Pt_ARG_TIMER_INITIAL = ( 41 * 1000 + 0 );
+//public static final int Pt_ARG_TIMER_REPEAT = ( 41 * 1000 + 1 );
+//public static final int Pt_ARG_TOP_BORDER_COLOR = ( 2 * 1000 + 6 );
+ public static final int Pt_ARG_TOP_ITEM_POS = ( 23 * 1000 + 8 );
+//public static final int Pt_ARG_TRANS_PATTERN = ( 2 * 1000 + 13 );
+//public static final int Pt_ARG_TREE_BALLOON = ( 23 * 1000 + 30 );
+//public static final int Pt_ARG_TREE_FLAGS = ( 23 * 1000 + 18 );
+ public static final int Pt_ARG_TREE_IMAGES = ( 23 * 1000 + 19 );
+//public static final int Pt_ARG_TREE_IMGMASK = ( 23 * 1000 + 20 );
+//public static final int Pt_ARG_UNDERLINE1 = ( 3 * 1000 + 12 );
+//public static final int Pt_ARG_UNDERLINE2 = ( 3 * 1000 + 13 );
+//public static final int Pt_ARG_UNDERLINE_TYPE = ( 3 * 1000 + 14 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_BOT = ( 52 * 1000 + 8 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_BOTTOM = ( 52 * 1000 + 8 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_LEF = ( 52 * 1000 + 9 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_LEFT = ( 52 * 1000 + 9 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_RIGHT = ( 52 * 1000 + 10 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_RIT = ( 52 * 1000 + 10 );
+//public static final int Pt_ARG_UPDOWN_ARM_DATA_TOP = ( 52 * 1000 + 7 );
+//public static final int Pt_ARG_UPDOWN_BOT_BDR_COLOR = ( 52 * 1000 + 12 );
+//public static final int Pt_ARG_UPDOWN_BOTTOM_BORDER_COLOR = ( 52 * 1000 + 12 );
+//public static final int Pt_ARG_UPDOWN_DATA_BOT = ( 52 * 1000 + 4 );
+//public static final int Pt_ARG_UPDOWN_DATA_BOTTOM = ( 52 * 1000 + 4 );
+//public static final int Pt_ARG_UPDOWN_DATA_LEF = ( 52 * 1000 + 5 );
+//public static final int Pt_ARG_UPDOWN_DATA_LEFT = ( 52 * 1000 + 5 );
+//public static final int Pt_ARG_UPDOWN_DATA_RIGHT = ( 52 * 1000 + 6 );
+//public static final int Pt_ARG_UPDOWN_DATA_RIT = ( 52 * 1000 + 6 );
+//public static final int Pt_ARG_UPDOWN_DATA_TOP = ( 52 * 1000 + 3 );
+//public static final int Pt_ARG_UPDOWN_FILL_COLOR = ( 52 * 1000 + 16 );
+//public static final int Pt_ARG_UPDOWN_FLAGS = ( 52 * 1000 + 15 );
+//public static final int Pt_ARG_UPDOWN_HIGHLGHT_ROUND = ( 52 * 1000 + 14 );
+//public static final int Pt_ARG_UPDOWN_HIGHLIGHT_ROUND = ( 52 * 1000 + 14 );
+//public static final int Pt_ARG_UPDOWN_MARGIN_HEIGHT = ( 52 * 1000 + 17 );
+//public static final int Pt_ARG_UPDOWN_MARGIN_WIDTH = ( 52 * 1000 + 18 );
+//public static final int Pt_ARG_UPDOWN_ORIENTATION = ( 52 * 1000 + 1 );
+//public static final int Pt_ARG_UPDOWN_SPACING = ( 52 * 1000 + 2 );
+//public static final int Pt_ARG_UPDOWN_TOP_BDR_COLOR = ( 52 * 1000 + 13 );
+//public static final int Pt_ARG_UPDOWN_TOP_BORDER_COLOR = ( 52 * 1000 + 13 );
+ public static final int Pt_ARG_USER_DATA = ( 1 * 1000 + 14 );
+//public static final int Pt_ARG_VERTICAL_ALIGNMENT = ( 3 * 1000 + 15 );
+ public static final int Pt_ARG_VISIBLE_COUNT = ( 23 * 1000 + 9 );
+//public static final int Pt_ARG_WIN_PARENT = ( 18 * 1000 + 8 );
+//public static final int Pt_ARG_WINDOW_ACTIVE_COLOR = ( 18 * 1000 + 18 );
+//public static final int Pt_ARG_WINDOW_CURSOR_OVERRIDE = ( 18 * 1000 + 9 );
+//public static final int Pt_ARG_WINDOW_FORCE_FRONT = ( 18 * 1000 + 10 );
+//public static final int Pt_ARG_WINDOW_FRONT_WINDOW = ( 18 * 1000 + 22 );
+//public static final int Pt_ARG_WINDOW_HELP_ROOT = ( 18 * 1000 + 20 );
+//public static final int Pt_ARG_WINDOW_INACTIVE_COLOR = ( 18 * 1000 + 19 );
+ public static final int Pt_ARG_WINDOW_MANAGED_FLAGS = ( 18 * 1000 + 11 );
+ public static final int Pt_ARG_WINDOW_NOTIFY_FLAGS = ( 18 * 1000 + 12 );
+ public static final int Pt_ARG_WINDOW_RENDER_FLAGS = ( 18 * 1000 + 13 );
+ public static final int Pt_ARG_WINDOW_STATE = ( 18 * 1000 + 14 );
+ public static final int Pt_ARG_WINDOW_TITLE = ( 18 * 1000 + 15 );
+//public static final int Pt_ARG_WINDOW_TITLE_COLOR = ( 18 * 1000 + 16 );
+ public static final int Pt_AS_REQUIRED = 0x02;
+ public static final int Pt_AUTO_EXTENT = 0x00000002;
+ public static final int Pt_AUTOHIGHLIGHT = 0x00000004;
+//public static final int Pt_BACKFILL_TEXT = 0x10;
+//public static final int Pt_BALLOON_AS_REQUIRED = 0x08;
+ public static final int Pt_BALLOON_BOTTOM = 3;
+//public static final int Pt_BALLOON_INPLACE = 4;
+//public static final int Pt_BALLOON_LEFT = 1;
+//public static final int Pt_BALLOON_PROPAGATE = 0x00000040;
+//public static final int Pt_BALLOON_REGISTERED = 0x80;
+ public static final int Pt_BALLOON_RIGHT = 0;
+//public static final int Pt_BALLOON_TOP = 2;
+//public static final int Pt_BALLOONS_ACTIVE = 0x02000000;
+//public static final int Pt_BALLOONS_LOCKED = 0x80000000;
+//public static final int Pt_BALLOONS_ON = 0x00001000;
+//public static final int Pt_BASIC_RO_FLAGS = 0xffffffff;
+//public static final int Pt_BITMAP = 0x02;
+//public static final int Pt_BITMAP_BALLOON_BOTTOM = 3;
+//public static final int Pt_BITMAP_BALLOON_INPLACE = 4;
+//public static final int Pt_BITMAP_BALLOON_LEFT = 1;
+//public static final int Pt_BITMAP_BALLOON_RIGHT = 0;
+//public static final int Pt_BITMAP_BALLOON_TOP = 2;
+//public static final int Pt_BITMAP_SHOW_BALLOON = 0x04;
+//public static final int Pt_BKGD_ALT = 2;
+//public static final int Pt_BKGD_BRIGHTNESS = 3;
+//public static final int Pt_BKGD_CENTER = 3;
+//public static final int Pt_BKGD_CENTER_GRID = 4;
+//public static final int Pt_BKGD_GRID = 1;
+//public static final int Pt_BKGD_HORIZONTAL = 1;
+//public static final int Pt_BKGD_HUE = 1;
+//public static final int Pt_BKGD_IMAGE = 5;
+//public static final int Pt_BKGD_NONE = 0;
+//public static final int Pt_BKGD_PIXMAP = 4;
+//public static final int Pt_BKGD_SATURATION = 2;
+//public static final int Pt_BKGD_VERTICAL = 2;
+//public static final int Pt_BLIT = 0xFFFF;
+//public static final int Pt_BLIT_FORCE = 0xFFFE;
+//public static final int Pt_BLOCK_CUA_FOCUS = 0x00000001;
+ public static final int Pt_BLOCKED = 0x00020000;
+//public static final int Pt_BOTTOM = 1;
+ public static final int Pt_BOTTOM_ANCHORED_BOTTOM = 0x00000080;
+ public static final int Pt_BOTTOM_ANCHORED_RELATIVE = 0x00000008;
+ public static final int Pt_BOTTOM_ANCHORED_TOP = 0x00000800;
+ public static final int Pt_BOTTOM_IS_ANCHORED = Pt_BOTTOM_ANCHORED_BOTTOM | Pt_BOTTOM_ANCHORED_RELATIVE | Pt_BOTTOM_ANCHORED_TOP;
+//public static final int Pt_BROWSE_MODE = 3;
+//public static final int Pt_CALENDAR_DATE_SELECTED = 1;
+//public static final int Pt_CALENDAR_ID = 56;
+//public static final int Pt_CALENDAR_MONTH_BTNS = 2;
+//public static final int Pt_CALENDAR_MONTH_SELECTED = 3;
+//public static final int Pt_CALENDAR_SHOW_GRID = 16;
+//public static final int Pt_CALENDAR_SHOW_NEXT = 8;
+//public static final int Pt_CALENDAR_SHOW_PREV = 4;
+//public static final int Pt_CALENDAR_WDAY_SELECTED = 2;
+//public static final int Pt_CALENDAR_YEAR_BTNS = 1;
+//public static final int Pt_CALENDAR_YEAR_SELECTED = 4;
+ public static final int Pt_CALLBACKS_ACTIVE = 0x04000000;
+//public static final int Pt_CANVAS_INVALID = 0x00004000;
+ public static final int Pt_CB_ACTIVATE = ( 2 * 1000 + 9 );
+ public static final int Pt_CB_ARM = ( 2 * 1000 + 7 );
+//public static final int Pt_CB_BALLOONS = ( 10 * 1000 + 4 );
+//public static final int Pt_CB_BLOCKED = ( 1 * 1000 + 16 );
+//public static final int Pt_CB_CALENDAR_SELECT = ( 56 * 1000 + 16 );
+//public static final int Pt_CB_CBOX_ACTIVATE = ( 31 * 1000 + 14 );
+//public static final int Pt_CB_CBOX_CLOSE = ( 31 * 1000 + 20 );
+//public static final int Pt_CB_CLIENT_CONNECTED = ( 99 * 1000 + 6 );
+//public static final int Pt_CB_CLIENT_EVENT = ( 99 * 1000 + 3 );
+//public static final int Pt_CB_CLIENT_NOT_FOUND = ( 99 * 1000 + 8 );
+//public static final int Pt_CB_CLOCK_TIME_CHANGED = (57 * 1000 +18);
+//public static final int Pt_CB_DESTROYED = ( 1 * 1000 + 9 );
+//public static final int Pt_CB_DISARM = ( 2 * 1000 + 8 );
+//public static final int Pt_CB_DIVIDER_DRAG = ( 44 * 1000 + 3 );
+//public static final int Pt_CB_DIVIDER_SETRESOURCES = 9;
+//public static final int Pt_CB_FONT_MODIFY = (38 * 1000 + 4);
+//public static final int Pt_CB_FS_BKGD_HANDLER = ( 47 * 1000 + 8 );
+//public static final int Pt_CB_FS_SELECTION = ( 47 * 1000 + 7 );
+//public static final int Pt_CB_FS_STATE = ( 47 * 1000 + 6 );
+//public static final int Pt_CB_GEN_TREE_INPUT = ( 23 * 1000 + 23 );
+ public static final int Pt_CB_GOT_FOCUS = ( 2 * 1000 + 10 );
+//public static final int Pt_CB_HOTKEY = ( 1 * 1000 + 10);
+//public static final int Pt_CB_HTML_ERROR = ( 45 * 1000 + 30 );
+//public static final int Pt_CB_HTML_FILE_POST = ( 45 * 1000 + 16 );
+//public static final int Pt_CB_HTML_FILE_PRE = ( 45 * 1000 + 15 );
+//public static final int Pt_CB_HTML_IMAGE = ( 45 * 1000 + 17 );
+//public static final int Pt_CB_IMAGEAREA_DRAG = ( 103 * 1000 + 15 );
+//public static final int Pt_CB_IMAGEAREA_MOVEMENT = ( 103 * 1000 + 10 );
+//public static final int Pt_CB_IMAGEAREA_SCROLLED = ( 103 * 1000 + 9 );
+//public static final int Pt_CB_IMAGEAREA_SELECTION = ( 103 * 1000 + 11 );
+//public static final int Pt_CB_IMAGETREE_COLUMN_SEL = ( 49 * 1000 + 3 );
+//public static final int Pt_CB_IS_DESTROYED = ( 1 * 1000 + 19 );
+//public static final int Pt_CB_LIST_INPUT = ( 23 * 1000 + 24 );
+ public static final int Pt_CB_LOST_FOCUS = ( 2 * 1000 + 11 );
+//public static final int Pt_CB_MENU = ( 2 * 1000 + 16 );
+//public static final int Pt_CB_MODIFY_NOTIFY = ( 4 * 1000 + 10);
+ public static final int Pt_CB_MODIFY_VERIFY = ( 4 * 1000 + 9 );
+//public static final int Pt_CB_MOTION_NOTIFY = ( 4 * 1000 + 14);
+//public static final int Pt_CB_MOTION_VERIFY = ( 4 * 1000 + 11);
+//public static final int Pt_CB_MSG_BUTTON1 = ( 32 * 1000 + 8 );
+//public static final int Pt_CB_MSG_BUTTON2 = ( 32 * 1000 + 9 );
+//public static final int Pt_CB_MSG_BUTTON3 = ( 32 * 1000 +10 );
+//public static final int Pt_CB_MULTITEXT_SCROLLUPDATE = ( 5 * 1000 + 14 );
+//public static final int Pt_CB_NUMERIC_CHANGED = ( 53 * 1000 + 15 );
+//public static final int Pt_CB_ONOFF_NEW_VALUE = ( 8 * 1000 + 1 );
+//public static final int Pt_CB_PRINT_PROPS = (46 * 1000 + 2);
+//public static final int Pt_CB_PRINT_TOFILE = (46 * 1000 + 3);
+//public static final int Pt_CB_RAW = ( 1 * 1000 + 11 );
+//public static final int Pt_CB_RAW_EVENT = ( 1 * 1000 + 11 );
+ public static final int Pt_CB_REALIZED = ( 1 * 1000 + 12 );
+//public static final int Pt_CB_REPEAT = ( 2 * 1000 + 12 );
+//public static final int Pt_CB_RESCALE = ( 25 * 1000 + 7 );
+ public static final int Pt_CB_RESIZE = ( 10 * 1000 + 3 );
+ public static final int Pt_CB_SCROLL_MOVE = ( 29 * 1000 + 10 );
+//public static final int Pt_CB_SCROLLED_X = ( 13 * 1000 + 10 );
+//public static final int Pt_CB_SCROLLED_Y = ( 13 * 1000 + 11 );
+ public static final int Pt_CB_SELECTION = ( 23 * 1000 + 10 );
+//public static final int Pt_CB_SERVER_CONNECTED = ( 98 * 1000 + 8 );
+//public static final int Pt_CB_SERVER_RECEIVE = ( 98 * 1000 + 3 );
+//public static final int Pt_CB_SERVER_TRANSPORT = ( 98 * 1000 + 4 );
+ public static final int Pt_CB_SLIDER_MOVE = ( 22 * 1000 + 17 );
+//public static final int Pt_CB_STRING_CHANGED = ( 4 * 1000 + 10);
+ public static final int Pt_CB_TEXT_CHANGED = ( 4 * 1000 + 10);
+ public static final int Pt_CB_TIMER_ACTIVATE = ( 41 * 1000 + 2 );
+//public static final int Pt_CB_TREE_SELECTION = ( 23 * 1000 + 22 );
+//public static final int Pt_CB_TREE_STATE = ( 23 * 1000 + 21 );
+ public static final int Pt_CB_UNREALIZED = ( 1 * 1000 + 13 );
+ public static final int Pt_CB_WINDOW = ( 18 * 1000 + 17 );
+//public static final int Pt_CB_WINDOW_CLOSING = ( 18 * 1000 + 24 );
+//public static final int Pt_CB_WINDOW_OPENING = ( 18 * 1000 + 23 );
+//public static final int Pt_CB_WINDOW_TRANSPORT = ( 18 * 1000 + 21 );
+ public static final int Pt_CENTER = 2;
+//public static final int Pt_CHANGE_ACTIVATE = 0x00000020;
+//public static final int Pt_CHANGE_INVISIBLE = 0;
+//public static final int Pt_CHECK = 5;
+//public static final int Pt_CHILD_CREATED = 0x01000000;
+//public static final int Pt_CHILD_DESTROYED = 0x00800000;
+//public static final int Pt_CHILD_GETTING_FOCUS = 0x10000000;
+//public static final int Pt_CHILD_GETTING_RESOURCE = 0x80000000;
+//public static final int Pt_CHILD_LOSING_FOCUS = 0x20000000;
+//public static final int Pt_CHILD_LOST_FOCUS = 0x20000000;
+//public static final int Pt_CHILD_MOVED_RESIZED = 0x08000000;
+//public static final int Pt_CHILD_REALIZED = 0x02000000;
+//public static final int Pt_CHILD_REDIRECTOR = 0x00400000;
+//public static final int Pt_CHILD_SETTING_RESOURCE = 0x40000000;
+//public static final int Pt_CHILD_UNREALIZED = 0x04000000;
+//public static final int Pt_CLEAN_RESOURCES = 0x00000010;
+//public static final int Pt_CLEAR = 0x00010000;
+//public static final int Pt_CLIENT_GETEVENTS = 0x0001;
+//public static final int Pt_CLIENT_NEEDEVENTS = 0x0002;
+//public static final int Pt_CLIENT_NOEVENTS = 0x0002;
+//public static final int Pt_CLIENT_NONBLOCK = 0x0001;
+//public static final int Pt_CLIP_HIGHLIGHT = 0x00000010;
+//public static final int Pt_CLOCK_24_HOUR = 4;
+//public static final int Pt_CLOCK_ANALOG = 1;
+//public static final int Pt_CLOCK_CURRENT = -1;
+//public static final int Pt_CLOCK_DIGITAL = 0;
+//public static final int Pt_CLOCK_HOUR_CHANGED = 1;
+//public static final int Pt_CLOCK_LED = 2;
+//public static final int Pt_CLOCK_MINUTE_CHANGED = 2;
+//public static final int Pt_CLOCK_PAD_HOURS = 32;
+//public static final int Pt_CLOCK_SECOND_CHANGED = 4;
+//public static final int Pt_CLOCK_SHOW_AMPM = 16;
+//public static final int Pt_CLOCK_SHOW_NUMBERS = 8;
+//public static final int Pt_CLOCK_SHOW_SECONDS = 2;
+//public static final int Pt_CLOCK_TRACK_TIME = 1;
+//public static final int Pt_CMT_IN_UPDATE = 0x80000000;
+//public static final int Pt_CMT_SCROLL_CB_ACTIVE = 0x40000000;
+//public static final int Pt_COMBOBOX_ALT_DOWN = 0x00000100;
+//public static final int Pt_COMBOBOX_EXTENTING = 0x20000000;
+//public static final int Pt_COMBOBOX_MAX_WIDTH = 0x00000080;
+//public static final int Pt_COMBOBOX_ON_BOTTOM = 0x40000000;
+//public static final int Pt_COMBOBOX_OPEN = 0x80000000;
+ public static final int Pt_COMBOBOX_STATIC = 0x00000020;
+//public static final int Pt_COMBOBOX_TOP = 0x00000040;
+//public static final int Pt_COMPOUND = 0x00000100;
+//public static final int Pt_CONNECTION_NOTIFY_FLUSH = 4;
+//public static final int Pt_CONNECTION_NOTIFY_NOFLUSH = 2;
+//public static final int Pt_CONNECTION_NOTIFY_RESIZE = 1;
+//public static final int Pt_CONSUME_EVENTS = 0x0001;
+//public static final int Pt_CONTAINER = 0x00000001;
+//public static final int Pt_CONTAINER_ANCHORING = 0x20000000;
+//public static final int Pt_CONTAINER_CONSTRAINT_BITS = 0xFFFF0000;
+//public static final int Pt_CONTAINER_FLAGS_MASK = 0x00001fff;
+//public static final int Pt_CONTAINER_RESIZING = 0x01000000;
+ public static final int Pt_CONTINUE = 0;
+//public static final int Pt_CURSOR_IN_CONTAINER = 0x00001000;
+//public static final int Pt_CURSOR_VISIBLE = 0x00000001;
+//public static final int Pt_DAMAGE_FAMILY = 0x00040000;
+//public static final int Pt_DAMAGE_ON_FOCUS = 0x8000;
+//public static final int Pt_DAMAGE_PARENT = 0x4000;
+//public static final int Pt_DAMAGED = 0x00002000;
+//public static final int Pt_DB_INLINE_IMAGE = 0x00000001;
+ public static final int Pt_DEFAULT_COLOR = (-3);
+//public static final int Pt_DEFAULT_FONT = (0);
+ public static final int Pt_DELAY_ACTIVATION = 0x00000040;
+ public static final int Pt_DELAY_REALIZE = Pt_DELAY_ACTIVATION;
+//public static final int Pt_DESTROYED = 0x00001000;
+//public static final int Pt_DISABLE_BALLOONS = 0x00000008;
+//public static final int Pt_DISCONTINUOUS = 0x00000004;
+//public static final int Pt_DISJOINT = 0x00000080;
+//public static final int Pt_DIVIDER_CASCADE = 0x0008;
+//public static final int Pt_DIVIDER_INVISIBLE = 0x0004;
+//public static final int Pt_DIVIDER_NORESIZE = 0x0001;
+//public static final int Pt_DIVIDER_RESIZE_BOTH = 0x0002;
+//public static final int Pt_DOOMED = 0x0800;
+//public static final int Pt_DOUBLE_DASH_LINE = 3;
+//public static final int Pt_DOUBLE_LINE = 1;
+//public static final int Pt_DOUBLE_ULINE = 2;
+//public static final int Pt_DRAW_COPY_RECTS = 0x0010;
+//public static final int Pt_DRAW_DEFAULT = 0x0000;
+//public static final int Pt_DRAW_MODE_MASK = 0x000F;
+//public static final int Pt_DRAW_OVERWRITE = 0x0001;
+//public static final int Pt_DRAW_RAW = 0x0002;
+//public static final int Pt_DRAW_START = 0x0003;
+//public static final int Pt_DYNAMIC = 0;
+//public static final int Pt_EDIT_ACTIVATE = 1;
+ public static final int Pt_EDITABLE = 0x00000002;
+//public static final int Pt_EMT_AUTOINDENT = 0x00000010;
+ public static final int Pt_EMT_CHAR = 0x02;
+//public static final int Pt_EMT_DISABLE_PURGE = 0x40000000;
+//public static final int Pt_EMT_FOCUSED = 0x20000000;
+//public static final int Pt_EMT_FORCED_SCROLL = 0x00000040;
+//public static final int Pt_EMT_FULL_LINES = 0x00000020;
+ public static final int Pt_EMT_NEWLINE = 0x04;
+//public static final int Pt_EMT_NO_TABS = 0x00000080;
+//public static final int Pt_EMT_READ_ONLY_FLAGS = Pt_EMT_DISABLE_PURGE | Pt_EMT_FOCUSED;
+//public static final int Pt_EMT_SCROLL_TO_CURSOR = 0x80000000;
+ public static final int Pt_EMT_WORD = 0x01;
+//public static final int Pt_ENABLE_CUA = 0x00000010;
+//public static final int Pt_ENABLE_CUA_ARROWS = 0x00000020;
+ public static final int Pt_END = 2;
+//public static final int Pt_ESC_DISABLE = 0x8;
+//public static final int Pt_ETCH_HIGHLIGHT = 0x00000200;
+ public static final int Pt_ETCHED_IN = 4;
+ public static final int Pt_ETCHED_OUT = 5;
+//public static final int Pt_EV_REDIRECTED = (Ph_EV_BUT_PRESS|Ph_EV_BUT_RELEASE|Ph_EV_KEY|Ph_EV_BUT_REPEAT);
+ public static final int Pt_EXTENDED_MODE = 4;
+//public static final int Pt_FALSE = 0;
+//public static final int Pt_FD_DRAIN = 0x00000001;
+//public static final int Pt_FD_NOPOLL = 0x8;
+//public static final int Pt_FD_OBAND = 0x40000000;
+//public static final int Pt_FD_READ = 0x10000000;
+//public static final int Pt_FD_WRITE = 0x20000000;
+//public static final int Pt_FEP_PRESENT = 0x00000002;
+//public static final int Pt_FEP_QUERIED = 0x00000004;
+//public static final int Pt_FLOAT_ORIGIN = 0x02;
+//public static final int Pt_FLOAT_POS = 0x01;
+//public static final int Pt_FOCUS_RENDER = 0x02000000;
+//public static final int Pt_FONTSEL_AA_CHECK = 0x01;
+//public static final int Pt_FONTSEL_ALL_FONTS = PHFONT_ALL_FONTS;
+//public static final int Pt_FONTSEL_ALL_SYMBOLS = PHFONT_ALL_SYMBOLS;
+//public static final int Pt_FONTSEL_BITMAP = PHFONT_BITMAP;
+//public static final int Pt_FONTSEL_FIXED = PHFONT_FIXED;
+//public static final int Pt_FONTSEL_PROP = PHFONT_PROP;
+//public static final int Pt_FONTSEL_SAMPLE = 0x02;
+//public static final int Pt_FONTSEL_SCALABLE = PHFONT_SCALABLE;
+//public static final int Pt_FORCE_UNREALIZE = 0x00000040;
+//public static final int Pt_FREE_MEMORY = 0x20000000;
+//public static final int Pt_FS_DIR_CL = 1;
+//public static final int Pt_FS_DIR_OP = 0;
+//public static final int Pt_FS_DLINK_CL = 3;
+//public static final int Pt_FS_DLINK_OP = 2;
+//public static final int Pt_FS_ERROR = 6;
+//public static final int Pt_FS_FILE = 4;
+//public static final int Pt_FS_FLINK = 5;
+//public static final int Pt_FS_FREE_ON_COLLAPSE = 0x10;
+//public static final int Pt_FS_NEW_DIR = 0;
+//public static final int Pt_FS_NEW_ITEM = 1;
+//public static final int Pt_FS_NO_ROOT_DISPLAY = 0x80;
+//public static final int Pt_FS_OLD_DIR = 1;
+//public static final int Pt_FS_OLD_ITEM = -1;
+//public static final int Pt_FS_SEEK_KEY = 0x30;
+//public static final int Pt_FS_SHOW_DIRS = 0x1;
+//public static final int Pt_FS_SHOW_ERRORS = 0x8;
+//public static final int Pt_FS_SHOW_FILES = 0x2;
+//public static final int Pt_FS_SHOW_HIDDEN = 0x4;
+//public static final int Pt_FS_SINGLE_LEVEL = 0x20;
+//public static final int Pt_FS_ALL_FLAGS = Pt_FS_SHOW_DIRS|Pt_FS_SHOW_FILES|Pt_FS_SHOW_HIDDEN|Pt_FS_SHOW_ERRORS|Pt_FS_FREE_ON_COLLAPSE|Pt_FS_SINGLE_LEVEL|Pt_FS_SEEK_KEY;
+//public static final int Pt_FS_STATE_END = 2;
+//public static final int Pt_FS_STATE_START = 1;
+//public static final int Pt_FSDIALOG_BTN1 = 1;
+ public static final int Pt_FSDIALOG_BTN2 = 2;
+//public static final int Pt_FSDIALOG_CANCEL = 1;
+//public static final int Pt_FSDIALOG_NO_DIRS = 0x10;
+//public static final int Pt_FSDIALOG_NO_FCHECK = 0x1;
+//public static final int Pt_FSDIALOG_NO_FILES = 0x20;
+//public static final int Pt_FSDIALOG_NO_FSPEC = 0x4;
+//public static final int Pt_FSDIALOG_NO_UP_BUTTON = 0x4;
+//public static final int Pt_FSDIALOG_OPEN = 2;
+//public static final int Pt_FSDIALOG_SHOW_HIDDEN = 0x8;
+//public static final int Pt_GAUGE_MAX_ON_BOTTOM = 1;
+//public static final int Pt_GAUGE_MAX_ON_LEFT = 1;
+//public static final int Pt_GAUGE_MAX_ON_RIGHT = 0;
+//public static final int Pt_GAUGE_MAX_ON_TOP = 0;
+//public static final int Pt_GAUGE_LIVE = 0x40;
+//public static final int Pt_GEN_LIST_FULL_WIDTH = 0x08;
+//public static final int Pt_GEN_LIST_ITEM_BACKGROUND = 0x20;
+//public static final int Pt_GEN_LIST_NO_AUTOFOCUS = 0x10;
+//public static final int Pt_GEN_LIST_NO_BACKGROUND = 0x01;
+//public static final int Pt_GEN_LIST_NO_CLIPPING = 0x02;
+//public static final int Pt_GEN_LIST_SHOW_DAMAGED = 0x04;
+ public static final int Pt_GETS_FOCUS = 0x00000400;
+ public static final int Pt_GHOST = 0x01000000;
+//public static final int Pt_GROUP_ASIS = 2;
+ public static final int Pt_GROUP_EQUAL_SIZE = 0x00000002;
+//public static final int Pt_GROUP_EQUAL_SIZE_HORIZONTAL = 0x00000100;
+//public static final int Pt_GROUP_EQUAL_SIZE_VERTICAL = 0x00000200;
+//public static final int Pt_GROUP_EXCLUSIVE = 0x00000001;
+//public static final int Pt_GROUP_HORIZONTAL = 0;
+//public static final int Pt_GROUP_HORZ_CENTER = 0;
+//public static final int Pt_GROUP_HORZ_LEFT = 1;
+//public static final int Pt_GROUP_HORZ_NONE = -1;
+ public static final int Pt_GROUP_HORZ_RIGHT = 2;
+//public static final int Pt_GROUP_NO_KEY_WRAP_HORIZONTAL = 0x00000010;
+//public static final int Pt_GROUP_NO_KEY_WRAP_VERTICAL = 0x00000020;
+//public static final int Pt_GROUP_NO_KEY_WRAP = (Pt_GROUP_NO_KEY_WRAP_HORIZONTAL | Pt_GROUP_NO_KEY_WRAP_VERTICAL );
+//public static final int Pt_GROUP_NO_KEYS = 0x00000008;
+//public static final int Pt_GROUP_NO_SELECT_ALLOWED = 0x00000004;
+//public static final int Pt_GROUP_STRETCH_FILL = 0x00001000;
+//public static final int Pt_GROUP_STRETCH_HORIZONTAL = 0x00000400;
+//public static final int Pt_GROUP_STRETCH_VERTICAL = 0x00000800;
+//public static final int Pt_GROUP_STRETCH = (Pt_GROUP_STRETCH_VERTICAL|Pt_GROUP_STRETCH_HORIZONTAL);
+//public static final int Pt_GROUP_VERT_BOTTOM = 2;
+ public static final int Pt_GROUP_VERT_CENTER = 0;
+//public static final int Pt_GROUP_VERT_NONE = -1;
+//public static final int Pt_GROUP_VERT_TOP = 1;
+//public static final int Pt_GROUP_VERTICAL = 1;
+//public static final int Pt_HALT = 1;
+ public static final int Pt_HIGHLIGHTED = 0x00000100;
+ public static final int Pt_HORIZONTAL = 1;
+//public static final int Pt_HOTKEY_IGNORE_MODS = 0x0002;
+//public static final int Pt_HOTKEY_SYM = 0x0001;
+//public static final int Pt_HOTKEY_TERMINATOR = 0x00000004;
+//public static final int Pt_HOTKEYS_FIRST = 0x00000080;
+//public static final int Pt_HTML_DISPLAY = 0x01;
+//public static final int Pt_HTML_LOAD = 0x08;
+//public static final int Pt_HTML_PAGE = 0x10;
+//public static final int Pt_HTML_PAGE_MODE = 0x2;
+//public static final int Pt_HTML_REDIRECT = 0x04;
+//public static final int Pt_HTML_RELOAD = 0x1;
+//public static final int Pt_HTML_RESIZE = 0x02;
+//public static final int Pt_IGNORE_CONSTRAINTS = 0x00008000;
+ public static final int Pt_IMAGE = 0x04;
+//public static final int Pt_IMAGEAREA_AUTOSCALE = 0x2;
+//public static final int Pt_IMAGEAREA_COMPLETE = 3;
+//public static final int Pt_IMAGEAREA_DRAG = 2;
+//public static final int Pt_IMAGEAREA_EDITABLE_SELECTION = 0x8;
+//public static final int Pt_IMAGEAREA_ENABLE_SELECTION = 0x4;
+//public static final int Pt_IMAGEAREA_IMGCRC_VALID = 0x1;
+//public static final int Pt_IMAGEAREA_INIT = 1;
+//public static final int Pt_IMAGEAREA_NO_MEMORY = 0x10;
+//public static final int Pt_IMAGEAREA_PALCRC_VALID = 0x2;
+//public static final int Pt_IMAGEAREA_RENDERED = 0x1;
+//public static final int Pt_IMAGEAREA_SCROLLED_X = 1;
+//public static final int Pt_IMAGEAREA_SCROLLED_Y = 2;
+//public static final int Pt_IMMEDIATE_CHILD = 1;
+//public static final int Pt_IN_EXPOSE = 0x00000008;
+//public static final int Pt_IN_FLUX = 0x00008000;
+//public static final int Pt_INDEX_RESOURCES = 0x00000020;
+//public static final int Pt_INFLATE_BALLOON = 0;
+//public static final int Pt_INHERIT_COLOR = (-4);
+//public static final int Pt_INHERIT_FONT = (-1);
+ public static final int Pt_INITIAL = 0x04;
+//public static final int Pt_INITIALIZED = 0x04000000;
+//public static final int PT_INPUT_ID = 1;
+//public static final int Pt_INSERT_MODE = 0x00000008;
+//public static final int Pt_INTERNAL_HELP = 0x0002;
+//public static final int Pt_LABEL_SELECT_SHIFT = 0x01;
+ public static final int Pt_LEFT = 0;
+ public static final int Pt_LEFT_ANCHORED_LEFT = 0x00000100;
+ public static final int Pt_LEFT_ANCHORED_RELATIVE = 0x00000001;
+ public static final int Pt_LEFT_ANCHORED_RIGHT = 0x00000010;
+ public static final int Pt_LEFT_IS_ANCHORED = Pt_LEFT_ANCHORED_LEFT | Pt_LEFT_ANCHORED_RELATIVE | Pt_LEFT_ANCHORED_RIGHT;
+//public static final int Pt_LINK_DELETE = -2;
+//public static final int Pt_LINK_INSERT = -1;
+//public static final int Pt_LIST_BALLOON_AS_REQUIRED = 0x0040;
+//public static final int Pt_LIST_BALLOON_CENTER = (-3);
+//public static final int Pt_LIST_BALLOON_LEFT = (-1);
+//public static final int Pt_LIST_BALLOON_MASK = 0x0060;
+//public static final int Pt_LIST_BALLOON_NEVER = 0x0000;
+//public static final int Pt_LIST_BALLOON_REGISTERED = 0x0080;
+//public static final int Pt_LIST_BALLOON_RIGHT = (-2);
+//public static final int Pt_LIST_BALLOONS_IN_COLUMNS = 0x1000;
+//public static final int Pt_LIST_BOUNDARY_KEY_EVENTS = 0x2000;
+//public static final int Pt_LIST_COLUMN_ALIGNMENT = ( Pg_TEXT_LEFT | Pg_TEXT_RIGHT | Pg_TEXT_CENTER );
+//public static final int Pt_LIST_COLUMN_CENTER = Pg_TEXT_CENTER;
+//public static final int Pt_LIST_COLUMN_DAMAGE_ALWAYS = 0x0001;
+//public static final int Pt_LIST_COLUMN_LEFT = Pg_TEXT_LEFT;
+//public static final int Pt_LIST_COLUMN_RIGHT = Pg_TEXT_RIGHT;
+//public static final int Pt_LIST_FIND_STRING = 6;
+//public static final int Pt_LIST_GOTO_POS = 10;
+//public static final int Pt_LIST_HEADER_AUTORESIZE = 0x0400;
+//public static final int Pt_LIST_INACTIVE = 0x0004;
+//public static final int Pt_LIST_INSERT_ITEMS = 1;
+//public static final int Pt_LIST_ITEM_ABOVE = 0x010;
+//public static final int Pt_LIST_ITEM_BELOW = 0x020;
+//public static final int Pt_LIST_ITEM_CURRENT = 0x002;
+//public static final int Pt_LIST_ITEM_DAMAGED = 0x008;
+//public static final int Pt_LIST_ITEM_DISABLED = 0x004;
+//public static final int Pt_LIST_ITEM_NOCOLUMNS = 0x200;
+//public static final int Pt_LIST_ITEM_SAVED = 0x100;
+//public static final int Pt_LIST_ITEM_SELECTED = 0x001;
+//public static final int Pt_LIST_ITEM_USED_FLAGS = 0x33F;
+//public static final int Pt_LIST_MOD_LONG_POSITIONS = 5;
+//public static final int Pt_LIST_MOD_RANGE = 3;
+//public static final int Pt_LIST_MOD_SHORT_POSITIONS = 4;
+//public static final int Pt_LIST_MOD_STRINGS = 2;
+//public static final int Pt_LIST_NOBLIT = 0x0200;
+//public static final int Pt_LIST_NON_SELECT = 0x0008;
+//public static final int Pt_LIST_REMOVE_ALL_ITEMS = 0;
+//public static final int Pt_LIST_SCROLL_LIST = 0x00;
+//public static final int Pt_LIST_SCROLL_SCROLLBAR = 0x01;
+//public static final int Pt_LIST_SCROLLBAR_ALWAYS = 0x0001;
+//public static final int Pt_LIST_SCROLLBAR_AS_REQUIRED = 0x0002;
+//public static final int Pt_LIST_SCROLLBAR_AUTORESIZE = 0x0800;
+//public static final int Pt_LIST_SCROLLBAR_GETS_FOCUS = 0x0100;
+//public static final int Pt_LIST_SCROLLBAR_MASK = 0x0003;
+//public static final int Pt_LIST_SCROLLBAR_NEVER = 0x0000;
+//public static final int Pt_LIST_SELECT_POS = 7;
+//public static final int Pt_LIST_SELECTION_BROWSE = 0x01;
+//public static final int Pt_LIST_SELECTION_CANCEL = 0x02;
+ public static final int Pt_LIST_SELECTION_FINAL = 0x00;
+//public static final int Pt_LIST_SHOW_BALLOON = 0x0020;
+//public static final int Pt_LIST_SHOW_POS = 9;
+//public static final int Pt_LIST_SNAP = 0x0010;
+//public static final int Pt_LIST_UNSELECT_POS = 8;
+//public static final int Pt_MAX_ON_BOTTOM = 1;
+//public static final int Pt_MAX_ON_LEFT = 0;
+//public static final int Pt_MAX_ON_RIGHT = 1;
+//public static final int Pt_MAX_ON_TOP = 0;
+ public static final int Pt_MENU_AUTO = 0x00000001;
+//public static final int Pt_MENU_BAR = 1;
+ public static final int Pt_MENU_BUTTON = 0x00000800;
+ public static final int Pt_MENU_CHILD = 0x00000008;
+ public static final int Pt_MENU_DOWN = 3;
+//public static final int Pt_MENU_END_RELEASE = 0x40000000;
+//public static final int Pt_MENU_FOCUS = 0x20000000;
+//public static final int Pt_MENU_GOT_FOCUS = 0x10000000;
+//public static final int Pt_MENU_NAVIGATE = 1;
+//public static final int Pt_MENU_ON_LEFT = 0x08000000;
+//public static final int Pt_MENU_ON_TOP = 0x04000000;
+//public static final int Pt_MENU_PDR_ON = 0x80000000;
+ public static final int Pt_MENU_RIGHT = 2;
+//public static final int Pt_MENU_TEAR_OFF = 0x00000004;
+//public static final int Pt_MENU_TEXT = 0;
+//public static final int Pt_MENU_TRANSIENT = 0x00000002;
+//public static final int Pt_MENU_UP = 4;
+//public static final int Pt_MENUABLE = 0x08000000;
+//public static final int Pt_MENUBAR_LAST_R_ALIGNED = 0x0001;
+//public static final int Pt_MENUBAR_MENU_OPEN = 0x8000;
+//public static final int Pt_MERGE_NEXT = 0x80000000;
+//public static final int Pt_MERGE_PREV = 0x40000000;
+ public static final int Pt_MODAL = 0x4;
+//public static final int Pt_MSG_CENTER_ON_PARENT = 0x1;
+//public static final int Pt_MSG_FONT_ON_BUTTONS = 0x2;
+//public static final int Pt_MT_ALIGN_BITS = 0x00000007;
+//public static final int Pt_MT_BACKGROUND = 0x0004;
+//public static final int Pt_MT_BACKGROUND_COLOR = 0x0004;
+//public static final int Pt_MT_CENTER = 0x00000002;
+//public static final int Pt_MT_FLAGS = 0x0010;
+//public static final int Pt_MT_FONT = 0x0001;
+//public static final int Pt_MT_FOREGROUND = 0x0002;
+//public static final int Pt_MT_LEFT = 0x00000004;
+//public static final int Pt_MT_QUERY_CHAR = 0;
+//public static final int Pt_MT_QUERY_LINE = 1;
+//public static final int Pt_MT_RIGHT = 0x00000001;
+//public static final int Pt_MT_TAG = 0x0008;
+//public static final int Pt_MT_TEXT_COLOR = 0x0002;
+//public static final int Pt_MT_UPDATE_POS_ONLY = 4;
+//public static final int Pt_MT_UPDATE_X_SCROLLBAR = 2;
+//public static final int Pt_MT_UPDATE_Y_SCROLLBAR = 1;
+ public static final int Pt_MULTIPLE_MODE = 2;
+//public static final int Pt_MULTITEXT = 0x20;
+ public static final int Pt_N_OF_MANY = 0;
+ public static final int Pt_NEVER = 0x00;
+//public static final int Pt_NO_INHERITED_RESOURCES = 0x00000400;
+//public static final int Pt_NO_RANGE_SELECTION = 0x00000040;
+//public static final int Pt_NO_ULINE = 0;
+ public static final int Pt_NOLINE = 6;
+//public static final int Pt_NOREDRAW_SET = 0x10000000;
+//public static final int Pt_NUMERIC_ACTIVATE = 0x2;
+//public static final int Pt_NUMERIC_AUTO_HIGHLIGHT = 0x08;
+//public static final int Pt_NUMERIC_CHANGED = 0x1;
+//public static final int Pt_NUMERIC_ENABLE_UPDOWN = 0x01;
+//public static final int Pt_NUMERIC_HEXADECIMAL = 0x10;
+//public static final int Pt_NUMERIC_UPDOWN_ACTIVATE = 0x8;
+//public static final int Pt_NUMERIC_UPDOWN_REPEAT = 0x4;
+//public static final int Pt_NUMERIC_USE_SEPARATORS = 0x02;
+//public static final int Pt_NUMERIC_VALUE_CHANGED = 0x80000000;
+//public static final int Pt_NUMERIC_WRAP = 0x04;
+//public static final int Pt_OBSCURED = 0x00004000;
+//public static final int Pt_OCCLUSIVE = 0x00000800;
+ public static final int Pt_ONE_OF_MANY = 1;
+//public static final int Pt_OPAQUE = 0x00000020;
+//public static final int Pt_PANE_XLR_ANCHOR_RIGHT = 0x0020;
+//public static final int Pt_PANE_XLR_REL = 0x0002;
+//public static final int Pt_PANE_XUL_ANCHOR_RIGHT = 0x0010;
+//public static final int Pt_PANE_XUL_REL = 0x0001;
+//public static final int Pt_PANE_YLR_ANCHOR_BOTTOM = 0x0080;
+//public static final int Pt_PANE_YLR_REL = 0x0008;
+//public static final int Pt_PANE_YUL_ANCHOR_BOTTOM = 0x0040;
+//public static final int Pt_PANE_YUL_REL = 0x0004;
+//public static final int Pt_PASS_END = 3;
+//public static final int Pt_PEN_PRESENT = 0x00000001;
+//public static final int Pt_POP_BALLOON = 1;
+//public static final int Pt_POSITIONING = 1;
+//public static final int Pt_PP_NO_RESIZE = 2;
+//public static final int Pt_PP_RESIZE_PC = 1;
+//public static final int Pt_PP_RESIZE_WIDGET = 0;
+//public static final int Pt_PROCREATED = 0x00400000;
+ public static final int Pt_RADIO = 2;
+ public static final int Pt_RANGE_MODE = 5;
+//public static final int Pt_REALIZED = 0x00000001;
+//public static final int Pt_REALIZING = 0x80000000;
+//public static final int Pt_RECTANGULAR = 0x00000002;
+//public static final int Pt_REGION = 0x40000000;
+//public static final int Pt_RELATIVE = 0x10;
+ public static final int Pt_RESIZE_BITS = 0x07;
+//public static final int Pt_RESIZE_WIDTH = 0x00000004;
+ public static final int Pt_RESIZE_Y_SHIFT = 20;
+ public static final int Pt_RESIZE_X_SHIFT = 23;
+ public static final int Pt_RESIZE_X_ALWAYS = (Pt_ALWAYS << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_X_AS_REQUIRED = (Pt_AS_REQUIRED << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_X_BITS = (Pt_RESIZE_BITS << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_X_INITIAL = (Pt_INITIAL << Pt_RESIZE_X_SHIFT);
+ public static final int Pt_RESIZE_Y_ALWAYS = (Pt_ALWAYS << Pt_RESIZE_Y_SHIFT);
+ public static final int Pt_RESIZE_Y_AS_REQUIRED = (Pt_AS_REQUIRED << Pt_RESIZE_Y_SHIFT);
+ public static final int Pt_RESIZE_Y_BITS = (Pt_RESIZE_BITS << Pt_RESIZE_Y_SHIFT);
+ public static final int Pt_RESIZE_Y_INITIAL = (Pt_INITIAL << Pt_RESIZE_Y_SHIFT);
+//public static final int Pt_RESIZE_XY_ALWAYS = (Pt_RESIZE_X_ALWAYS |Pt_RESIZE_Y_ALWAYS);
+ public static final int Pt_RESIZE_XY_AS_REQUIRED = (Pt_RESIZE_X_AS_REQUIRED|Pt_RESIZE_Y_AS_REQUIRED);
+ public static final int Pt_RESIZE_XY_BITS = (Pt_RESIZE_X_BITS |Pt_RESIZE_Y_BITS);
+//public static final int Pt_RESIZE_XY_INITIAL = (Pt_RESIZE_X_INITIAL |Pt_RESIZE_Y_INITIAL);
+ public static final int Pt_RIGHT = 1;
+ public static final int Pt_RIGHT_ANCHORED_LEFT = 0x00000200;
+ public static final int Pt_RIGHT_ANCHORED_RELATIVE = 0x00000002;
+ public static final int Pt_RIGHT_ANCHORED_RIGHT = 0x00000020;
+ public static final int Pt_RIGHT_IS_ANCHORED = Pt_RIGHT_ANCHORED_LEFT | Pt_RIGHT_ANCHORED_RELATIVE | Pt_RIGHT_ANCHORED_RIGHT;
+//public static final int Pt_ROUND = 3;
+//public static final int Pt_SCROLL_AREA_IGNORE_KEYS = 0x0001;
+//public static final int Pt_SCROLL_AREA_RO_FLAGS = 0x0000;
+//public static final int Pt_SCROLL_AREA_TRACK_FOCUS = 0x0002;
+ public static final int Pt_SCROLL_DECREMENT = 1;
+//public static final int Pt_SCROLL_DECREMENT_PRESSED = 0x2000;
+ public static final int Pt_SCROLL_DRAGGED = 7;
+//public static final int Pt_SCROLL_HORIZONTAL = 0;
+ public static final int Pt_SCROLL_INCREMENT = 2;
+//public static final int Pt_SCROLL_INCREMENT_PRESSED = 0x4000;
+//public static final int Pt_SCROLL_INVERTED = 2;
+ public static final int Pt_SCROLL_PAGE_DECREMENT = 4;
+ public static final int Pt_SCROLL_PAGE_INCREMENT = 3;
+//public static final int Pt_SCROLL_PRESSED_MASK = 0xe000;
+//public static final int Pt_SCROLL_RELEASED = 8;
+//public static final int Pt_SCROLL_RESTART_DRAG = 0x1000;
+//public static final int Pt_SCROLL_SET = 9;
+//public static final int Pt_SCROLL_SHOW_ARROWS = 1;
+//public static final int Pt_SCROLL_SLIDER_PRESSED = 0x8000;
+ public static final int Pt_SCROLL_TO_MAX = 5;
+ public static final int Pt_SCROLL_TO_MIN = 6;
+//public static final int Pt_SCROLLAREA_EXTENTING = 0x8000;
+//public static final int Pt_SCROLLBAR_FOCUSED = 0x0080;
+//public static final int Pt_SCROLLBAR_HORIZONTAL = 0x0001;
+//public static final int Pt_SCROLLBAR_INVERTED = 0x0004;
+//public static final int Pt_SCROLLBAR_NOTIFY_ONLY = 0x0008;
+//public static final int Pt_SCROLLBAR_SHOW_ARROWS = 0x0002;
+ public static final int Pt_SELECT_NOREDRAW = 0x00080000;
+ public static final int Pt_SELECTABLE = 0x00000080;
+ public static final int Pt_SELECTION_MODE_AUTO = 0x8200;
+//public static final int Pt_SELECTION_MODE_COMPOSE_FLAG = 0x8000;
+//public static final int Pt_SELECTION_MODE_COMPOSE_MASK = 0x9FF0;
+ public static final int Pt_SELECTION_MODE_MULTIPLE = 0x8000;
+ public static final int Pt_SELECTION_MODE_NOCLEAR = 0x8400;
+ public static final int Pt_SELECTION_MODE_NOFOCUS = 0x9000;
+ public static final int Pt_SELECTION_MODE_NOMOVE = 0x8080;
+//public static final int Pt_SELECTION_MODE_NONE = 0x8030;
+//public static final int Pt_SELECTION_MODE_NOREST = 0x8100;
+ public static final int Pt_SELECTION_MODE_NOSCROLL = 0x8040;
+ public static final int Pt_SELECTION_MODE_RANGE = 0x8010;
+ public static final int Pt_SELECTION_MODE_SINGLE = 0x8020;
+ public static final int Pt_SELECTION_MODE_TOGGLE = 0x8800;
+ public static final int Pt_SEP_HORIZONTAL = 1;
+//public static final int Pt_SEP_HORIZONTAL_F = 1;
+//public static final int Pt_SEP_ORIENTATION = 0x01;
+ public static final int Pt_SEP_VERTICAL = 0;
+ public static final int Pt_SET = 0x00000002;
+//public static final int Pt_SHOW_BALLOON = 0x04;
+//public static final int Pt_SHOW_VALUE = 0x10;
+//public static final int Pt_SHOW_VALUE_BOTTOM = 0x20;
+//public static final int Pt_SHOW_VALUE_CENTER = 0xc0;
+//public static final int Pt_SHOW_VALUE_LEFT = 0x40;
+//public static final int Pt_SHOW_VALUE_MASK = 0xf0;
+//public static final int Pt_SHOW_VALUE_RIGHT = 0x80;
+//public static final int Pt_SHOW_VALUE_TOP = 0x10;
+//public static final int Pt_SINGLE_DASH_LINE = 2;
+//public static final int Pt_SINGLE_LINE = 0;
+//public static final int Pt_SINGLE_MODE = 1;
+//public static final int Pt_SINGLE_ULINE = 1;
+//public static final int Pt_SKIP_CHILDREN = 0x2000;
+//public static final int Pt_SLIDER_IMAGE = 0x80;
+//public static final int Pt_SLIDER_MASK = 0x70;
+//public static final int Pt_SLIDER_MIN_ON_BOTTOM = 1;
+//public static final int Pt_SLIDER_MIN_ON_LEFT = 0;
+//public static final int Pt_SLIDER_MIN_ON_RIGHT = 1;
+//public static final int Pt_SLIDER_MIN_ON_TOP = 0;
+//public static final int Pt_SLIDER_POINT_DOWN = 0x40;
+//public static final int Pt_SLIDER_POINT_LEFT = 0x20;
+//public static final int Pt_SLIDER_POINT_RIGHT = 0x40;
+//public static final int Pt_SLIDER_POINT_UP = 0x20;
+//public static final int Pt_SLIDER_X1_RESOURCES = 1;
+//public static final int Pt_SUBORDINATES_CHILD = 2;
+//public static final int Pt_SUPER_CONSTRAINTS = 0x00000800;
+//public static final int Pt_SYSINFO_VALID = 0x00002000;
+//public static final int Pt_TAB_UPSIDE_DOWN = 0x1;
+//public static final int Pt_TEXT_AUTO_HIGHLIGHT = 0x00000080;
+//public static final int Pt_TEXT_CHANGED = 0x80000000;
+//public static final int Pt_TEXT_FULL = 0x00000010;
+ public static final int Pt_TEXT_IMAGE = 0x08;
+//public static final int Pt_TEXT_RANGE_ACTIVE = 0x40000000;
+//public static final int Pt_TEXT_X1_RESOURCES = 1;
+ public static final int Pt_TICK = 4;
+//public static final int Pt_TICKS_ETCHED_IN = 0x10;
+//public static final int Pt_TICKS_ETCHED_OUT = 0x08;
+//public static final int Pt_TICKS_MASK = 0x03;
+//public static final int Pt_TICKS_ON_BOTTOM = 0x02;
+//public static final int Pt_TICKS_ON_LEFT = 0x01;
+//public static final int Pt_TICKS_ON_RIGHT = 0x02;
+//public static final int Pt_TICKS_ON_TOP = 0x01;
+//public static final int Pt_TICKS_TOUCH_TROUGH = 0x04;
+//public static final int Pt_TIMER_INITIAL = 1;
+//public static final int Pt_TIMER_REPEAT = 2;
+ public static final int Pt_TOGGLE = 0x00000008;
+//public static final int Pt_TOP = 0;
+ public static final int Pt_TOP_ANCHORED_BOTTOM = 0x00000040;
+//public static final int Pt_TOP_ANCHORED_RELATIVE = 0x00000004;
+ public static final int Pt_TOP_ANCHORED_TOP = 0x00000400;
+//public static final int Pt_TOP_IS_ANCHORED = Pt_TOP_ANCHORED_BOTTOM | Pt_TOP_ANCHORED_RELATIVE | Pt_TOP_ANCHORED_TOP;
+//public static final int Pt_TRAVERSE_BACK = 0x00000004;
+//public static final int Pt_TRAVERSE_DONE = 0;
+//public static final int Pt_TRAVERSE_FORCE = 0x00000008;
+//public static final int Pt_TRAVERSE_LAST = 0x00000002;
+//public static final int Pt_TRAVERSE_ROOT = 0x00000001;
+//public static final int Pt_TRAVERSE_START = 0;
+//public static final int Pt_TREE_BALLOON_ON_IMAGE = 0x0100;
+//public static final int Pt_TREE_BALLOON_ON_TREE = 0x0200;
+//public static final int Pt_TREE_COLLAPSING = 0;
+//public static final int Pt_TREE_EXPANDING = 1;
+//public static final int Pt_TREE_HAS_BUTTONS = 0x0001;
+//public static final int Pt_TREE_HAS_LINES = 0x0002;
+//public static final int Pt_TREE_ITEM_EXPANDABLE = 0x0040;
+ public static final int Pt_TREE_ITEM_EXPANDED = 0x0080;
+//public static final int Pt_TREE_ROOT_LINES = 0x0004;
+//public static final int Pt_TREE_TO_LEFT = 0x0010;
+//public static final int Pt_TREE_TO_RIGHT = 0x0008;
+//public static final int Pt_TRUE = -1;
+//public static final int Pt_UCLIP = 0x08000000;
+//public static final int Pt_ULINE_ETCHED_IN = 3;
+//public static final int Pt_ULINE_ETCHED_OUT = 4;
+//public static final int Pt_UNCLEAN_RESOURCES = 0x00000200;
+//public static final int Pt_UNUSED = 0x00000008;
+//public static final int Pt_USE_ELLIPSIS = 0x20;
+//public static final int Pt_VALUE_XOR = 0x20;
+//public static final int Pt_VERSION = 1;
+public static final int Pt_VERTICAL = 0;
+//public static final int Pt_WIDGET_REBUILD = 0x00100000;
+//public static final int Pt_WIDGET_RESIZE = 0x00200000;
+//public static final int Pt_WIN_REQUEST = 0x1000;
+//public static final int Pt_WINDOW_CURSOR_OVERRIDE = 0x0002;
+//public static final int Pt_WINDOW_EXTENTING = 0x0008;
+//public static final int Pt_WINDOW_FORCE_FRONT = 0x0001;
+//public static final int Pt_WINDOW_MAXING = 0x8000;
+//public static final int Pt_WINDOW_SETTING = 0x0010;
+//public static final int Pt_WINDOW_TASKBAR = 0x0004;
+//
+//public static final int Ph_WM_APP_DEF_MANAGED = ( Ph_WM_CLOSE | Ph_WM_FOCUS | Ph_WM_MENU | Ph_WM_TOFRONT | Ph_WM_TOBACK |
+// Ph_WM_RESIZE | Ph_WM_MOVE | Ph_WM_HIDE | Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_TASKBAR );
+//
+//public static final int Ph_WM_APP_DEF_NOTIFY = ( 0 );
+//public static final int Ph_WM_APP_DEF_RENDER = ( Ph_WM_RENDER_ASAPP | Ph_WM_RENDER_BORDER |
+// Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MOVE |
+// Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MENU |
+// Ph_WM_RENDER_MIN | Ph_WM_RENDER_MAX );
+//
+//public static final int Ph_WM_ICON_DEF_MANAGED = ( Ph_WM_CLOSE | Ph_WM_FOCUS | Ph_WM_MENU | Ph_WM_TOFRONT | Ph_WM_TOBACK | Ph_WM_MOVE | Ph_WM_ICON | Ph_WM_RESTORE );
+//public static final int Ph_WM_ICON_DEF_NOTIFY = ( 0 );
+//public static final int Ph_WM_ICON_DEF_RENDER = ( Ph_WM_RENDER_ASICON | Ph_WM_RENDER_BORDER );
+//
+//public static final int Pt_RO_EFLAGS = (Pt_DAMAGE_ON_FOCUS | Pt_SKIP_CHILDREN | Pt_WIN_REQUEST | Pt_DOOMED );
+//public static final int Pt_CONTAINER_RO_FLAGS = (Pt_IGNORE_CONSTRAINTS | Pt_CANVAS_INVALID | Pt_CONTAINER_CONSTRAINT_BITS);
+//
+//public static final int PT_WORKPROC_ID = 2;
+ public static final int Pt_Z_STRING = 0x01;
+//public static final int PX_DIRECT_COLOR = 0x04;
+//public static final int PX_DODITHER = 0x40;
+//public static final int PX_IMAGE = 0x01;
+//public static final int PX_IMAGE_BMP = 0x00;
+//public static final int PX_IMAGE_GIF = 0x01;
+//public static final int PX_IMAGE_JPG = 0x02;
+//public static final int PX_IMAGE_PCX = 0x03;
+//public static final int PX_IMAGE_PNG = 0x05;
+//public static final int PX_IMAGE_TGA = 0x04;
+//public static final int PX_IMAGE_TIFF = 0x06;
+//public static final int PX_IMAGE_XBM = 0x07;
+//public static final int PX_LOAD = 0x00;
+//public static final int PX_METHODS = 0x80000000;
+//public static final int PX_NORMAL = 0x00;
+//public static final int PX_PALETTE = 0x02;
+//public static final int PX_QUERY = 0x01;
+//public static final int PX_SUPPRESS_CRC = 0x02;
+//public static final int PX_SUPPRESS_TAG = 0x02;
+//public static final int PX_TRANSPARENT = 0x08;
+//public static final int PX_USECOLORS = 0x20;
+//public static final int PXCONFIG_CREATE = 0x4;
+//public static final int PXCONFIG_FMT_BOOL_ON = 1;
+//public static final int PXCONFIG_FMT_BOOL_TRUE = 3;
+//public static final int PXCONFIG_FMT_BOOL_YES = 2;
+//public static final int PXCONFIG_FMT_CHAR_CHAR = 11;
+//public static final int PXCONFIG_FMT_CHAR_HEX = 12;
+//public static final int PXCONFIG_FMT_INT_DECIMAL = 21;
+//public static final int PXCONFIG_FMT_INT_HEX = 22;
+//public static final int PXCONFIG_FMT_STRING = 31;
+//public static final int PXCONFIG_READ = 0x0;
+//public static final int PXCONFIG_WRITE = 0x1;
+//public static final int REMOTE_FLAG_FIXED = 0x0001;
+//public static final int REMOTE_FLAG_INITIAL = 0x0002;
+//public static final int REMOTE_FLAG_IS_ORIGIN = 0x0004;
+//public static final int REMOTE_FLAG_NO_DIM = 0x0008;
+//public static final int REMOTE_WM_TITLE = 2;
+//public static final int REMOTE_WM_WINDOW = 1;
+//public static final int RF_BUF_MALLOCED = 0x0020;
+//public static final int RF_CTRL_MALLOCED = 0x0080;
+//public static final int RF_DO_PALETTE = 0x0001;
+//public static final int RF_DO_RAM = 0x0002;
+//public static final int RF_DONT_COPY = 0x0010;
+//public static final int RF_DONT_FONTMAP = 0x0008;
+//public static final int RF_DRAWFUNCS_AVAILABLE = 0x0400;
+//public static final int RF_DRAWFUNCS_MALLOCED = 0x0800;
+//public static final int RF_FORCE_ANTIALIAS = 0x0004;
+//public static final int RF_FUNCS_LOADED = 0x0040;
+//public static final int RF_NEVER_ANTIALIAS = 0x0200;
+//public static final int RF_ONE2ONE = 0x0100;
+//public static final int TTF_STATS = 0x03;
+//public static final int UPDOWN_BOT = 2;
+//public static final int UPDOWN_BOTTOM = 2;
+//public static final int UPDOWN_LEF = 3;
+//public static final int UPDOWN_LEFT = 3;
+//public static final int UPDOWN_RIGHT = 4;
+//public static final int UPDOWN_RIT = 4;
+//public static final int UPDOWN_TOP = 1;
+//public static final int VKEYMODBIT = 32;
+//public static final int WM_CONSWITCH_BACK = 1;
+//public static final int WM_CONSWITCH_CONSOLE = 0;
+//public static final int WM_CONSWITCH_FWD = 2;
+//public static final int WM_CONSWITCH_RID = 3;
+//public static final int WM_VERSION = 8;
+//
+//public static final String Ph_CLIPBOARD_TYPE_TEXT = "TEXT";
+//public static final String Ph_CURSOR_DEFAULT_FONT = "phcursor";
+//public static final String PHFONT_ENVVAR = "PHFONT";
+//public static final String PHFONT_FDNAME = "/dev/phfont";
+
+public static final int MAX_DESC_LENGTH = 32;
+public static final int MAX_FONT_TAG = 80;
+
+public static final native int PfQueryFontInfo (byte[] font, FontQueryInfo info);
+public static final native PhRect_t PfExtentWideText(PhRect_t extent, PhPoint_t pos, byte[] font, char[] str, int len);
+public static final native PhRect_t PfExtentText(PhRect_t extent, PhPoint_t pos, int font, int str, int len);
+public static final native int PfQueryFonts(int symbol, int flags, int list, int n);
+public static final native byte[] PfGenerateFontName(byte[] pkucDescription, int kuiFlags, int kuiSize, byte[] pucBuff);
+//public static final native int PfFindFont(byte[] pkucDescription, int kulFlags, int kulSize);
+//public static final native int PfFreeFont(int ptsID);
+//public static final native int PfFontDescription(int ptsID);
+//public static final native int PfFontSize(int ptsID);
+//public static final native int PfFontFlags(int ptsID);
+//public static final native int PfConvertFontID(int ptsID);
+
+public static final native int PgCreateGC (int size);
+public static final native void PgDestroyGC (int GC);
+public static final native int PgDrawArc (PhPoint_t center, PhPoint_t radii, int start, int end, int flags);
+public static final native int PgDrawEllipse (PhPoint_t center, PhPoint_t radii, int flags);
+public static final native int PgDrawPolygon (short[] ptr, int num, PhPoint_t pos, int flags);
+public static final native int PgDrawRoundRect (PhRect_t rect, PhPoint_t radii, int flags);
+public static final native int PgDrawILine (int x1, int y1, int x2, int y2);
+public static final native int PgDrawIRect (int ulx, int uly, int lrx, int lry, int flags);
+//public static final native int PgDrawText (char[] ptr, int len, short x, short y, int flags);
+public static final native int PgDrawText (byte[] ptr, int len, short x, short y, int flags);
+public static final native int PgFlush ();
+public static final native int PgSetFillColor (int color);
+public static final native int PgSetStrokeColor (int color);
+public static final native int PgSetTextColor (int color);
+public static final native void PgSetFont (byte[] ff);
+public static final native int PgSetStrokeDash (byte[] DashList, int ListLen, int DashScale);
+public static final native int PgSetStrokeWidth (int width);
+public static final native int PgSetDrawMode (int mode);
+public static final native int PgSetClipping (short n, int rects);
+public static final native int PgSetPalette (int palette, int palette_id, short first_color, short num_colors, int flags, int tag);
+public static final native int PgSetGC (int GC);
+public static final native void PgSetRegion (int rid);
+public static final native int PgSetMultiClip (int num, int clip_list);
+//public static final native void PgSetUserClip (int ClipRect);
+public static final native void PgSetUserClip (PhRect_t ClipRect);
+public static final native int PgDrawImage (int ptr, int type, PhPoint_t pos, PhDim_t size, int bpl, int tag);
+public static final native int PgDrawBitmap (int ptr, int flags, PhPoint_t pos, PhDim_t size, int bpl, int tag);
+public static final native int PgDrawTImage (int ptr, int type, PhPoint_t pos, PhDim_t size, int bpl, int tag, int TransPtr, int TransBPl);
+public static final native int PgDrawPhImageRectmx (PhPoint_t pos, int image, PhRect_t rect, int flags);
+public static final native int PhMakeTransBitmap (int image, int trans_color);
+public static final native int PiCropImage (int image, PhRect_t bounds, int flags);
+public static final native void PhBlit (int rid, PhRect_t rect, PhPoint_t offset);
+public static final native int PtClippedBlit (int widget, int src, PhPoint_t delta, int clip);
+public static final native int PgSetDrawBufferSize (int cmd_buf_len);
+
+public static final native int PhEventPeek (int buffer, int size);
+public static final native int PhGetMsgSize (int event_buf);
+public static final native int PhGetTile ();
+public static final native int PhAddMergeTiles (int tiles, int add_tiles, int[] added);
+public static final native int PhIntersectTilings (int tile1, int tile2, short[] num_intersect_tiles);
+public static final native int PhCoalesceTiles (int tiles);
+public static final native int PhMergeTiles (int tiles);
+public static final native int PhRectUnion (int rect1, int rect2);
+public static final native int PhRectIntersect (int rect1, int rect2);
+public static final native int PhTranslateTiles (int tile, PhPoint_t point_add);
+public static final native int PhDeTranslateTiles (int tile, int point_subtract);
+public static final native int PhClipTilings (int tiles, int clip_tiles, int[] intersection);
+public static final native int PhTilesToRects (int tiles, int[] num_rects);
+public static final native int PhRectsToTiles (int rects, int num_rects);
+public static final native void PhFreeTiles (int tiles);
+public static final native int PhWindowQueryVisible (int flag, int rid, int input_group, PhRect_t rect);
+//public static final native int PhCreateImage(PhImage_t buffer, short width, short height, int type, int[] palette, int ncolors, int shmem);
+public static final native int PhCreateImage(PhImage_t buffer, short width, short height, int type, int palette, int ncolors, int shmem);
+public static final native void PhReleaseImage(int image);
+
+public static final native int PmMemCreateMC(int image, PhDim_t dim, PhPoint_t translation);
+public static final native void PmMemReleaseMC(int mc);
+public static final native int PmMemStart(int mc);
+public static final native int PmMemStop(int mc);
+public static final native int PmMemFlush(int mc, int image);
+
+public static final native int PtList ();
+public static final native int PtLabel ();
+public static final native int PtWindow ();
+public static final native int PtInit (byte [] name);
+public static final native int PtEnter (int flags);
+public static final native int PtLeave (int flags);
+public static final native int PtCreateWidget (int clazz, int parent, int n_args, int [] args);
+public static final native int PtGetResources (int widget, int n_args, int [] args);
+public static final native int PtSetResources (int widget, int n_args, int [] args);
+public static final native int PtRealizeWidget (int widget);
+public static final native void PtAddEventHandler (int widget, int event_mask, int callback, int data);
+public static final native int PtWidgetRid (int widget);
+public static final native void PtMainLoop ();
+public static final native int PtEventHandler (int event);
+public static final native int PtDestroyWidget (int widget);
+public static final native int PtWidgetCanvas (int widget, int canvas_rect);
+public static final native int PtLabelWidgetCanvas (int widget, PhRect_t canvas_rect);
+public static final native int PtWidgetExtent (int widget, int extent);
+public static final native int PtWidgetChildBack (int widget);
+public static final native boolean PtWidgetIsRealized (int widget);
+public static final native int PtWidgetBrotherInFront (int widget);
+public static final native int PtWidgetParent (int widget);
+
+public static final native int malloc (int size);
+public static final native void free (int ptr);
+
+public static final native void memmove (int address, PhPoint_t point, int size);
+public static final native void memmove (PhPoint_t point, int address, int size);
+
+public static final native void memmove (int [] buffer, int address, int size);
+public static final native void memmove (int address, int [] buffer, int size);
+
+public static final native void memmove (int address, PhTile_t tile, int size);
+public static final native void memmove (PhTile_t tile, int address, int size);
+
+//public static final native void memmove (int address, PtCallbackInfo_t callack, int size);
+public static final native void memmove (PtCallbackInfo_t callack, int address, int size);
+
+//public static final native void memmove (int address, PhWindowEvent_t event, int size);
+public static final native void memmove (PhWindowEvent_t event, int address, int size);
+
+public static final native void PtAddCallback (int widget, int callback_type, int callback, int data);
+
+public static final native int PtWidgetChildFront (int widget);
+public static final native int PtWidgetBrotherBehind (int widget);
+
+public static final native void memmove (byte [] buffer, int address, int size);
+public static final native void memmove (int address, byte [] buffer, int size);
+
+public static final native int PtButton ();
+
+public static final native void memmove (int address, PhRect_t rect, int size);
+public static final native void memmove (PhRect_t rect, int address, int size);
+
+public static final native int PtUnrealizeWidget (int widget);
+
+public static final native int PtSyncWidget (int widget);
+public static final native int PtFlush ();
+
+public static final native int PtContainerGiveFocus (int widget, PhEvent_t event);
+
+public static final native int PtWidgetToBack (int widget);
+public static final native int PtWidgetToFront (int widget);
+public static final native int PtWidgetInsert (int widget, int new_sibling, int behind);
+
+public static final native int PtDamageExtent (int widget, PhRect_t extent);
+
+public static final native int PtCreateWidgetClass (int superclass_ref, int size, int num_args, int [] arg);
+public static final native void PtSuperClassDraw (int wc_ref, int widget, int damage);
+
+public static final native int PtToggleButton ();
+public static final native int PtComboBox ();
+public static final native int PtText ();
+public static final native int PtMultiText ();
+public static final native int PtMenu ();
+public static final native int PtMenuBar ();
+public static final native int PtMenuButton ();
+public static final native int PtScrollbar ();
+public static final native int PtSeparator ();
+
+public static final native int PtListAddItems (int widget, int [] items, int item_count, int position);
+public static final native void PtListUnselectPos (int widget, int pos);
+
+public static final native void memmove (short [] buffer, int address, int size);
+public static final native void memmove (int address, short [] buffer, int size);
+public static final native int strlen (int string);
+
+public static final native int PtListDeleteItemPos (int widget, int item_count, int position);
+public static final native int PtListDeleteAllItems (int widget);
+public static final native void PtListSelectPos (int widget, int pos);
+public static final native int PtListReplaceItemPos (int widget, int [] new_items, int item_count, int position);
+public static final native void PtListGotoPos (int widget, int pos);
+
+public static final native int PtTextModifyText (int widget, int start, int end, int insert_pos, byte [] text, int length);
+public static final native int PtTextModifyText (int widget, int start, int end, int insert_pos, int text, int length);
+public static final native int PhClipboardCopyString (short ig, byte [] string);
+public static final native int PtTextGetSelection (int widget, int [] start, int [] end);
+public static final native int PtTextSetSelection (int widget, int [] start, int [] end);
+
+public static final native int PtPositionMenu (int widget, PhEvent_t event);
+public static final native int PtReParentWidget (int widget, int parent);
+
+public static final native int PtForwardWindowEvent (PhWindowEvent_t event);
+
+public static final native int PtWidgetOffset (int widget, PhPoint_t offset);
+
+public static final native void PtRemoveCallback (int widget, int callback_type, int callback, int data);
+
+public static final native int PtScrollContainer ();
+
+public static final native int PtWidgetCanvas (int widget, PhRect_t canvas_rect);
+//public static final native int PtAddClassStyle (int wclass, int style);
+public static final native int PtWidgetClass (int widget);
+public static final native int PtWidgetIsClassMember (int widget, int clazz);
+
+public static final native void memmove (int dest, int src, int size);
+
+public static final native void memmove (int address, PhImage_t image, int size);
+public static final native void memmove (PhImage_t image, int address, int size);
+
+//public static final native void memmove (int address, FontDetails details, int size);
+public static final native void memmove (FontDetails details, int address, int size);
+
+//public static final native void memmove (int address, PhImage_t image, int size);
+public static final native void memmove (PhPointerEvent_t dest, int src, int size);
+
+public static final native int PhGetData (int event);
+public static final native int PhGetRects (int event);
+
+//public static final native void memmove (int address, PhWindowEvent_t event, int size);
+public static final native void memmove (PhEvent_t event, int address, int size);
+
+public static final native int PtExtentWidget (int widget);
+public static final native int PtExtentWidgetFamily (int widget);
+
+public static final native void PtGetAbsPosition (int widget, short [] x, short [] y);
+
+//public static final native int PtSetAreaFromExtent (int widget, PhRect_t extent_rect, PhArea_t area);
+public static final native int PtSetAreaFromWidgetCanvas (int widget, PhRect_t canvas_rect, PhArea_t area);
+
+//NOT THE SAME
+//public static final native int PtSetAreaFromCanvas (int widget, PhRect_t canvas_rect, PhArea_t area);
+
+//public static final native void memmove (int address, PhImage_t image, int size);
+public static final native void memmove (PhKeyEvent_t dest, int src, int size);
+
+//public static final native int PhTo8859_1 (int event);
+//public static final native int PhKeyToMb (byte [] buffer, int event);
+
+//public static final native void memmove (int dest, PhImage_t src, int size);
+public static final native void memmove (PtScrollbarCallback_t dest, int src, int size);
+
+public static final native void memmove (int dest, PhArea_t src, int size);
+//public static final native void memmove (PhArea_t dest, int src, int size);
+
+public static final native int PtSetParentWidget (int widget);
+public static final native void PtFrameSize (int widget, int border_width, int [] left_border, int [] top_border, int [] right_border, int [] bottom_border);
+
+public static final native int PtCreateAppContext ();
+public static final native void PtAppProcessEvent (int app_context);
+public static final native int PtAppAddWorkProc (int app_context, int work_func, int data);
+public static final native void PtAppRemoveWorkProc (int app_context, int WorkProc_id);
+
+public static final native int PtWidgetExtent (int widget, PhRect_t extent);
+public static final native int PtWidgetArea (int widget, PhArea_t area);
+public static final native int PhQueryCursor (short ig, PhCursorInfo_t buf);
+public static final native int PhInputGroup (int event);
+
+public static final native int PtContainer ();
+public static final native int PtDisjoint ();
+public static final native int PtScrollArea ();
+public static final native int PhCopyTiles (int tile);
+
+public static final native int PtFileSelection (int parent, PhPoint_t pos, byte [] title, byte [] root_dir, byte [] file_spec, byte [] btn1, byte [] btn2, byte [] format, PtFileSelectionInfo_t info, int flags);
+
+public static final native int PtWidgetPreferredSize (int widget, PhDim_t dim);
+
+public static final native int PtAppCreatePulse (int app, int priority);
+public static final native int PtAppAddInput (int app_context, int pid, int input_func, int data);
+public static final native void PtAppRemoveInput (int app_context, int input_id);
+public static final native int PtAppDeletePulse (int app, int pulse_pid);
+public static final native int PtAppPulseTrigger (int app, int pulse);
+
+public static final native int PtContainerFindFocus (int family_member);
+public static final native int PtIsFocused (int widget);
+public static final native int PtWindowFocus (int widget);
+public static final native void PtWindowToBack (int widget);
+public static final native void PtWindowToFront (int widget);
+public static final native int PtFindDisjoint (int widget);
+
+//public static final native int PhClipboardCopyString (short ig, int string);
+public static final native int PhClipboardPasteString (short ig);
+
+public static final native int PtBlockAllWindows(int skip, short cursor, int cursor_color);
+public static final native void PtUnblockWindows(int bl);
+public static final native int PtNextTopLevelWidget(int widget);
+public static final native int PtWindowGetState(int widget);
+
+public static final native void PtAddHotkeyHandler(int widget, int key_sym_cap, int key_mods, short flags, int data, int callback);
+public static final native void PtRemoveHotkeyHandler(int widget, int key_sym_cap, int key_mods, short flags, int data, int callback);
+
+public static final native void memmove (PgAlpha_t dest, int src, int size);
+public static final native void memmove (int dest, PgAlpha_t src, int size);
+
+public static final native void PgAlphaOn();
+public static final native void PgAlphaOff();
+//public static final native void PgSetAlpha(int alpha_op, int src_alpha_map, int src_alpha_gradient, byte src_global_alpha, byte dst_global_alpha);
+public static final native void PgSetAlpha(int alpha_op, PgMap_t src_alpha_map, int src_alpha_gradient, byte src_global_alpha, byte dst_global_alpha);
+
+public static final native void memmove (PtTextCallback_t dest, int src, int size);
+public static final native void memmove (int dest, PtTextCallback_t src, int size);
+
+public static final native int PhInitDrag (int rid, int flags, PhRect_t rect, PhRect_t boundary, int input_group, PhDim_t min, PhDim_t max, PhDim_t step, PhPoint_t ptrpos, short [] cursor);
+
+public static final native int PtProgress ();
+public static final native int PtPanelGroup ();
+
+public static final native void PhAreaToRect (PhArea_t area, PhRect_t rect);
+public static final native int PtCalcCanvas (int widget, PhRect_t canvas_rect);
+public static final native int PtValidParent (int widget_parent, int class_ref);
+public static final native void PtCalcBorder (int widget, PhRect_t rect);
+
+public static final native int PtPane ();
+
+public static final native int PtTree ();
+public static final native int PtTreeAllocItem (int tree, byte[] str, short set_img, short unset_img);
+public static final native int PtTreeModifyItem (int tree, int item, byte[] str, short set_img, short unset_img);
+public static final native int PtTreeModifyItemString (int tree, int item, byte[] string);
+public static final native int PtTreeFreeItems (int items);
+public static final native int PtTreeAddFirst (int tree, int item, int parent);
+public static final native int PtTreeAddAfter (int tree, int item, int brother);
+public static final native int PtTreeExpand (int tree, int item, int event);
+public static final native int PtTreeCollapse (int tree, int item, int event);
+public static final native void PtTreeRemoveItem (int tree, int item);
+public static final native void PtTreeFreeAllItems (int tree);
+public static final native int PtTreeRootItem (int tree);
+public static final native void PtTreeClearSelection (int tree);
+public static final native void PtTreeSelect (int tree, int item);
+
+public static final native void memmove (PtTreeItem_t dest, int src, int size);
+public static final native void memmove (int dest, PtTreeItem_t src, int size);
+
+public static final native void memmove (PgMap_t dest, int src, int size);
+public static final native void memmove (int dest, PgMap_t src, int size);
+
+public static final native int PtDamageWidget (int widget);
+public static final native int PtBlit (int widget, PhRect_t source, PhPoint_t delta);
+public static final native int PtContainerHold (int container_widget);
+public static final native int PtContainerRelease (int container_widget);
+
+public static final native int PtFontSelection (int parent, PhPoint_t pos, byte[] title, byte[] font, int symbol, int flags, byte[] sample);
+
+public static final native int PtToolbar ();
+
+//public static final native int PtColorSelGroup ();
+//public static final native int PtColorPatch ();
+//public static final native int PtColorPalette ();
+
+//public static final native int PtGroup ();
+
+//public static final native int Pg_CM_RGB ();
+//public static final native int Pg_CM_HSB ();
+//public static final native int Pg_CM_HLS ();
+
+public static final native int PhRectUnion (PhRect_t rect1, PhRect_t rect2);
+public static final native int PtRegion ();
+public static final native void PtAddFilterCallback (int widget, int event_mask, int callback, int data);
+
+public static final native int PtListItemPos (int widget, byte[] item);
+
+public static final native int PtTimer ();
+public static final native int PtHit (int container, int n, PhRect_t rect);
+
+public static final native int PtColorSelect (int parent, byte[] title, PtColorSelectInfo_t info);
+
+public static final native void PgDrawArrow (PhRect_t rect, short unknown, int color, int flags);
+
+public static final native int PtBeep ();
+
+public static final native int PtAlert (int parent, PhPoint_t location, byte[] title, int image, byte[] message, byte[] msgFont, int btnCount, int[] buttons, int[] btnFonts, int defBtn, int escBtn, int flags);
+
+public static final native int PtSlider ();
+
+public static final native int PiDuplicateImage (int image, int flags);
+
+public static final native int PhMakeGhostBitmap (int image);
+
+public static final native int PgReadScreen (PhRect_t rect, int buffer);
+public static final native int PgReadScreenSize (PhRect_t rect);
+public static final native int PgShmemCreate (int size, byte[] name);
+//public static final native int PgShmemDetach (int addr);
+public static final native int PgShmemDestroy (int addr);
+//public static final native void PgShmemCleanup ();
+public static final native int PhRegionQuery (int rid, PhRegion_t region, PhRect_t rect, int data, int data_len);
+//public static final native int PiGetPixelRGB (int image, short x, short y, int[] value);
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
new file mode 100755
index 0000000000..ebf21fad67
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgAlpha_t.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PgAlpha_t {
+
+ public int alpha_op;
+ // PgMap_t src_alpha_map;
+ public short src_alpha_map_dim_w;
+ public short src_alpha_map_dim_h;
+ public short src_alpha_map_bpl;
+ public short src_alpha_map_bpp;
+ public int src_alpha_map_map;
+ // PgGradient_t src_alpha_gradient; *** unused
+ // PgMap_t dest_alpha_map; *** unused
+ // PgGradient_t dest_alpha_gradient; *** unused
+ public byte src_global_alpha;
+ public byte dest_global_alpha;
+ // char spare[2]; *** unused
+ public static final int sizeof = 104;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
new file mode 100755
index 0000000000..e41f9bfd48
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PgMap_t.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PgMap_t {
+
+ public short dim_w;
+ public short dim_h;
+ public short bpl;
+ public short bpp;
+ public int map;
+ public static final int sizeof = 12;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
new file mode 100755
index 0000000000..ab892950c6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhArea_t.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhArea_t {
+ public short pos_x;
+ public short pos_y;
+ public short size_w;
+ public short size_h;
+ public static final int sizeof = 8;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
new file mode 100755
index 0000000000..8249867c82
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhCursorInfo_t.java
@@ -0,0 +1,38 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhCursorInfo_t {
+// PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+ public int region;
+ public int ig_region;
+ public int color;
+// PhPoint_t last_press;
+ public short last_press_x;
+ public short last_press_y;
+ public int msec;
+// PhPoint_t steady;
+ public int steady_x;
+ public int steady_y;
+ public int dragger;
+// PhRect_t drag_boundary;
+ public short drag_boundary_xUL;
+ public short drag_boundary_yUL;
+ public short drag_boundary_xLR;
+ public short drag_boundary_yLR;
+ public int phantom_rid;
+ public short type;
+ public short ig;
+ public short button_state;
+ public byte click_count;
+ public byte zero10, zero11,zero12;
+ public int key_mods;
+ public int zero2;
+ public static final int sizeof = 60;
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
new file mode 100755
index 0000000000..95ccd121d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhDim_t.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhDim_t {
+ public short w;
+ public short h;
+ public static final int sizeof = 4;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
new file mode 100755
index 0000000000..ee5a6ab230
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhEvent_t.java
@@ -0,0 +1,27 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhEvent_t {
+ public int type;
+ public short subtype;
+ public short processing_flags;
+// public PhEventRegion_t emitter;
+ public int emitter_rid;
+ public int emitter_handle;
+// public PhEventRegion_t collector;
+ public int collector_rid;
+ public int collector_handle;
+ public short input_group;
+ public short flags;
+ public int timestamp;
+// public PhPoint_t translation;
+ public short translation_x;
+ public short translation_y;
+ public short num_rects;
+ public short data_len;
+ public static final int sizeof = 40;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
new file mode 100755
index 0000000000..eaad75d4a4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhImage_t.java
@@ -0,0 +1,28 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhImage_t {
+ public int type;
+ public int image_tag;
+ public int bpl;
+ public short size_w;
+ public short size_h;
+ public int palette_tag;
+ public int colors;
+ public int alpha;
+ public int transparent;
+ public byte format;
+ public byte flags;
+ public byte ghost_bpl;
+ public byte spare1;
+ public int ghost_bitmap;
+ public int mask_bpl;
+ public int mask_bm;
+ public int palette;
+ public int image;
+ public static final int sizeof = 56;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
new file mode 100755
index 0000000000..3c74f4df11
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhKeyEvent_t.java
@@ -0,0 +1,21 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhKeyEvent_t {
+ public int key_mods;
+ public int key_flags;
+ public int key_cap;
+ public int key_sym;
+ public byte key_scan;
+ public byte key_zero1;
+ public short key_zero2;
+// PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+ public short button_state;
+ public static final int sizeof = 26;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
new file mode 100755
index 0000000000..fabd9f25fe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPoint_t.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhPoint_t {
+ public short x;
+ public short y;
+ public static final int sizeof = 4;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
new file mode 100755
index 0000000000..9240762c20
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhPointerEvent_t.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhPointerEvent_t {
+// public PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+ public short buttons;
+ public short button_state;
+ public byte click_count;
+ public byte flags;
+ public short z;
+ public int key_mods;
+ public int zero;
+ public static final int sizeof = 20;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
new file mode 100755
index 0000000000..db6377c99a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRect_t.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhRect_t {
+ public short ul_x;
+ public short ul_y;
+ public short lr_x;
+ public short lr_y;
+ public static final int sizeof = 8;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
new file mode 100755
index 0000000000..b3d1b78c96
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhRegion_t.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhRegion_t {
+ public int rid;
+ public int handle;
+ public int owner;
+ public int flags;
+ public short state;
+// public short zero1;
+ public int events_sense;
+ public int events_opaque;
+ public short origin_x;
+ public short origin_y;
+ public int parent;
+ public int child;
+ public int bro_in_front;
+ public int bro_behind;
+ public int cursor_color;
+ public short input_group;
+ public short data_len;
+// public int zero21;
+// public int zero22;
+ public short cursor_type;
+// public short zero3;
+
+ public static final int sizeof = 68;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
new file mode 100755
index 0000000000..d006c2ade4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhTile_t.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhTile_t {
+ // PhRect_t rect;
+ public short rect_ul_x;
+ public short rect_ul_y;
+ public short rect_lr_x;
+ public short rect_lr_y;
+ public int next;
+ public static final int sizeof = 12;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
new file mode 100755
index 0000000000..f490159630
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PhWindowEvent_t.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PhWindowEvent_t {
+ public int event_f;
+ public int state_f;
+ public int rid;
+// PhPoint_t pos;
+ public short pos_x;
+ public short pos_y;
+// PhDim_t size;
+ public short size_w;
+ public short size_h;
+ public short event_state;
+ public short input_group;
+ public int rsvd0, rsvd1, rsvd2, rsvd3;
+ public static final int sizeof = 40;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
new file mode 100755
index 0000000000..2ecde6b294
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtCallbackInfo_t.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtCallbackInfo_t {
+ public int reason;
+ public int reason_subtype;
+ public int event;
+ public int cbdata;
+ public static final int sizeof = 16;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
new file mode 100755
index 0000000000..54dec671d7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtColorSelectInfo_t.java
@@ -0,0 +1,27 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtColorSelectInfo_t {
+ public short flags;
+ public byte nselectors;
+ public byte ncolor_models;
+ public int color_models;
+ public int selectors;
+ public short pos_x;
+ public short pos_y;
+ public short size_w;
+ public short size_h;
+ public int palette;
+ public int accept_text;
+ public int dismiss_text;
+ public int accept_dismiss_text;
+ public int apply_f;
+ public int data;
+ public int rgb;
+ public int dialog;
+ public static final int sizeof = 52;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
new file mode 100755
index 0000000000..0cc12aef00
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtFileSelectionInfo_t.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtFileSelectionInfo_t {
+ public short ret;
+ public byte [] path = new byte [(OS.PATH_MAX + OS.NAME_MAX + 4) & (~3)];
+ public PhDim_t dim = new PhDim_t ();
+ public PhPoint_t pos = new PhPoint_t ();
+ public byte [] format = new byte [80];
+ public byte [] fspec = new byte [80];
+ public int user_data;
+ public int confirm_display;
+ public int confirm_selection;
+ public int new_directory;
+ public int btn1;
+ public int btn2;
+ public int num_args;
+ public int args;
+ public int [] spare = new int [4];
+ public static final int sizeof = 1500;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
new file mode 100755
index 0000000000..aac48e6020
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtScrollbarCallback_t.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtScrollbarCallback_t {
+ public int action;
+ public int position;
+ public static final int sizeof = 8;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
new file mode 100755
index 0000000000..abac0c47d9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTextCallback_t.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtTextCallback_t {
+ public int start_pos;
+ public int end_pos;
+ public int cur_insert;
+ public int new_insert;
+ public int length;
+ public short reserved;
+ public int text;
+ public int doit;
+ public static final int sizeof = 30;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
new file mode 100755
index 0000000000..27f857a96c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/internal/photon/PtTreeItem_t.java
@@ -0,0 +1,25 @@
+package org.eclipse.swt.internal.photon;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class PtTreeItem_t {
+ public int list_flags;
+ public short list_size_w;
+ public short list_size_h;
+ public int list_next;
+ public int list_prev;
+ public int father;
+ public int son;
+ public int brother;
+ public short dim_w;
+ public short dim_h;
+ public short img_set;
+ public short img_unset;
+ public int data;
+// char string [1];
+// byte string;
+ public static final int sizeof = 40;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
new file mode 100755
index 0000000000..b23dff6c03
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/AbstractTreeItem.java
@@ -0,0 +1,318 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class stores and manages child items of a tree item.
+ * It provides protocol to query the index of an item relative
+ * to the root and to retrieve items by index.
+ * The TreeItem class implements this protocol for general
+ * tree items.
+ * TreeRoots provides a special implementation that allows the
+ * Tree class to treat trees with one root and with multiple
+ * roots equally.
+ */
+abstract class AbstractTreeItem extends SelectableItem {
+ private Vector children;
+ private boolean isExpanded = false;
+ // number of children.
+ // includes all expanded items down to the leafs.
+ private int visibleItemCount = 0;
+
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver belongs to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+AbstractTreeItem(Tree parent, int swtStyle) {
+ super(parent, swtStyle);
+}
+/**
+ * Insert 'item' in the list of child items. Notify the
+ * parent about the new item.
+ * @param 'item' - the item that should be added to the
+ * receiver's children.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void add(TreeItem item, int index) {
+ Vector items = getChildren();
+ int visibleIndex = getVisibleIndex();
+
+ if (index < 0 || index > items.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ if (item.isRoot()) {
+ visibleIndex = index;
+ }
+ else
+ if (isExpanded == false) {
+ visibleIndex = -1;
+ }
+ if (visibleIndex != -1) {
+ if (index > 0) {
+ TreeItem previousChild = (TreeItem) getChildren().elementAt(index - 1);
+ visibleIndex = previousChild.getVisibleIndex() + previousChild.getVisibleItemCount() + 1;
+ }
+ else {
+ visibleIndex = getVisibleIndex() + 1;
+ }
+ }
+ getSelectableParent().addingItem(item, visibleIndex);
+ item.setIndex(index);
+ resetChildIndices(index, true);
+ items.insertElementAt(item, index);
+ if (isExpanded == true) {
+ visibleItemCount++;
+ calculateVisibleItemCountParent();
+ }
+ getSelectableParent().addedItem(item, visibleIndex);
+}
+/**
+ * Set whether the receiver is expanded or not.
+ * If the receiver is expanded its child items are visible.
+ * @param expanded -
+ * true=the receiver is expanded, making its child items visible.
+ * false=the receiver is collapsed, making its child items invisible
+ */
+void internalSetExpanded(boolean expanded) {
+ isExpanded = expanded;
+ calculateVisibleItemCount();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+abstract void calculateVisibleItemCount();
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+abstract void calculateVisibleItemCountParent();
+/**
+ * Deselect the receiver and all children
+ */
+void deselectAll() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ setSelected(false);
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.deselectAll();
+ }
+}
+/**
+ * Destroy all children of the receiver
+ */
+void disposeItem() {
+ Vector children = getChildren();
+ AbstractTreeItem child;
+ while (children.size() > 0) { // TreeItem objects are removed from vector during dispose
+ child = (AbstractTreeItem) children.firstElement();
+ child.dispose();
+ }
+ doDispose();
+ super.disposeItem();
+}
+/**
+ * Subclasses should free resources here
+ */
+void doDispose() {
+ setChildren(null);
+ visibleItemCount = 0;
+}
+/**
+ * Answer the Vector containing the child items of the receiver.
+ */
+Vector getChildren() {
+ if (children == null) {
+ children = new Vector(4);
+ }
+ return children;
+}
+/**
+ * Answer whether the receiver is expanded or not.
+ * If the receiver is expanded its children are visible.
+ * @return
+ * true - the receiver is expanded, making its children visible
+ * false - the receiver is collapsed, making its children invisible
+ */
+public boolean getExpanded() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return isExpanded;
+}
+/**
+ * Answer the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getChildren().size();
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the global index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+abstract int getVisibleIndex();
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+abstract int getVisibleIndex(int childIndex);
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ */
+abstract TreeItem getVisibleItem(int searchIndex);
+/**
+ * Answer the number of expanded children, direct and indirect.
+ */
+int getVisibleItemCount() {
+ return visibleItemCount;
+}
+/**
+ * Returns the expanded state. Circumvent widget/thread check
+ * for performance. For non-API callers only.
+ */
+boolean internalGetExpanded() {
+ return isExpanded;
+}
+/**
+ * Answer whether the receiver is a leaf item.
+ * An item is a leaf when it has no child items.
+ * @return
+ * true - receiver is a leaf item
+ * false - receiver is not a leaf item.
+ */
+boolean isLeaf() {
+ return (getChildren().size() == 0);
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it doesn't have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return false;
+}
+/**
+ * Remove 'child' from the receiver.
+ * Notify the parent widget only if it is not being disposed itself.
+ */
+void removeItem(SelectableItem child) {
+ Vector children = getChildren();
+ SelectableItemWidget parent = getSelectableParent();
+ int childIndex = children.indexOf(child);
+
+ if (childIndex != -1) {
+ if (((Tree) parent).isRemovingAll() == true) {
+ children.removeElementAt(childIndex); // just remove the item from the list if the whole tree is being disposed
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ }
+ else {
+ parent.removingItem(child);
+ children.removeElementAt(childIndex);
+ if (isExpanded == true) {
+ visibleItemCount--;
+ calculateVisibleItemCountParent();
+ }
+ resetChildIndices(childIndex, false); // mark child index dirty
+ parent.removedItem(child);
+ }
+ }
+}
+/**
+ * Allow subclasses to reset any cached data.
+ * Called for all children of the receiver.
+ */
+void reset() {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ treeItem.reset();
+ }
+}
+/**
+ * Mark all child indices dirty starting with the child at
+ * 'startIndex'. This causes getIndex to recalculate the index.
+ * @param startIndex - index in the list of children at which
+ * and after which the indices are reset.
+ */
+void resetChildIndices(int startIndex, boolean addItem) {
+ Vector children = getChildren();
+ TreeItem child;
+ int increment = addItem ? 1 : 0;
+
+ for (int i = startIndex; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ child.setIndex(i + increment); // mark child index dirty
+ }
+}
+/**
+ * Select the receiver and all children.
+ * Return a Vector containing all the items that have been selected
+ * (and that have not been selected before).
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ if (isSelected() == false) {
+ selectedItems.addElement(this);
+ setSelected(true);
+ getSelectableParent().redrawSelection(this);
+ }
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+/**
+ * Set the Array containing the receiver's child items to 'children'.
+ */
+void setChildren(Vector children) {
+ this.children = children;
+}
+
+void setVisibleItemCount(int count) {
+ visibleItemCount = count;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
new file mode 100755
index 0000000000..92992ee18a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Button.java
@@ -0,0 +1,337 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Button extends Control {
+ Image image;
+
+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) != 0) {
+ return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) {
+ return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
+ }
+ if ((style & SWT.ARROW) != 0) {
+ return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0);
+ }
+ return style;
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.ARROW) != 0) {
+ if (wHint != SWT.DEFAULT) width += wHint;
+ else width = 17;
+ if (hHint != SWT.DEFAULT) height += hHint;
+ else height = 17;
+ return new Point (width, height);
+ }
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ width = dim.w; height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) width = area.size_w;
+ if (hHint != SWT.DEFAULT) height = area.size_h;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+
+ /* ARROW button */
+ if ((style & SWT.ARROW) != 0) {
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, OS.Pt_HORIZONTAL_GRADIENT, OS.Pt_STATIC_GRADIENT | OS.Pt_HORIZONTAL_GRADIENT,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (display.PtButton, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* Compute alignment */
+ int alignment = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) alignment = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.Pt_RIGHT;
+
+ /* CHECK or RADIO button */
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ int [] args = {
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_INDICATOR_TYPE, (style & SWT.CHECK) != 0 ? OS.Pt_N_OF_MANY : OS.Pt_ONE_OF_MANY, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+
+ handle = OS.PtCreateWidget (display.PtToggleButton, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ /* PUSH or TOGGLE button */
+ int [] args = {
+ OS.Pt_ARG_FLAGS, (style & SWT.TOGGLE) != 0 ? OS.Pt_TOGGLE : 0, OS.Pt_TOGGLE,
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (display.PtButton, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+}
+
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_SET) != 0;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) return "";
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ OS.Pt_ARG_ACCEL_KEY, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] result = Converter.mbcsToWcs (null, buffer);
+ int count = 0;
+ int mnemonic = 0;
+ if (args [4] != 0) {
+ int length2 = OS.strlen (args [4]);
+ if (length2 > 0) {
+ byte [] buffer2 = new byte [length2];
+ OS.memmove (buffer2, args [4], length2);
+ char [] result2 = Converter.mbcsToWcs (null, buffer2);
+ if (result2.length > 0) mnemonic = result2 [0];
+ }
+ }
+ if (mnemonic != 0) count++;
+ for (int i=0; i<result.length-1; i++)
+ if (result [i] == Mnemonic) count++;
+ char [] newResult = result;
+ if ((count != 0) || (mnemonic != 0)) {
+ newResult = new char [result.length + count];
+ int i = 0, j = 0;
+ while (i < result.length) {
+ if ((mnemonic != 0) && (result [i] == mnemonic)) {
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ mnemonic = 0;
+ }
+ if ((newResult [j++] = result [i++]) == Mnemonic)
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ }
+ }
+ return new String (newResult);
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+}
+
+int processPaint (int damage) {
+ if ((style & SWT.ARROW) != 0) {
+ OS.PtSuperClassDraw (OS.PtButton (), handle, damage);
+ PhRect_t rect = new PhRect_t ();
+ OS.PtCalcCanvas (handle, rect);
+ int flags = 0;
+ if ((style & SWT.RIGHT) != 0) flags = 2;
+ if ((style & SWT.LEFT) != 0) flags = 1;
+ if ((style & SWT.DOWN) != 0) flags = 8;
+ if ((style & SWT.UP) != 0) flags = 4;
+ OS.PgDrawArrow (rect, (short)0, 0x000000, flags);
+ } else if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ OS.PtSuperClassDraw (OS.PtToggleButton (), handle, damage);
+ } else {
+ OS.PtSuperClassDraw (OS.PtButton (), handle, damage);
+ }
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) selectRadio ();
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+void selectRadio () {
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child && child instanceof Button) {
+ Button button = (Button) child;
+ if ((button.style & SWT.RADIO) != 0) {
+ if (button.getSelection ()) {
+ button.setSelection (false);
+ button.postEvent (SWT.Selection);
+ }
+ }
+ }
+ }
+ setSelection (true);
+}
+
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+ OS.PtDamageWidget (handle);
+ 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);
+ int [] args = {OS.Pt_ARG_HORIZONTAL_ALIGNMENT, OS.Pt_LEFT, 0};
+ if ((style & SWT.CENTER) != 0) args [1] = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) args [1] = OS.Pt_RIGHT;
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.ARROW) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) imageHandle = copyPhImage (image.handle);
+ int [] args = {
+ OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.ARROW) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ int i=0, j=0;
+ char mnemonic=0;
+ while (i < text.length) {
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int ptr2 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
+ OS.Pt_ARG_ACCEL_KEY, ptr2, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ OS.free (ptr2);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
new file mode 100755
index 0000000000..1eff950532
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Canvas.java
@@ -0,0 +1,180 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.internal.photon.*;
+
+public class Canvas extends Composite {
+ Caret caret;
+
+Canvas () {
+ /* Do nothing */
+}
+
+public Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+
+public Caret getCaret () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return caret;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (handle, OS.Ph_EV_DRAG, windowProc, SWT.MouseMove);
+}
+
+int processFocusIn (int info) {
+ int result = super.processFocusIn (info);
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+int processFocusOut (int info) {
+ int result = super.processFocusOut (info);
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+int processPaint (int callData) {
+ boolean isVisible = caret != null && caret.isVisible ();
+ if (isVisible) caret.hideCaret ();
+ int result = super.processPaint (callData);
+ if (isVisible) caret.showCaret ();
+ return result;
+}
+
+int processMouse (int info) {
+ /*
+ * Bug in Photon. Despite the fact that we are returning
+ * Pt_END when a button is pressed, for some reason, the
+ * single-line text widget does not end the processing and
+ * the callback is sent to the parent. This causes us to
+ * call PhInitDrag () which interferes with drag selection
+ * in the text widget. The fix is to only call PhInitDrag ()
+ * when there are no children.
+ */
+ if (OS.PtWidgetChildFront (handle) != 0) {
+ return super.processMouse (info);
+ }
+
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ PhRect_t rect = new PhRect_t ();
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = pe.pos_x;
+ pos.y = pe.pos_y;
+ rect.ul_x = rect.lr_x = (short) (pos.x + ev.translation_x);
+ rect.ul_y = rect.lr_y = (short) (pos.y + ev.translation_y);
+ int rid = OS.PtWidgetRid (handle);
+// int input_group = OS.PhInputGroup (cbinfo.event);
+ int input_group = OS.PhInputGroup (0);
+ OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, pos, null);
+ }
+ return super.processMouse (info);
+}
+
+public void redraw () {
+ boolean isVisible = caret != null && caret.isVisible ();
+ if (isVisible) caret.hideCaret ();
+ super.redraw ();
+ if (isVisible) caret.showCaret ();
+}
+
+public void redraw (int x, int y, int width, int height, boolean all) {
+ boolean isVisible = caret != null && caret.isVisible ();
+ if (isVisible) caret.hideCaret ();
+ super.redraw (x, y, width, height, all);
+ if (isVisible) caret.showCaret ();
+}
+
+void releaseWidget () {
+ if (caret != null) {
+ caret.releaseWidget ();
+ caret.releaseHandle ();
+ }
+ caret = null;
+ super.releaseWidget();
+}
+
+public void scroll (int destX, int destY, int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (width <= 0 || height <= 0) return;
+ int deltaX = destX - x, deltaY = destY - y;
+ if (deltaX == 0 && deltaY == 0) return;
+ if (!isVisible ()) return;
+ boolean isVisible = (caret != null) && (caret.isVisible ());
+ if (isVisible) caret.hideCaret ();
+ PhRect_t rect = new PhRect_t();
+ rect.ul_x = (short)x;
+ rect.ul_y = (short)y;
+ rect.lr_x = (short)(x + width - 1);
+ rect.lr_y = (short)(y + height - 1);
+ PhPoint_t delta = new PhPoint_t();
+ delta.x = (short)deltaX;
+ delta.y = (short)deltaY;
+ OS.PtFlush ();
+ OS.PhBlit(OS.PtWidgetRid(handle), rect, delta);
+ boolean overlaps = (destX < x + width) && (destY < y + height) &&
+ (destX + width > x) && (destY + height > y);
+ if (!overlaps) {
+ OS.PtDamageExtent (handle, rect);
+ } else {
+ int src = OS.PhGetTile();
+ int dest = OS.PhGetTile();
+ OS.memmove(src, rect, PhRect_t.sizeof);
+ OS.memmove(dest, rect, PhRect_t.sizeof);
+ OS.PhTranslateTiles(dest, delta);
+ int damage_tile = OS.PhClipTilings(src, dest, null);
+ int[] damage_rects_count = new int[1];
+ int damage_rects = OS.PhTilesToRects(damage_tile, damage_rects_count);
+ OS.PhFreeTiles(dest);
+ OS.PhFreeTiles(damage_tile);
+ for (int i=0; i<damage_rects_count[0]; i++) {
+ OS.memmove(rect, damage_rects + (i * PhRect_t.sizeof), PhRect_t.sizeof);
+ OS.PtDamageExtent (handle, rect);
+ }
+ OS.free(damage_rects);
+ }
+ if (isVisible) caret.showCaret ();
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean isVisible = (caret != null) && (caret.isVisible ());
+ if (isVisible) caret.hideCaret ();
+ super.setBounds (x, y, width, height, move, resize);
+ if (isVisible) caret.showCaret ();
+}
+
+public void setCaret (Caret caret) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Caret newCaret = caret;
+ Caret oldCaret = this.caret;
+ this.caret = newCaret;
+ if (isFocusControl ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) newCaret.setFocus ();
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
new file mode 100755
index 0000000000..858ff99e8c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Caret.java
@@ -0,0 +1,222 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class Caret extends Widget {
+ Canvas parent;
+ int x, y, width, height;
+ boolean moved, resized;
+ boolean isVisible, isShowing;
+// int blinkRate = 500;
+
+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);
+ isVisible = true;
+ if (parent.getCaret () == null) {
+ parent.setCaret (this);
+ }
+}
+
+boolean drawCaret () {
+ if (parent == null) return false;
+ if (parent.isDisposed ()) return false;
+ int handle = parent.handle;
+ if (!OS.PtWidgetIsRealized (handle)) return false;
+ int phGC = OS.PgCreateGC (0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) return false;
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int foreground = args [1];
+ int background = args [4];
+ int color = foreground ^ ~background;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (OS.PtWidgetRid (handle));
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (color);
+ int nWidth = width;
+ if (nWidth <= 0) nWidth = 2;
+ OS.PgDrawIRect (x, y, x + nWidth - 1, y + height - 1, OS.Pg_DRAW_FILL);
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+ return true;
+}
+
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Rectangle (x, y, width, height);
+}
+
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public Font getFont () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getFont ();
+}
+
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point (x, y);
+}
+
+public Canvas getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return new Point (width, height);
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return isVisible;
+}
+
+boolean hideCaret () {
+// Display display = getDisplay ();
+// if (display.currentCaret != this) return false;
+ if (!isShowing) return true;
+ isShowing = false;
+ return drawCaret ();
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+void killFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret != this) return;
+ if (isVisible) hideCaret ();
+// display.setCurrentCaret (null);
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+// Display display = getDisplay ();
+// if (display.currentCaret == this) {
+// if (isVisible) hideCaret ();
+// display.setCurrentCaret (null);
+// }
+ parent = null;
+}
+
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean samePosition, sameExtent, showing;
+ samePosition = (this.x == x) && (this.y == y);
+ sameExtent = (this.width == width) && (this.height == height);
+ if ((samePosition) && (sameExtent)) return;
+ if (showing = isShowing) hideCaret ();
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ if (sameExtent) {
+ moved = true;
+ if (isVisible ()) {
+ moved = false;
+ }
+ } else {
+ resized = true;
+ if (isVisible ()) {
+ moved = false;
+ resized = false;
+ }
+ }
+ if (showing) showCaret ();
+}
+
+void setFocus () {
+// Display display = getDisplay ();
+// if (display.currentCaret == this) return;
+// display.setCurrentCaret (this);
+ if (isVisible) showCaret ();
+}
+
+public void setFont (Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height);
+}
+
+public void setLocation (Point location) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height);
+}
+
+public void setSize (Point size) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (visible == isVisible) return;
+ if (isVisible = visible) {
+ showCaret ();
+ } else {
+ hideCaret ();
+ }
+}
+
+boolean showCaret () {
+// if (getDisplay ().currentCaret != this) return false;
+ if (isShowing) return true;
+ isShowing = true;
+ return drawCaret ();
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
new file mode 100755
index 0000000000..15d71cf99d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ColorDialog.java
@@ -0,0 +1,51 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class ColorDialog extends Dialog {
+ RGB rgb;
+
+public ColorDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public ColorDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public RGB getRGB () {
+ return rgb;
+}
+
+public RGB open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte[] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ PtColorSelectInfo_t info = new PtColorSelectInfo_t();
+ info.flags = OS.Pt_COLORSELECT_MODAL;
+ if (rgb != null) info.rgb = (rgb. blue & 0xFF) | ((rgb.green & 0xFF) << 8) | ((rgb.red & 0xFF) << 16);
+ rgb = null;
+
+ OS.PtColorSelect(parentHandle, title, info);
+
+ if ((info.flags & OS.Pt_COLORSELECT_ACCEPT) != 0) {
+ int color = info.rgb;
+ rgb = new RGB ((color & 0xFF0000) >> 16, (color & 0xFF00) >> 8, color & 0xFF);
+ }
+ return rgb;
+}
+
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
new file mode 100755
index 0000000000..9b3723f87f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Combo.java
@@ -0,0 +1,497 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Combo extends Composite {
+
+public Combo (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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;
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE: this only works with a DROP_DOWN combo
+ if ((style & SWT.SIMPLE) != 0) return new Point(100, 100);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w;
+ int height = dim.h;
+ int text = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(text, dim);
+ height += dim.h;
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtSetAreaFromWidgetCanvas (text, rect, area);
+ width += area.size_w;
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ OS.Pt_ARG_TEXT_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int maxWidth = 0;
+ rect = new PhRect_t();
+ int [] items = new int [1];
+ for (int i = 0; i < args [1]; i++) {
+ OS.memmove (items, args [4] + (i * 4), 4);
+ int length = OS.strlen (items [0]);
+ OS.PfExtentText(rect, null, args [7], items [0], length);
+ maxWidth = Math.max(maxWidth, rect.lr_x - rect.ul_x + 1);
+ }
+ width += maxWidth;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ rect = new PhRect_t ();
+ area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) width = area.size_w;
+ if (hHint != SWT.DEFAULT) height = area.size_h;
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtComboBox;
+ int parentHandle = parent.handle;
+ int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
+ int [] args = {
+ OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
+ OS.Pt_ARG_CBOX_MAX_VISIBLE_COUNT, 5, 0,
+ OS.Pt_ARG_CBOX_FLAGS, (style & SWT.SIMPLE) != 0 ? OS.Pt_COMBOBOX_STATIC: 0, OS.Pt_COMBOBOX_STATIC,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public void deselect (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == index) {
+ args = new int [] {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+}
+
+public void deselectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void add (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListAddItems (handle, new int [] {ptr}, 1, 0);
+ OS.free (ptr);
+}
+
+public void add (String string, int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int result = OS.PtListAddItems (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+ if (result != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (0 <= index && index <= args [1]) error (SWT.ERROR_ITEM_NOT_ADDED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+public void addModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 void clearSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
+}
+
+public String getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int [] items = new int [1];
+ OS.memmove (items, args [4] + (index * 4), 4);
+ int length = OS.strlen (items [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [0], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getItemHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public String [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] items = new int [args [1]];
+ OS.memmove (items, args [4], args [1] * 4);
+ String [] result = new String [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ int length = OS.strlen (items [i]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [i], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ result [i] = new String (unicode);
+ }
+ return result;
+
+}
+
+public Point getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (((style & SWT.DROP_DOWN) != 0) && ((style & SWT.READ_ONLY) != 0)) {
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int length = 0;
+ if (args [1] != 0) length = OS.strlen (args [1]);
+ return new Point (0, length);
+ }
+// if (textVerify != null) {
+// return new Point (textVerify.start_pos, textVerify.end_pos);
+// }
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ return new Point (start [0], end [0]);
+}
+
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return -1;
+ return args [1] - 1;
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getTextHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - Only works for DROP_DOWN
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int height = dim.h;
+ int text = OS.PtWidgetChildBack(handle);
+ OS.PtWidgetPreferredSize(text, dim);
+ height += dim.h;
+ return height;
+}
+
+public int getTextLimit () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, SWT.Selection);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, SWT.Modify);
+}
+
+public int indexOf (String string) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ return indexOf (string, 0);
+}
+
+public int indexOf (String string, int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ // NOT DONE - start is ignored
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos(handle, buffer) - 1;
+}
+
+int processModify (int info) {
+ sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtComboBox (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.reason_subtype == OS.Pt_LIST_SELECTION_FINAL) {
+ postEvent(SWT.Selection);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+public void remove (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 < start && start <= end && end < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int count = end - start + 1;
+ int result = OS.PtListDeleteItemPos (handle, count, start + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void remove (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void remove (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
+public void removeAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtListDeleteAllItems (handle);
+}
+
+public void removeModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void select (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index < 0) return;
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, index + 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int newHeight = ((style & SWT.DROP_DOWN) != 0) ? getTextHeight() : height;
+ super.setBounds (x, y, width, newHeight, move, resize);
+}
+
+public void setItem (int index, String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListReplaceItemPos (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+}
+
+public void setItems (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtListDeleteAllItems (handle);
+ int[] itemsPtr = new int [items.length];
+ for (int i=0; i<itemsPtr.length; i++) {
+ byte [] buffer = Converter.wcsToMbcs (null, items [i], true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ itemsPtr [i] = ptr;
+ }
+ OS.PtListAddItems (handle, itemsPtr, itemsPtr.length, 0);
+ for (int i=0; i<itemsPtr.length; i++) {
+ OS.free (itemsPtr [i]);
+ }
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (Point selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtTextSetSelection (handle, new int [] {selection.x}, new int [] {selection.y});
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ if ((style & SWT.READ_ONLY) != 0) {
+ int index = OS.PtListItemPos(handle, buffer);
+ if (index > 0) {
+ int [] args = new int [] {OS.Pt_ARG_CBOX_SELECTION_ITEM, index, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+// sendEvent (SWT.Modify);
+ }
+ return;
+ }
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setTextLimit (int limit) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
new file mode 100755
index 0000000000..40fc195c5a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Composite.java
@@ -0,0 +1,258 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Composite extends Scrollable {
+ Layout layout;
+
+Composite () {
+ /* Do nothing */
+}
+
+public Composite (Composite parent, int style) {
+ super (parent, style);
+}
+
+Control [] _getChildren () {
+ int count = 0;
+ int child = OS.PtWidgetChildFront (handle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ Control [] children = new Control [count];
+ int i = 0, j = 0;
+ child = OS.PtWidgetChildFront (handle);
+ while (i < count) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget != this) {
+ if (widget instanceof Control) {
+ children [j++] = (Control) widget;
+ }
+ }
+ i++;
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+ if (i == j) return children;
+ Control [] newChildren = new Control [j];
+ System.arraycopy (children, 0, newChildren, 0, j);
+ return newChildren;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size;
+ if (layout != null) {
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = new Point (wHint, hHint);
+ }
+ } else {
+ size = minimumSize ();
+ }
+ 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);
+}
+
+void createHandle (int index) {
+ int parentHandle = parent.handle;
+ createScrolledHandle (parentHandle);
+}
+
+void createScrollBars () {
+ if (scrolledHandle == 0) return;
+ if ((style & SWT.H_SCROLL) != 0) {
+ horizontalBar = new ScrollBar (this, SWT.HORIZONTAL);
+ }
+ if ((style & SWT.V_SCROLL) != 0) {
+ verticalBar = new ScrollBar (this, SWT.VERTICAL);
+ }
+}
+
+void createScrolledHandle (int parentHandle) {
+ int etches = OS.Pt_ALL_ETCHES | OS.Pt_ALL_OUTLINES;
+ int [] args = new int [] {
+ /*
+ * Bug in Photon. We must set Pt_GETS_FOCUS or Photon will
+ * segment fault when no widget has focus and a key is pressed.
+ */
+ OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_FLAGS, hasBorder () ? OS.Pt_HIGHLIGHTED : 0, OS.Pt_HIGHLIGHTED,
+ OS.Pt_ARG_BASIC_FLAGS, hasBorder () ? etches : 0, etches,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ scrolledHandle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ if (scrolledHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ args = new int [] {
+ OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, scrolledHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createScrollBars ();
+}
+
+public Control [] getChildren () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return _getChildren ();
+}
+
+int getChildrenCount () {
+ int count = 0;
+ int child = OS.PtWidgetChildFront (handle);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherBehind (child);
+ count++;
+ }
+ return count;
+}
+
+public Layout getLayout () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return layout;
+}
+
+boolean hasBorder () {
+ return (style & SWT.BORDER) != 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_RESIZE, windowProc, SWT.Resize);
+}
+
+public void layout () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ layout (true);
+}
+
+Point minimumSize () {
+ 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);
+}
+
+public void layout (boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (layout == null) return;
+ int count = getChildrenCount ();
+ if (count == 0) return;
+ layout.layout (this, changed);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processResize (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ sendEvent (SWT.Resize);
+ if (layout != null) layout (false);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) {
+ child.releaseWidget ();
+ child.releaseHandle ();
+ }
+ }
+ super.releaseWidget ();
+}
+
+void resizeClientArea () {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (scrolledHandle, args.length / 3, args);
+ resizeClientArea (args [1], args [4]);
+}
+
+boolean sendResize () {
+ return false;
+}
+
+void resizeClientArea (int width, int height) {
+ int vBarWidth = 0, hBarHeight = 0;
+ boolean isVisibleHBar = horizontalBar != null && horizontalBar.getVisible ();
+ boolean isVisibleVBar = verticalBar != null && verticalBar.getVisible ();
+ if (isVisibleHBar) {
+ int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (horizontalBar.handle, args.length / 3, args);
+ height = height - (hBarHeight = args [1]);
+ }
+ if (isVisibleVBar) {
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (verticalBar.handle, args.length / 3, args);
+ width = width - (vBarWidth = args [1]);
+ }
+
+ //NOT DONE - used widget canvas to compute insets
+ int left = 0, right = 0;
+ if (hasBorder ()) {
+ left = 2;
+ if (isVisibleHBar && isVisibleVBar) right = 3;
+ }
+ if (isVisibleHBar) {
+ horizontalBar.setBounds (-left, height - left, width + right, hBarHeight);
+ }
+ if (isVisibleVBar) {
+ verticalBar.setBounds (width - left, -left, vBarWidth, height + right);
+ }
+
+ PhArea_t area = new PhArea_t ();
+ area.size_w = (short) (Math.max (width - (left * 2), 0));
+ area.size_h = (short) (Math.max (height - (left * 2), 0));
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ int [] args = {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (resize) resizeClientArea (width, height);
+ super.setBounds (x, y, width, height, move, resize);
+}
+
+public void setLayout (Layout layout) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.layout = layout;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
new file mode 100755
index 0000000000..079c6efd82
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Control.java
@@ -0,0 +1,991 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.*;
+
+public abstract class Control extends Widget implements Drawable {
+ Composite parent;
+ Menu menu;
+ Object layoutData;
+
+Control () {
+ /* Do nothing */
+}
+
+public Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget (0);
+}
+
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Resize,typedListener);
+ addListener (SWT.Move,typedListener);
+}
+
+public void addFocusListener (FocusListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.FocusIn,typedListener);
+ addListener (SWT.FocusOut,typedListener);
+}
+
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+public void addKeyListener (KeyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.KeyUp,typedListener);
+ addListener (SWT.KeyDown,typedListener);
+}
+
+public void addMouseListener (MouseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+
+public void addMouseTrackListener (MouseTrackListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+
+public void addMouseMoveListener (MouseMoveListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.MouseMove,typedListener);
+}
+
+public void addPaintListener (PaintListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Paint,typedListener);
+}
+
+public void addTraverseListener (TraverseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Traverse,typedListener);
+}
+
+public boolean forceFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int shellHandle = OS.PtFindDisjoint (handle);
+ OS.PtWindowToFront (shellHandle);
+ return handle != OS.PtContainerGiveFocus (handle, null);
+}
+
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = DEFAULT_WIDTH;
+ int 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 createWidget (int index) {
+ super.createWidget (index);
+ setZOrder ();
+ realizeWidget ();
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.TEXT_FONT;
+}
+
+public Color getBackground () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+public Font getFont () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ OS.Pt_ARG_TITLE_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ byte [] font;
+ int ptr = args [1];
+ if (ptr == 0) ptr = args [4];
+ if (ptr == 0) ptr = args [7];
+ if (ptr == 0) {
+ font = defaultFont ();
+ } else {
+ int length = OS.strlen (ptr);
+ font = new byte [length + 1];
+ OS.memmove (font, ptr, length);
+ }
+ return Font.photon_new (getDisplay (), font);
+}
+public Color getForeground () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return Color.photon_new (getDisplay (), args [1]);
+}
+
+public int getBorderWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {
+ OS.Pt_ARG_BASIC_FLAGS, 0, 0,
+// OS.Pt_ARG_BEVEL_WIDTH, 0, 0,
+ };
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ int border = 0;
+ int flags = args [1];
+ if ((flags & OS.Pt_ALL_ETCHES) != 0) border++;
+ if ((flags & OS.Pt_ALL_OUTLINES) != 0) border++;
+ if ((flags & OS.Pt_ALL_INLINES) != 0) border++;
+// if ((flags & OS.Pt_ALL_BEVELS) != 0) border += args [4];
+ return border;
+}
+
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_BLOCKED) == 0;
+}
+
+public Object getLayoutData () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return layoutData;
+}
+
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.pos_x, area.pos_y);
+}
+
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
+
+public Composite getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ return new Point (area.size_w, area.size_h);
+}
+
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
+
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ return (args [1] & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+boolean hasFocus () {
+ return OS.PtIsFocused (handle) == 2;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddEventHandler (handle, OS.Ph_EV_KEY, windowProc, SWT.KeyDown);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_PRESS, windowProc, SWT.MouseDown);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BUT_RELEASE, windowProc, SWT.MouseUp);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_PTR_MOTION, windowProc, SWT.MouseMove);
+ OS.PtAddEventHandler (handle, OS.Ph_EV_BOUNDARY, windowProc, SWT.MouseEnter);
+ OS.PtAddCallback (handle, OS.Pt_CB_GOT_FOCUS, windowProc, SWT.FocusIn);
+ OS.PtAddCallback (handle, OS.Pt_CB_LOST_FOCUS, windowProc, SWT.FocusOut);
+}
+
+public int internal_new_GC (GCData data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ data.device = getDisplay ();
+ data.widget = handle;
+ data.topWidget = topHandle ();
+ data.foreground = args [1];
+ data.background = args [4];
+ data.font = getFont ().handle;
+ return phGC;
+}
+
+public void internal_dispose_GC (int phGC, GCData data) {
+ //if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ OS.PgDestroyGC(phGC);
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+public boolean isFocusControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hasFocus ();
+}
+
+public boolean isReparentable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.PtWidgetIsRealized (handle);
+}
+
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+
+public void moveAbove (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ OS.PtWidgetToFront (topHandle1);
+ OS.PtWindowToFront (topHandle1);
+ return;
+ }
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 0);
+}
+
+public void moveBelow (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle1 = topHandle ();
+ if (control == null) {
+ OS.PtWidgetToBack (topHandle1);
+ OS.PtWindowToBack (topHandle1);
+ return;
+ }
+ int topHandle2 = control.topHandle ();
+ OS.PtWidgetInsert (topHandle1, topHandle2, 1);
+}
+
+public void pack () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ pack (true);
+}
+
+public void pack (boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+
+int processPaint (int damage) {
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusIn (int info) {
+ sendEvent (SWT.FocusIn);
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusOut (int info) {
+ sendEvent (SWT.FocusOut);
+ /*
+ * Feature in Photon. Cannot return Pt_END
+ * or the text widget will not take focus.
+ */
+ return OS.Pt_CONTINUE;
+}
+
+int processKey (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhKeyEvent_t ke = new PhKeyEvent_t ();
+ OS.memmove (ke, data, PhKeyEvent_t.sizeof);
+ /*
+ * Feature in Photon. The multi-line text widget consumes
+ * key down events. The fix is to use a filter callback
+ * for the text widget to see the key down. The following
+ * code ignores key up when called from a filter callback.
+ */
+ if (cbinfo.reason == OS.Pt_CB_FILTER) {
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) == 0) {
+ return OS.Pt_PROCESS;
+ }
+ }
+ /*
+ * Feature in Photon. When the user presses certain keys
+ * (such as the arrow keys), Photon sends 2 event for one
+ * key press. The first event has only the scan code while
+ * the second has the keysym and other information. This
+ * also happens for key release. The fix is to ignore the
+ * first event.
+ */
+ if (ke.key_flags == OS.Pk_KF_Scan_Valid) {
+ return (cbinfo.reason == OS.Pt_CB_FILTER) ? OS.Pt_PROCESS : OS.Pt_END;
+ }
+ if ((ke.key_flags & OS.Pk_KF_Key_Repeat) != 0) {
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ switch (ke.key_sym) {
+ case OS.Pk_Alt_L:
+ case OS.Pk_Alt_R:
+ case OS.Pk_Control_L:
+ case OS.Pk_Control_R:
+ case OS.Pk_Shift_L:
+ case OS.Pk_Shift_R:
+ /*
+ * Bug in Photon. Despite the fact that we return Pt_END,
+ * for some reason, Photon continues to forward the event
+ * to the parent. The fix is to change the event type to
+ * zero. This doesn't stop the forwarding but makes the
+ * event unknown.
+ */
+ if (cbinfo.reason == OS.Pt_CB_FILTER) return OS.Pt_PROCESS;
+ OS.memmove (cbinfo.event, new int [1], 4);
+ return OS.Pt_END;
+ }
+ }
+ }
+ Display display = getDisplay ();
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ int type = SWT.KeyUp;
+ if ((ke.key_flags & (OS.Pk_KF_Key_Down | OS.Pk_KF_Key_Repeat)) != 0) {
+ type = SWT.KeyDown;
+ }
+ if ((ke.key_flags & OS.Pk_KF_Sym_Valid) != 0) {
+ event.keyCode = Display.translateKey (ke.key_sym);
+ if (event.keyCode == 0) {
+ switch (ke.key_sym) {
+ case OS.Pk_BackSpace: event.character = '\b'; break;
+ case OS.Pk_Tab: event.character = '\t'; break;
+ case OS.Pk_Linefeed: event.character = '\n'; break;
+ case OS.Pk_Clear: event.character = 0xB; break;
+ case OS.Pk_Return: event.character = '\r'; break;
+ case OS.Pk_Pause: event.character = 0x13; break;
+ case OS.Pk_Scroll_Lock: event.character = 0x14; break;
+ case OS.Pk_Escape: event.character = 0x1B; break;
+ case OS.Pk_Delete: event.character = 0x7F; break;
+ default:
+ event.character = (char) ke.key_sym;
+ }
+ }
+ display.lastKey = event.keyCode;
+ display.lastAscii = event.character;
+ }
+ if ((ke.key_mods & OS.Pk_KM_Alt) != 0) {
+ if (type != SWT.KeyDown || event.keyCode != SWT.ALT) {
+ event.stateMask |= SWT.ALT;
+ }
+ }
+ if ((ke.key_mods & OS.Pk_KM_Shift) != 0) {
+ if (type != SWT.KeyDown || event.keyCode != SWT.SHIFT) {
+ event.stateMask |= SWT.SHIFT;
+ }
+ }
+ if ((ke.key_mods & OS.Pk_KM_Ctrl) != 0) {
+ if (type != SWT.KeyDown || event.keyCode != SWT.CONTROL) {
+ event.stateMask |= SWT.CONTROL;
+ }
+ }
+ if ((ke.button_state & OS.Ph_BUTTON_SELECT) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((ke.button_state & OS.Ph_BUTTON_ADJUST) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((ke.button_state & OS.Ph_BUTTON_MENU) != 0) event.stateMask |= SWT.BUTTON3;
+ if (type == SWT.KeyUp) {
+ if (event.keyCode == 0) event.keyCode = display.lastKey;
+ if (event.character == 0) event.character = (char) display.lastAscii;
+ if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
+ if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
+ if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
+ }
+ postEvent (type, event);
+ /*
+ * Bug in Photon. Despite the fact that we return Pt_END,
+ * for some reason, Photon continues to forward the event
+ * to the parent. The fix is to change the event type to
+ * zero. This doesn't stop the forwarding but makes the
+ * event unknown.
+ */
+ if (cbinfo.reason == OS.Pt_CB_FILTER) return OS.Pt_PROCESS;
+ OS.memmove (cbinfo.event, new int [1], 4);
+ return OS.Pt_END;
+}
+
+int processMouse (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ Event event = new Event ();
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ event.type = SWT.MouseDown;
+ break;
+ case OS.Ph_EV_BUT_RELEASE:
+ if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
+ return OS.Pt_END;
+ }
+ event.type = SWT.MouseUp;
+ break;
+ case OS.Ph_EV_PTR_MOTION_BUTTON:
+ case OS.Ph_EV_PTR_MOTION_NOBUTTON:
+ event.type = SWT.MouseMove;
+ break;
+ case OS.Ph_EV_DRAG:
+ if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
+ return OS.Pt_END;
+ }
+ event.type = SWT.MouseMove;
+ break;
+ }
+ event.time = ev.timestamp;
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ event.x = pe.pos_x + ev.translation_x;
+ event.y = pe.pos_y + ev.translation_y;
+ int type = ev.type;
+ int buttons = pe.buttons;
+ int key_mods = pe.key_mods;
+ int button_state = pe.button_state;
+ int click_count = pe.click_count;
+ switch (buttons) {
+ case OS.Ph_BUTTON_SELECT: event.button = 1; break;
+ case OS.Ph_BUTTON_ADJUST: event.button = 2; break;
+ case OS.Ph_BUTTON_MENU: event.button = 3; break;
+ }
+ if ((key_mods & OS.Pk_KM_Alt) != 0) event.stateMask |= SWT.ALT;
+ if ((key_mods & OS.Pk_KM_Shift) != 0) event.stateMask |= SWT.SHIFT;
+ if ((key_mods & OS.Pk_KM_Ctrl) != 0) event.stateMask |= SWT.CONTROL;
+ if ((button_state & OS.Ph_BUTTON_SELECT) != 0) event.stateMask |= SWT.BUTTON1;
+ if ((button_state & OS.Ph_BUTTON_ADJUST) != 0) event.stateMask |= SWT.BUTTON2;
+ if ((button_state & OS.Ph_BUTTON_MENU) != 0) event.stateMask |= SWT.BUTTON3;
+ if (type == OS.Ph_EV_BUT_PRESS) {
+ if (buttons == OS.Ph_BUTTON_SELECT && (button_state & OS.Ph_BUTTON_SELECT) != 0) {
+ event.stateMask &= ~SWT.BUTTON1;
+ }
+ if (buttons == OS.Ph_BUTTON_ADJUST && (button_state & OS.Ph_BUTTON_ADJUST) != 0) {
+ event.stateMask &= ~SWT.BUTTON2;
+ }
+ if (buttons == OS.Ph_BUTTON_MENU && (button_state & OS.Ph_BUTTON_MENU) != 0) {
+ event.stateMask &= ~SWT.BUTTON3;
+ }
+ }
+ if (type == OS.Ph_EV_BUT_RELEASE) {
+ if (buttons == OS.Ph_BUTTON_SELECT) event.stateMask |= SWT.BUTTON1;
+ if (buttons == OS.Ph_BUTTON_ADJUST) event.stateMask |= SWT.BUTTON2;
+ if (buttons == OS.Ph_BUTTON_MENU) event.stateMask |= SWT.BUTTON3;
+ }
+ postEvent (event.type, event);
+ if (type == OS.Ph_EV_BUT_PRESS && click_count == 2) {
+ postEvent (SWT.MouseDoubleClick, event);
+ }
+ return OS.Pt_END;
+}
+
+int processMouseEnter (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int rects = OS.PhGetRects (cbinfo.event);
+ PhRect_t rect = new PhRect_t ();
+ OS.memmove (rect, rects, PhRect_t.sizeof);
+ Event event = new Event ();
+ event.time = ev.timestamp;
+ event.x = rect.ul_x;
+ event.y = rect.ul_y;
+ switch (ev.subtype) {
+ case OS.Ph_EV_PTR_ENTER:
+ case OS.Ph_EV_PTR_ENTER_FROM_CHILD:
+ sendEvent (SWT.MouseEnter, event);
+ break;
+ case OS.Ph_EV_PTR_LEAVE:
+ case OS.Ph_EV_PTR_LEAVE_TO_CHILD:
+ sendEvent (SWT.MouseExit, event);
+ break;
+ }
+ return OS.Pt_END;
+}
+
+void realizeWidget() {
+ int parentHandle = parent.handle;
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ }
+}
+
+public void redraw () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtDamageWidget (handle);
+}
+
+public void redraw (int x, int y, int width, int height, boolean allChildren) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhRect_t rect = new PhRect_t ();
+ rect.ul_x = (short) x;
+ rect.ul_y = (short) y;
+ rect.lr_x = (short) (x + width - 1);
+ rect.lr_y = (short) (y + height - 1);
+ OS.PtDamageExtent (handle, rect);
+}
+
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+ eventTable.unhook (SWT.Resize, listener);
+}
+
+public void removeFocusListener(FocusListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.FocusIn, listener);
+ eventTable.unhook (SWT.FocusOut, listener);
+}
+
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+public void removeKeyListener(KeyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.KeyUp, listener);
+ eventTable.unhook (SWT.KeyDown, listener);
+}
+
+public void removeMouseTrackListener(MouseTrackListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+
+public void removeMouseListener (MouseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+
+public void removeMouseMoveListener(MouseMoveListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.MouseMove, listener);
+}
+
+public void removePaintListener(PaintListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Paint, listener);
+}
+
+public void removeTraverseListener(TraverseListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Traverse, listener);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ int topHandle = topHandle ();
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (topHandle, area);
+ boolean sameOrigin = x == area.pos_x && y == area.pos_y;
+ boolean sameExtent = width == area.size_w && height == area.size_h;
+ if (move && resize) {
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) (Math.max (width, 0));
+ area.size_h = (short) (Math.max (height, 0));
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ int [] args = {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ OS.free (ptr);
+ } else {
+ if (move) {
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) x;
+ pt.y = (short) y;
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ int [] args = {OS.Pt_ARG_POS, ptr, 0};
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ OS.free (ptr);
+ }
+ if (resize) {
+ int [] args = {
+ OS.Pt_ARG_WIDTH, Math.max (width, 0), 0,
+ OS.Pt_ARG_HEIGHT, Math.max (height, 0), 0,
+ };
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ }
+ }
+ if (!OS.PtWidgetIsRealized (topHandle)) {
+ OS.PtExtentWidgetFamily (topHandle);
+ }
+ if (!sameOrigin & move) sendEvent (SWT.Move);
+ if (!sameExtent & resize & sendResize()) sendEvent (SWT.Resize);
+}
+
+public void setBounds (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, width, height, true, true);
+}
+
+public void setBounds (Rectangle rect) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+public void setCapture (boolean capture) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setCursor (Cursor cursor) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int type = OS.Ph_CURSOR_INHERIT;
+ if (cursor != null) type = cursor.handle;
+ int [] args = {OS.Pt_ARG_CURSOR_TYPE, type, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public boolean setFocus () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return forceFocus ();
+}
+
+void sendPaintEvent (int damage) {
+
+ if (!hooks(SWT.Paint)) return;
+
+ /* Translate the damage to widget coordinates */
+ short [] widgetX = new short [1];
+ short [] widgetY = new short [1];
+ OS.PtGetAbsPosition (handle, widgetX, widgetY);
+ short [] shellX = new short [1];
+ short [] shellY = new short [1];
+ int shellHandle = OS.PtFindDisjoint (handle);
+ OS.PtGetAbsPosition (shellHandle, shellX, shellY);
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) (shellX [0] - widgetX [0]);
+ pt.y = (short) (shellY [0] - widgetY [0]);
+ damage = OS.PhCopyTiles (damage);
+ damage = OS.PhTranslateTiles (damage, pt);
+
+ /* Send the paint event */
+ PhTile_t tile = new PhTile_t ();
+ OS.memmove (tile, damage, PhTile_t.sizeof);
+ Event event = new Event ();
+ event.x = tile.rect_ul_x;
+ event.y = tile.rect_ul_y;
+ event.width = tile.rect_lr_x - tile.rect_ul_x + 1;
+ event.height = tile.rect_lr_y - tile.rect_ul_y + 1;
+ Region region = Region.photon_new (tile.next);
+ GC gc = event.gc = new GC (this);
+ gc.setClipping (region);
+ sendEvent (SWT.Paint, event);
+ gc.dispose ();
+ OS.PhFreeTiles (damage);
+ event.gc = null;
+}
+
+boolean sendResize () {
+ return true;
+}
+
+public void setBackground (Color color) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int pixel = OS.Pt_DEFAULT_COLOR;
+ if (color != null) pixel = color.handle;
+ int [] args = {OS.Pt_ARG_FILL_COLOR, pixel, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setFont (Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ byte [] buffer = (font != null) ? font.handle : defaultFont ();
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {
+ OS.Pt_ARG_TEXT_FONT, ptr, 0,
+ OS.Pt_ARG_LIST_FONT, ptr, 0,
+ OS.Pt_ARG_TITLE_FONT, ptr, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setForeground (Color color) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int pixel = OS.Pt_DEFAULT_COLOR;
+ if (color != null) pixel = color.handle;
+ int [] args = {OS.Pt_ARG_COLOR, pixel, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMenu (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.menu = menu;
+}
+
+public boolean setParent (Composite parent) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public void setLayoutData (Object layoutData) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.layoutData = layoutData;
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (x, y, 0, 0, true, false);
+}
+
+public void setLocation (Point location) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (location == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setLocation (location.x, location.y);
+}
+
+public void setSize (Point size) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSize (size.x, size.y);
+}
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (redraw) {
+ OS.PtContainerRelease (handle);
+ } else {
+ OS.PtContainerHold (handle);
+ }
+}
+public void setSize (int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ setBounds (0, 0, width, height, false, true);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {
+ OS.Pt_ARG_FLAGS, visible ? 0 : OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (topHandle, args.length / 3, args);
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (topHandle);
+ } else {
+ OS.PtUnrealizeWidget (topHandle);
+ sendEvent(SWT.Hide);
+ }
+}
+
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+void setZOrder() {
+ OS.PtWidgetToBack (topHandle ());
+}
+
+public Point toControl (Point point) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (handle, x, y);
+ return new Point (x [0] - point.x, y [0] - point.y);
+}
+
+public Point toDisplay (Point point) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ short [] x = new short [1], y = new short [1];
+ OS.PtGetAbsPosition (handle, x, y);
+ return new Point (point.x + x [0], point.y + y [0]);
+}
+
+public boolean traverse (int traversal) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public void update () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtFlush ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
new file mode 100755
index 0000000000..80f4787cc6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Decorations.java
@@ -0,0 +1,174 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Decorations extends Canvas {
+ Menu menuBar;
+ Menu [] menus;
+ String text = "";
+ Image image;
+
+Decorations () {
+ /* Do nothing */
+}
+
+public Decorations (Composite parent, int style) {
+ super (parent, style);
+}
+
+static int checkStyle (int style) {
+ if ((style & (SWT.MENU | SWT.MIN | SWT.MAX | SWT.CLOSE)) != 0) {
+ style |= SWT.TITLE;
+ }
+ return style;
+}
+
+void add (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;
+}
+
+void bringToTop () {
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Button getDefaultButton () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return null;
+}
+
+public Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+
+public boolean getMaximized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public boolean getMinimized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return false;
+}
+
+public Menu getMenuBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menuBar;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return text;
+}
+
+boolean hasBorder () {
+ return false;
+}
+
+Decorations menuShell () {
+ return this;
+}
+
+void releaseWidget () {
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null && !menu.isDisposed ()) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ }
+ }
+ menuBar = null;
+ menus = null;
+ image = null;
+ super.releaseWidget ();
+}
+
+void remove (Menu menu) {
+ if (menus == null) return;
+ for (int i=0; i<menus.length; i++) {
+ if (menus [i] == menu) {
+ menus [i] = null;
+ return;
+ }
+ }
+}
+
+void resizeBounds (int width, int height) {
+ if (menuBar != null) {
+ int [] args = {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (menuBar.handle, args.length / 3, args);
+ height = Math.max (height - args [1], 0);
+ }
+ int [] args = {OS.Pt_ARG_WIDTH, width, 0, OS.Pt_ARG_HEIGHT, height, 0};
+ OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ resizeClientArea (width, height);
+}
+
+public void setDefaultButton (Button button) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.image = image;
+}
+
+public void setMaximized (boolean maximized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setMenuBar (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE
+}
+
+public void setMinimized (boolean minimized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ text = string;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
new file mode 100755
index 0000000000..dc7aad26e1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -0,0 +1,61 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "";
+
+public DirectoryDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public DirectoryDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public String getFilterPath () {
+ return filterPath;
+}
+
+public String getMessage () {
+ return message;
+}
+
+public String open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ byte [] root_dir = null;
+ if (filterPath != null) {
+ root_dir = Converter.wcsToMbcs (null, filterPath, true);
+ }
+ byte [] file_spec = null;
+ int flags = OS.Pt_FSR_NO_FCHECK | OS.Pt_FSR_NO_SELECT_FILES | OS.Pt_FSR_SELECT_DIRS;
+ PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
+ OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, null, null, null, info, flags);
+ if (info.ret == OS.Pt_FSDIALOG_BTN2) return null;
+ int length = 0;
+ while (length < info.path.length && info.path [length] != 0) length++;
+ byte [] path = new byte [length];
+ System.arraycopy (info.path, 0, path, 0, length);
+ return new String (Converter.mbcsToWcs (null, path));
+}
+
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+public void setMessage (String string) {
+ message = string;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
new file mode 100755
index 0000000000..f4412502fa
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Display.java
@@ -0,0 +1,943 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class Display extends Device {
+
+ /**** TEMPORARY CODE FOR MOTIF TABLE ***/
+ static int textHighlightThickness = 0;
+
+ /* TEMPORARY HACK FOR PHOTON */
+ public boolean embedded;
+
+ /* Photon Only Public Fields */
+ public int app_context;
+// public int phEventSize = PhEvent_t.sizeof + 1024;
+// public int phEvent = OS.malloc (phEventSize);
+
+ /* Deferred Events */
+ Event [] eventQueue;
+
+ /* Events Dispatching and Callback */
+ Callback windowCallback, drawCallback, workCallback, inputCallback;
+ int windowProc, drawProc, workProc, inputProc, input, pulse;
+ boolean idle;
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread = Thread.currentThread ();
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timers;
+ Runnable [] timerList;
+ Callback timerCallback;
+ int timerProc, timerHandle;
+
+ /* Keyboard */
+ int lastKey, lastAscii;
+
+ /* Key Mappings. */
+ private static final int [] [] KeyTable = {
+
+ /* Keyboard and Mouse Masks */
+ {OS.Pk_Alt_L, SWT.ALT},
+ {OS.Pk_Alt_R, SWT.ALT},
+ {OS.Pk_Shift_L, SWT.SHIFT},
+ {OS.Pk_Shift_R, SWT.SHIFT},
+ {OS.Pk_Control_L, SWT.CONTROL},
+ {OS.Pk_Control_R, SWT.CONTROL},
+
+// {OS.VK_LBUTTON, SWT.BUTTON1},
+// {OS.VK_MBUTTON, SWT.BUTTON3},
+// {OS.VK_RBUTTON, SWT.BUTTON2},
+
+ /* Non-Numeric Keypad Constants */
+ {OS.Pk_Up, SWT.ARROW_UP},
+ {OS.Pk_Down, SWT.ARROW_DOWN},
+ {OS.Pk_Left, SWT.ARROW_LEFT},
+ {OS.Pk_Right, SWT.ARROW_RIGHT},
+ {OS.Pk_Prior, SWT.PAGE_UP},
+ {OS.Pk_Next, SWT.PAGE_DOWN},
+ {OS.Pk_Home, SWT.HOME},
+ {OS.Pk_End, SWT.END},
+ {OS.Pk_Insert, SWT.INSERT},
+// {OS.Pk_Delete, SWT.DELETE},
+// {OS.Pk_Escape, 0x001B},
+
+ /* Functions Keys */
+ {OS.Pk_F1, SWT.F1},
+ {OS.Pk_F2, SWT.F2},
+ {OS.Pk_F3, SWT.F3},
+ {OS.Pk_F4, SWT.F4},
+ {OS.Pk_F5, SWT.F5},
+ {OS.Pk_F6, SWT.F6},
+ {OS.Pk_F7, SWT.F7},
+ {OS.Pk_F8, SWT.F8},
+ {OS.Pk_F9, SWT.F9},
+ {OS.Pk_F10, SWT.F10},
+ {OS.Pk_F11, SWT.F11},
+ {OS.Pk_F12, SWT.F12},
+
+
+ /* Numeric Keypad Constants */
+ /*
+ {OS.XK_KP_Add, SWT.KP_PLUS},
+ {OS.XK_KP_Subtract, SWT.KP_MINUS},
+ {OS.XK_KP_Multiply, SWT.KP_TIMES},
+ {OS.XK_KP_Divide, SWT.KP_DIVIDE},
+ {OS.XK_KP_Decimal, SWT.KP_PERIOD},
+ {OS.XK_KP_Enter, SWT.KP_ENTER},
+ {OS.XK_KP_0, SWT.KP_0},
+ {OS.XK_KP_1, SWT.KP_1},
+ {OS.XK_KP_2, SWT.KP_2},
+ {OS.XK_KP_3, SWT.KP_3},
+ {OS.XK_KP_4, SWT.KP_4},
+ {OS.XK_KP_5, SWT.KP_5},
+ {OS.XK_KP_6, SWT.KP_6},
+ {OS.XK_KP_7, SWT.KP_7},
+ {OS.XK_KP_8, SWT.KP_8},
+ {OS.XK_KP_9, SWT.KP_9},
+ */
+ };
+
+ /* Multiple Displays. */
+ static Display Default;
+ static Display [] Displays = new Display [4];
+
+ /* Window Classes */
+ static int ClassesPtr;
+ static int PtButton;
+ static int PtList;
+ static int PtLabel;
+ static int PtWindow;
+ static int PtToggleButton;
+ static int PtComboBox;
+ static int PtText;
+ static int PtMultiText;
+ static int PtScrollbar;
+ static int PtScrollContainer;
+ static int PtScrollArea;
+ static int PtContainer;
+ static int PtProgress;
+ static int PtPanelGroup;
+ static int PtPane;
+ static int PtTree;
+ static int PtSlider;
+ static int PtSeparator;
+
+ /* Colors */
+ int WIDGET_DARK_SHADOW, WIDGET_NORMAL_SHADOW, WIDGET_LIGHT_SHADOW;
+ int WIDGET_HIGHLIGHT_SHADOW, WIDGET_BACKGROUND, WIDGET_FOREGROUND, WIDGET_BORDER;
+ int LIST_FOREGROUND, LIST_BACKGROUND, LIST_SELECTION, LIST_SELECTION_TEXT;
+
+ /* Fonts */
+ byte [] TEXT_FONT, LIST_FONT;
+
+ /* Package name */
+ static final String PACKAGE_NAME;
+ static {
+ String name = Display.class.getName ();
+ int index = name.lastIndexOf ('.');
+ PACKAGE_NAME = name.substring (0, index + 1);
+ }
+
+ /* Photon Draw Buffer - shared by all widgets */
+ static int DrawBufferSize = 1024 * 48;
+
+ /* Display Data */
+ Object data;
+ String [] keys;
+ Object [] values;
+
+public Display () {
+ this (null);
+}
+
+public Display (DeviceData data) {
+ super (data);
+}
+
+public void asyncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.asyncExec (runnable);
+}
+
+public void beep () {
+ checkDevice ();
+ OS.PtBeep ();
+}
+
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+synchronized void checkDisplay () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+
+protected void checkSubclass () {
+ if (!isValidClass (getClass ())) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+protected void create (DeviceData data) {
+ checkSubclass ();
+ checkDisplay ();
+ createDisplay (data);
+ register ();
+ if (Default == null) Default = this;
+}
+
+void createDisplay (DeviceData data) {
+ OS.PtInit (null);
+ OS.PgSetDrawBufferSize (DrawBufferSize);
+ app_context = OS.PtCreateAppContext ();
+}
+
+synchronized void deregister () {
+ for (int i=0; i<Displays.length; i++) {
+ if (this == Displays [i]) Displays [i] = null;
+ }
+}
+
+protected void destroy () {
+ if (this == Default) Default = null;
+ deregister ();
+ destroyDisplay ();
+}
+
+void destroyDisplay () {
+ // NEED to destroy app_context ???
+}
+
+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;
+}
+
+int drawProc (int handle, int damage) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return 0;
+ return widget.processPaint (damage);
+}
+
+void error (int code) {
+ SWT.error(code);
+}
+
+public static synchronized Display findDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ Display display = Displays [i];
+ if (display != null && display.thread == thread) {
+ return display;
+ }
+ }
+ return null;
+}
+
+public Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+
+public Shell getActiveShell () {
+ checkDevice ();
+ int handle = 0;
+ while ((handle = OS.PtNextTopLevelWidget (handle)) != 0) {
+ int state = OS.PtWindowGetState (handle);
+ if (state != -1 && (state & OS.Ph_WM_STATE_ISFOCUS) != 0) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget instanceof Shell) return (Shell) widget;
+ }
+ }
+ return null;
+}
+
+public Rectangle getBounds () {
+ checkDevice ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle (rect.ul_x, rect.ul_y, width, height);
+}
+
+public Control getCursorControl () {
+ checkDevice ();
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short) ig, info);
+ PhRect_t rect = new PhRect_t ();
+ rect.ul_x = rect.lr_x = info.pos_x;
+ rect.ul_y = rect.lr_y = info.pos_y;
+ int handle = 0;
+ //DOESN'T WORK WHEN SHELLS OVERLAP (NEED Z ORDER)
+ while ((handle = OS.PtNextTopLevelWidget (handle)) != 0) {
+ int child = handle, parent = 0;
+ short [] x = new short [1], y = new short [1];
+ do {
+ OS.PtGetAbsPosition (child, x, y);
+ rect.ul_x = rect.lr_x = (short) (info.pos_x - x [0]);
+ rect.ul_y = rect.lr_y = (short) (info.pos_y - y [0]);
+ if ((child = OS.PtHit (child, 1, rect)) == 0) break;
+ parent = child;
+ if (OS.PtWidgetIsClassMember (child, OS.PtContainer ()) == 0) break;
+ } while (child != 0);
+ if (parent != 0) {
+ do {
+ Widget widget = WidgetTable.get (parent);
+ if (widget != null && widget instanceof Control) {
+ Control control = (Control) widget;
+ if (control.getEnabled ()) return control;
+ return control;
+ }
+ } while ((parent = OS.PtWidgetParent (parent)) != 0);
+ }
+ }
+ return null;
+}
+
+public Point getCursorLocation () {
+ checkDevice ();
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short)ig, info);
+ return new Point (info.pos_x, info.pos_y);
+}
+
+public static synchronized Display getCurrent () {
+ Thread current = Thread.currentThread ();
+ for (int i=0; i<Displays.length; i++) {
+ Display display = Displays [i];
+ if (display != null && display.thread == current) return display;
+ }
+ return null;
+}
+
+public static synchronized Display getDefault () {
+ if (Default == null) Default = new Display ();
+ return Default;
+}
+
+public static void setAppName (String name) {
+ /* Do nothing */
+}
+
+public int getDoubleClickTime () {
+ checkDevice ();
+ //NOT DONE
+ return 250;
+}
+
+public Control getFocusControl () {
+ checkDevice ();
+ int handle = 0;
+ while ((handle = OS.PtNextTopLevelWidget (handle)) != 0) {
+ int state = OS.PtWindowGetState (handle);
+ if (state != -1 && (state & OS.Ph_WM_STATE_ISFOCUS) != 0) {
+ int focusHandle = OS.PtContainerFindFocus (handle);
+ if (focusHandle != 0) {
+ Widget widget = WidgetTable.get (focusHandle);
+ if (widget instanceof Control) return (Control) widget;
+ }
+ return null;
+ }
+ }
+ return null;
+}
+
+public int getIconDepth () {
+ return getDepth ();
+}
+
+public Shell [] getShells () {
+ checkDevice ();
+ /*
+ * NOTE: Need to check that the shells that belong
+ * to another display have not been disposed by the
+ * other display's thread as the shells list is being
+ * processed.
+ */
+ int count = 0;
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ count++;
+ }
+ }
+ if (count == shells.length) return shells;
+ int index = 0;
+ Shell [] result = new Shell [count];
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ result [index++] = shell;
+ }
+ }
+ return result;
+}
+
+public Color getSystemColor (int id) {
+ checkDevice ();
+ int color = 0x000000;
+ switch (id) {
+ case SWT.COLOR_TITLE_FOREGROUND: color = 0x000000; break;
+ case SWT.COLOR_TITLE_BACKGROUND: color = 0x6493E7; break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: color = 0x0000FF; break;
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: color = 0x000000; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: color = 0xABBBD3; break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: color = 0x0000FF; break;
+ case SWT.COLOR_WIDGET_DARK_SHADOW: color = WIDGET_DARK_SHADOW; break;
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: color = WIDGET_NORMAL_SHADOW; break;
+ case SWT.COLOR_WIDGET_LIGHT_SHADOW: color = WIDGET_LIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: color = WIDGET_HIGHLIGHT_SHADOW; break;
+ case SWT.COLOR_WIDGET_BACKGROUND: color = WIDGET_BACKGROUND; break;
+ case SWT.COLOR_WIDGET_FOREGROUND: color = WIDGET_FOREGROUND; break;
+ case SWT.COLOR_WIDGET_BORDER: color = WIDGET_BORDER; break;
+ case SWT.COLOR_LIST_FOREGROUND: color = LIST_FOREGROUND; break;
+ case SWT.COLOR_LIST_BACKGROUND: color = LIST_BACKGROUND; break;
+ case SWT.COLOR_LIST_SELECTION: color = LIST_SELECTION; break;
+ case SWT.COLOR_LIST_SELECTION_TEXT: color = LIST_SELECTION_TEXT; break;
+ default:
+ return super.getSystemColor (id);
+ }
+ return Color.photon_new (this, color);
+}
+
+public Font getSystemFont () {
+ checkDevice ();
+ return Font.photon_new (this, TEXT_FONT);
+}
+
+public Thread getSyncThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return synchronizer.syncThread;
+}
+
+public Thread getThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+}
+
+protected void init () {
+ super.init ();
+ initializeDisplay ();
+ initializeWidgetClasses ();
+ initializeWidgetColors ();
+ initializeWidgetFonts ();
+}
+
+void initializeDisplay () {
+ windowCallback = new Callback (this, "windowProc", 3);
+ windowProc = windowCallback.getAddress ();
+ if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ drawCallback = new Callback (this, "drawProc", 2);
+ drawProc = drawCallback.getAddress ();
+ if (drawProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ workCallback = new Callback (this, "workProc", 1);
+ workProc = workCallback.getAddress ();
+ if (workProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ inputCallback = new Callback (this, "inputProc", 4);
+ inputProc = inputCallback.getAddress ();
+ if (inputProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+ timerCallback = new Callback (this, "timerProc", 3);
+ timerProc = timerCallback.getAddress ();
+ if (timerProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ pulse = OS.PtAppCreatePulse (app_context, -1);
+ input = OS.PtAppAddInput (app_context, pulse, inputProc, 0);
+ int [] args = {
+ OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
+ OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ OS.Pt_ARG_REGION_SENSE, OS.Ph_EV_TIMER, ~0,
+ };
+ OS.PtSetParentWidget (0);
+ timerHandle = OS.PtCreateWidget (OS.PtRegion (), 0, args.length / 3, args);
+ if (timerHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.PtRealizeWidget (timerHandle);
+}
+
+void initializeWidgetClasses () {
+ int [] args = {OS.Pt_SET_DRAW_F, drawProc, 0};
+ int [] buffer = {
+ OS.PtCreateWidgetClass (OS.PtButton (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtList (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtLabel (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtWindow (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtToggleButton (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtComboBox (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtText (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtMultiText (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtScrollbar (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtScrollContainer (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtScrollArea (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtContainer (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtProgress (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtPanelGroup (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtPane (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtTree (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtSlider (), 0, args.length / 3, args), 0, 0,
+ OS.PtCreateWidgetClass (OS.PtSeparator (), 0, args.length / 3, args), 0, 0,
+ };
+ ClassesPtr = OS.malloc (buffer.length * 4);
+ OS.memmove (ClassesPtr, buffer, buffer.length * 4);
+ PtButton = ClassesPtr;
+ PtList = ClassesPtr + 12;
+ PtLabel = ClassesPtr + 24;
+ PtWindow = ClassesPtr + 36;
+ PtToggleButton = ClassesPtr + 48;
+ PtComboBox = ClassesPtr + 60;
+ PtText = ClassesPtr + 72;
+ PtMultiText = ClassesPtr + 84;
+ PtScrollbar = ClassesPtr + 96;
+ PtScrollContainer = ClassesPtr + 108;
+ PtScrollArea = ClassesPtr + 120;
+ PtContainer = ClassesPtr + 132;
+ PtProgress = ClassesPtr + 144;
+ PtPanelGroup = ClassesPtr + 156;
+ PtPane = ClassesPtr + 168;
+ PtTree = ClassesPtr + 180;
+ PtSlider = ClassesPtr + 192;
+ PtSeparator = ClassesPtr + 204;
+}
+
+void initializeWidgetColors () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int [] args = {
+ OS.Pt_ARG_COLOR, 0, 0,
+ OS.Pt_ARG_FILL_COLOR, 0, 0,
+ };
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ WIDGET_FOREGROUND = args [1];
+ WIDGET_BACKGROUND = args [4];
+ int handle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
+ args = new int [] {
+ OS.Pt_ARG_COLOR, 0, 0,
+ OS.Pt_ARG_FILL_COLOR, 0, 0,
+ OS.Pt_ARG_SELECTION_FILL_COLOR, 0, 0,
+ OS.Pt_ARG_SELECTION_TEXT_COLOR, 0, 0,
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_OUTLINE_COLOR, 0, 0,
+ OS.Pt_ARG_INLINE_COLOR, 0, 0,
+ OS.Pt_ARG_INLINE_COLOR, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ LIST_FOREGROUND = args [1];
+ LIST_BACKGROUND = args [4];
+ LIST_SELECTION = args [7];
+ LIST_SELECTION_TEXT = args [10];
+ WIDGET_BORDER = args [13];
+ WIDGET_DARK_SHADOW = args [16];
+ WIDGET_NORMAL_SHADOW = args [19];
+ WIDGET_LIGHT_SHADOW = args [22];
+ WIDGET_HIGHLIGHT_SHADOW = args [25];
+ OS.PtDestroyWidget (shellHandle);
+}
+
+void initializeWidgetFonts () {
+ OS.PtSetParentWidget (0);
+ int shellHandle = OS.PtCreateWidget (OS.PtWindow (), 0, 0, null);
+ int listHandle = OS.PtCreateWidget (OS.PtList (), shellHandle, 0, null);
+ int [] args = {OS.Pt_ARG_LIST_FONT, 0, 0};
+ OS.PtGetResources (listHandle, args.length / 3, args);
+ int count = OS.strlen (args [1]);
+ LIST_FONT = new byte [count + 1];
+ OS.memmove (LIST_FONT, args [1], count);
+ int textHandle = OS.PtCreateWidget (OS.PtText (), shellHandle, 0, null);
+ args = new int [] {OS.Pt_ARG_TEXT_FONT, 0, 0};
+ OS.PtGetResources (textHandle, args.length / 3, args);
+ count = OS.strlen (args [1]);
+ TEXT_FONT = new byte [count + 1];
+ OS.memmove (TEXT_FONT, args [1], count);
+ OS.PtDestroyWidget (shellHandle);
+}
+
+int inputProc (int data, int rcvid, int message, int size) {
+ if (embedded) {
+ runDeferredEvents ();
+ runAsyncMessages ();
+ }
+ return OS.Pt_CONTINUE;
+}
+
+public int internal_new_GC (GCData data) {
+ int phGC = OS.PgCreateGC(0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ data.device = this;
+ data.rid = OS.Ph_DEV_RID;
+ return phGC;
+}
+
+public void internal_dispose_GC (int phGC, GCData data) {
+ OS.PgDestroyGC(phGC);
+}
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+
+public Object getData (String key) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (keys == null) return null;
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) return values [i];
+ }
+ return null;
+}
+
+public Object getData () {
+ checkDevice ();
+ return data;
+}
+static boolean isValidClass (Class clazz) {
+ String name = clazz.getName ();
+ int index = name.lastIndexOf ('.');
+ return name.substring (0, index + 1).equals (PACKAGE_NAME);
+}
+
+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;
+ if (embedded) wake ();
+}
+
+public boolean readAndDispatch () {
+ checkDevice ();
+ idle = false;
+ int id = OS.PtAppAddWorkProc (app_context, workProc, 0);
+ OS.PtAppProcessEvent (app_context);
+ OS.PtAppRemoveWorkProc (app_context, id);
+ if (!idle) {
+ runDeferredEvents ();
+ return true;
+ }
+ return runAsyncMessages ();
+}
+
+synchronized void register () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] == null) {
+ Displays [i] = this;
+ return;
+ }
+ }
+ Display [] newDisplays = new Display [Displays.length + 4];
+ System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+ newDisplays [Displays.length] = this;
+ Displays = newDisplays;
+}
+
+protected void release () {
+ super.release ();
+
+ /* Release shells */
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ if (this == shell.getDisplay ()) shell.dispose ();
+ }
+ }
+ while (readAndDispatch ()) {};
+
+ /* Run dispose list */
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+
+ /* Release synchronizer */
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+
+ releaseDisplay ();
+}
+
+void releaseDisplay () {
+
+ OS.PtDestroyWidget (timerHandle);
+
+ /* Free the classes array */
+ OS.free (ClassesPtr);
+
+ /* Free pulses and input proc */
+ OS.PtAppRemoveInput (app_context, input);
+ OS.PtAppDeletePulse (app_context, pulse);
+
+ /* Free the window proc */
+ windowCallback.dispose ();
+ windowCallback = null;
+
+ /* Free the timers */
+ if (timers != null) {
+ for (int i=0; i<=timers.length; i++) {
+ OS.PtDestroyWidget (timers [i]);
+ }
+ }
+ timers = null;
+ timerList = null;
+ timerProc = 0;
+ timerCallback.dispose ();
+ timerCallback = null;
+
+ /* Free callbacks */
+ drawCallback.dispose();
+ drawCallback = null;
+ workCallback.dispose();
+ workCallback = null;
+ inputCallback.dispose();
+ inputCallback = null;
+
+ /* Release references */
+ thread = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
+boolean runAsyncMessages () {
+ return synchronizer.runAsyncMessages ();
+}
+
+boolean runDeferredEvents () {
+ /*
+ * Run deferred events. This code is always
+ * called in the Display's thread so it must
+ * be re-enterant 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.notifyListeners (event.type, 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;
+}
+
+public void setData (String key, Object value) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* 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;
+}
+
+public void setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+
+public void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+
+public boolean sleep () {
+ checkDevice ();
+ OS.PtAppProcessEvent (app_context);
+ runDeferredEvents ();
+ return true;
+}
+
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+
+public void timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (timerList == null) timerList = new Runnable [4];
+ if (timers == null) timers = new int [4];
+ int 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 [] newTimers = new int [timers.length + 4];
+ System.arraycopy (timers, 0, newTimers, 0, timers.length);
+ timers = newTimers;
+ }
+ int [] args = {OS.Pt_ARG_TIMER_INITIAL, milliseconds, 0};
+ int handle = OS.PtCreateWidget (OS.PtTimer (), timerHandle, args.length / 3, args);
+ OS.PtRealizeWidget (handle);
+ if (handle != 0) {
+ OS.PtAddCallback (handle, OS.Pt_CB_TIMER_ACTIVATE, timerProc, index);
+ timerList [index] = runnable;
+ timers [index] = handle;
+ }
+
+}
+int timerProc (int handle, int index, int info) {
+ if (timerList == null) return 0;
+ if (0 <= index && index < timerList.length) {
+ Runnable runnable = timerList [index];
+ timerList [index] = null;
+ OS.PtDestroyWidget (timers [index]);
+ timers [index] = 0;
+ if (runnable != null) runnable.run ();
+ }
+ return 0;
+}
+
+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;
+}
+
+public void update() {
+ checkDevice ();
+ Shell[] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ shell.update ();
+ }
+ }
+}
+
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+// int flags = OS.PtEnter (0);
+ OS.PtAppPulseTrigger (app_context, pulse);
+// if (flags >= 0) OS.PtLeave (flags);
+}
+
+int windowProc (int handle, int data, int info) {
+ Widget widget = WidgetTable.get (handle);
+ if (widget == null) return OS.Pt_CONTINUE;
+ return widget.processEvent (data, info);
+}
+
+int workProc (int data) {
+ idle = true;
+ return OS.Pt_CONTINUE;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
new file mode 100755
index 0000000000..d456c137b4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FileDialog.java
@@ -0,0 +1,125 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String filterPath = "", fileName = "";
+ static final String FILTER = "*";
+
+public FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public String getFileName () {
+ return fileName;
+}
+
+public String [] getFileNames () {
+ return new String [] {fileName};
+}
+
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
+public String [] getFilterNames () {
+ return filterNames;
+}
+
+public String getFilterPath () {
+ return filterPath;
+}
+
+public String open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ byte [] root_dir = null;
+ if (filterPath != null) {
+ root_dir = Converter.wcsToMbcs (null, filterPath, true);
+ }
+
+ /* Compute the filter */
+ String mask = FILTER;
+ /*
+ * Photon does not support filter names.
+ */
+ if (filterNames == null) filterNames = new String [0];
+ /*
+ * Photon supports only one filter with multiple patterns
+ * separated by commas.
+ */
+ if (filterExtensions == null) filterExtensions = new String [0];
+ if (filterExtensions.length > 0) {
+ String comma = ",";
+ mask = comma;
+ for (int i=0; i<filterExtensions.length; i++) {
+ String ext = filterExtensions [i];
+ int length = ext.length();
+ int end, start = 0;
+ do {
+ int index = end = ext.indexOf(';', start);
+ if (end < 0) end = length;
+ String subExt = ext.substring(start, end).trim();
+ if (subExt.length() > 0) {
+ subExt += comma;
+ if (mask.indexOf(comma + subExt) == -1) mask += subExt;
+ }
+ start = end + 1;
+ } while (end < length);
+ }
+ mask = mask.substring(1, Math.max(1, mask.length() - 1));
+ }
+ byte [] file_spec = Converter.wcsToMbcs (null, mask, true);
+
+ int flags = OS.Pt_FSR_NO_FCHECK;
+ PtFileSelectionInfo_t info = new PtFileSelectionInfo_t ();
+ OS.PtFileSelection (parentHandle, null, title, root_dir, file_spec, null, null, null, info, flags);
+ if (info.ret == OS.Pt_FSDIALOG_BTN2) return null;
+ int length = 0;
+ while (length < info.path.length && info.path [length] != 0) length++;
+ byte [] path = new byte [length];
+ System.arraycopy (info.path, 0, path, 0, length);
+ String fullPath = new String (Converter.mbcsToWcs (null, path));
+ length = fullPath.length ();
+ if (length != 0) {
+ int index = length - 1;
+ while (index >= 0 && (fullPath.charAt (index) != '/')) --index;
+ fileName = fullPath.substring (index + 1, length);
+ filterPath = fullPath.substring (0, index);
+ }
+ return fullPath;
+}
+
+public void setFileName (String string) {
+ fileName = string;
+}
+
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
new file mode 100755
index 0000000000..6402e9c2e4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/FontDialog.java
@@ -0,0 +1,59 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class FontDialog extends Dialog {
+ FontData fontData;
+public FontDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+}
+public FontData getFontData() {
+ return fontData;
+}
+public FontData open () {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+
+ byte[] font = null;
+ if (fontData != null) {
+ if (fontData.stem != null) {
+ font = fontData.stem;
+ } else {
+ byte[] description = Converter.wcsToMbcs(null, fontData.getName(), true);
+ int osStyle = 0, style = fontData.getStyle();
+ if ((style & SWT.BOLD) != 0) osStyle |= OS.PF_STYLE_BOLD;
+ if ((style & SWT.ITALIC) != 0) osStyle |= OS.PF_STYLE_ITALIC;
+ int size = fontData.getHeight();
+ font = OS.PfGenerateFontName(description, osStyle, size, new byte[OS.MAX_FONT_TAG]);
+ }
+ fontData = null;
+ }
+
+ int fontPtr = OS.PtFontSelection (parentHandle, null, title, font, -1, OS.PHFONT_ALL_FONTS | OS.PFFONT_DONT_SHOW_LEGACY, null);
+
+ if (fontPtr != 0) {
+ int length = OS.strlen(fontPtr);
+ font = new byte[length];
+ OS.memmove(font, fontPtr, length);
+ fontData = FontData.photon_new(font);
+ }
+ return fontData;
+}
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
new file mode 100755
index 0000000000..7f5022c5cf
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Group.java
@@ -0,0 +1,122 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class Group extends Composite {
+
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point titleSize = getTitleSize();
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ int width = size.x; int height = size.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;
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = Math.max (trim.width, titleSize.x + 6);
+ height = trim.height + titleSize.y;
+ return new Point (width, height);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtPane;
+ int parentHandle = parent.handle;
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TITLE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+Point getTitleSize() {
+ int width = 0, height = 0;
+ int [] args = {
+ OS.Pt_ARG_TITLE, 0, 0,
+ OS.Pt_ARG_TITLE_FONT, 0, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if ((OS.Pt_ARG_CONTAINER_FLAGS & OS.Pt_SHOW_TITLE) != 0) {
+ PhRect_t rect = new PhRect_t();
+ if (args [1] != 0) {
+ int length = OS.strlen (args [1]);
+ OS.PfExtentText(rect, null, args [4], args [1], length);
+ }
+ int inset = 4;
+ width = inset + rect.lr_x - rect.ul_x + 1;
+ height = inset + rect.lr_y - rect.ul_y + 1;
+ }
+ return new Point(width, height);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtPane (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int flags = OS.Pt_SHOW_TITLE | OS.Pt_ETCH_TITLE_AREA | OS.Pt_GRADIENT_TITLE_AREA;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {
+ OS.Pt_ARG_TITLE, ptr, 0,
+ OS.Pt_ARG_CONTAINER_FLAGS, string.length () == 0 ? 0 : flags, flags,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
new file mode 100755
index 0000000000..0c2e37f0b6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Header.java
@@ -0,0 +1,336 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * A header draws one or more header items. Each item may have a text
+ * label. Each item is identified by an index and can be resized.
+ */
+class Header extends Canvas {
+ private static final int DEFAULT_WIDTH = 64; // used in computeSize if width could not be calculated
+ private static final int DEFAULT_HEIGHT = 64; // used in computeSize if height could not be calculated
+ private static final int VERTICAL_MARGIN = 4; // space added to the height of the header label
+ private static final int TEXT_Y_OFFSET = 2; // space between the header label and the lower header boundary
+ private static final int DEFAULT_ITEM_WIDTH = 9; // default width of a header item
+ private static final int TEXT_MARGIN = 6; // space in front and behind header text
+ private static final int SHADOW_WIDTH = 2; // width of the right side header shadow
+/**
+ * Create a Header widget as a child of 'parent'.
+ * @param parent - the parent of the new instance
+ */
+Header(Table parent) {
+ super(parent, SWT.NO_REDRAW_RESIZE | SWT.NO_FOCUS);
+
+ addListener(SWT.Paint, new Listener() {
+ public void handleEvent(Event event) {paint(event);}
+ });
+ setHeaderHeight();
+}
+/**
+ * Answer the size of the receiver needed to display all items.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = 0;
+ int height = 0;
+
+ for (int i = 0; i < getItemCount(); i++) {
+ width += getBounds(i).width;
+ if (height == 0) {
+ height = getBounds(i).height;
+ }
+ }
+ 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);
+}
+/**
+ * Draw the bright shadow on the upper and left sides of a header item.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawHighlightShadow(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+ Color oldForeground = getForeground();
+
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW));
+ // draw top horizontal line
+ gc.drawLine(bounds.x, bounds.y, bounds.x + bounds.width - 1, bounds.y);
+ // draw left vertical line
+ gc.drawLine(bounds.x, bounds.y, bounds.x, bounds.y + bounds.height - 1);
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw the dark shadow on the lower and right side of a header item.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawLowlightShadows(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+ Point bottomShadowStart = new Point(bounds.x + 1, bounds.height - 2);
+ Point bottomShadowStop = new Point(bottomShadowStart.x + bounds.width - 2, bottomShadowStart.y);
+ Point rightShadowStart = null;
+ Point rightShadowStop = null;
+ Display display = getDisplay();
+ Color oldForeground = getForeground();
+
+ // light inner shadow
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW));
+ gc.drawLine(
+ bottomShadowStart.x, bottomShadowStart.y,
+ bottomShadowStop.x, bottomShadowStop.y);
+ if(itemIndex != TableColumn.FILL) {
+ rightShadowStart = new Point(bounds.x + bounds.width - 2, bounds.y + 1);
+ rightShadowStop = new Point(rightShadowStart.x, bounds.height - 2);
+ gc.drawLine(
+ rightShadowStart.x, rightShadowStart.y,
+ rightShadowStop.x, rightShadowStop.y);
+ }
+ // dark outer shadow
+ bottomShadowStart.x--;
+ bottomShadowStart.y++;
+ bottomShadowStop.y++;
+ gc.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
+ gc.drawLine(
+ bottomShadowStart.x, bottomShadowStart.y,
+ bottomShadowStop.x, bottomShadowStop.y);
+ if(itemIndex != TableColumn.FILL) {
+ rightShadowStart.x++;
+ rightShadowStart.y--;
+ rightShadowStop.y++;
+ rightShadowStop.x++;
+ gc.drawLine(
+ rightShadowStart.x, rightShadowStart.y,
+ rightShadowStop.x, rightShadowStop.y);
+ }
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw the item text of the item identified by 'itemIndex'.
+ * @param gc - GC to draw on
+ * @param itemIndex - specifies the item to draw
+ */
+void drawText(GC gc, int itemIndex) {
+ String label = getText(gc, itemIndex);
+ Point textExtent;
+ Rectangle bounds = getBounds(itemIndex);
+ int yPosition;
+ int xPosition = 0;
+ int alignment;
+
+ if (label != null) {
+ alignment = ((Table) getParent()).internalGetColumn(itemIndex).getAlignment();
+ textExtent = gc.stringExtent(label);
+ yPosition = bounds.height - textExtent.y - TEXT_Y_OFFSET;
+
+ if ((alignment & SWT.CENTER) != 0) {
+ xPosition = (bounds.width - textExtent.x) / 2;
+ }
+ else
+ if ((alignment & SWT.RIGHT) != 0) {
+ xPosition = bounds.width - textExtent.x - TEXT_MARGIN;
+ }
+ xPosition = Math.max(TEXT_MARGIN, xPosition);
+ xPosition += bounds.x;
+ gc.drawString(label, xPosition, yPosition);
+ }
+}
+/**
+ * Answer the bounding rectangle of the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the item whose bounding rectangle
+ * should be returned.
+ * @return the bouding rectangle of the item identified by 'itemIndex'.
+ */
+Rectangle getBounds(int itemIndex) {
+ Rectangle bounds = null;
+ int itemCount = getItemCount();
+ Table parent = (Table) getParent();
+
+ if (itemIndex >= 0 && itemIndex < itemCount) {
+ bounds = parent.internalGetColumn(itemIndex).getBounds();
+ bounds.y = 0;
+ bounds.height = getBounds().height;
+ }
+ else
+ if (itemIndex == TableColumn.FILL) {
+ if (itemCount > 0) {
+ bounds = parent.internalGetColumn(itemCount - 1).getBounds();
+ bounds.x += bounds.width;
+ }
+ else {
+ bounds = new Rectangle(0, 0, 0, 0);
+ }
+ bounds.width = Math.max(0, getBounds().width - bounds.x);
+ bounds.y = 0;
+ bounds.height = getBounds().height;
+ }
+ return bounds;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+int getItemCount() {
+ return ((Table) getParent()).internalGetColumnCount();
+}
+/**
+ * Answer the maximum label width that fits into the item identified by
+ * 'itemIndex'.
+ */
+int getMaxLabelWidth(int itemIndex) {
+ return getBounds(itemIndex).width - 2 * TEXT_MARGIN;
+}
+/**
+ * Answer the width required to display the complete label of the header
+ * item at position 'index'.
+ * @param index - position of the header item whose preferred width should
+ * be returned.
+ */
+int getPreferredWidth(int index) {
+ Table parent = (Table) getParent();
+ String text = getText(index);
+ int headerWidth = 0;
+
+ if (text != null) {
+ headerWidth = parent.getTextWidth(text) + 2 * TEXT_MARGIN + 1;
+ }
+ return headerWidth;
+}
+/**
+ * Answer the label of the item identified by 'itemIndex'.
+ */
+String getText(int itemIndex) {
+ String itemLabel = null;
+
+ if (itemIndex >= 0 && itemIndex < getItemCount()) {
+ itemLabel = ((Table) getParent()).internalGetColumn(itemIndex).getText();
+ }
+ return itemLabel;
+}
+/**
+ * Answer the text that is going to be drawn in the header item
+ * identified by 'itemIndex'. This may be truncated to fit the item
+ * width.
+ * @param gc - GC to use for measuring the label width.
+ * @param itemIndex - specifies the item whose label should be returned.
+ */
+String getText(GC gc, int itemIndex) {
+ String label = getText(itemIndex);
+ int maxWidth;
+
+ if (label != null) {
+ maxWidth = getMaxLabelWidth(itemIndex);
+ label = ((Table) getParent()).trimItemText(label, maxWidth, gc);
+ }
+ return label;
+}
+/**
+ * Draw the header item identified by 'itemIndex'.
+ * @param gc - GC to draw on
+ * @param itemIndex - item that should be drawn
+ */
+void paint(GC gc, int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+
+ // draw header background
+ gc.fillRectangle(bounds.x, bounds.y + 1, bounds.width, bounds.height - 3);
+ if (itemIndex != TableColumn.FILL) {
+ drawText(gc, itemIndex);
+ }
+ drawHighlightShadow(gc, itemIndex);
+ drawLowlightShadows(gc, itemIndex);
+}
+/**
+ * Draw all header items.
+ * @param event - Paint event triggering the drawing operation.
+ */
+void paint(Event event) {
+ int labelCount = getItemCount();
+
+ for (int i = 0; i < labelCount; i++) {
+ paint(event.gc, i);
+ }
+ paint(event.gc, TableColumn.FILL); // paint empty fill item behind last item
+}
+/**
+ * Redraw the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the header item that should be redrawn
+ */
+void redraw(int itemIndex) {
+ Rectangle bounds = getBounds(itemIndex);
+
+ if (bounds != null) {
+ redraw(bounds.x, 0, bounds.width, bounds.height, false);
+ }
+}
+
+/**
+ * Set a new font. Recalculate the header height and redraw the header.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ super.setFont(font);
+ setHeaderHeight();
+ redraw();
+}
+/**
+ * Calculate and store the height of the receiver.
+ */
+void setHeaderHeight() {
+ GC gc = new GC(this);
+ Rectangle bounds = getBounds();
+
+ bounds.height = gc.stringExtent("aString").y + VERTICAL_MARGIN;
+ setBounds(bounds);
+ gc.dispose();
+}
+/**
+ * The width of the header item at position 'itemIndex' is about to change.
+ * Adjust the width of the header. Scroll and redraw all header items
+ * starting behind the item identified by 'itemIndex'.
+ * @param itemIndex - specifies the item after which the redraw
+ * should begin.
+ * @param widthDiff - the width change of the item.
+ * > 0 = item width increased. < 0 = item width decreased
+ */
+void widthChange(int itemIndex, int widthDiff) {
+ Rectangle bounds = getBounds(itemIndex);
+ Rectangle headerBounds = getBounds();
+
+ if (bounds != null) {
+ if (itemIndex != TableColumn.FILL) { // ignore the fill column header item - there's nothing to redraw anyway
+ scroll(
+ bounds.x + bounds.width + widthDiff, 0, // destination x, y
+ bounds.x + bounds.width, 0, // source x, y
+ headerBounds.width + widthDiff, headerBounds.height, false);
+ redraw(bounds.x, 0, bounds.width, bounds.height, false);
+ }
+ }
+ headerBounds.width += widthDiff;
+ setBounds(headerBounds);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
new file mode 100755
index 0000000000..ac5f1acd86
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Label.java
@@ -0,0 +1,231 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class Label extends Control {
+ Image image;
+
+public Label (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ if ((style & SWT.SEPARATOR) != 0) return style;
+ return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.SEPARATOR) != 0) {
+ 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);
+ }
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ width = dim.w; height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) width = area.size_w;
+ if (hHint != SWT.DEFAULT) height = area.size_h;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+
+ if ((style & SWT.SEPARATOR) != 0) {
+ int clazz = display.PtSeparator;
+ int orientation = (style & SWT.HORIZONTAL) != 0 ? OS.Pt_SEP_HORIZONTAL : OS.Pt_SEP_VERTICAL;
+ int type = OS.Pt_ETCHED_IN;
+ if ((style & (SWT.SHADOW_OUT)) != 0) type = OS.Pt_ETCHED_OUT;
+ int [] args = {
+ OS.Pt_ARG_SEP_FLAGS, orientation, OS.Pt_SEP_VERTICAL | OS.Pt_SEP_HORIZONTAL,
+ OS.Pt_ARG_SEP_TYPE, type, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+
+ int clazz = display.PtLabel;
+ int alignment = OS.Pt_LEFT;
+ if ((style & SWT.CENTER) != 0) alignment = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) alignment = OS.Pt_RIGHT;
+ int [] args = {
+ OS.Pt_ARG_HORIZONTAL_ALIGNMENT, alignment, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 Image getImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return image;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return "";
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, 0, 0,
+ OS.Pt_ARG_ACCEL_KEY, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] result = Converter.mbcsToWcs (null, buffer);
+ int count = 0;
+ int mnemonic = 0;
+ if (args [4] != 0) {
+ int length2 = OS.strlen (args [4]);
+ if (length2 > 0) {
+ byte [] buffer2 = new byte [length2];
+ OS.memmove (buffer2, args [4], length2);
+ char [] result2 = Converter.mbcsToWcs (null, buffer2);
+ if (result2.length > 0) mnemonic = result2 [0];
+ }
+ }
+ if (mnemonic != 0) count++;
+ for (int i=0; i<result.length-1; i++)
+ if (result [i] == Mnemonic) count++;
+ char [] newResult = result;
+ if ((count != 0) || (mnemonic != 0)) {
+ newResult = new char [result.length + count];
+ int i = 0, j = 0;
+ while (i < result.length) {
+ if ((mnemonic != 0) && (result [i] == mnemonic)) {
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ mnemonic = 0;
+ }
+ if ((newResult [j++] = result [i++]) == Mnemonic)
+ if (j < newResult.length) newResult [j++] = Mnemonic;
+ }
+ }
+ return new String (newResult);
+}
+
+int processPaint (int damage) {
+ int clazz = OS.PtLabel ();
+ if ((style & SWT.SEPARATOR) != 0) clazz = OS.PtSeparator ();
+ OS.PtSuperClassDraw (clazz, handle, damage);
+ return super.processPaint (damage);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
+public void setAlignment (int alignment) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+ int [] args = {OS.Pt_ARG_HORIZONTAL_ALIGNMENT, OS.Pt_LEFT, 0};
+ if ((style & SWT.CENTER) != 0) args [1] = OS.Pt_CENTER;
+ if ((style & SWT.RIGHT) != 0) args [1] = OS.Pt_RIGHT;
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public boolean setFocus () {
+ return false;
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ this.image = image;
+ int imageHandle = 0;
+ if (image != null) imageHandle = copyPhImage (image.handle);
+ int [] args = {
+ OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_IMAGE, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ int i=0, j=0;
+ char mnemonic=0;
+ while (i < text.length) {
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer = Converter.wcsToMbcs (null, text, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int ptr2 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr2 = OS.malloc (buffer2.length);
+ OS.memmove (ptr2, buffer2, buffer2.length);
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, OS.Pt_Z_STRING, 0,
+ OS.Pt_ARG_ACCEL_KEY, ptr2, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ OS.free (ptr2);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
new file mode 100755
index 0000000000..5fc15bfb72
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/List.java
@@ -0,0 +1,589 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class List extends Scrollable {
+
+public List (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+public void add (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListAddItems (handle, new int [] {ptr}, 1, 0);
+ OS.free (ptr);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public void add (String string, int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int result = OS.PtListAddItems (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+ if (result != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (0 <= index && index <= args [1]) error (SWT.ERROR_ITEM_NOT_ADDED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /**
+ * Feature in Photon - The preferred width calculated by
+ * PtWidgetPreferredSize is the current width.
+ */
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = 0, height = dim.h;
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ PhRect_t rect = new PhRect_t();
+ int [] items = new int [1];
+ for (int i = 0; i < args [1]; i++) {
+ OS.memmove (items, args [4] + (i * 4), 4);
+ int length = OS.strlen (items [0]);
+ OS.PfExtentText(rect, null, args [7], items [0], length);
+ width = Math.max(width, rect.lr_x - rect.ul_x + 1);
+ }
+ rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (width + 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ width = area.size_w;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ rect = new PhRect_t ();
+ area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ ScrollBar scroll;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w;
+ if ((scroll = getVerticalBar()) != null)
+ width += scroll.getSize().x;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h;
+ if ((scroll = getHorizontalBar()) != null)
+ height += scroll.getSize().y;
+ }
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtList;
+ int parentHandle = parent.handle;
+ int mode = OS.Pt_SELECTION_MODE_SINGLE | OS.Pt_SELECTION_MODE_AUTO;
+ if ((style & SWT.MULTI) != 0) {
+ if ((style & SWT.SIMPLE) != 0) {
+ mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_NOCLEAR
+ | OS.Pt_SELECTION_MODE_TOGGLE | OS.Pt_SELECTION_MODE_NOMOVE;
+ } else {
+ mode = OS.Pt_SELECTION_MODE_MULTIPLE | OS.Pt_SELECTION_MODE_AUTO;
+ }
+ }
+ mode |= OS.Pt_SELECTION_MODE_NOFOCUS;
+ int [] args = {
+ OS.Pt_ARG_SELECTION_MODE, mode, 0,
+ OS.Pt_ARG_FLAGS, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW, OS.Pt_SELECTABLE | OS.Pt_SELECT_NOREDRAW,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createScrollBars();
+}
+
+byte [] defaultFont () {
+ Display display = getDisplay ();
+ return display.LIST_FONT;
+}
+
+public void deselect (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index < 0) return;
+ OS.PtListUnselectPos (handle, index + 1);
+}
+
+public void deselect (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int index = Math.min (count - 1, end);
+ if (index >= start) deselect (index);
+ return;
+ }
+ for (int i=start; i<end; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
+public void deselect (int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (index != -1) {
+ OS.PtListUnselectPos (handle, index + 1);
+ }
+ }
+}
+
+public void deselectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListUnselectPos (handle, i + 1);
+ }
+}
+
+public int getFocusIndex () {
+ return getSelectionIndex ();
+}
+
+public String getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int [] items = new int [1];
+ OS.memmove (items, args [4] + (index * 4), 4);
+ int length = OS.strlen (items [0]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [0], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getItemHeight () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_TOTAL_HEIGHT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_LIST_FONT, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [4] == 0) {
+ int ptr = OS.malloc(1);
+ PhRect_t rect = new PhRect_t ();
+ OS.PfExtentText(rect, null, args [7], ptr, 1);
+ OS.free(ptr);
+ int inset = 4;
+ return inset + (rect.lr_y - rect.ul_y + 1);
+ }
+ return args [1] / args [4];
+}
+
+public String [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0,
+ OS.Pt_ARG_ITEMS, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] items = new int [args [1]];
+ OS.memmove (items, args [4], args [1] * 4);
+ String [] result = new String [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ int length = OS.strlen (items [i]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, items [i], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ result [i] = new String (unicode);
+ }
+ return result;
+
+}
+
+public String [] getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] indices = getSelectionIndices ();
+ String [] result = new String [indices.length];
+ for (int i=0; i<indices.length; i++) {
+ result [i] = getItem (indices [i]);
+ }
+ return result;
+}
+
+public int getSelectionCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return -1;
+ short [] buffer = new short [1];
+ OS.memmove (buffer, args [4], 2);
+ return buffer [0] - 1;
+}
+
+public int [] getSelectionIndices () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ short [] indices = new short [args [1]];
+ OS.memmove (indices, args [4], args [1] * 2);
+ int [] result = new int [args [1]];
+ for (int i=0; i<args [1]; i++) {
+ result [i] = indices [i] - 1;
+ }
+ return result;
+}
+
+public int getTopIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SELECTION, windowProc, SWT.Selection);
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.DefaultSelection);
+}
+
+public int indexOf (String string) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ return indexOf (string, 0);
+}
+
+public int indexOf (String string, int start) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ // NOT DONE - start is ignored
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ return OS.PtListItemPos(handle, buffer) - 1;
+}
+
+public boolean isSelected (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ short [] buffer = new short [1];
+ for (int i=0; i<args [1]; i++) {
+ OS.memmove (buffer, args [4] + (i * 2), 2);
+ if (buffer [0] == index + 1) return true;
+ }
+ return false;
+}
+
+int processDefaultSelection (int info) {
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_END;
+ int[] click_count = new int [1];
+ OS.memmove(click_count, cbinfo.cbdata, 4);
+ if (click_count [0] > 1) postEvent (SWT.DefaultSelection);
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtList (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+public void remove (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) error (SWT.ERROR_INVALID_RANGE);
+ int result = OS.PtListDeleteItemPos (handle, 1, index + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void remove (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ remove (index);
+}
+
+public void remove (int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ //NOT DONE
+}
+
+
+public void remove (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 < start && start <= end && end < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ int count = end - start + 1;
+ int result = OS.PtListDeleteItemPos (handle, count, start + 1);
+ if (result != 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+public void removeAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtListDeleteAllItems (handle);
+}
+
+
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void select (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ int index = Math.min (count - 1, end);
+ if (index >= start) select (index);
+ return;
+ }
+ for (int i=start; i<end; i++) {
+ OS.PtListSelectPos (handle, start + 1);
+ }
+ OS.PtListGotoPos (handle, start + 1);
+}
+
+public void select (int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ for (int i=0; i<indices.length; i++) {
+ if (indices [i] >= 0) {
+ OS.PtListSelectPos (handle, indices [i] + 1);
+ }
+ }
+ OS.PtListGotoPos (handle, indices [0] + 1);
+}
+
+public void select (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (index < 0) return;
+ OS.PtListSelectPos (handle, index + 1);
+ OS.PtListGotoPos (handle, index + 1);
+}
+
+public void selectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return;
+ int [] args = new int [] {OS.Pt_ARG_LIST_SEL_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [1];
+ for (int i=0; i<count; i++) {
+ OS.PtListSelectPos (handle, i + 1);
+ }
+}
+
+public void setItem (int index, String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] args = new int [] {OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [1])) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ OS.PtListReplaceItemPos (handle, new int [] {ptr}, 1, index + 1);
+ OS.free (ptr);
+}
+
+public void setItems (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.PtListDeleteAllItems (handle);
+ int[] itemsPtr = new int [items.length];
+ for (int i=0; i<itemsPtr.length; i++) {
+ byte [] buffer = Converter.wcsToMbcs (null, items [i], true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ itemsPtr [i] = ptr;
+ }
+ OS.PtListAddItems (handle, itemsPtr, itemsPtr.length, 0);
+ for (int i=0; i<itemsPtr.length; i++) {
+ OS.free (itemsPtr [i]);
+ }
+}
+
+public void setSelection (int start, int end) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+
+public void setSelection (int index) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+}
+
+public void setSelection(int[] indices) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (indices);
+}
+
+public void setSelection (String [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ for (int i=items.length-1; i>=0; --i) {
+ int index = 0;
+ String string = items [i];
+ if (string != null) {
+ while ((index = indexOf (string, index)) != -1) {
+ select (index);
+ if (((style & SWT.SINGLE) != 0) && isSelected (index)) return;
+ index++;
+ }
+ }
+ }
+ if ((style & SWT.SINGLE) != 0) deselectAll ();
+}
+
+public void setTopIndex (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, index + 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void showSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {
+ OS.Pt_ARG_LIST_SEL_COUNT, 0, 0,
+ OS.Pt_ARG_SELECTION_INDEXES, 0, 0,
+ OS.Pt_ARG_TOP_ITEM_POS, 0, 0,
+ OS.Pt_ARG_VISIBLE_COUNT, 0, 0,
+ OS.Pt_ARG_LIST_ITEM_COUNT, 0, 0
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return;
+ short [] buffer = new short [1];
+ OS.memmove (buffer, args [4], 2);
+ int index = buffer [0] - 1;
+ int topIndex = args [7] - 1, visibleCount = args [10], count = args [13];
+ int bottomIndex = Math.min (topIndex + visibleCount - 1, count);
+ if ((topIndex <= index) && (index <= bottomIndex)) return;
+ int lastIndex = Math.max (1, count - visibleCount + 1);
+ int newTop = Math.min (Math.max (index - (visibleCount / 2), 1), lastIndex);
+ args = new int [] {OS.Pt_ARG_TOP_ITEM_POS, newTop, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
new file mode 100755
index 0000000000..929031a615
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Menu.java
@@ -0,0 +1,338 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Menu extends Widget {
+ int x, y;
+ boolean hasLocation;
+ Decorations parent;
+ MenuItem cascade;
+
+public Menu (Control parent) {
+ this (checkNull (parent).getShell (), SWT.POP_UP);
+}
+
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
+public Menu (Menu parentMenu) {
+ this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
+public Menu (MenuItem parentItem) {
+ this (checkNull (parentItem).parent);
+}
+
+static Control checkNull (Control control) {
+ if (control == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return control;
+}
+
+static Menu checkNull (Menu menu) {
+ if (menu == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return menu;
+}
+
+static MenuItem checkNull (MenuItem item) {
+ if (item == null) 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);
+}
+
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+public void addMenuListener (MenuListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Hide,typedListener);
+ addListener (SWT.Show,typedListener);
+}
+
+void createHandle (int index) {
+ int parentHandle = parent.topHandle ();
+ if ((style & SWT.BAR) != 0) {
+ int [] args = {
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ handle = OS.PtCreateWidget (OS.PtMenuBar (), parentHandle, args.length / 3, args);
+ } else {
+ handle = OS.PtCreateWidget (OS.PtMenu (), parentHandle, 0, null);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ parent.add (this);
+}
+
+public MenuItem getDefaultItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return null;
+}
+
+public Display getDisplay () {
+ Decorations parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_BLOCKED) == 0;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ count++;
+ }
+ return count;
+}
+
+public MenuItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - bogus
+ MenuItem[] items = getItems();
+ if (!(0 <= index && index < items.length)) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ return items [index];
+}
+
+public MenuItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ int child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ count++;
+ }
+ MenuItem [] items = new MenuItem [count];
+ int i = 0, j = 0;
+ child = OS.PtWidgetChildBack (handle);
+ if (child != 0 && (style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (i < count) {
+ Widget widget = WidgetTable.get (child);
+ if (widget != null && widget instanceof MenuItem) {
+ items [j++] = (MenuItem) widget;
+ }
+ i++;
+ child = OS.PtWidgetBrotherInFront (child);
+ }
+ if (i == j) return items;
+ MenuItem [] newItems = new MenuItem [j];
+ System.arraycopy (items, 0, newItems, 0, j);
+ return newItems;
+}
+
+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;
+}
+
+public Decorations getParent () {
+ return parent;
+}
+
+public MenuItem getParentItem () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return cascade;
+}
+
+public Menu getParentMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (cascade != null) return cascade.parent;
+ return null;
+}
+
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getShell ();
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return true;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_REALIZED, windowProc, SWT.Show);
+ OS.PtAddCallback (handle, OS.Pt_CB_UNREALIZED, windowProc, SWT.Hide);
+}
+
+public int indexOf (MenuItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ //NOT DONE - bogus
+ MenuItem[] items = getItems();
+ for (int i=0; i<items.length; i++) {
+ if (item == items [i]) return i;
+ }
+ return -1;
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible ();
+}
+
+int processHide (int info) {
+ sendEvent (SWT.Hide);
+ return OS.Pt_CONTINUE;
+}
+
+int processShow (int info) {
+ sendEvent (SWT.Show);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (cascade != null) cascade.setMenu (null);
+ if ((style & SWT.BAR) != 0 && this == parent.menuBar) {
+ parent.setMenuBar (null);
+ }
+}
+
+void releaseWidget () {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (!item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ super.releaseWidget ();
+ if (parent != null) parent.remove (this);
+ parent = null;
+
+}
+
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+public void removeMenuListener (MenuListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Hide, listener);
+ eventTable.unhook (SWT.Show, listener);
+}
+
+public void setDefaultItem (MenuItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setLocation (int x, int y) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.x = x; this.y = y;
+ hasLocation = true;
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.POP_UP) == 0) return;
+ if (visible) {
+ PhPoint_t pt = new PhPoint_t ();
+ pt.x = (short) x;
+ pt.y = (short) y;
+ if (!hasLocation) {
+ int ig = OS.PhInputGroup (0);
+ PhCursorInfo_t info = new PhCursorInfo_t ();
+ OS.PhQueryCursor ((short) ig, info);
+ pt.x = info.last_press_x;
+ pt.y = info.last_press_y;
+ }
+ int ptr = OS.malloc (PhPoint_t.sizeof);
+ OS.memmove (ptr, pt, PhPoint_t.sizeof);
+ int [] args = {OS.Pt_ARG_POS, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ OS.PtRealizeWidget (handle);
+ } else {
+ OS.PtUnrealizeWidget(handle);
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
new file mode 100755
index 0000000000..e014e1f8b0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MenuItem.java
@@ -0,0 +1,371 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class MenuItem extends Item {
+ Menu parent, menu;
+
+public MenuItem (Menu parent, int style) {
+ this (parent, style, parent.getItemCount());
+}
+
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (index);
+}
+
+public void addArmListener (ArmListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Arm, typedListener);
+}
+
+public void addHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Help, typedListener);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
+}
+
+void createHandle (int index) {
+ int count = parent.getItemCount();
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int parentHandle = parent.handle;
+ if ((style & SWT.SEPARATOR) != 0) {
+ handle = OS.PtCreateWidget (OS.PtSeparator (), parentHandle, 0, null);
+ } else if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ int [] args = {
+// OS.Pt_ARG_FLAGS, OS.Pt_MENU_BUTTON | OS.Pt_SELECTABLE, OS.Pt_MENU_BUTTON | OS.Pt_SELECTABLE,
+// OS.Pt_ARG_FLAGS, OS.Pt_AUTOHIGHLIGHT, OS.Pt_AUTOHIGHLIGHT,
+ OS.Pt_ARG_INDICATOR_TYPE, (style & SWT.CHECK) != 0 ? OS.Pt_N_OF_MANY : OS.Pt_ONE_OF_MANY, 0
+ };
+ handle = OS.PtCreateWidget (OS.PtToggleButton (), parentHandle, args.length / 3, args);
+ } else {
+ handle = OS.PtCreateWidget (OS.PtMenuButton (), parentHandle, 0, null);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if (index != count) {
+ int i = 0;
+ int child = OS.PtWidgetChildBack (parentHandle);
+ /*
+ * Feature in Photon. Menu bars have an extra widget which
+ * is the parent of all menu items. PtValidParent() can not be
+ * used, since it does not return that widget.
+ */
+ if (child != 0 && (parent.style & SWT.BAR) != 0) child = OS.PtWidgetChildBack (child);
+ while (i != index && child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ i++;
+ }
+ OS.PtWidgetInsert (topHandle (), child, 1);
+ }
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ if ((parent.style & SWT.BAR) == 0) {
+ OS.PtExtentWidgetFamily (parentHandle);
+ OS.PtPositionMenu (parentHandle, null);
+ }
+ }
+}
+
+public int getAccelerator () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public Display getDisplay () {
+ Menu parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_BLOCKED) == 0;
+}
+
+public Menu getMenu () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return menu;
+}
+
+String getNameText () {
+ if ((style & SWT.SEPARATOR) != 0) return "|";
+ return super.getNameText ();
+}
+
+public Menu getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_SET) != 0;
+}
+
+void hookEvents () {
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int windowProc = getDisplay ().windowProc;
+ if ((style & SWT.CASCADE) != 0) {
+ OS.PtAddCallback (handle, OS.Pt_CB_ARM, windowProc, SWT.Show);
+ }
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+}
+
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+int processSelection (int info) {
+ if ((style & SWT.CASCADE) != 0) {
+ int [] args = {OS.Pt_ARG_BUTTON_TYPE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if ((args [1] & (OS.Pt_MENU_RIGHT | OS.Pt_MENU_DOWN)) != 0) {
+ return OS.Pt_CONTINUE;
+ }
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+// parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ if (menu != null) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ menu = null;
+ super.releaseWidget ();
+// if (accelerator != 0) {
+// parent.destroyAcceleratorTable ();
+// }
+// accelerator = 0;
+// Decorations shell = parent.parent;
+// shell.remove (this);
+ parent = null;
+}
+
+int processShow (int damage) {
+ if (menu != null) {
+ int menuHandle = menu.handle;
+ OS.PtPositionMenu (menuHandle, null);
+ OS.PtRealizeWidget (menuHandle);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+public void removeArmListener (ArmListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Arm, listener);
+}
+
+public void removeHelpListener (HelpListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Help, listener);
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setAccelerator (int accelerator) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE: remove previous - NEEDED NEEDED
+//
+// if (accelerator != 0) {
+// int keyMods = 0;
+// if ((accelerator & SWT.ALT) != 0) keyMods |= OS.Pk_KM_Alt;
+// if ((accelerator & SWT.SHIFT) != 0) keyMods |= OS.Pk_KM_Shift;
+// if ((accelerator & SWT.CONTROL) != 0) keyMods |= OS.Pk_KM_Ctrl;
+// int key = accelerator & ~(SWT.ALT | SWT.SHIFT | SWT.CONTROL);
+// //key = Display.untranslateKey(key);
+// key = 0x61;
+// System.out.println("key=" + Integer.toHexString(key));
+// OS.PtAddHotkeyHandler(handle, key, keyMods, (short)0, SWT.Selection, 0);
+// }
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+
+ //NOT DONE - The OS has support
+}
+
+public void setMenu (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+ }
+ }
+ Menu oldMenu = this.menu;
+ if (oldMenu == menu) return;
+ this.menu = menu;
+ if (oldMenu != null) {
+ oldMenu.cascade = null;
+ int menuHandle = oldMenu.handle;
+ int shellHandle = oldMenu.parent.topHandle ();
+ if ((parent.style & SWT.BAR) == 0) {
+ int [] args = {OS.Pt_ARG_BUTTON_TYPE, 0, OS.Pt_MENU_RIGHT};
+ OS.PtSetResources (handle, args.length / 3, args);
+ args = new int [] {OS.Pt_ARG_MENU_FLAGS, 0, OS.Pt_MENU_CHILD};
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ }
+ OS.PtReParentWidget (menuHandle, shellHandle);
+ }
+ if (menu != null) {
+ menu.cascade = this;
+ int menuHandle = menu.handle;
+ if ((parent.style & SWT.BAR) == 0) {
+ int [] args = {OS.Pt_ARG_BUTTON_TYPE, OS.Pt_MENU_RIGHT, OS.Pt_MENU_RIGHT};
+ OS.PtSetResources (handle, args.length / 3, args);
+ args = new int [] {OS.Pt_ARG_MENU_FLAGS, OS.Pt_MENU_CHILD, OS.Pt_MENU_CHILD};
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ }
+ OS.PtReParentWidget (menuHandle, handle);
+ }
+}
+
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ char [] text = new char [string.length ()];
+ string.getChars (0, text.length, text, 0);
+ boolean accel = false;
+ int i=0, j=0;
+ char mnemonic=0;
+ while (i < text.length) {
+ if (text [i] == '\t') {accel = true; break;};
+ if ((text [j++] = text [i++]) == Mnemonic) {
+ if (i == text.length) {continue;}
+ if (text [i] == Mnemonic) {i++; continue;}
+ if (mnemonic == 0) mnemonic = text [i];
+ j--;
+ }
+ }
+ byte [] buffer2;
+ if (accel && ++i < text.length) {
+ char [] accelText = new char [text.length - i];
+ System.arraycopy (text, i, accelText, 0, accelText.length);
+ buffer2 = Converter.wcsToMbcs (null, accelText, true);
+ } else {
+ buffer2 = new byte [1];
+ }
+ while (j < text.length) text [j++] = 0;
+ byte [] buffer1 = Converter.wcsToMbcs (null, text, true);
+ int ptr = OS.malloc (buffer1.length);
+ OS.memmove (ptr, buffer1, buffer1.length);
+ int ptr3 = 0;
+ if (mnemonic != 0) {
+ byte [] buffer3 = Converter.wcsToMbcs (null, new char []{mnemonic}, true);
+ ptr3 = OS.malloc (buffer3.length);
+ OS.memmove (ptr3, buffer3, buffer3.length);
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_ACCEL_KEY, ptr3, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+ OS.free (ptr3);
+ /*
+ * Bug on Photon. When a the text is set on a menu
+ * item that is realized, the menu item does not resize
+ * to show the new text. The fix is to force the item
+ * to recalculate the size.
+ */
+ if (OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
new file mode 100755
index 0000000000..97348244e3
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/MessageBox.java
@@ -0,0 +1,99 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+public /*final*/ class MessageBox extends Dialog {
+ String message = "";
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+public MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+}
+static int checkStyle (int style) {
+ if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) == 0) style |= SWT.APPLICATION_MODAL;
+ 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;
+}
+public String getMessage () {
+ return message;
+}
+public int open () {
+ String[] buttons = null;
+ if ((style & SWT.OK) == SWT.OK) buttons = new String[]{"&Ok"};
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) buttons = new String[]{"&Ok", "&Cancel"};
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) buttons = new String[]{"&Yes", "&No"};
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) buttons = new String[]{"&Yes", "&No", "&Cancel"};
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) buttons = new String[]{"&Retry", "&Cancel"};
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) buttons = new String[]{"&Abort", "&Retry", "&Ignore"};
+ if (buttons == null) buttons = new String[]{"&Ok"};
+
+ int phImage = 0;
+// int iconBits = 0;
+// if ((style & SWT.ICON_ERROR) != 0) iconBits = OS.MB_ICONERROR;
+// if ((style & SWT.ICON_INFORMATION) != 0) iconBits = OS.MB_ICONINFORMATION;
+// if ((style & SWT.ICON_QUESTION) != 0) iconBits = OS.MB_ICONQUESTION;
+// if ((style & SWT.ICON_WARNING) != 0) iconBits = OS.MB_ICONWARNING;
+// if ((style & SWT.ICON_WORKING) != 0) iconBits = OS.MB_ICONINFORMATION;
+
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.shellHandle;
+
+ byte [] title = null;
+ if (this.title != null) title = Converter.wcsToMbcs (null, this.title, true);
+ byte [] message = null;
+ if (this.message != null) message = Converter.wcsToMbcs (null, this.message, true);
+
+ int[] buttonsPtr = new int [buttons.length];
+ for (int i=0; i<buttons.length; i++) {
+ byte[] text = Converter.wcsToMbcs (null, buttons [i], true);
+ int textPtr = OS.malloc (text.length);
+ OS.memmove (textPtr, text, text.length);
+ buttonsPtr [i] = textPtr;
+ }
+
+ int button = OS.PtAlert (parentHandle, null, title, phImage, message, null, buttons.length, buttonsPtr, null, 0, buttons.length, OS.Pt_MODAL);
+
+ for (int i=0; i<buttons.length; i++) {
+ OS.free (buttonsPtr [i]);
+ }
+
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) {
+ if (button == 1) return SWT.ABORT;
+ if (button == 2) return SWT.RETRY;
+ return SWT.IGNORE;
+ }
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) {
+ return (button == 1) ? SWT.RETRY : SWT.CANCEL;
+ }
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) {
+ if (button == 1) return SWT.YES;
+ if (button == 2) return SWT.NO;
+ return SWT.CANCEL;
+ }
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) {
+ return (button == 1) ? SWT.YES : SWT.NO;
+ }
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) {
+ return (button == 1) ? SWT.OK : SWT.CANCEL;
+ }
+ if ((style & SWT.OK) == SWT.OK && button == 1) return SWT.OK;
+ return SWT.CANCEL;
+}
+public void setMessage (String string) {
+ message = string;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
new file mode 100755
index 0000000000..0e9b4579fc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ProgressBar.java
@@ -0,0 +1,121 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public class ProgressBar extends Control {
+
+public ProgressBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+/*
+* Not done - check Windows
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = wHint, height = hHint;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ if (width == SWT.DEFAULT) {
+ width = 64;
+// width = getMaximum() - getMinimum() + 1;
+ }
+ if (height == SWT.DEFAULT) height = 15;
+ } else {
+ if (height == SWT.DEFAULT) {
+ height = 64;
+// height = getMaximum() - getMinimum() + 1;
+ }
+ if (width == SWT.DEFAULT) width = 15;
+ }
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (width - 1);
+ rect.lr_y = (short) (height - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ width = area.size_w;
+ height = area.size_h;
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtProgress;
+ int parentHandle = parent.handle;
+ int [] args = {
+// OS.Pt_ARG_GAUGE_FLAGS, OS.Pt_GAUGE_LIVE, OS.Pt_GAUGE_LIVE,
+ OS.Pt_ARG_ORIENTATION, (style & SWT.HORIZONTAL) != 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtProgress (), handle, damage);
+ return super.processPaint (damage);
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int minimum = getMinimum();
+ if (0 <= minimum && minimum < value) {
+ int [] args = {OS.Pt_ARG_MAXIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int maximum = getMaximum();
+ if (0 <= value && value < maximum) {
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ }
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ int [] args = {OS.Pt_ARG_GAUGE_VALUE, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
new file mode 100755
index 0000000000..2f97a08506
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Sash.java
@@ -0,0 +1,225 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+
+public Sash (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ Display display = getDisplay ();
+ int clazz = display.PtContainer;
+ int parentHandle = parent.handle;
+ int cursor = ((style & SWT.HORIZONTAL) != 0) ? OS.Ph_CURSOR_DRAG_VERTICAL : OS.Ph_CURSOR_DRAG_HORIZONTAL;
+ int [] args = {
+ OS.Pt_ARG_CURSOR_TYPE, cursor, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void drawBand (int x, int y, int width, int height) {
+ if (parent == null) return;
+ if (parent.isDisposed ()) return;
+ int parentHandle = parent.handle;
+ if (!OS.PtWidgetIsRealized (parentHandle)) return;
+ int phGC = OS.PgCreateGC (0); // NOTE: PgCreateGC ignores the parameter
+ if (phGC == 0) return;
+ int [] args = {OS.Pt_ARG_COLOR, 0, 0, OS.Pt_ARG_FILL_COLOR, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int foreground = args [1];
+ int background = args [4];
+ int color = foreground ^ ~background;
+ int prevContext = OS.PgSetGC (phGC);
+ OS.PgSetRegion (OS.PtWidgetRid (parentHandle));
+ OS.PgSetDrawMode (OS.Pg_DRAWMODE_XOR);
+ OS.PgSetFillColor (color);
+ OS.PgDrawIRect (x, y, x + width - 1, y + height - 1, OS.Pg_DRAW_FILL);
+ OS.PgSetGC (prevContext);
+ OS.PgDestroyGC (phGC);
+}
+
+int processMouse (int info) {
+ int result = super.processMouse (info);
+
+ if (info == 0) return OS.Pt_END;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.event == 0) return OS.Pt_END;
+ PhEvent_t ev = new PhEvent_t ();
+ OS.memmove (ev, cbinfo.event, PhEvent_t.sizeof);
+ int data = OS.PhGetData (cbinfo.event);
+ if (data == 0) return OS.Pt_END;
+ PhPointerEvent_t pe = new PhPointerEvent_t ();
+ OS.memmove (pe, data, PhPointerEvent_t.sizeof);
+ if (pe.buttons != OS.Ph_BUTTON_SELECT) return result;
+
+ int x = pe.pos_x + ev.translation_x;
+ int y = pe.pos_y + ev.translation_y;
+ PhArea_t area = new PhArea_t();
+ OS.PtWidgetArea (handle, area);
+ Event event = new Event ();
+ int width = event.width = area.size_w;
+ int height = event.height = area.size_h;
+ switch (ev.type) {
+ case OS.Ph_EV_BUT_PRESS:
+ PhRect_t rect = new PhRect_t ();
+ PhPoint_t pos = new PhPoint_t();
+ pos.x = pe.pos_x;
+ pos.y = pe.pos_y;
+ rect.ul_x = rect.lr_x = (short) (pos.x + ev.translation_x);
+ rect.ul_y = rect.lr_y = (short) (pos.y + ev.translation_y);
+ int rid = OS.PtWidgetRid (handle);
+ int input_group = OS.PhInputGroup (cbinfo.event);
+// int input_group = OS.PhInputGroup (0);
+ OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_DRAG_TRACK | OS.Ph_TRACK_DRAG, rect, null, input_group, null, null, null, pos, null);
+
+ /* Compute the banding rectangle */
+ startX = x;
+ startY = y;
+ lastX = area.pos_x;
+ lastY = area.pos_y;
+
+ /* The event must be sent because doit flag is used */
+ event.x = lastX; event.y = lastY;
+ event.detail = SWT.DRAG;
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the selection
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return OS.Pt_END;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ dragging = true;
+ menuShell ().bringToTop ();
+ OS.PtFlush ();
+ drawBand (lastX = event.x, lastY = event.y, width, height);
+ }
+ break;
+ case OS.Ph_EV_BUT_RELEASE:
+ if (ev.subtype != OS.Ph_EV_RELEASE_PHANTOM) {
+ return result;
+ }
+ /* Compute the banding rectangle */
+ if (!dragging) return result;
+ dragging = false;
+
+ /* The event must be sent because doit flag is used */
+ event.x = lastX; event.y = lastY;
+ drawBand (lastX, lastY, width, height);
+ sendEvent (SWT.Selection, event);
+ // widget could be disposed at this point
+ break;
+ case OS.Ph_EV_PTR_MOTION_BUTTON:
+ case OS.Ph_EV_PTR_MOTION_NOBUTTON:
+ case OS.Ph_EV_DRAG:
+ if (ev.subtype != OS.Ph_EV_DRAG_MOTION_EVENT) {
+ return result;
+ }
+ if (!dragging) return result;
+
+ /* Compute the banding rectangle */
+ x += area.pos_x;
+ y += area.pos_y;
+ int parentHandle = parent.handle;
+ rect = new PhRect_t ();
+ int vParent = OS.PtValidParent (handle, OS.PtContainer ());
+ OS.PtCalcCanvas (vParent, rect);
+ int clientWidth = rect.lr_x - rect.ul_x + 1;
+ int clientHeight = rect.lr_y - rect.ul_y + 1;
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, x - startX), clientWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, y - startY), clientHeight - height);
+ }
+ if ((newX == lastX) && (newY == lastY)) return result;
+ drawBand (lastX, lastY, width, height);
+
+ /* The event must be sent because doit flag is used */
+ event.x = newX; event.y = newY;
+ event.detail = SWT.DRAG;
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the selection
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return OS.Pt_END;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ OS.PtFlush ();
+ drawBand (lastX, lastY, width, height);
+ }
+ break;
+ }
+ return result;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtContainer (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
new file mode 100755
index 0000000000..96820ad7b6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scale.java
@@ -0,0 +1,167 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Scale extends Control {
+
+
+public Scale (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w * 7; int height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) width = area.size_w;
+ if (hHint != SWT.DEFAULT) height = area.size_h;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtSlider;
+ int parentHandle = parent.handle;
+ int [] args = {
+ OS.Pt_ARG_MAXIMUM, 100, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
+ OS.Pt_ARG_SLIDER_SIZE, 10, 0,
+ OS.Pt_ARG_ORIENTATION, (style & SWT.HORIZONTAL) != 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SLIDER_MOVE, windowProc, SWT.Selection);
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtSlider (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ sendEvent(SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
new file mode 100755
index 0000000000..3b810a2ab2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ScrollBar.java
@@ -0,0 +1,306 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class ScrollBar extends Widget {
+ Scrollable parent;
+
+ScrollBar (Scrollable parent, int style, int handle) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ this.handle = handle;
+ createWidget (0);
+}
+
+ScrollBar (Scrollable parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget (0);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener(listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+void createHandle (int index) {
+ if (handle != 0) return;
+ int parentHandle = parent.scrolledHandle;
+ int [] args = {
+ OS.Pt_ARG_MAXIMUM, 100, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
+ OS.Pt_ARG_SLIDER_SIZE, 10, 0,
+ OS.Pt_ARG_ORIENTATION, (style & SWT.HORIZONTAL) != 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (OS.PtScrollbar (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ OS.PtExtentWidget (handle);
+}
+
+public Display getDisplay () {
+ Scrollable parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_BLOCKED) == 0;
+}
+
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Scrollable getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return new Point (args [1], args [4]);
+}
+
+public int getThumb () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public boolean getVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int topHandle = topHandle ();
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (topHandle, args.length / 3, args);
+ return (args [1] & OS.Pt_DELAY_REALIZE) == 0;
+}
+
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, SWT.Selection);
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+public boolean isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return OS.PtWidgetIsRealized (handle);
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ PtScrollbarCallback_t cb = new PtScrollbarCallback_t ();
+ OS.memmove (cb, cbinfo.cbdata, PtScrollbarCallback_t.sizeof);
+ Event event = new Event ();
+ switch (cb.action) {
+ case OS.Pt_SCROLL_DRAGGED:
+ event.detail = SWT.DRAG;
+ break;
+ case OS.Pt_SCROLL_TO_MIN:
+ event.detail = SWT.HOME;
+ break;
+ case OS.Pt_SCROLL_TO_MAX:
+ event.detail = SWT.END;
+ break;
+ case OS.Pt_SCROLL_INCREMENT:
+ event.detail = SWT.ARROW_DOWN;
+ break;
+ case OS.Pt_SCROLL_DECREMENT :
+ event.detail = SWT.ARROW_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_DECREMENT:
+ event.detail = SWT.PAGE_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_INCREMENT:
+ event.detail = SWT.PAGE_DOWN;
+ break;
+ }
+ sendEvent(SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ PhArea_t area = new PhArea_t ();
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) (Math.max (width, 0));
+ area.size_h = (short) (Math.max (height, 0));
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ int [] args = {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] args = {
+ OS.Pt_ARG_SCROLL_POSITION, selection, 0,
+ OS.Pt_ARG_INCREMENT, increment, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, pageIncrement, 0,
+ OS.Pt_ARG_SLIDER_SIZE, thumb, 0,
+ OS.Pt_ARG_MINIMUM, minimum, 0,
+ OS.Pt_ARG_MAXIMUM, maximum - 1, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, visible ? 0 : OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (visible) {
+ sendEvent (SWT.Show);
+ OS.PtRealizeWidget (handle);
+ parent.resizeClientArea ();
+ } else {
+ OS.PtUnrealizeWidget (handle);
+ parent.resizeClientArea ();
+ sendEvent(SWT.Hide);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
new file mode 100755
index 0000000000..ac2121a3de
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Scrollable.java
@@ -0,0 +1,120 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public abstract class Scrollable extends Control {
+ int scrolledHandle;
+ ScrollBar horizontalBar, verticalBar;
+
+Scrollable () {
+ /* Do nothing */
+}
+
+public Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+
+void createScrollBars () {
+ /* Search the handle to find the scroll bars */
+ int child = OS.PtWidgetChildFront (handle);
+ while (child != 0) {
+ if (OS.PtWidgetClass (child) == OS.PtScrollbar ()) {
+ int [] args = {OS.Pt_ARG_ORIENTATION, 0, 0};
+ OS.PtGetResources (child, args.length / 3, args);
+ switch (args [1]) {
+ case OS.Pt_HORIZONTAL:
+ horizontalBar = new ScrollBar (this, SWT.HORIZONTAL, child);
+ break;
+ case OS.Pt_VERTICAL:
+ verticalBar = new ScrollBar (this, SWT.VERTICAL, child);
+ break;
+ }
+ }
+ child = OS.PtWidgetBrotherBehind (child);
+ }
+}
+
+void deregister () {
+ super.deregister ();
+ if (scrolledHandle != 0) WidgetTable.remove (scrolledHandle);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.ul_x = (short) x;
+ rect.ul_y = (short) y;
+ rect.lr_x = (short) (x + width - 1);
+ rect.lr_y = (short) (y + height - 1);
+ OS.PtSetAreaFromWidgetCanvas (scrolledHandle != 0 ? scrolledHandle : handle, rect, area);
+ if (horizontalBar != null && horizontalBar.getVisible ()) {
+ Point size = horizontalBar.getSize ();
+ area.size_h += size.y;
+ }
+ if (verticalBar != null && verticalBar.getVisible ()) {
+ Point size = verticalBar.getSize ();
+ area.size_w += size.x;
+ }
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+public Rectangle getClientArea () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhRect_t rect = new PhRect_t ();
+ int vParent = OS.PtValidParent (handle, OS.PtContainer ());
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtCalcCanvas (vParent, rect);
+ int width = rect.lr_x - rect.ul_x + 1;
+ int height = rect.lr_y - rect.ul_y + 1;
+ return new Rectangle (0, 0, width, height);
+}
+
+public ScrollBar getHorizontalBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return horizontalBar;
+}
+
+public ScrollBar getVerticalBar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return verticalBar;
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ scrolledHandle = 0;
+}
+
+void resizeClientArea () {
+ /* Do nothing */
+}
+
+void releaseWidget () {
+ if (horizontalBar != null) horizontalBar.releaseWidget ();
+ if (verticalBar != null) verticalBar.releaseWidget ();
+ horizontalBar = verticalBar = null;
+ super.releaseWidget ();
+}
+
+void register () {
+ super.register ();
+ if (scrolledHandle != 0) WidgetTable.put (scrolledHandle, this);
+}
+
+int topHandle () {
+ if (scrolledHandle == 0) return handle;
+ return scrolledHandle;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
new file mode 100755
index 0000000000..7b590263a7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItem.java
@@ -0,0 +1,320 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class implements common behavior of TreeItem and TableItem.
+ */
+abstract class SelectableItem extends Item {
+ protected static final int CHECKBOX_PADDING = 1; // Space behind check box, before item image or text
+
+ private SelectableItemWidget parent; // parent widget of the receiver
+ private boolean isSelected = false; // item selection state
+ private boolean isChecked = false; // item checked state. Can be one of checked and unchecked
+ private boolean isGrayed = false; // item grayed state. The gray state is combined with the
+ // checked state to create gray checked and gray unchecked.
+/**
+ * Create a new instance of the receiver.
+ * @param parent - widget the receiver is created in
+ * @param style - widget style. see Widget class for details
+ */
+SelectableItem(SelectableItemWidget parent, int style) {
+ super(parent, style);
+ setParent(parent);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeItem();}});
+}
+/**
+ * Subclasses should free resources here
+ */
+void disposeItem() {
+ setParent(null);
+}
+/**
+ * Draw the check box of the receiver at 'position' using 'gc'.
+ * @param gc - GC to draw on.
+ * @param destinationPosition - position on the GC to draw at.
+ * @return Answer the position where drawing stopped.
+ */
+Point drawCheckbox(GC gc, Point position) {
+ SelectableItemWidget parent = getSelectableParent();
+ Image image;
+ Point imageExtent;
+ Rectangle imageBounds;
+ int imageOffset;
+ int xInset;
+ int yInset;
+
+ if (getGrayed() == true) {
+ image = parent.getGrayUncheckedImage();
+ }
+ else {
+ image = parent.getUncheckedImage();
+ }
+ if (image != null) {
+ imageExtent = parent.getCheckBoxExtent();
+ imageOffset = (parent.getItemHeight() - imageExtent.y) / 2;
+ gc.drawImage(image, position.x, position.y + imageOffset);
+ if (getChecked() == true) {
+ image = parent.getCheckMarkImage();
+ imageBounds = image.getBounds();
+ xInset = (imageExtent.x - imageBounds.width) / 2;
+ yInset = (imageExtent.y - imageBounds.height) / 2;
+ gc.drawImage(image, position.x + xInset, position.y + imageOffset + yInset);
+ }
+ position.x += imageExtent.x;
+ }
+ position.x += CHECKBOX_PADDING; // leave extra space behind check box
+ return position;
+}
+void drawInsertMark(GC gc, Point position) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+ final int markerWidth = getInsertMarkWidth();
+ int insertMarkYOffset = 0;
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (parent.isInsertAfter()) {
+ insertMarkYOffset = selectionExtent.y - markerWidth;
+ }
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_BLACK));
+ gc.fillRectangle(position.x, position.y + insertMarkYOffset, selectionExtent.x, markerWidth);
+ gc.setBackground(parent.getBackground());
+}
+/**
+ * Answer the bounding rectangle of the item check box.
+ * All points within this rectangle hit the check box.
+ */
+Rectangle getCheckboxBounds() {
+ SelectableItemWidget parent = getSelectableParent();
+ Point checkBoxExtent;
+ int redrawPosition;
+ Rectangle checkboxBounds = new Rectangle(0, 0, 0, 0);
+
+ if (isCheckable() == true) {
+ checkboxBounds.x = getCheckboxXPosition();
+ redrawPosition = parent.getRedrawY(this);
+ if (redrawPosition != -1) {
+ checkboxBounds.y = redrawPosition;
+ }
+ checkBoxExtent = parent.getCheckBoxExtent();
+ checkboxBounds.width = checkBoxExtent.x;
+ checkboxBounds.height = checkBoxExtent.y;
+ checkboxBounds.y += (parent.getItemHeight() - checkBoxExtent.y) / 2;
+ }
+ return checkboxBounds;
+}
+/**
+ * Answer the x position of the item check box
+ */
+abstract int getCheckboxXPosition();
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean checked = false;
+
+ if (isCheckable() == true) {
+ checked = isChecked;
+ }
+ return checked;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ SelectableItemWidget parent = getSelectableParent();
+
+ if (parent == null) {
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return parent.getDisplay();
+}
+
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <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 boolean getGrayed () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ boolean grayed = false;
+
+ if (isCheckable() == true) {
+ grayed = isGrayed;
+ }
+ return grayed;
+}
+/**
+ * Return the width in pixels of the line drawn to indicate the
+ * drop insert position during a drag and drop operation.
+ */
+int getInsertMarkWidth() {
+ return 2;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+SelectableItemWidget getSelectableParent() {
+ return parent;
+}
+/**
+ * Answer the background color to use for drawing the
+ * selection rectangle.
+ */
+Color getSelectionBackgroundColor() {
+ Display display = getSelectableParent().getDisplay();
+
+ return display.getSystemColor(SWT.COLOR_LIST_SELECTION);
+}
+/**
+ * Return the size of the rectangle drawn to indicate the
+ * selected state of the receiver.
+ */
+abstract Point getSelectionExtent();
+/**
+ * Answer the foreground color to use for drawing the
+ * selection rectangle.
+ */
+Color getSelectionForegroundColor() {
+ Display display = getSelectableParent().getDisplay();
+
+ return display.getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT);
+}
+/**
+ * Return the x position of the selection rectangle
+ */
+abstract int getSelectionX();
+/**
+ * Answer whether 'posiiton' is inside the item check box.
+ * @return
+ * true - item check box hit
+ * false - item check box not hit
+ */
+boolean isCheckHit(Point position) {
+ boolean isCheckHit = false;
+
+ if (isCheckable() == true) {
+ isCheckHit = getCheckboxBounds().contains(position);
+ }
+ return isCheckHit;
+}
+/**
+ * Return whether or not the receiver has a check box and can
+ * be checked.
+ */
+boolean isCheckable() {
+ return (getSelectableParent().getStyle() & SWT.CHECK) != 0;
+}
+/**
+ * Answer whether the receiver is selected.
+ * @return
+ * true - the receiver is selected
+ * false - the receiver is not selected
+ */
+boolean isSelected() {
+ return isSelected;
+}
+/**
+ * Redraw the insert mark
+ * @param yPosition - y position in the receiver's client area
+ * where the item should be drawn.
+ */
+void redrawInsertMark(int yPosition) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+ int redrawHeight = getInsertMarkWidth();
+
+ if (selectionExtent != null) {
+ parent.redraw(getSelectionX(), yPosition, selectionExtent.x, redrawHeight, false);
+ parent.redraw(getSelectionX(), yPosition + selectionExtent.y - redrawHeight, selectionExtent.x, redrawHeight, false);
+ }
+}
+/**
+ * Redraw the selection
+ * @param yPosition - y position in the receiver's client area
+ * where the item should be drawn.
+ */
+void redrawSelection(int yPosition) {
+ SelectableItemWidget parent = getSelectableParent();
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent != null) {
+ parent.redraw(getSelectionX(), yPosition, selectionExtent.x, selectionExtent.y, false);
+ }
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItemWidget parent = getSelectableParent();
+ Rectangle redrawRectangle = getCheckboxBounds();
+
+ if (isCheckable() == true && isChecked != checked) {
+ isChecked = checked;
+ parent.redraw(
+ redrawRectangle.x, redrawRectangle.y,
+ redrawRectangle.width, redrawRectangle.height, false);
+ }
+}
+
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <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 setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItemWidget parent = getSelectableParent();
+ Rectangle redrawRectangle = getCheckboxBounds();
+
+ if (isCheckable() == true && isGrayed != grayed) {
+ isGrayed = grayed;
+ parent.redraw(
+ redrawRectangle.x, redrawRectangle.y,
+ redrawRectangle.width, redrawRectangle.height, false);
+ }
+}
+
+/**
+ * Set the receiver's parent widget to 'parent'.
+ */
+void setParent(SelectableItemWidget parent) {
+ this.parent = parent;
+}
+/**
+ * Set whether the receiver is selected.
+ * @param selected - true=the receiver is selected
+ * false=the receiver is not selected
+ */
+void setSelected(boolean selected) {
+ isSelected = selected;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
new file mode 100755
index 0000000000..0eda6178f2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/SelectableItemWidget.java
@@ -0,0 +1,2027 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class is intended for widgets that display data of
+ * type Item. It provides a framework for scrolling and
+ * handles the screen refresh required when adding and
+ * removing items.
+ */
+abstract class SelectableItemWidget extends Composite {
+ private static final int DEFAULT_WIDTH = 64; // used in computeSize if width could not be calculated
+ private static final int DEFAULT_HEIGHT = 64; // used in computeSize if height could not be calculated
+ private static final int HORIZONTAL_SCROLL_INCREMENT = 5; // number of pixel the tree is moved
+ // during horizontal line scrolling
+ private static ImageData UncheckedImageData; // deselected check box image data. used to create an image at run time
+ private static ImageData GrayUncheckedImageData; // grayed deselected check box image data. used to create an image at run time
+ private static ImageData CheckMarkImageData; // check mark image data for check box. used to create an image at run time
+ static {
+ initializeImageData();
+ }
+
+ private int topIndex = 0; // index of the first visible item
+ private int itemHeight = 0; // height of a table item
+ private Point itemImageExtent = null; // size of the item images. Null unless an image is set for any item
+ private int textHeight = -1;
+ private int contentWidth = 0; // width of the widget data (ie. table rows/tree items)
+ private int horizontalOffset = 0;
+ private Vector selectedItems; // indices of the selected items
+ private SelectableItem lastSelectedItem; // item that was selected last
+ private SelectableItem lastFocusItem; // item that had the focus last. Always equals lastSelectedItem
+ // for mouse selection but may differ for keyboard selection
+ private SelectableItem insertItem; // item that draws the insert marker to indicate the drop location in a drag and drop operation
+ private boolean isInsertAfter; // indicates where the insert marker is rendered, at the top or bottom of 'insertItem'
+ private boolean isCtrlSelection = false; // the most recently selected item was
+ // selected using the Ctrl modifier key
+ private boolean isRemovingAll = false; // true=all items are removed. Used to optimize screen updates and to control item selection on dispose.
+ private boolean hasFocus; // workaround for 1FMITIE
+ private Image uncheckedImage; // deselected check box
+ private Image grayUncheckedImage; // grayed check box
+ private Image checkMarkImage; // check mark for selected check box
+ private Point checkBoxExtent = null; // width, height of the item check box
+ private Listener listener; // event listener used for all events. Events are dispatched
+ // to handler methods in handleEvents(Event)
+ private int drawCount = 0; // used to reimplement setRedraw(boolean)
+/**
+ * Create a new instance of ScrollableItemWidget.
+ * @param parent - the parent window of the new instance
+ * @param style - window style for the new instance
+ */
+SelectableItemWidget(Composite parent, int style) {
+ super(parent, style | SWT.H_SCROLL | SWT.V_SCROLL | SWT.NO_REDRAW_RESIZE);
+ initialize();
+}
+/**
+ * The SelectableItem 'item' has been added to the tree.
+ * Calculate the vertical scroll bar.
+ * Update the screen to display the new item.
+ * @param item - item that has been added to the receiver.
+ */
+void addedItem(SelectableItem item, int index) {
+ calculateVerticalScrollbar();
+ if (getLastFocus() == null) { // if no item has the focus
+ setLastFocus(item, true); // set focus to new (must be first) item
+ }
+}
+/**
+ * The SelectableItem 'item' is about to be added to the tree.
+ * @param item - item that is about to be added to the receiver.
+ */
+void addingItem(SelectableItem item, int index) {
+ if (index >= 0 && index <= getBottomIndex()) {
+ scrollVerticalAddingItem(index);
+ }
+}
+/**
+ * Set the scroll range of the horizontal scroll bar.
+ * Resize the scroll bar if the scroll range maximum
+ * has changed.
+ */
+void calculateHorizontalScrollbar() {
+ int newMaximum = getContentWidth();
+ ScrollBar horizontalBar = getHorizontalBar();
+
+ if (horizontalBar.getMaximum() != newMaximum) {
+ // The call to setMaximum is ignored if newMaximum is 0.
+ // Therefore we can not rely on getMaximum to subsequently return the number of
+ // items in the receiver. We always have to use getVisibleItemCount().
+ // Never rely on getMaximum to return what you set. It may not accept the
+ // value you set. Even if you use a valid value now the implementation may change
+ // later. That's what caused 1FRLOSG.
+ horizontalBar.setMaximum(newMaximum);
+ if (getVerticalBar().getVisible() == false) { // remove these lines
+ horizontalBar.setMaximum(newMaximum); // when PR 1FIG5CG
+ } // is fixed
+ resizeHorizontalScrollbar();
+ }
+}
+/**
+ * Calculate the height of items in the receiver.
+ * Only the image height is calculated if an item height
+ * has already been calculated. Do nothing if both the item
+ * height and the image height have already been calculated
+ */
+void calculateItemHeight(SelectableItem item) {
+ GC gc;
+ String itemText;
+ int itemHeight = -1;
+
+ if (itemImageExtent != null && textHeight != -1) {
+ return;
+ }
+ itemText = item.getText();
+ if (itemText != null && textHeight == -1) {
+ gc = new GC(this);
+ itemHeight = gc.stringExtent(itemText).y;
+ textHeight = itemHeight;
+ gc.dispose();
+ }
+ if (itemImageExtent == null) {
+ itemImageExtent = getImageExtent(item);
+ if (itemImageExtent != null) {
+ if (itemImageExtent.y > textHeight) {
+ itemHeight = itemImageExtent.y;
+ }
+ else {
+ itemHeight = textHeight;
+ }
+ }
+ }
+ itemHeight += getItemPadding(); // make sure that there is empty space below the image/text
+ if (itemHeight > getItemHeight()) { // only set new item height if it's higher because new,
+ setItemHeight(itemHeight); // smaller item height may not include an icon
+ }
+}
+/**
+ * Calculate the range of items that need to be selected given
+ * the clicked item identified by 'hitItemIndex'
+ * @param hitItemIndex - item that was clicked and that the new
+ * selection range will be based on. This index is relative to
+ * the top index.
+ */
+int [] calculateShiftSelectionRange(int hitItemIndex) {
+ int selectionRange[] = new int[] {-1, -1};
+ SelectableItem closestItem = null;
+ SelectableItem selectedItem;
+ Enumeration selectedItems = getSelectionVector().elements();
+
+ while (selectedItems.hasMoreElements() == true) {
+ selectedItem = (SelectableItem) selectedItems.nextElement();
+ if (closestItem == null) {
+ closestItem = selectedItem;
+ }
+ else
+ if (Math.abs(hitItemIndex - getVisibleIndex(selectedItem)) <
+ Math.abs(hitItemIndex - getVisibleIndex(closestItem))) {
+ closestItem = selectedItem;
+ }
+ }
+ if (closestItem == null) { // no item selected
+ closestItem = getLastSelection(); // item selected last may still have the focus
+ }
+ if (closestItem != null) {
+ selectionRange[0] = getVisibleIndex(closestItem);
+ selectionRange[1] = hitItemIndex;
+ }
+ return selectionRange;
+}
+/**
+ * Set the scroll range of the vertical scroll bar.
+ * Resize the scroll bar if the scroll range maximum
+ * has changed.
+ */
+void calculateVerticalScrollbar() {
+ int newMaximum = getVisibleItemCount();
+ ScrollBar verticalBar = getVerticalBar();
+
+ // The call to setMaximum is ignored if newMaximum is 0.
+ // Therefore we can not rely on getMaximum to subsequently return the number of
+ // items in the receiver. We always have to use getVisibleItemCount().
+ // Never rely on getMaximum to return what you set. It may not accept the
+ // value you set. Even if you use a valid value now the implementation may change
+ // later. That's what caused 1FRLOSG.
+ verticalBar.setMaximum(newMaximum);
+ if (getHorizontalBar().getVisible() == false) { // remove these lines
+ verticalBar.setMaximum(newMaximum); // when PR 1FIG5CG
+ } // is fixed
+ resizeVerticalScrollbar();
+}
+
+/**
+ * Answer the size of the receiver needed to display all items.
+ * The length of the longest item in the receiver is used for the
+ * width.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int width = getContentWidth();
+ int height = getItemCount() * getItemHeight();
+ int style = getStyle();
+ int scrollBarWidth = computeTrim(0, 0, 0, 0).width;
+
+ if (width == 0) {
+ width = DEFAULT_WIDTH;
+ }
+ if (height == 0) {
+ height = DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) {
+ width = wHint;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = hHint;
+ }
+ if ((getStyle() & SWT.V_SCROLL) != 0) {
+ width += scrollBarWidth;
+ }
+ if ((getStyle() & SWT.H_SCROLL) != 0) {
+ height += scrollBarWidth;
+ }
+ return new Point(width, height);
+}
+/**
+ * Do a ctrl+shift selection meaning the ctrl and shift keys
+ * were pressed when the mouse click on an item occurred.
+ * If an already selected item was clicked the focus is moved to
+ * that item.
+ * If the previous selection was a ctrl or ctrl+shift selection
+ * the range between the last selected item and the clicked item
+ * is selected.
+ * Otherwise a regular shift selection is performed.
+ * @param hitItem - specifies the clicked item
+ * @param hitItemIndex - specifies the index of the clicked item
+ * relative to the first item.
+ */
+void ctrlShiftSelect(SelectableItem hitItem, int hitItemIndex) {
+ int fromIndex = -1;
+ int toIndex = -1;
+ int lastSelectionIndex = -1;
+ int selectionRange[];
+ SelectableItem lastSelection = getLastSelection();
+
+ if (lastSelection != null) {
+ lastSelectionIndex = getVisibleIndex(lastSelection);
+ }
+ if ((getSelectionVector().contains(hitItem) == true) && // clicked an already selected item?
+ (hitItemIndex != lastSelectionIndex)) { // and click was not on last selected item?
+ setLastSelection(hitItem, true); // set last selection which also sets the focus
+ }
+ else
+ if (isCtrlSelection() == true) { // was last selection ctrl/ctrl+shift selection?
+ fromIndex = lastSelectionIndex; // select from last selection
+ toIndex = hitItemIndex;
+ }
+ else { // clicked outside existing selection range
+ selectionRange = calculateShiftSelectionRange(hitItemIndex);
+ fromIndex = selectionRange[0];
+ toIndex = selectionRange[1];
+ }
+ if (fromIndex != -1 && toIndex != -1) {
+ selectRange(fromIndex, toIndex);
+ }
+}
+/**
+ * Deselect 'item'.
+ * @param item - item that should be deselected
+ */
+void deselect(SelectableItem item) {
+ Vector selectedItems = getSelectionVector();
+
+ if ((item != null) && (item.isSelected() == true)) {
+ item.setSelected(false);
+ redrawSelection(item);
+ selectedItems.removeElement(item);
+ }
+}
+/**
+ * Deselect all item except 'keepSelected'.
+ * @param keepSelected - item that should remain selected
+ */
+void deselectAllExcept(SelectableItem keepSelected) {
+ Vector selectedItems = getSelectionVector();
+ Vector deselectedItems = new Vector(selectedItems.size());
+ Enumeration elements = selectedItems.elements();
+ SelectableItem item;
+
+ // deselect and repaint previously selected items
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ if (item.isSelected() == true && item != keepSelected) {
+ item.setSelected(false);
+ // always redraw the selection, even if item is redrawn again
+ // in setLastSelection. Fixes 1G0GQ8W
+ redrawSelection(item);
+ deselectedItems.addElement(item);
+ }
+ }
+ elements = deselectedItems.elements();
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ selectedItems.removeElement(item);
+ }
+ setLastSelection(keepSelected, false);
+}
+/**
+ * Deselect all items except those in 'keepSelected'.
+ * @param keepSelected - items that should remain selected
+ */
+void deselectAllExcept(Vector keepSelected) {
+ Vector selectedItems = getSelectionVector();
+ Vector deselectedItems = new Vector(selectedItems.size());
+ Enumeration elements = selectedItems.elements();
+ SelectableItem item;
+
+ // deselect and repaint previously selected items
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ if (item.isSelected() == true && keepSelected.contains(item) == false) {
+ item.setSelected(false);
+ // always redraw the selection, even if item is redrawn again
+ // in setLastSelection. Fixes 1G0GQ8W
+ redrawSelection(item);
+ deselectedItems.addElement(item);
+ }
+ }
+ elements = deselectedItems.elements();
+ while (elements.hasMoreElements() == true) {
+ item = (SelectableItem) elements.nextElement();
+ selectedItems.removeElement(item);
+ }
+ if (keepSelected.size() > 0) {
+ setLastSelection((SelectableItem) keepSelected.firstElement(), false);
+ }
+}
+/**
+ * Deselect 'item'. Notify listeners.
+ * @param item - item that should be deselected
+ */
+void deselectNotify(SelectableItem item) {
+ Event event = new Event();
+
+ if (item.isSelected() == true) {
+ deselect(item);
+ setLastSelection(item, true);
+ update(); // looks better when event notification takes long to return
+ }
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+}
+/**
+ * Deselect all items starting at and including 'fromIndex'
+ * stopping at and including 'toIndex'.
+ * @param fromIndex - index relative to the first item where
+ * deselection should start. Deselecion includes 'fromIndex'.
+ * @param toIndex - index relative to the first item where
+ * deselection should stop. Deselecion includes 'toIndex'.
+ */
+void deselectRange(int fromIndex, int toIndex) {
+ if (fromIndex > toIndex) {
+ for (int i = toIndex; i <= fromIndex; i++) {
+ deselect(getVisibleItem(i));
+ }
+ }
+ else
+ if (fromIndex < toIndex) {
+ for (int i = toIndex; i >= fromIndex; i--) {
+ deselect(getVisibleItem(i));
+ }
+ }
+ setLastSelection(getVisibleItem(fromIndex), true);
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection down one item
+ * Ctrl Keep old selection, move input focus down one item
+ * Shift Extend selection by one item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowDown(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+
+ if (focusItemIndex < (getVisibleItemCount() - 1)) { // - 1 because indices are 0 based
+ focusItemIndex++;
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Scroll receiver to the left
+ * Ctrl See None above
+ * Shift See None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowLeft(int keyMask) {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int scrollSelection = horizontalBar.getSelection();
+ int scrollAmount;
+
+ if (horizontalBar.getVisible() == false) {
+ return;
+ }
+ scrollAmount = Math.min(HORIZONTAL_SCROLL_INCREMENT, scrollSelection);
+ horizontalBar.setSelection(scrollSelection - scrollAmount);
+ setHorizontalOffset(horizontalBar.getSelection() * -1);
+}
+/**
+ * Modifier Key Action
+ * None Scroll receiver to the right
+ * Ctrl See None above
+ * Shift See None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowRight(int keyMask) {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int scrollSelection = horizontalBar.getSelection();
+ int scrollAmount;
+
+ if (horizontalBar.getVisible() == false) {
+ return;
+ }
+ scrollAmount = Math.min( // scroll by the smaller of
+ HORIZONTAL_SCROLL_INCREMENT, // the scroll increment
+ horizontalBar.getMaximum() // and the remaining scroll range
+ - horizontalBar.getPageIncrement()
+ - scrollSelection);
+ horizontalBar.setSelection(scrollSelection + scrollAmount);
+ setHorizontalOffset(horizontalBar.getSelection() * -1);
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection up one item
+ * Ctrl Keep old selection, move input focus up one item
+ * Shift Extend selection by one item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowUp(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+
+ if (focusItemIndex > 0) {
+ focusItemIndex--;
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Perform a selection operation on the item check box.
+ * @param item - the item that was clicked
+ */
+void doCheckItem(SelectableItem item) {
+ Event event = new Event();
+
+ item.setChecked(!item.getChecked());
+ event.item = item;
+ event.detail = SWT.CHECK;
+ notifyListeners(SWT.Selection, event);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ setRemovingAll(true);
+ getSelectionVector().removeAllElements();
+ lastFocusItem = null;
+ lastSelectedItem = null;
+ if (uncheckedImage != null) {
+ uncheckedImage.dispose();
+ }
+ if (grayUncheckedImage != null) {
+ grayUncheckedImage.dispose();
+ }
+ if (checkMarkImage != null) {
+ checkMarkImage.dispose();
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection to the
+ * last item
+ * Ctrl Keep old selection, move input focus to the
+ * last item
+ * Shift Extend selection to the last item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doEnd(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(lastFocus);
+ int lastItemIndex = getVisibleItemCount() - 1; // - 1 because indices are 0 based
+
+ if (focusItemIndex < lastItemIndex) {
+ newFocus = getVisibleItem(lastItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, lastItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection to the
+ * first item
+ * Ctrl Keep old selection, move input focus to the
+ * first item
+ * Shift Extend selection to the first item.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doHome(int keyMask) {
+ SelectableItem lastFocus = getLastFocus();
+ SelectableItem newFocus;
+ int firstItemIndex = 0;
+
+ if (getVisibleIndex(lastFocus) > firstItemIndex) {
+ newFocus = getVisibleItem(firstItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, firstItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Perform a mouse select action according to the key state
+ * mask in 'eventStateMask'.
+ * Key state mask is ignored when receiver has the single selection
+ * style.
+ * @param item - the item that was clicked
+ * @param itemIndex - the index of the clicked item relative
+ * to the first item of the receiver
+ * @param eventStateMask - the key state mask of the mouse event
+ * @param button - the mouse button that was pressed
+ */
+void doMouseSelect(SelectableItem item, int itemIndex, int eventStateMask, int button) {
+ if (((eventStateMask & SWT.CTRL) != 0) &&
+ ((eventStateMask & SWT.SHIFT) != 0) &&
+ (isMultiSelect() == true)) {
+ if (getSelectionVector().size() == 0) { // no old selection?
+ selectNotify(item); // do standard CTRL selection
+ }
+ else {
+ ctrlShiftSelect(item, itemIndex);
+ }
+ setCtrlSelection(true);
+ }
+ else
+ if (((eventStateMask & SWT.SHIFT) != 0) && (isMultiSelect() == true)) {
+ shiftSelect(item, itemIndex);
+ setCtrlSelection(false);
+ }
+ else
+ if (((eventStateMask & SWT.CTRL) != 0) && (isMultiSelect() == true)) {
+ toggleSelectionNotify(item);
+ setCtrlSelection(true);
+ }
+ else
+ if (button != 3 || item.isSelected() == false) {
+ // only select the item (and deselect all others) if the mouse click is
+ // not a button 3 click or if a previously unselected item was clicked.
+ // Fixes 1G97L65
+ deselectAllExcept(item);
+ selectNotify(item);
+ setCtrlSelection(false);
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection one page down
+ * Ctrl Keep old selection, move input focus one page down
+ * Shift Extend selection one page down
+ * One page is the number of items that can be displayed in the
+ * receiver's canvas without truncating the last item.
+ * The selection is set to the last item if there is no full page
+ * of items left.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doPageDown(int keyMask) {
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(getLastFocus());
+ int lastItemIndex = getVisibleItemCount() - 1; // - 1 because indices are 0 based
+ int visibleItemCount;
+
+ if (focusItemIndex < lastItemIndex) {
+ visibleItemCount = getItemCountWhole();
+ focusItemIndex = Math.min(
+ lastItemIndex,
+ focusItemIndex + (visibleItemCount - 1));
+ newFocus = getVisibleItem(focusItemIndex);
+ if (newFocus == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * None Remove old selection, move selection one page up
+ * Ctrl Keep old selection, move input focus one page up
+ * Shift Extend selection one page up
+ * One page is the number of items that can be displayed in the
+ * receiver's canvas without truncating the last item.
+ * The selection is set to the first item if there is no full page
+ * of items left.
+ * Modifier Key is ignored when receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+void doPageUp(int keyMask) {
+ SelectableItem newFocus;
+ int focusItemIndex = getVisibleIndex(getLastFocus());
+ int visibleItemCount;
+
+ if (focusItemIndex > 0) {
+ visibleItemCount = getItemCountWhole();
+ focusItemIndex = Math.max(
+ 0,
+ focusItemIndex - (visibleItemCount - 1));
+ newFocus = getVisibleItem(focusItemIndex);
+ if (keyMask == SWT.CTRL && isMultiSelect() == true) {
+ setLastFocus(newFocus, true);
+ }
+ else
+ if (keyMask == SWT.SHIFT && isMultiSelect() == true) {
+ shiftSelect(newFocus, focusItemIndex);
+ }
+ else {
+ deselectAllExcept(newFocus);
+ selectNotify(newFocus);
+ }
+ }
+}
+/**
+ * Modifier Key Action
+ * Ctrl Keep old selection, toggle selection of the item
+ * that has the input focus
+ * Shift Extend selection to the item that has the input
+ * focus
+ * Ctrl & Shift Set selection to the item that has input focus
+ * Do nothing if receiver has single selection style.
+ * @param keyMask - the modifier key that was pressed
+ */
+
+void doSpace(int keyMask) {
+ SelectableItem item = getLastFocus();
+ int itemIndex = getVisibleIndex(item);
+
+ if (keyMask == SWT.NULL && item.isSelected() == false) { // do simple space select in SINGLE and MULTI mode
+ deselectAllExcept(item);
+ selectNotify(item);
+ return;
+ }
+ if (isMultiSelect() == false || item == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ toggleSelectionNotify(item);
+ }
+ else
+ if (((keyMask & SWT.CTRL) != 0) && ((keyMask & SWT.SHIFT) != 0)) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ }
+ else
+ if (keyMask == SWT.SHIFT) {
+ shiftSelect(item, itemIndex);
+ }
+}
+/**
+ * Make sure that free space at the bottom of the receiver is
+ * occupied.
+ * There will be new space available below the last item when the
+ * receiver's height is increased. In this case the receiver
+ * is scrolled down to occupy the new space.if the top item is
+ * not the first item of the receiver.
+ */
+void claimBottomFreeSpace() {
+ int clientAreaItemCount = getItemCountWhole();
+ int topIndex = getTopIndex();
+ int newTopIndex;
+ int lastItemIndex = getVisibleItemCount() - topIndex;
+
+ if ((topIndex > 0) &&
+ (lastItemIndex > 0) &&
+ (lastItemIndex < clientAreaItemCount)) {
+ newTopIndex = Math.max(0, topIndex-(clientAreaItemCount-lastItemIndex));
+ setTopIndex(newTopIndex, true);
+ }
+}
+/**
+ * Make sure that free space at the right side of the receiver is
+ * occupied.
+ * There will be new space available at the right side of the receiver
+ * when the receiver's width is increased. In this case the receiver
+ * is scrolled to the right to occupy the new space.if possible.
+ */
+void claimRightFreeSpace() {
+ int clientAreaWidth = getClientArea().width;
+ int newHorizontalOffset = clientAreaWidth - getContentWidth();
+
+ if (newHorizontalOffset - getHorizontalOffset() > 0) { // item is no longer drawn past the right border of the client area
+ newHorizontalOffset = Math.min(0, newHorizontalOffset); // align the right end of the item with the right border of the
+ setHorizontalOffset(newHorizontalOffset); // client area (window is scrolled right)
+ }
+}
+/** Not used right now. Replace focusIn/focusOut with this method once
+ * Display.getFocusWindow returns the new focus window on FocusOut event
+ * (see 1FMITIE)
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusChange(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusIn(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ // Workaround for 1FMITIE
+ hasFocus = true;
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+ // Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ.
+ update();
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusOut(Event event) {
+ Enumeration items = getSelectionVector().elements();
+ SelectableItem lastFocusItem = getLastFocus();
+ SelectableItem item;
+
+ // Workaround for 1FMITIE
+ hasFocus = false;
+ while (items.hasMoreElements() == true) {
+ item = (SelectableItem) items.nextElement();
+ redrawSelection(item);
+ }
+ if (lastFocusItem != null) {
+ redrawSelection(lastFocusItem);
+ }
+ // Fix blank item on slow machines/VMs. Also fixes 1G0IFMZ.
+ update();
+}
+/**
+ * Answer the index of the last item position in the receiver's
+ * client area.
+ * @return 0-based index of the last item position in the tree's
+ * client area.
+ */
+int getBottomIndex() {
+ return getTopIndex() + getItemCountTruncated(getClientArea());
+}
+/**
+ * Answer the size of the check box image.
+ * The calculation is cached and assumes that the images for
+ * the checked and unchecked state are the same size.
+ */
+Point getCheckBoxExtent() {
+ Image checkedImage;
+ Rectangle imageBounds;
+
+ if (checkBoxExtent == null) {
+ checkedImage = getUncheckedImage();
+ if (checkedImage != null) {
+ imageBounds = checkedImage.getBounds();
+ checkBoxExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ else {
+ checkBoxExtent = new Point(0, 0);
+ }
+ }
+ return checkBoxExtent;
+}
+/**
+ * Answer the image for the selected check box
+ * Answer null if the image couldn't be loaded.
+ */
+Image getCheckMarkImage() {
+ InputStream resourceStream;
+
+ if (checkMarkImage == null) {
+ checkMarkImage = new Image(getDisplay(), CheckMarkImageData);
+ }
+ return checkMarkImage;
+}
+/**
+ * Answer the width of the receiver's content.
+ * Needs to be set by subclasses.
+ */
+int getContentWidth() {
+ return contentWidth;
+}
+/**
+ * Answer the horizontal drawing offset used for scrolling.
+ * This is < 0 if the receiver has been scrolled to the left,
+ * > 0 if the receiver has been scrolled to the right and 0
+ * if the receiver has not been scrolled.
+ */
+int getHorizontalOffset() {
+ return horizontalOffset;
+}
+
+/**
+ * Answer the size of item images. Calculated during the item
+ * height calculation.
+ */
+Point getImageExtent() {
+ return itemImageExtent;
+}
+/**
+ * Answer the image extent of 'item'. Overridden by subclasses.
+ */
+Point getImageExtent(SelectableItem item) {
+ Image image = item.getImage();
+ Rectangle imageBounds;
+ Point imageExtent = null;
+
+ if (image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+abstract int getIndex(SelectableItem item);
+/**
+ * Answer the first and last index of items that can be displayed in
+ * the area defined by 'clipRectangle'. This includes partial items.
+ * @return
+ * Array -
+ * First element is the index of the first item in 'clipRectangle'.
+ * Second element is the index of the last item in 'clipRectangle'.
+ */
+int[] getIndexRange(Rectangle clipRectangle) {
+ int visibleRange[] = new int[] {0, 0};
+
+ visibleRange[0] = clipRectangle.y / getItemHeight();
+ visibleRange[1] =
+ visibleRange[0] +
+ getItemCountTruncated(clipRectangle) - 1; // - 1 because item index is 0 based
+ return visibleRange;
+}
+/**
+ * Return the item that draws the marker indicating the insert location
+ * in a drag and drop operation
+ */
+SelectableItem getInsertItem() {
+ return insertItem;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+public abstract int getItemCount();
+/**
+ * Answer the number of items that can be displayed in 'rectangle'.
+ * The result includes partially visible items.
+ */
+int getItemCountTruncated(Rectangle rectangle) {
+ int itemHeight = getItemHeight();
+ int itemCount = 0;
+ int startIndex;
+
+ startIndex = rectangle.y / itemHeight;
+ itemCount = (int) Math.ceil(((float) rectangle.y + rectangle.height) / itemHeight)-startIndex;
+ return itemCount;
+}
+/**
+ * Answer the number of items that can be displayed in the client
+ * area of the receiver.
+ * The result only includes items that completely fit into the
+ * client area.
+ */
+int getItemCountWhole() {
+ return getClientArea().height / getItemHeight();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ GC gc;
+ if (itemHeight == 0) {
+ gc = new GC(this);
+ itemHeight = gc.stringExtent("String").y + getItemPadding(); // initial item height=font height + item spacing
+ // use real font height here when available in SWT, instead of GC.textExtent
+ gc.dispose();
+ }
+ return itemHeight;
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return 2 + getDisplay().textHighlightThickness;
+}
+/**
+ * Answer the item that most recently received the input focus.
+ */
+SelectableItem getLastFocus() {
+ return lastFocusItem;
+}
+/**
+ * Answer the item that was selected most recently.
+ */
+SelectableItem getLastSelection() {
+ return lastSelectedItem;
+}
+/**
+ * Answer the event listener used for all events. Events are
+ * dispatched to handler methods in handleEvents(Event).
+ * This scheme saves a lot of inner classes.
+ */
+Listener getListener() {
+ return listener;
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is not an item of the receiver
+ */
+int getRedrawY(SelectableItem item) {
+ int redrawIndex = getVisibleIndex(item);
+ int redrawY = -1;
+
+ if (redrawIndex != -1) {
+ redrawY = (redrawIndex - getTopIndex()) * getItemHeight();
+ }
+ return redrawY;
+}
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getSelectionVector().size();
+}
+/**
+ * Answer the selected items of the receiver.
+ * @return The selected items of the receiver stored in a Vector.
+ * Returned Vector is empty if no items are selected.
+ */
+Vector getSelectionVector() {
+ return selectedItems;
+}
+/**
+ * Answer the width of 'text' in pixel.
+ * Answer 0 if 'text' is null.
+ */
+int getTextWidth(String text) {
+ int textWidth = 0;
+ GC gc;
+
+ if (text != null) {
+ gc = new GC(this);
+ textWidth = gc.stringExtent(text).x;
+ gc.dispose();
+ }
+ return textWidth;
+}
+/**
+ * Answer the index of the first visible item in the receiver's
+ * client area.
+ * @return 0-based index of the first visible item in the
+ * receiver's client area.
+ */
+int getTopIndex() {
+ return topIndex;
+}
+/**
+ * Answer the image for the deselected check box.
+ */
+Image getUncheckedImage() {
+ InputStream resourceStream;
+
+ if (uncheckedImage == null) {
+ uncheckedImage = new Image(getDisplay(), UncheckedImageData);
+ }
+ return uncheckedImage;
+}
+
+/**
+ * Answer the image for the grayed eck box.
+ */
+Image getGrayUncheckedImage() {
+ InputStream resourceStream;
+
+ if (grayUncheckedImage == null) {
+ grayUncheckedImage = new Image(getDisplay(), GrayUncheckedImageData);
+ }
+ return grayUncheckedImage;
+}
+
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Normally, every item of the receiver is visible.
+ */
+abstract int getVisibleIndex(SelectableItem item);
+/**
+ * Answer the SelectableItem located at 'itemIndex' in the
+ * receiver.
+ * @param itemIndex - location of the SelectableItem object
+ * to return
+ */
+abstract SelectableItem getVisibleItem(int itemIndex);
+/**
+ * Answer the number of visible items of the receiver.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Normally every item of the receiver is visible.
+ */
+int getVisibleItemCount() {
+ return getItemCount();
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+abstract int getVisibleRedrawY(SelectableItem item);
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.Dispose:
+ doDispose();
+ break;
+ case SWT.KeyDown:
+ keyDown(event);
+ break;
+ case SWT.Resize:
+ resize(event);
+ break;
+ case SWT.Selection:
+ if (event.widget == getVerticalBar()) {
+ scrollVertical(event);
+ }
+ else
+ if (event.widget == getHorizontalBar()) {
+ scrollHorizontal(event);
+ }
+ break;
+ case SWT.FocusOut:
+ focusOut(event);
+ break;
+ case SWT.FocusIn:
+ focusIn(event);
+ break;
+ }
+}
+
+
+
+/**
+ * Answer whether 'item' has the input focus.
+ */
+boolean hasFocus(SelectableItem item) {
+ return (isFocusControl() && item == getLastFocus());
+}
+/**
+ * Initialize the receiver. Add event listeners and set widget
+ * colors.
+ */
+void initialize() {
+ Display display = getDisplay();
+ ScrollBar horizontalBar = getHorizontalBar();
+ ScrollBar verticalBar = getVerticalBar();
+
+ // listener may be needed by overridden installListeners()
+ listener = new Listener() {
+ public void handleEvent(Event event) {handleEvents(event);}
+ };
+ setSelectionVector(new Vector());
+ installListeners();
+ calculateVerticalScrollbar();
+ calculateHorizontalScrollbar();
+ horizontalBar.setMinimum(0);
+ verticalBar.setMinimum(0);
+ horizontalBar.setIncrement(HORIZONTAL_SCROLL_INCREMENT);
+ setForeground(display.getSystemColor(SWT.COLOR_LIST_FOREGROUND));
+ setBackground(display.getSystemColor(SWT.COLOR_LIST_BACKGROUND));
+}
+/**
+ * Initialize the ImageData used for the checked/unchecked images.
+ */
+static void initializeImageData() {
+ PaletteData uncheckedPalette = new PaletteData(
+ new RGB[] {new RGB(128, 128, 128), new RGB(255, 255, 255)});
+ PaletteData grayUncheckedPalette = new PaletteData(
+ new RGB[] {new RGB(128, 128, 128), new RGB(192, 192, 192)});
+ PaletteData checkMarkPalette = new PaletteData(
+ new RGB[] {new RGB(0, 0, 0), new RGB(252, 3, 251)});
+ byte[] checkbox = new byte[] {0, 0, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 0, 0};
+
+ // Each pixel is represented by one bit in the byte data.
+ // The bit references the palette position (0 or 1). Each pixel row of an image is padded to one byte.
+ // Arguments: width, height, depth, palette, scanline padding, data
+ UncheckedImageData = new ImageData(11, 11, 1, uncheckedPalette, 2, checkbox);
+ GrayUncheckedImageData = new ImageData(11, 11, 1, grayUncheckedPalette, 2, checkbox);
+ CheckMarkImageData = new ImageData(7, 7, 1, checkMarkPalette, 1, new byte[] {-4, -8, 112, 34, 6, -114, -34});
+ CheckMarkImageData.transparentPixel = 1;
+}
+/**
+ * Add event listeners to the tree widget and its scroll bars.
+ */
+void installListeners() {
+ Listener listener = getListener();
+
+ addListener(SWT.Dispose, listener);
+ addListener(SWT.Resize, listener);
+ addListener(SWT.KeyDown, listener);
+ addListener(SWT.FocusOut, listener);
+ addListener(SWT.FocusIn, listener);
+
+ getVerticalBar().addListener(SWT.Selection, listener);
+ getHorizontalBar().addListener(SWT.Selection, listener);
+}
+/**
+ * Answer whether the currently selected items were selected
+ * using the ctrl key.
+ */
+boolean isCtrlSelection() {
+ return isCtrlSelection;
+}
+/**
+ * Answer true if all items in the widget are disposed.
+ * Used to optimize item disposal. Prevents unnecessary screen
+ * updates.
+ */
+boolean isRemovingAll() {
+ return isRemovingAll;
+}
+/**
+ * Answer whether the receiver has the input focus.
+ * Workaround for 1FMITIE
+ */
+public boolean isFocusControl() {
+ return hasFocus;
+}
+/**
+ * Return whether the drop insert position is before or after the
+ * item set using motif_setInsertMark.
+ * @return
+ * true=insert position is after the insert item
+ * false=insert position is before the insert item
+ */
+boolean isInsertAfter() {
+ return isInsertAfter;
+}
+/**
+ * Answer whether the receiver has the MULTI selection style set.
+ * @return
+ * true = receiver is in multiple selection mode.
+ * false = receiver is in single selection mode.
+ */
+boolean isMultiSelect() {
+ return ((getStyle() & SWT.MULTI) != 0);
+}
+/**
+ * The item identified by 'changedItem' has changed.
+ * Calculate the item height based on the new item data (it might
+ * now have an image which could also be the first image in the
+ * receiver)
+ * Redraw the whole window if the item height has changed. Otherwise
+ * redraw only the changed item or part of it depending on the
+ * 'repaintStartX' and 'repaintWidth' parameters.
+ * @param changedItem - the item that has changed
+ * @param repaintStartX - x position of the item redraw.
+ * @param repaintWidth - width of the item redraw.
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ int yPosition;
+ int itemHeight;
+ int oldItemHeight = getItemHeight();
+ Point oldImageExtent = getImageExtent();
+
+ calculateItemHeight(changedItem); // make sure that the item height is recalculated
+ // no redraw necessary if redraw width is 0 or item is not visible
+ if (repaintWidth == 0 || (yPosition = getVisibleRedrawY(changedItem)) == -1) {
+ return;
+ } // if changedItem is the first item with image.
+ itemHeight = getItemHeight();
+ if ((oldItemHeight == itemHeight) && // only redraw changed item if the item height and
+ (oldImageExtent == getImageExtent())) { // image size has not changed. The latter will only change once,
+ // from null to a value-so it's safe to test using !=
+ // redrawing outside the client area redraws the widget border on Motif.
+ // adjust the redraw width if necessary. Workaround for 1G4TQRW
+ repaintWidth = Math.min(repaintWidth, getClientArea().width - repaintStartX);
+ if (repaintWidth > 0) {
+ redraw(repaintStartX, yPosition, repaintWidth, itemHeight, true);
+ }
+ }
+ else {
+ redraw(); // redraw all items if the item height has changed
+ }
+}
+/**
+ * A key was pressed. Call the appropriate handler method.
+ * @param event - the key event
+ */
+void keyDown(Event event) {
+ boolean isCtrlSelection = isCtrlSelection();
+
+ if (event.stateMask != SWT.CTRL) {
+ isCtrlSelection = false;
+ }
+ switch (event.keyCode) {
+ case SWT.ARROW_UP:
+ doArrowUp(event.stateMask);
+ break;
+ case SWT.ARROW_DOWN:
+ doArrowDown(event.stateMask);
+ break;
+ case SWT.ARROW_LEFT:
+ doArrowLeft(event.stateMask);
+ break;
+ case SWT.ARROW_RIGHT:
+ doArrowRight(event.stateMask);
+ break;
+ case SWT.PAGE_UP:
+ doPageUp(event.stateMask);
+ break;
+ case SWT.PAGE_DOWN:
+ doPageDown(event.stateMask);
+ break;
+ case SWT.HOME:
+ doHome(event.stateMask);
+ break;
+ case SWT.END:
+ doEnd(event.stateMask);
+ break;
+ default: // no selection occurred, keep previous
+ isCtrlSelection = isCtrlSelection(); // selection type information
+ }
+ if (event.character == ' ') {
+ doSpace(event.stateMask);
+ isCtrlSelection = (event.stateMask == SWT.CTRL);
+ }
+ setCtrlSelection(isCtrlSelection);
+}
+/**
+ * Sets the drop insert item.
+ * The drop insert item has a visual hint to show where a dragged item
+ * will be inserted when dropped on the tree.
+ * <p>
+ * @param item the insert item
+ * @param after true places the insert mark below 'item'. false places
+ * the insert mark above 'item'.
+ */
+void motif_setInsertMark(SelectableItem item, boolean after) {
+ SelectableItem currentItem = getInsertItem();
+ int redrawY;
+
+ setInsertItem(item);
+ setInsertAfter(after);
+ if (currentItem != null) {
+ redrawY = getVisibleRedrawY(currentItem);
+ if (redrawY != -1) {
+ currentItem.redrawInsertMark(redrawY);
+ }
+ }
+ if (item != null) {
+ redrawY = getVisibleRedrawY(item);
+ if (redrawY != -1) {
+ item.redrawInsertMark(redrawY);
+ }
+ }
+}
+
+
+/**
+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was
+ * set to false.
+ */
+public void redraw () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (drawCount == 0) {
+ super.redraw();
+ }
+}
+/**
+ * Overridden to implement setRedraw(). Redraw is ignored if setRedraw was
+ * set to false.
+ */
+public void redraw (int x, int y, int width, int height, boolean all) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (drawCount == 0) {
+ super.redraw(x, y, width, height, all);
+ }
+}
+
+/**
+ * Redraw the selection of 'item'
+ * @param item - SelectableItem that should have the selection redrawn.
+ */
+void redrawSelection(SelectableItem item) {
+ int redrawPosition = getVisibleRedrawY(item);
+
+ if (redrawPosition != -1) {
+ item.redrawSelection(redrawPosition);
+ }
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Update the display and the scroll bars.
+ */
+void removedItem(SelectableItem item) {
+ claimBottomFreeSpace();
+ calculateVerticalScrollbar();
+ if (getItemCount() == 0) {
+ reset();
+ }
+}
+/**
+ * 'item' is about to be removed from the tree.
+ * Move the selection/input focus if 'item' is selected or has the
+ * input focus,
+ * @param item - item that is about to be removed from the tree.
+ */
+void removingItem(SelectableItem item) {
+ SelectableItem nextFocusItem = null;
+ int itemIndex = getVisibleIndex(item);
+ int itemCount = getVisibleItemCount();
+
+ // deselect item and remove from selection
+ if (item.isSelected() == true) {
+ getSelectionVector().removeElement(item);
+ }
+ if (item == getLastFocus() && itemCount > 1) {
+ // select previous item if removed item is bottom item
+ // otherwise select next item. Fixes 1GA6L85
+ if (itemIndex == itemCount - 1) {
+ nextFocusItem = getVisibleItem(itemIndex - 1);
+ }
+ else {
+ nextFocusItem = getVisibleItem(itemIndex + 1);
+ }
+ setLastFocus(nextFocusItem, true);
+ }
+ // ignore items below widget client area
+ if (itemIndex != -1 && itemIndex <= getBottomIndex()) {
+ scrollVerticalRemovedItem(itemIndex);
+ }
+}
+/**
+ * Reset state that is dependent on or calculated from the state
+ * of the receiver.
+ */
+void reset() {
+ setSelectionVector(new Vector());
+ setTopIndexNoScroll(0, true);
+ lastSelectedItem = null;
+ lastFocusItem = null;
+ resetItemData();
+}
+/**
+ * Reset state that is dependent on or calculated from the items
+ * of the receiver.
+ */
+void resetItemData() {
+ setHorizontalOffset(0);
+ setItemHeight(0);
+ itemImageExtent = null;
+ textHeight = -1;
+ claimRightFreeSpace();
+}
+/**
+ * The receiver has been resized. Update the scroll bars and
+ * make sure that new space is being occupied by items.
+ */
+void resize(Event event) {
+ int horizontalPageSize = getHorizontalBar().getPageIncrement();
+
+ resizeHorizontalScrollbar();
+ resizeVerticalScrollbar();
+ if (getClientArea().width > horizontalPageSize) { // window resized wider? - Do this check here
+ claimRightFreeSpace(); // because claimRightFreeSpace is called elsewhere.
+ }
+ claimBottomFreeSpace();
+}
+/**
+ * Display the horizontal scroll bar if items are drawn off
+ * screen. Update the page size.
+ */
+void resizeHorizontalScrollbar() {
+ ScrollBar horizontalBar = getHorizontalBar();
+ int clientAreaWidth = getClientArea().width;
+
+ if (clientAreaWidth < getContentWidth()) {
+ if (horizontalBar.getVisible() == false) {
+ horizontalBar.setVisible(true);
+ horizontalBar.setSelection(0);
+ }
+ }
+ else
+ if (horizontalBar.getVisible() == true) {
+ horizontalBar.setVisible(false);
+ }
+ horizontalBar.setThumb(clientAreaWidth);
+ horizontalBar.setPageIncrement(clientAreaWidth);
+}
+/**
+ * Display the vertical scroll bar if items are drawn off screen.
+ * Update the page size.
+ */
+void resizeVerticalScrollbar() {
+ int clientAreaItemCount = getItemCountWhole();
+ ScrollBar verticalBar = getVerticalBar();
+
+ if (clientAreaItemCount == 0) {
+ return;
+ }
+ if (clientAreaItemCount < getVisibleItemCount()) {
+ if (verticalBar.getVisible() == false) {
+ verticalBar.setVisible(true);
+ }
+ // Only set the page size to something smaller than the scroll
+ // range maximum. Otherwise the scroll selection will be reset.
+ verticalBar.setPageIncrement(clientAreaItemCount);
+ verticalBar.setThumb(clientAreaItemCount);
+ }
+ else
+ if (verticalBar.getVisible() == true) {
+ verticalBar.setVisible(false);
+ }
+}
+/**
+ * Scroll the rectangle specified by x, y, width, height to the destination
+ * position. Do nothing if redraw is set to false using setRedraw().
+ *
+ * @param destX - destination x position of the scrolled rectangle
+ * @param destY - destination y position of the scrolled rectangle
+ * @param x - x location of the upper left corner of the scroll rectangle
+ * @param y - y location of the upper left corner of the scroll rectangle
+ * @param width - width of the scroll rectangle
+ * @param height - height of the scroll rectangle
+ * @param all - not used. Used to be true=scroll children intersecting the
+ * scroll rectangle.
+ */
+void scroll(int destX, int destY, int x, int y, int width, int height, boolean all) {
+ if (drawCount == 0) {
+ update();
+ GC gc = new GC(this);
+ gc.copyArea(x, y, width, height, destX, destY);
+ gc.dispose();
+ }
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * numPixel > 0 = scroll to left. numPixel < 0 = scroll to right
+ */
+abstract void scrollHorizontal(int numPixel);
+/**
+ * The position of the horizontal scroll bar has been modified
+ * by the user.
+ * Adjust the horizontal offset to trigger a horizontal scroll.
+ * @param event-the scroll event
+ */
+void scrollHorizontal(Event event) {
+ setHorizontalOffset(getHorizontalBar().getSelection() * -1);
+}
+/**
+ * Scroll 'item' into the receiver's client area if necessary.
+ * @param item - the item that should be scrolled.
+ */
+void scrollShowItem(SelectableItem item) {
+ int itemIndexFromTop = getIndex(item) - getTopIndex();
+ int clientAreaWholeItemCount = getItemCountWhole();
+ int scrollAmount = 0;
+
+ if (itemIndexFromTop >= clientAreaWholeItemCount) { // show item below visible items?
+ scrollAmount = itemIndexFromTop;
+ if (clientAreaWholeItemCount > 0) { // will be 0 if showItem is called and receiver hasn't been displayed yet
+ scrollAmount -= clientAreaWholeItemCount - 1;
+ }
+ }
+ else
+ if (itemIndexFromTop < 0) { // show item above visible items?
+ scrollAmount = itemIndexFromTop;
+ }
+ setTopIndex(getTopIndex() + scrollAmount, true);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+abstract void scrollVertical(int scrollIndexCount);
+/**
+ * The position of the horizontal scroll bar has been modified
+ * by the user.
+ * Adjust the index of the top item to trigger a vertical scroll.
+ * @param event-the scroll event
+ */
+void scrollVertical(Event event) {
+ setTopIndex(getVerticalBar().getSelection(), false);
+}
+/**
+ * Scroll items down to make space for a new item added to
+ * the receiver at position 'index'.
+ * @param index - position at which space for one new item
+ * should be made. This index is relative to the first item
+ * of the receiver.
+ */
+void scrollVerticalAddingItem(int index) {
+ Rectangle clientArea = getClientArea();
+ int itemHeight = getItemHeight();
+ int sourceY = Math.max(0, (index - getTopIndex()) * itemHeight); // need to scroll in visible area
+
+ scroll(
+ 0, sourceY + itemHeight, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll the items below the item at position 'index' up
+ * so that they cover the removed item.
+ * @param index - index of the removed item
+ */
+void scrollVerticalRemovedItem(int index) {
+ Rectangle clientArea = getClientArea();
+ int itemHeight = getItemHeight();
+ int destinationY = Math.max(0, (index - getTopIndex()) * itemHeight);
+
+ scroll(
+ 0, destinationY, // destination x, y
+ 0, destinationY + itemHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select 'item' if it is not selected.
+ * @param item - item that should be selected
+ */
+void select(SelectableItem item) {
+ Vector selectedItems = getSelectionVector();
+
+ if (item != null && item.isSelected() == false && isRemovingAll() == false) {
+ item.setSelected(true);
+ redrawSelection(item);
+ selectedItems.addElement(item);
+ }
+}
+/**
+ * Select 'item' if it is not selected. Send a Selection event
+ * if the selection was changed.
+ * @param item - item that should be selected
+ */
+void selectNotify(SelectableItem item) {
+ Event event;
+
+ if (isRemovingAll() == false) {
+ if (item.isSelected() == false) {
+ select(item);
+ setLastSelection(item, true);
+ update(); // looks better when event notification takes long to return
+ }
+ event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Selection, event);
+ }
+}
+/**
+ * Select all items of the receiver starting at 'fromIndex'
+ * and including 'toIndex'.
+ */
+void selectRange(int fromIndex, int toIndex) {
+ if (fromIndex > toIndex) {
+ for (int i = fromIndex; i > toIndex; i--) {
+ select(getVisibleItem(i));
+ }
+ }
+ else {
+ for (int i = fromIndex; i < toIndex; i++) {
+ select(getVisibleItem(i));
+ }
+ }
+ selectNotify(getVisibleItem(toIndex)); // select last item, notifying listeners
+}
+/**
+ * Set the width of the receiver's contents to 'newWidth'.
+ * Content width is used to calculate the horizontal scrollbar.
+ */
+void setContentWidth(int newWidth) {
+ ScrollBar horizontalBar;
+ boolean scrollBarVisible;
+
+ if (contentWidth != newWidth) {
+ horizontalBar = getHorizontalBar();
+ scrollBarVisible = horizontalBar.getVisible();
+ contentWidth = newWidth;
+ calculateHorizontalScrollbar();
+ if (scrollBarVisible != horizontalBar.getVisible()) {
+ resizeVerticalScrollbar(); // the vertical scroll bar needs to be resized if the horizontal
+ } // scroll bar was hidden or made visible during recalculation
+ }
+}
+/**
+ * Set whether the currently selected items were selected using the
+ * ctrl key.
+ * @param isCtrlSelection -
+ * true = currently selected items were selected using the ctrl key.
+ * false = currently selected items were not selected using the
+ * ctrl key.
+ */
+void setCtrlSelection(boolean isCtrlSelection) {
+ this.isCtrlSelection = isCtrlSelection;
+}
+/**
+ * The font is changing. Reset the text height to force a
+ * recalculation during itemChanged().
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setFont(font);
+ textHeight = -1;
+}
+/**
+ * Set the horizontal drawing offset to 'offset'.
+ * Scroll the receiver's contents according to the offset change.
+ * @param offset - value < 0 = widget contents is drawn left of the client area.
+ */
+void setHorizontalOffset(int offset) {
+ int offsetChange = offset - horizontalOffset;
+
+ if (offsetChange != 0) {
+ scrollHorizontal(offsetChange);
+ horizontalOffset = offset;
+ }
+}
+
+/**
+ * Set whether the drop insert position is before or after the
+ * item set using motif_setInsertMark.
+ * @param after true=insert position is after the insert item
+ * false=insert position is before the insert item
+ */
+void setInsertAfter(boolean after) {
+ isInsertAfter = after;
+}
+
+/**
+ * Set the item that draws the marker indicating the insert location
+ * in a drag and drop operation.
+ * @param item the item that draws the insert marker
+ */
+void setInsertItem(SelectableItem item) {
+ insertItem = item;
+}
+/**
+ * Set the height of the receiver's items to 'height'.
+ */
+void setItemHeight(int height) {
+ itemHeight = height;
+}
+/**
+ * Set the item that most recently received the input focus
+ * to 'focusItem'. Redraw both, the item that lost focus
+ * and the one that received focus.
+ * @param focusItem - the item that most recently received
+ * the input focus
+ * @param showItem true=new focus item, if any, should be scrolled
+ * into view. false=don't scroll
+ */
+void setLastFocus(SelectableItem focusItem, boolean showItem) {
+ SelectableItem oldFocusItem = lastFocusItem;
+
+ if (focusItem != lastFocusItem) {
+ lastFocusItem = focusItem;
+ if (oldFocusItem != null) {
+ redrawSelection(oldFocusItem);
+ }
+ if (lastFocusItem != null && isFocusControl() == true) {
+ redrawSelection(lastFocusItem);
+ }
+ }
+ if (focusItem != null && showItem == true) {
+ showSelectableItem(focusItem);
+ }
+}
+/**
+ * Set the item that was selected most recently to 'selectedItem'.
+ * Set the input focus to that item.
+ * @param selectedItem - the item that was selected most recently
+ * @param showItem true=new focus item, if any, should be scrolled
+ * into view. false=don't scroll
+ */
+void setLastSelection(SelectableItem selectedItem, boolean showItem) {
+ if (selectedItem == null) { // always store the item selected last
+ return;
+ }
+ setLastFocus(selectedItem, showItem);
+ lastSelectedItem = selectedItem;
+}
+/**
+ * Sets the redraw flag.
+ * @param redraw -
+ * true = redraw and scroll operations are performed normally
+ * false = redraw and scroll operations are ignored
+ */
+public void setRedraw (boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (redraw) {
+ if (--drawCount == 0) redraw();
+ } else {
+ drawCount++;
+ }
+}
+/**
+ * Set whether all items in the widget are disposed.
+ * Used to optimize item disposal. Prevents unnecessary screen
+ * updates.
+ * @param removingAll
+ * true=all items are removed.
+ * false=normal state, no items or not all items are removed.
+ */
+void setRemovingAll(boolean removingAll) {
+ isRemovingAll = removingAll;
+}
+/**
+ * Select the items stored in 'selectionItems'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+void setSelectableSelection(SelectableItem selectionItems[]) {
+ SelectableItem item = null;
+ int selectionCount = selectionItems.length;
+ Vector keepSelected;
+
+ if (isMultiSelect() == false && selectionCount > 1) {
+ selectionCount = 1;
+ }
+ keepSelected = new Vector(selectionItems.length);
+ for (int i = 0; i < selectionCount; i++) {
+ if (selectionItems[i] != null) {
+ keepSelected.addElement(selectionItems[i]);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ // select in the same order as all the other selection and deslection methods.
+ // Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated
+ // selections of the items, causing flash.
+ for (int i = selectionCount - 1; i >= 0; i--) {
+ item = selectionItems[i];
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, true);
+ }
+}
+/**
+ * Set the vector used to store the selected items of the receiver
+ * to 'newVector'.
+ * @param newVector - the vector used to store the selected items
+ * of the receiver
+ */
+void setSelectionVector(Vector newVector) {
+ selectedItems = newVector;
+}
+/**
+ * Scroll the item at 'index' to the top.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndex(int index, boolean adjustScrollbar) {
+ int indexDiff = index-topIndex;
+
+ if (indexDiff != 0) {
+ scrollVertical(indexDiff);
+ setTopIndexNoScroll(index, adjustScrollbar);
+ }
+}
+/**
+ * Set the index of the first visible item in the receiver's client
+ * area to 'index'.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
+ topIndex = index;
+ if (adjustScrollbar == true) {
+ getVerticalBar().setSelection(index);
+ }
+}
+/**
+ * The shift key was pressed when the mouse click on an item
+ * occurred. Do a shift selection. If an already selected item was
+ * clicked the selection is expanded/reduced to that item
+ * @param hitItem - specifies the clicked item
+ * @param hitItemIndex - specifies the index of the clicked item
+ * relative to the first item.
+ */
+void shiftSelect(SelectableItem hitItem, int hitItemIndex) {
+ int fromIndex = -1;
+ int toIndex = -1;
+ int lastSelectionIndex = -1;
+ int selectionRange[];
+ SelectableItem lastSelection = getLastSelection();
+
+ if (lastSelection != null) {
+ lastSelectionIndex = getVisibleIndex(lastSelection);
+ }
+ if (isCtrlSelection() == true) { // was last selection ctrl selection?
+ deselectAllExcept(lastSelection);
+ fromIndex = lastSelectionIndex; // select from last selection
+ toIndex = hitItemIndex;
+ }
+ else
+ if (getSelectionVector().contains(hitItem) == true) { // clicked an item already selected?
+ deselectRange(hitItemIndex, lastSelectionIndex); // reduce selection
+ }
+ else { // clicked outside existing selection range
+ selectionRange = calculateShiftSelectionRange(hitItemIndex);
+ fromIndex = selectionRange[0];
+ toIndex = selectionRange[1];
+ }
+ if (hitItemIndex == lastSelectionIndex) { // was click on last selected item?
+ return;
+ }
+ if (fromIndex == -1 || toIndex == -1) { // are there previously selected items?
+ toggleSelectionNotify(hitItem); // do a single select.
+ }
+ else {
+ if (((lastSelectionIndex < fromIndex) && (hitItemIndex > fromIndex)) || // does selection reverse direction?
+ ((lastSelectionIndex > fromIndex) && (hitItemIndex < fromIndex))) {
+ deselectAllExcept((SelectableItem) null); // remove old selection
+ }
+ selectRange(fromIndex, toIndex);
+ }
+}
+/**
+ * Make 'item' visible by scrolling it into the receiver's client
+ * area if necessary.
+ * @param item - the item that should be made visible to the user.
+ */
+void showSelectableItem(SelectableItem item) {
+ if (item.getSelectableParent() != this) {
+ return;
+ }
+ scrollShowItem(item);
+ scrollShowItem(item); // second call makes sure that the item is still visible
+ // even if the first scroll caused the horizontal scroll
+ // to be displayed and the item to be hidden again.
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selection = getSelectionVector();
+ SelectableItem selectionItem;
+
+ if (selection.size() > 0) {
+ selectionItem = (SelectableItem) selection.firstElement();
+ showSelectableItem(selectionItem);
+ }
+}
+/**
+ * Sorts the specified range in the array.
+ *
+ * @param array the SelectableItem array to be sorted
+ * @param start the start index to sort
+ * @param end the last + 1 index to sort
+ */
+void sort(SelectableItem[] array, int start, int end) {
+ int middle = (start + end) / 2;
+ if (start + 1 < middle) sort(array, start, middle);
+ if (middle + 1 < end) sort(array, middle, end);
+ if (start + 1 >= end) return; // this case can only happen when this method is called by the user
+ if (getVisibleIndex(array[middle-1]) <= getVisibleIndex(array[middle])) return;
+ if (start + 2 == end) {
+ SelectableItem temp = array[start];
+ array[start] = array[middle];
+ array[middle] = temp;
+ return;
+ }
+ int i1 = start, i2 = middle, i3 = 0;
+ SelectableItem[] merge = new SelectableItem[end - start];
+ while (i1 < middle && i2 < end) {
+ merge[i3++] = getVisibleIndex(array[i1]) <= getVisibleIndex(array[i2]) ?
+ array[i1++] : array[i2++];
+ }
+ if (i1 < middle) System.arraycopy(array, i1, merge, i3, middle - i1);
+ System.arraycopy(merge, 0, array, start, i2 - start);
+}
+/**
+ * Toggle the selection of 'item'.
+ * @param item - item that should be selected/deselected
+ */
+void toggleSelectionNotify(SelectableItem item) {
+ if (item.isSelected() == true) {
+ deselectNotify(item);
+ }
+ else {
+ selectNotify(item);
+ }
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
new file mode 100755
index 0000000000..46decb71bd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Shell.java
@@ -0,0 +1,541 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Shell extends Decorations {
+ int shellHandle;
+ Display display;
+ int modal, blockedList;
+
+public Shell () {
+ this ((Display) null);
+}
+
+public Shell (int style) {
+ this ((Display) null, style);
+}
+
+public Shell (Display display) {
+ this (display, SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE);
+}
+
+public Shell (Display display, int style) {
+ this (display, null, style, 0);
+}
+
+Shell (Display display, Shell parent, int style, int handle) {
+ super ();
+ 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.parent = parent;
+ this.display = display;
+ this.handle = handle;
+ createWidget (0);
+}
+
+public Shell (Shell parent) {
+ this (parent, SWT.TITLE | SWT.CLOSE | SWT.BORDER);
+}
+
+public Shell (Shell parent, int style) {
+ this (parent != null ? parent.getDisplay () : null, parent, style, 0);
+}
+
+public static Shell photon_new (Display display, int handle) {
+ return new Shell (display, null, SWT.NO_TRIM, handle);
+}
+
+public void addShellListener (ShellListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 bringToTop () {
+ OS.PtWidgetToFront (shellHandle);
+}
+
+void closeWidget () {
+ Event event = new Event ();
+ event.time = (int) System.currentTimeMillis ();
+ sendEvent (SWT.Close, event);
+ if (event.doit && !isDisposed ()) dispose ();
+}
+
+public void close () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ closeWidget ();
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int flags = args [1];
+ int [] left = new int [1], top = new int [1];
+ int [] right = new int [1], bottom = new int [1];
+ OS.PtFrameSize (flags, 0, left, top, right, bottom);
+ int trimX = x - left [0];
+ int trimY = y - top [0];
+ int trimWidth = width + left [0] + right [0];
+ int trimHeight = height + top [0] + bottom [0];
+ if (menuBar != null) {
+ args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (menuBar.handle, args.length / 3, args);
+ trimHeight += args [1];
+ trimY -= args [1];
+ }
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+void createHandle (int index) {
+ if (handle != 0) {
+ int clazz = display.PtContainer;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_GETS_FOCUS, OS.Pt_GETS_FOCUS,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ shellHandle = OS.PtCreateWidget (clazz, handle, args.length / 3, args);
+ if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ } else {
+ int parentHandle = 0;
+ if (parent != null) parentHandle = parent.topHandle ();
+ PhRect_t rect = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, rect);
+ int width = (short) ((rect.lr_x - rect.ul_x + 1) * 5 / 8);
+ int height = (short) ((rect.lr_y - rect.ul_y + 1) * 5 / 8);
+ int decorations = 0;
+ int flags =
+ OS.Ph_WM_RENDER_MIN | OS.Ph_WM_RENDER_MAX | OS.Ph_WM_RENDER_RESIZE |
+ OS.Ph_WM_RENDER_BORDER | OS.Ph_WM_RENDER_MENU | OS.Ph_WM_RENDER_MIN |
+ OS.Ph_WM_RENDER_TITLE;
+ if ((style & SWT.NO_TRIM) == 0) {
+ if ((style & SWT.MIN) != 0) decorations |= OS.Ph_WM_RENDER_MIN;
+ if ((style & SWT.MAX) != 0) decorations |= OS.Ph_WM_RENDER_MAX;
+ if ((style & SWT.RESIZE) != 0) {
+ decorations |= OS.Ph_WM_RENDER_BORDER | OS.Ph_WM_RENDER_RESIZE;
+ }
+ if ((style & SWT.BORDER) != 0) decorations |= OS.Ph_WM_RENDER_BORDER;
+ if ((style & SWT.MENU) != 0) decorations |= OS.Ph_WM_RENDER_MENU;
+ if ((style & SWT.TITLE) != 0) decorations |= OS.Ph_WM_RENDER_TITLE;
+ }
+ int titlePtr = OS.malloc (1);
+ int [] args = {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_HEIGHT, height, 0,
+ OS.Pt_ARG_WINDOW_TITLE, titlePtr, 0,
+ OS.Pt_ARG_WINDOW_RENDER_FLAGS, decorations, flags,
+ OS.Pt_ARG_WINDOW_MANAGED_FLAGS, 0, OS.Ph_WM_CLOSE,
+ OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_ICON, OS.Ph_WM_ICON,
+ OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_FOCUS, OS.Ph_WM_FOCUS,
+ OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_MOVE, OS.Ph_WM_MOVE,
+ OS.Pt_ARG_WINDOW_NOTIFY_FLAGS, OS.Ph_WM_RESIZE, OS.Ph_WM_RESIZE,
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ OS.PtSetParentWidget (parentHandle);
+ shellHandle = OS.PtCreateWidget (OS.PtWindow (), parentHandle, args.length / 3, args);
+ OS.free (titlePtr);
+ if (shellHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ createScrolledHandle (shellHandle);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ resizeBounds (args [1], args [4]);
+}
+
+void deregister () {
+ super.deregister ();
+ WidgetTable.remove (shellHandle);
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_WINDOW, windowProc, SWT.Move);
+ OS.PtAddCallback (shellHandle, OS.Pt_CB_RESIZE, windowProc, -1);
+}
+
+public void open () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ bringToTop ();
+ setVisible (true);
+}
+
+int processMove (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ PhWindowEvent_t we = new PhWindowEvent_t ();
+ OS.memmove (we, cbinfo.cbdata, PhWindowEvent_t.sizeof);
+ switch (we.event_f) {
+ case OS.Ph_WM_CLOSE:
+ closeWidget ();
+ break;
+ case OS.Ph_WM_ICON:
+ if ((we.state_f & OS.Ph_WM_STATE_ISICONIFIED) != 0) {
+ sendEvent (SWT.Iconify);
+ } else {
+ sendEvent (SWT.Deiconify);
+ }
+ break;
+ case OS.Ph_WM_FOCUS:
+ switch (we.event_state) {
+ case OS.Ph_WM_EVSTATE_FOCUS: sendEvent (SWT.Activate); break;
+ case OS.Ph_WM_EVSTATE_FOCUSLOST: sendEvent (SWT.Deactivate); break;
+ }
+ break;
+ case OS.Ph_WM_MOVE:
+ sendEvent (SWT.Move);
+ break;
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int processShellResize (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ resizeBounds (args [1], args [4]);
+ return OS.Pt_CONTINUE;
+}
+
+void register () {
+ super.register ();
+ WidgetTable.put (shellHandle, this);
+}
+
+public Display getDisplay () {
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+
+public int getImeInputMode () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 0;
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled ();
+}
+
+public Point getLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - shell location is 0,0 when queried before event loop
+ return super.getLocation ();
+}
+
+public boolean getMaximized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //ONLY WORKS WHEN SET in setMaximized
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISMAX};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISMAX) != 0;
+}
+
+public boolean getMinimized () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //ONLY WORKS WHEN SET in setMinimized
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, 0, OS.Ph_WM_STATE_ISHIDDEN};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ return (args [1] & OS.Ph_WM_STATE_ISHIDDEN) != 0;
+}
+
+public Shell getShell () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return this;
+}
+
+public Shell [] getShells () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = 0;
+ Shell [] shells = display.getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Control shell = shells [i];
+ do {
+ shell = shell.parent;
+ } 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.parent;
+ } while (shell != null && shell != this);
+ if (shell == this) {
+ result [index++] = shells [i];
+ }
+ }
+ return result;
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0,
+ OS.Pt_ARG_WIDTH, 0, 0,
+ OS.Pt_ARG_HEIGHT, 0, 0,
+ };
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int flags = args [1];
+ int [] left = new int [1], top = new int [1];
+ int [] right = new int [1], bottom = new int [1];
+ OS.PtFrameSize (flags, 0, left, top, right, bottom);
+ int width = args [4] + left [0] + right [0];
+ int height = args [7] + top [0] + bottom [0];
+ return new Point (width, height);
+}
+
+void releaseHandle () {
+ super.releaseHandle ();
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = shellHandle = 0;
+}
+
+void realizeWidget() {
+ /* Do nothing */
+}
+
+public void removeShellListener (ShellListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+}
+
+void setBounds (int x, int y, int width, int height, boolean move, boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (OS.PtWidgetClass (shellHandle) != OS.PtWindow ()) {
+ super.setBounds (x, y, width, height, move, resize);
+ if (resize) resizeBounds (width, height);
+ return;
+ }
+ int [] args = {OS.Pt_ARG_WINDOW_RENDER_FLAGS, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int flags = args [1];
+ int [] left = new int [1], top = new int [1];
+ int [] right = new int [1], bottom = new int [1];
+ OS.PtFrameSize (flags, 0, left, top, right, bottom);
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (shellHandle, area);
+ int frameWidth = area.size_w + left [0] + right [0];
+ int frameHeight = area.size_h + top [0] + bottom [0];
+ if (!move) {
+ x = area.pos_x;
+ y = area.pos_y;
+ }
+ if (!resize) {
+ width = frameWidth;
+ height = frameHeight;
+ }
+ boolean sameOrigin = x == area.pos_x && y == area.pos_y;
+ boolean sameExtent = width == frameWidth && height == frameHeight;
+ area.pos_x = (short) x;
+ area.pos_y = (short) y;
+ area.size_w = (short) (Math.max (width - left [0] - right [0], 0));
+ area.size_h = (short) (Math.max (height - top [0] - bottom [0], 0));
+//TO DO - for some reason shell will move but won't resize after realize
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ args = new int [] {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ OS.free (ptr);
+ /*
+ * Feature in Photon. The shell does not issue WM_SIZE
+ * event notificatoin until it is realized. The fix is
+ * to detect size changes and send the events.
+ */
+ if (!OS.PtWidgetIsRealized (shellHandle)) {
+ if (!sameOrigin & move) sendEvent (SWT.Move);
+ if (!sameExtent & resize) {
+ resizeBounds (width, height);
+ sendEvent (SWT.Resize);
+ }
+ }
+}
+
+public void setImage (Image image) {
+}
+
+public void setImeInputMode (int mode) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+public void setMaximized (boolean maximized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ // RESTORE DOESN'T WORK
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.event_f = maximized ? OS.Ph_WM_MAX : OS.Ph_WM_RESTORE;
+ event.event_state = (short) (maximized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
+ event.rid = OS.PtWidgetRid (shellHandle);
+ OS.PtForwardWindowEvent (event);
+ } else {
+ int bits = 0;
+ if (maximized) bits = OS.Ph_WM_STATE_ISMAX;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISMAX};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ }
+}
+
+public void setMenuBar (Menu menu) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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);
+ }
+ if (menuBar != null) {
+ int menuHandle = menuBar.handle;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_DELAY_REALIZE, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ OS.PtUnrealizeWidget (menuBar.handle);
+ }
+ menuBar = menu;
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (shellHandle, args.length / 3, args);
+ int width = args [1], height = args [4];
+ PhArea_t area = new PhArea_t ();
+ if (menuBar != null) {
+ int menuHandle = menu.handle;
+ args = new int [] {
+ OS.Pt_ARG_WIDTH, width, 0,
+ OS.Pt_ARG_FLAGS, 0, OS.Pt_DELAY_REALIZE,
+ };
+ OS.PtSetResources (menuHandle, args.length / 3, args);
+ args = new int [] {OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (menuHandle, args.length / 3, args);
+ area.pos_y = (short) args [1];
+ area.size_w = (short) width;
+ area.size_h = (short) Math.max (0, (height - args [1]));
+ OS.PtRealizeWidget (menuBar.handle);
+ } else {
+ area.size_w = (short) width;
+ area.size_h = (short) height;
+ }
+ int ptr = OS.malloc (PhArea_t.sizeof);
+ OS.memmove (ptr, area, PhArea_t.sizeof);
+ args = new int [] {OS.Pt_ARG_AREA, ptr, 0};
+ OS.PtSetResources (scrolledHandle, args.length / 3, args);
+ OS.free (ptr);
+ resizeClientArea();
+}
+
+public void setMinimized (boolean minimized) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (OS.PtWidgetIsRealized (shellHandle)) {
+ // RESTORE DOESN'T WORK
+ PhWindowEvent_t event = new PhWindowEvent_t ();
+ event.event_f = minimized ? OS.Ph_WM_HIDE : OS.Ph_WM_RESTORE;
+ event.event_state = (short) (minimized ? OS.Ph_WM_EVSTATE_HIDE : OS.Ph_WM_EVSTATE_UNHIDE);
+ event.rid = OS.PtWidgetRid (shellHandle);
+ OS.PtForwardWindowEvent (event);
+ } else {
+ int bits = 0;
+ if (minimized) bits = OS.Ph_WM_STATE_ISHIDDEN;
+ int [] args = {OS.Pt_ARG_WINDOW_STATE, bits, OS.Ph_WM_STATE_ISHIDDEN};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ }
+}
+
+public void setModal (int modal) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ switch (modal) {
+ case SWT.MODELESS:
+ case SWT.PRIMARY_MODAL:
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
+ this.modal = modal;
+ break;
+ }
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ text = string;
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_WINDOW_TITLE, ptr, 0};
+ OS.PtSetResources (shellHandle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setVisible (boolean visible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (visible == OS.PtWidgetIsRealized (shellHandle)) return;
+ switch (modal) {
+ case SWT.PRIMARY_MODAL:
+ //NOT DONE: should not disable all windows
+ case SWT.APPLICATION_MODAL:
+ case SWT.SYSTEM_MODAL:
+ if (visible) {
+ blockedList = OS.PtBlockAllWindows (shellHandle, (short) 0, 0);
+ } else {
+ if (blockedList != 0) OS.PtUnblockWindows (blockedList);
+ blockedList = 0;
+ }
+ }
+ super.setVisible (visible);
+ OS.PtSyncWidget (shellHandle);
+ OS.PtFlush ();
+}
+
+int topHandle () {
+ return shellHandle;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
new file mode 100755
index 0000000000..b21f1b5831
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Slider.java
@@ -0,0 +1,236 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Slider extends Control {
+
+public Slider (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ //NOT DONE - hard coding value to be the same as list's scrollbars
+ int width = 17, height = 100;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width = 100; height = 17;
+ }
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) width = area.size_w;
+ if (hHint != SWT.DEFAULT) height = area.size_h;
+ }
+ return new Point (width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtScrollbar;
+ int parentHandle = parent.handle;
+ int [] args = {
+ OS.Pt_ARG_MAXIMUM, 100, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, 10, 0,
+ OS.Pt_ARG_SLIDER_SIZE, 10, 0,
+ OS.Pt_ARG_ORIENTATION, (style & SWT.HORIZONTAL) != 0 ? OS.Pt_HORIZONTAL : OS.Pt_VERTICAL, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+public int getIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMinimum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getMaximum () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getPageIncrement () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public Point getSize () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0, OS.Pt_ARG_HEIGHT, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return new Point (args [1], args [4]);
+}
+
+public int getThumb () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+void hookEvents () {
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_SCROLL_MOVE, windowProc, SWT.Selection);
+}
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtScrollbar (), handle, damage);
+ return super.processPaint (damage);
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ if (cbinfo.cbdata == 0) return OS.Pt_CONTINUE;
+ PtScrollbarCallback_t cb = new PtScrollbarCallback_t ();
+ OS.memmove (cb, cbinfo.cbdata, PtScrollbarCallback_t.sizeof);
+ Event event = new Event ();
+ switch (cb.action) {
+ case OS.Pt_SCROLL_DRAGGED:
+ event.detail = SWT.DRAG;
+ break;
+ case OS.Pt_SCROLL_TO_MIN:
+ event.detail = SWT.HOME;
+ break;
+ case OS.Pt_SCROLL_TO_MAX:
+ event.detail = SWT.END;
+ break;
+ case OS.Pt_SCROLL_INCREMENT:
+ event.detail = SWT.ARROW_DOWN;
+ break;
+ case OS.Pt_SCROLL_DECREMENT :
+ event.detail = SWT.ARROW_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_DECREMENT:
+ event.detail = SWT.PAGE_UP;
+ break;
+ case OS.Pt_SCROLL_PAGE_INCREMENT:
+ event.detail = SWT.PAGE_DOWN;
+ break;
+ }
+ sendEvent(SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MAXIMUM, value - 1, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_MINIMUM, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setPageIncrement (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PAGE_INCREMENT, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SCROLL_POSITION, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_SLIDER_SIZE, value, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setValues (int selection, int minimum, int maximum, int thumb, int increment, int pageIncrement) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ int [] args = {
+ OS.Pt_ARG_SCROLL_POSITION, selection, 0,
+ OS.Pt_ARG_INCREMENT, increment, 0,
+ OS.Pt_ARG_PAGE_INCREMENT, pageIncrement, 0,
+ OS.Pt_ARG_SLIDER_SIZE, thumb, 0,
+ OS.Pt_ARG_MINIMUM, minimum, 0,
+ OS.Pt_ARG_MAXIMUM, maximum - 1, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
new file mode 100755
index 0000000000..d69f35ad78
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabFolder.java
@@ -0,0 +1,360 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+
+public /*final*/ class TabFolder extends Composite {
+ TabItem [] items;
+
+public TabFolder (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+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);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w, height = dim.h;
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ 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;
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = trim.width; height = trim.height;
+ return new Point (width, height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int [] args = {
+ OS.Pt_ARG_MARGIN_BOTTOM, 0, 0, // 1
+ OS.Pt_ARG_MARGIN_TOP, 0, 0, // 4
+ OS.Pt_ARG_MARGIN_RIGHT, 0, 0, // 7
+ OS.Pt_ARG_MARGIN_LEFT, 0, 0, // 10
+// OS.Pt_ARG_BASIC_FLAGS, 0, 0, // 13
+ };
+ OS.PtGetResources(handle, args.length / 3, args);
+ int trimX = x - args [10];
+ int trimY = y - (dim.h - args [1]);
+ int trimWidth = width + args [7] + args [10];
+ int trimHeight = height + dim.h;
+ return new Rectangle (trimX, trimY, trimWidth, trimHeight);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int clazz = display.PtPanelGroup;
+ int parentHandle = parent.handle;
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ items = new TabItem [4];
+}
+
+void createItem (TabItem item, int index) {
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ if (count == items.length) {
+ TabItem [] newItems = new TabItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count + 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int offset = 0;
+ for (int i=0; i<count; i++) {
+ if (i == index) offset = 1;
+ int [] address = new int [1];
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ int length = OS.strlen (address [0]);
+ int str = OS.malloc (length + 1);
+ if (str == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (str, address [0], length + 1);
+ OS.memmove (newPtr + ((i + offset) * 4), new int [] {str}, 4);
+ }
+ int str = OS.malloc (1);
+ if (str == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (newPtr + ((index) * 4), new int [] {str}, 4);
+ args = new int [] {OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count + 1};
+ OS.PtSetResources (handle, args.length / 3, args);
+ for (int i=0; i<count+1; i++) {
+ int [] address = new int [1];
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+ System.arraycopy (items, index, items, index + 1, count - index);
+ items [index] = item;
+}
+
+void destroyItem (TabItem item) {
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
+ }
+ int oldPtr = args [1];
+ int newPtr = OS.malloc ((count - 1) * 4);
+ if (newPtr == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ int offset = 0;
+ for (int i=0; i<count; i++) {
+ if (i == index) {
+ offset = -1;
+ continue;
+ }
+ int [] address = new int [1];
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ int length = OS.strlen (address [0]);
+ int str = OS.malloc (length + 1);
+ if (str == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ OS.memmove (str, address [0], length + 1);
+ OS.memmove (newPtr + ((i + offset) * 4), new int [] {str}, 4);
+ }
+ args = new int [] {OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count - 1};
+ OS.PtSetResources (handle, args.length / 3, args);
+ for (int i=0; i<count-1; i++) {
+ int [] address = new int [1];
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+ if (index != count) {
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ }
+ items [count] = null;
+}
+
+public TabItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (!(0 <= index && index < args [2])) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
+public TabItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ TabItem [] result = new TabItem [args [2]];
+ System.arraycopy (items, 0, result, 0, result.length);
+ return result;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [2];
+}
+
+public TabItem [] getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = getSelectionIndex ();
+ if (index == -1) return new TabItem [0];
+ return new TabItem [] {items [index]};
+}
+
+public int getSelectionIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1] == OS.Pt_PG_INVALID ? -1 : args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_PG_PANEL_SWITCHING, windowProc, SWT.Selection);
+}
+
+public int indexOf (TabItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = getItemCount ();
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+int processPaint (int damage) {
+ OS.PtSuperClassDraw (OS.PtPanelGroup (), handle, damage);
+ sendPaintEvent (damage);
+ return OS.Pt_CONTINUE;
+}
+
+int processResize (int info) {
+ int result = super.processResize (info);
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int index = args [1];
+ if (index != OS.Pt_PG_INVALID) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ return result;
+}
+
+int processSelection (int info) {
+ if (info == 0) return OS.Pt_CONTINUE;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ short[] oldIndex = new short[1];
+ short[] newIndex = new short[1];
+ OS.memmove(oldIndex, cbinfo.cbdata + 8, 2);
+ OS.memmove(newIndex, cbinfo.cbdata + 10, 2);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ Control oldControl = null;
+ int index = oldIndex [0];
+ TabItem oldItem = items [index];
+ if (0 <= index && index < count) oldControl = oldItem.control;
+ Control newControl = null;
+ index = newIndex [0];
+ TabItem newItem = items [index];
+ if (0 <= index && index < count) newControl = newItem.control;
+ if (oldControl != null) oldControl.setVisible (false);
+ if (newControl != null) {
+ newControl.setBounds (getClientArea ());
+ newControl.setVisible (true);
+ }
+ Event event = new Event ();
+ event.item = newItem;
+ postEvent (SWT.Selection, event);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseWidget () {
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int count = args [2];
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setSelection (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int oldIndex = args [1];
+ if (oldIndex != OS.Pt_PG_INVALID) {
+ TabItem item = items [oldIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ args = new int[]{OS.Pt_ARG_PG_CURRENT_INDEX, index, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ args = new int[]{OS.Pt_ARG_PG_CURRENT_INDEX, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ int newIndex = args [1];
+ if (newIndex != -1) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ }
+}
+
+public void setSelection (TabItem [] items) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (items.length == 0) {
+ setSelection (-1);
+ return;
+ }
+ for (int i=items.length-1; i>=0; --i) {
+ int index = indexOf (items [i]);
+ if (index != -1) setSelection (index);
+ }
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
new file mode 100755
index 0000000000..e41dde1451
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TabItem.java
@@ -0,0 +1,135 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class TabItem extends Item {
+ TabFolder parent;
+ Control control;
+ String toolTipText;
+
+public TabItem (TabFolder parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+
+public Display getDisplay () {
+ TabFolder parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public TabFolder getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+
+public boolean isDisposed () {
+ //NOT DONE - should have a handle or state flag
+ return parent == null;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ control = null;
+ parent = null;
+}
+
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && 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 ()) return;
+ if (newControl != null) {
+ newControl.setBounds (parent.getClientArea ());
+ newControl.setVisible (true);
+ }
+ if (oldControl != null) oldControl.setVisible (false);
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT SUPPORTED
+}
+
+public void setText (String text) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ super.setText (text);
+ int index = parent.indexOf (this);
+ int [] args = {OS.Pt_ARG_PG_PANEL_TITLES, 0, 0};
+ OS.PtGetResources (parent.handle, args.length / 3, args);
+ int count = args [2];
+ int oldPtr = args [1];
+ int newPtr = OS.malloc (count * 4);
+ for (int i=0; i<count; i++) {
+ int str;
+ if (i == index) {
+ byte [] buffer = Converter.wcsToMbcs (null, text);
+ str = OS.malloc (buffer.length + 1);
+ OS.memmove (str, buffer, buffer.length);
+ } else {
+ int [] address = new int [1];
+ OS.memmove (address, oldPtr + (i * 4), 4);
+ int length = OS.strlen (address [0]);
+ str = OS.malloc (length + 1);
+ OS.memmove (str, address [0], length + 1);
+ }
+ OS.memmove (newPtr + (i * 4), new int [] {str}, 4);
+ }
+ args = new int [] {OS.Pt_ARG_PG_PANEL_TITLES, newPtr, count};
+ OS.PtSetResources (parent.handle, args.length / 3, args);
+ for (int i=0; i<count; i++) {
+ int [] address = new int [1];
+ OS.memmove (address, newPtr + (i * 4), 4);
+ OS.free (address [0]);
+ }
+ OS.free (newPtr);
+}
+
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java
new file mode 100755
index 0000000000..c0897e483c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Table.java
@@ -0,0 +1,2361 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class display rows of items arranged in one or more
+ * columns. Items can be selected, columns can be resized.
+ */
+public /*final*/ class Table extends SelectableItemWidget {
+ private static final int COLUMN_RESIZE_OFFSET = 7; // offset from the start and end of each
+ // column at which the resize cursor is displayed
+ // if the mouse is in the column header
+ static final String DOT_STRING = "..."; // used to indicate truncated item labels
+
+ private Header tableHeader;
+ private Control focusProxy; // used as a proxy to take focus in place of the table.
+ // The latter can't get focus because it has a child
+ // (the header widget). The header widget can't be used
+ // as a focus widget because it may be hidden.
+ private Vector items;
+ private Vector columns;
+ private boolean drawGridLines = false;
+ private boolean hasColumnFocus = false; // true if a column currently has focus
+ private boolean firstColumnImage = false; // true if any item in the first column has an image
+ private int columnResizeX; // last position of the cursor in a column resize operation
+ private Cursor columnResizeCursor; // cursor displayed when a column resize is in progress.
+ // Need to keep reference to the cursor in order to dispose it.
+ private boolean isColumnResizeCursor = false; // set to true if the column resize cursor is active
+ private TableColumn resizeColumn; // column that is currently being resized
+ private TableColumn fillColumn; // column used to fill up space that is not used
+ // by user defined columns
+ private TableColumn defaultColumn; // Default column that is created as soon as the table is created.
+ // Fix for 1FUSJY5
+ private int dotsWidth = -1; // width of the static String dots (see above)
+/**
+ * Create a new instance of Table.
+ * @param parent - the parent window of the new instance
+ * @param style - window style for the new instance
+ */
+public Table(Composite parent, int style) {
+ // use NO_MERGE_PAINTS to avoid flashing during column and widget resize redraw
+ super(parent, checkStyle(style| SWT.NO_MERGE_PAINTS));
+}
+/**
+ * Add 'column' to the receiver.
+ * @param column - new table column that should be added to
+ * the receiver
+ */
+void addColumn(TableColumn column) {
+ int index = column.getIndex();
+
+ getColumnVector().insertElementAt(column, index);
+ // has the column been inserted (vs. appended)?
+ if (index < getColumnCount() - 1) {
+ reindexColumns(index + 1);
+ }
+ // is there more than one user created column?
+ // There always is the data and visual of the default column
+ // so we don't need to create those for the first user column
+ if (getColumnCount() > 1) {
+ insertColumnData(column);
+ }
+ else { // first user created column
+ setContentWidth(0); // pretend it's ground zero for column resizings
+ redraw(); // redraw the table and header. The default column
+ getHeader().redraw(); // won't be drawn anymore, because there now is a user created table.
+ }
+ insertColumnVisual(column);
+}
+/**
+ * Add 'item' to the receiver.
+ * @param item - new table item that should be added to
+ * the receiver
+ * @param index - position the new item should be inserted at
+ */
+void addItem(TableItem item, int index) {
+ Vector items = getItemVector();
+
+ if (index < 0 || index > getItemCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ addingItem(item, index);
+ item.setIndex(index);
+ if (index < items.size()) {
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() + 1);
+ }
+ items.insertElementAt(item, index);
+ }
+ else {
+ items.addElement(item);
+ }
+ addedItem(item, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*/
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ 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);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * The width of 'column' is about to change.
+ * Adjust the position of all columns behind it.
+ */
+void columnChange(TableColumn column, Rectangle newBounds) {
+ Rectangle columnBounds = column.getBounds();
+ Rectangle clientArea = getClientArea();
+ int oldXPosition = columnBounds.x + columnBounds.width;
+ int newXPosition = newBounds.x + newBounds.width;
+ int widthChange = newBounds.width - columnBounds.width;
+ int headerHeight = getHeaderHeight();
+ int columnIndex = column.getIndex();
+
+ if (widthChange != 0) {
+ if (columnIndex != TableColumn.FILL) {
+ if (getLinesVisible() == true) {
+ oldXPosition -= getGridLineWidth(); // include vertical grid line when scrolling resized column.
+ newXPosition -= getGridLineWidth();
+ }
+ scroll( // physically move all following columns
+ newXPosition, headerHeight, // destination x, y
+ oldXPosition, headerHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+ }
+ column.internalSetBounds(newBounds);
+ if (columnIndex != TableColumn.FILL) {
+ resetTableItems(columnIndex);
+ moveColumns(columnIndex + 1, widthChange); // logically move all following columns (set their bounds)
+ setContentWidth(getContentWidth() + widthChange); // set the width of the receiver's content
+ claimRightFreeSpace();
+ resizeRedraw(column, columnBounds.width, newBounds.width);
+ }
+ }
+ getHeader().widthChange(columnIndex, widthChange);
+}
+/**
+ * The mouse pointer was double clicked on the receiver.
+ * Handle the event according to the position of the mouse click
+ * and the modifier key that was pressed, if any.
+ * @param event - the mouse event
+ */
+void columnMouseDoubleClick(Event event) {
+ int itemHeight = getItemHeight();
+ int itemIndex;
+ TableItem hitItem;
+ TableColumn hitColumn = getColumnAtX(event.x);
+ Event columnDblClickEvent;
+
+ if (isFocusControl() == false) {
+ setFocus(); // focus proxy gets focus here because it's the first child of the receiver
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null &&
+ hitColumn.getIndex() == TableColumn.FIRST) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ columnDblClickEvent = new Event();
+ columnDblClickEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, columnDblClickEvent);
+ }
+ }
+ else {
+ deselectAll();
+ }
+ }
+}
+/**
+ * The mouse pointer was pressed down on the receiver.
+ * Handle the event according to the position of the mouse click
+ * and the modifier key that was pressed, if any.
+ * @param event - the mouse event
+ */
+void columnMouseDown(Event event) {
+ int itemHeight = getItemHeight();
+ int itemIndex;
+ TableItem hitItem;
+ TableColumn hitColumn = getColumnAtX(event.x);
+
+ if (isFocusControl() == false) {
+ setFocus(); // focus proxy gets focus here because it's the first child of the receiver
+ }
+ if (hitColumn != null) {
+ itemIndex = (event.y - getHeaderHeight()) / itemHeight + getTopIndex();
+ hitItem = (TableItem) getVisibleItem(itemIndex);
+ if (hitItem != null) {
+ if (hitItem.isSelectionHit(event.x) == true) {
+ doMouseSelect(hitItem, itemIndex, event.stateMask, event.button);
+ }
+ else
+ if (hitItem.isCheckHit(new Point(event.x, event.y)) == true) {
+ doCheckItem(hitItem);
+ }
+ }
+ else {
+ deselectAll();
+ }
+ }
+}
+/**
+ * The mouse pointer was moved over the receiver.
+ * Reset the column resize cursor if it was active.
+ * @param event - the mouse event
+ */
+void columnMouseMove(Event event) {
+ if (isColumnResizeStarted() == false) {
+ setColumnResizeCursor(false);
+ }
+}
+/**
+ * Answer the size of the receiver needed to display all or
+ * the first 50 items whichever is less.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size = super.computeSize(wHint, hHint, changed);
+ Point headerSize;
+ GC gc;
+ final int WidthCalculationCount = Math.min(getItemCount(), 50); // calculate item width for the first couple of items only
+ TableItem item;
+ Image itemImage;
+ String itemText;
+ int width;
+ int newItemWidth = 0;
+
+ if (getHeaderVisible() == true) {
+ headerSize = getHeader().computeSize(SWT.DEFAULT, SWT.DEFAULT, false);
+ size.y += headerSize.y;
+ }
+ if (getContentWidth() == 0 && WidthCalculationCount > 0) {
+ gc = new GC(this);
+ for (int i = 0; i < WidthCalculationCount; i++) {
+ item = getItem(i);
+ if (item == null) {
+ break; // no more items
+ }
+ itemImage = item.getImage();
+ itemText = item.getText();
+ width = 0;
+ if (itemImage != null) {
+ width += itemImage.getBounds().width;
+ }
+ if (itemText != null) {
+ width += gc.stringExtent(itemText).x;
+ }
+ newItemWidth = Math.max(newItemWidth, width);
+ }
+ if (newItemWidth > 0) {
+ size.x = newItemWidth;
+ }
+ gc.dispose();
+ }
+ return size;
+}
+/**
+ * Deselect the items identified by the indices stored
+ * in 'indices'.
+ * A SWT.Selection event will not be sent.
+ * @param indices - indices of the items to deselect
+ */
+public void deselect(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ for (int i = 0; i < indices.length; i++) {
+ item = getVisibleItem(indices[i]);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect the item identified by 'index'.
+ * A SWT.Selection event will not be sent.
+ * @param index - index of the item to deselect
+ */
+public void deselect(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ deselect(item);
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect a range of items starting at index 'start'
+ * and stopping at index 'end'. Indices that are out of
+ * range are ignored. Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void deselect(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+
+ for (int i=start; i<=end; i++) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ deselect(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Deselect all items of the receiver.
+ */
+public void deselectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ deselectAllExcept((SelectableItem) null);
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ Vector items = getItemVector();
+
+ super.doDispose();
+ while (items.size() > 0) { // TableItem objects are removed from vector during dispose()
+ ((TableItem) items.lastElement()).dispose();
+ }
+ items = getColumnVector();
+ while (items.size() > 0) { // TableColumn objects are removed from vector during dispose()
+ ((TableColumn) items.lastElement()).dispose();
+ }
+ resizeColumn = null;
+ fillColumn = null;
+ defaultColumn = null;
+ if (columnResizeCursor != null) {
+ columnResizeCursor.dispose();
+ }
+}
+/**
+ * Draw a line tracking the current position of a column
+ * resize operation.
+ * @param xPosition - x coordinate to draw the line at
+ */
+void drawColumnResizeLine(int xPosition) {
+ GC gc = new GC(this);
+ int lineHeight = getClientArea().height;
+
+ redraw(getColumnResizeX(), 0, 1, lineHeight, false);
+ setColumnResizeX(xPosition);
+ gc.drawLine(xPosition, 0, xPosition, lineHeight);
+ gc.dispose();
+}
+/**
+ * Draw the grid lines for the receiver.
+ * @param event - Paint event triggering the drawing operation.
+ * @param drawColumns - The table columns for which the grid
+ * lines should be drawn.
+ */
+void drawGridLines(Event event, Enumeration drawColumns) {
+ GC gc = event.gc;
+ Color oldForeground = getForeground();
+ Rectangle columnBounds;
+ TableColumn column;
+ int lineWidth = getGridLineWidth();
+ int itemHeight = getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int lineXPosition;
+ int lineYPosition = headerHeight + ((event.y-headerHeight) / itemHeight) * itemHeight;
+ int lineYStopPosition = event.y + event.height;
+
+ gc.setForeground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW));
+ // Draw the horizontal lines
+ if (itemHeight > 0) {
+ while (lineYPosition < lineYStopPosition) {
+ gc.drawLine(
+ event.x, lineYPosition + itemHeight - lineWidth,
+ event.x + event.width, lineYPosition + itemHeight - lineWidth);
+ lineYPosition += itemHeight;
+ }
+ }
+ // Draw the vertical lines at the right border of each column except the fill column
+ while (drawColumns.hasMoreElements() == true) {
+ column = (TableColumn) drawColumns.nextElement();
+ if (column.getIndex() != TableColumn.FILL) {
+ columnBounds = column.getBounds();
+ lineXPosition = columnBounds.x + columnBounds.width - lineWidth;
+ gc.drawLine(
+ lineXPosition, event.y,
+ lineXPosition, event.y + event.height);
+ }
+ }
+ gc.setForeground(oldForeground);
+}
+/**
+ * Draw a filled rectangle indicating the selection state of 'item'
+ * If 'item' is selected the rectangle will be filled with the
+ * selection background color. Otherwise the rectangle will be filled
+ * with the background color to remove selection.
+ * The selection color depends on whether the table widget has
+ * focus or not. See getSelectionBackgroundColor() for details.
+ * The rectangle is drawn in either the first column or in all columns
+ * for full row select.
+ * @param item - item for which the selection state should be drawn
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @param extent - extent of the selection rectangle.
+ */
+void drawSelection(TableItem item, GC gc, Point position, Point extent) {
+ if (item.isSelected() == true) {
+ gc.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
+ }
+ gc.fillRectangle(position.x, position.y, extent.x, extent.y);
+ if (item.isSelected() == true) {
+ gc.setBackground(getBackground());
+ }
+}
+/**
+ * If the receiver has input focus draw a rectangle enclosing
+ * the label of 'item' to indicate the input focus.
+ * The rectangle is drawn in either the first column or in all columns
+ * for full row select.
+ * @param item - item for which the selection state should be drawn
+ * @param gc - GC to draw on.
+ */
+void drawSelectionFocus(TableItem item, GC gc) {
+ Point extent = item.getSelectionExtent();
+ Point position = new Point(
+ item.getImageStopX(TableColumn.FIRST) + getHorizontalOffset(),
+ getRedrawY(item));
+
+ gc.drawFocus(position.x, position.y, extent.x, extent.y);
+}
+
+/** Not used right now. Replace focusIn/focusOut with this method once
+ * Display.getFocusWindow returns the new focus window on FocusOut event
+ * The focus has moved in to or out of the receiver.
+ * Redraw the item selection to reflect the focus change.
+ * @param event - the focus change event
+ */
+void focusChange(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+ Control focusWindow = getDisplay().getFocusControl();
+
+ if (focusWindow == getFocusWindow() &&
+ focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = true;
+ }
+ else {
+ hasColumnFocus = false;
+ }
+ super.focusChange(event);
+ event.widget = this; // the ficus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * @param event - the focus change event
+ */
+void focusIn(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+
+ if (focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = true;
+ }
+ super.focusIn(event);
+ event.widget = this; // the focus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * The focus has moved in to or out of the receiver.
+ * @param event - the focus change event
+ */
+void focusOut(Event event) {
+ TableColumn focusColumn = getColumnAtX(event.x);
+
+ if (focusColumn != null &&
+ focusColumn.getIndex() == TableColumn.FIRST) {
+ hasColumnFocus = false;
+ }
+ super.focusOut(event);
+ event.widget = this; // the focus event is never sent to the table itself but only to the focus widget
+ notifyListeners(event.type, event); // make sure that listeners of the table get the focus event, too
+}
+/**
+ * Answer the TableColumn at 'index'.
+ */
+public TableColumn getColumn(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+
+ if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);
+ if (index < 0 || index >= columns.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ return (TableColumn) columns.elementAt(index);
+}
+/**
+ * Return the column located at 'xPosition' in the widget.
+ * Return null if xPosition is outside the widget.
+ * @param xPosition - position of the desired column
+ */
+TableColumn getColumnAtX(int xPosition) {
+ Enumeration columns = internalGetColumnVector().elements();
+ TableColumn column;
+ TableColumn hitColumn = null;
+ Rectangle bounds;
+
+ while (columns.hasMoreElements() == true && hitColumn == null) {
+ column = (TableColumn) columns.nextElement();
+ bounds = column.getBounds();
+ if ((xPosition >= bounds.x) &&
+ (xPosition <= bounds.x + bounds.width)) {
+ hitColumn = column;
+ }
+ }
+ if (hitColumn == null) {
+ column = getFillColumn();
+ bounds = column.getBounds();
+ if ((xPosition >= bounds.x) &&
+ (xPosition <= bounds.x + bounds.width)) {
+ hitColumn = column;
+ }
+ }
+ return hitColumn;
+}
+/**
+ * Answer the number of columns in the receiver.
+ */
+public int getColumnCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+ int count = 0;
+
+ if (columns != null) {
+ count = columns.size();
+ }
+ return count;
+}
+/** Replace CURSOR_SIZEWE with real column resize cursor
+ * (no standard cursor-have to load from file)
+ * Answer the cursor displayed during a column resize
+ * operation.
+ * Lazy initialize the cursor since it may never be needed.
+ */
+Cursor getColumnResizeCursor() {
+ if (columnResizeCursor == null) {
+ columnResizeCursor = new Cursor(getDisplay(), SWT.CURSOR_SIZEWE);
+ }
+ return columnResizeCursor;
+}
+/**
+ * Answer the current position of the mouse cursor during
+ * a column resize operation.
+ */
+int getColumnResizeX() {
+ return columnResizeX;
+}
+/**
+ * Answer an Array containing all columns of receiver except
+ * the fill column to the right of all content columns.
+ */
+public TableColumn [] getColumns() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector columns = getColumnVector();
+ TableColumn columnArray[] = new TableColumn[columns.size()];
+
+ columns.copyInto(columnArray);
+ return columnArray;
+}
+/**
+ * Answer a Vector containing all columns of receiver except
+ * the fill column to the right of all content columns.
+ */
+Vector getColumnVector() {
+ return columns;
+}
+/**
+ * Return the default column that is created as soon as the table
+ * is created.
+ * Fix for 1FUSJY5
+ */
+TableColumn getDefaultColumn() {
+ return defaultColumn;
+}
+/**
+ * Answer the width of the replacement String used to indicate
+ * truncated items.
+ * Cached to speed up calculation of truncated items.
+ * @param gc - GC used to measure the width of the replacement
+ * String
+ */
+int getDotsWidth(GC gc) {
+ if (dotsWidth == -1) {
+ dotsWidth = gc.stringExtent(DOT_STRING).x;
+ }
+ return dotsWidth;
+}
+/**
+ * Answer the column used to occupy any space left to the
+ * right of all the user created columns.
+ */
+TableColumn getFillColumn() {
+ return fillColumn;
+}
+/**
+ * Answer the widget that is used to hold focus for the receiver.
+ * The receiver can not get focus itself because it has children.
+ */
+Control getFocusWindow() {
+ return focusProxy;
+}
+/**
+* Gets the width of a grid line.
+* <p>
+* @return the width of a grid line
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getGridLineWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return 1;
+}
+/**
+ * Answer the table header widget.
+ */
+Header getHeader() {
+ return tableHeader;
+}
+/**
+ * Answer the header height or 0 if the header is not visible.
+ */
+int getHeaderHeight() {
+ Header header = getHeader();
+ int height = 0;
+
+ if (header.getVisible() == true) {
+ height = header.getBounds().height;
+ }
+ return height;
+}
+/**
+ * Answer whether the header is visible.
+ * @return
+ * true = header is visible. false = header is not visible
+ */
+public boolean getHeaderVisible() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getHeader().getVisible();
+}
+/**
+ * Answer the image extent of 'item'. Use the image of any column.
+ */
+Point getImageExtent(SelectableItem item) {
+ Image image = null;
+ Rectangle imageBounds;
+ Point imageExtent = null;
+ int columnCount = internalGetColumnCount();
+
+ for (int i = 0; i < columnCount && image == null; i++) {
+ image = ((TableItem) item).getImage(i);
+ }
+ if (image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+int getIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null && item.getSelectableParent() == this) {
+ index = ((TableItem) item).getIndex();
+ }
+ return index;
+}
+/**
+ * Answer the TableItem located at 'index' in the receiver.
+ * @param index - location of the TableItem object to return
+ */
+public TableItem getItem(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (!(0 <= index && index < getItemCount())) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ return (TableItem) getVisibleItem(index);
+}
+
+/**
+ * Return the item at the specified position in the widget
+ * Return null if the position is outside the widget or in the header widget.
+ */
+public TableItem getItem(Point point) {
+ int headerHeight = getHeaderHeight();
+ TableColumn column = getColumnAtX(point.x);
+ TableItem item = null;
+
+ if (column != null && column.getIndex() != TableColumn.FILL && point.y - headerHeight > 0) {
+ int itemIndex = (point.y - headerHeight) / getItemHeight() + getTopIndex();
+ item = (TableItem) getVisibleItem(itemIndex);
+ if (item != null) {
+ Point itemSize = item.getItemExtent(column);
+ if (point.x - column.getBounds().x > itemSize.x) {
+ item = null;
+ }
+ }
+ }
+ return item;
+}
+/**
+ * Answer the number of items in the receiver.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getItemVector().size();
+}
+/**
+ * Answer the number of items that can be displayed in the
+ * client area of the receiver without truncating any items.
+ */
+int getItemCountWhole() {
+ int clientAreaHeight = Math.max(0, getClientArea().height - getHeaderHeight());
+
+ return clientAreaHeight / getItemHeight();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the number of pixels that should be added to the item height.
+ */
+int getItemPadding() {
+ return getGridLineWidth() + getDisplay().textHighlightThickness + 1;
+}
+/**
+ * Answer all items of the receiver as an Array.
+ */
+public TableItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector items = getItemVector();
+ TableItem itemArray[] = new TableItem[items.size()];
+
+ items.copyInto(itemArray);
+ return itemArray;
+}
+/**
+ * Answer all items of the receiver.
+ */
+Vector getItemVector() {
+ return items;
+}
+/**
+ * Answer whether the receiver is drawing grid lines.
+ * @return
+ * true = receiver draws grid lines
+ * false = receiver does not draw grid lines
+ */
+public boolean getLinesVisible() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return drawGridLines;
+}
+/**
+ * Answer a Vector containing the columns that need repainting
+ * based on the 'paintArea'.
+ * @param paintArea - invalidated rectangle that needs repainting
+ */
+Vector getPaintColumns(Rectangle paintArea) {
+ Enumeration columns = internalGetColumnVector().elements();
+ Vector paintColumns = new Vector();
+ TableColumn column;
+ Rectangle columnBounds;
+ int paintAreaRightBorder = paintArea.x + paintArea.width;
+
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ columnBounds = column.getBounds();
+ if ((columnBounds.x + columnBounds.width >= paintArea.x) && // does the paintArea overlap the current column?
+ (columnBounds.x <= paintAreaRightBorder)) {
+ paintColumns.addElement(column);
+ }
+ }
+ return paintColumns;
+}
+/**
+ * Return the width of the widest item in the column identified by 'columnIndex'
+ * @param columnIndex - index of the column whose preferred width should be
+ * calculated
+ */
+int getPreferredColumnWidth(int columnIndex) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+ int width = 0;
+ int headerWidth;
+
+ if (columnIndex != TableColumn.FILL) {
+ while (tableItems.hasMoreElements() == true) {
+ tableItem = (TableItem) tableItems.nextElement();
+ width = Math.max(width, tableItem.getPreferredWidth(columnIndex));
+ }
+ headerWidth = getHeader().getPreferredWidth(columnIndex);
+ if (width < headerWidth) {
+ width = headerWidth;
+ }
+ }
+ return width;
+}
+/**
+ * Answer the position in the receiver where 'item' is drawn
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is not an item of the receiver
+ */
+int getRedrawY(SelectableItem item) {
+ int redrawY = super.getRedrawY(item);
+
+ if (redrawY != -1) {
+ redrawY += getHeaderHeight();
+ }
+ return redrawY;
+}
+/**
+ * Answer the column that is being resized or null if no
+ * resize operation is in progress.
+ */
+TableColumn getResizeColumn() {
+ return resizeColumn;
+}
+/**
+ * Return the positions at which the column identified by 'columnIndex'
+ * must be redrawn.
+ * These positions may be different for each item since each item may
+ * have a different label
+ * @param columnIndex - the column index
+ * @param columnWidth - width of the column
+ * @return the positions at which the column must be redrawn.
+ * Each item in the widget client area is represented by a slot in
+ * the array. The item at position 'topIndex' is the first item in
+ * the array.
+ */
+int [] getResizeRedrawX(int columnIndex, int columnWidth) {
+ int topIndex = getTopIndex();
+ int bottomIndex = getBottomIndex();
+ int resizeRedrawX[];
+ TableItem item;
+
+ bottomIndex = Math.min(bottomIndex, getItemCount());
+ resizeRedrawX = new int[bottomIndex-topIndex+1];
+ for (int i = topIndex; i < bottomIndex; i++) {
+ item = (TableItem) getVisibleItem(i);
+ resizeRedrawX[i-topIndex] = item.getDotStartX(columnIndex, columnWidth);
+ }
+ return resizeRedrawX;
+}
+/**
+ * Answer the selected items of the receiver.
+ * @return an Array of TableItems containing the selected items.
+ * An empty Array if no items are selected.
+ */
+public TableItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selectionVector = getSelectionVector();
+ TableItem[] selectionArray = new TableItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getSelectionCount();
+}
+/**
+ * Answer the size of the full row selection rectangle for 'item'.
+ */
+Point getFullSelectionExtent(TableItem item) {
+ TableColumn lastColumn = (TableColumn) internalGetColumnVector().lastElement();
+ Point selectionExtent = null;
+ Rectangle columnBounds;
+ int xPosition = item.getImageStopX(TableColumn.FIRST);
+ int gridLineWidth = getGridLineWidth();
+
+ if (lastColumn != null) {
+ columnBounds = lastColumn.getBounds();
+ selectionExtent = new Point(
+ columnBounds.x - getHorizontalOffset() + columnBounds.width - xPosition - gridLineWidth,
+ getItemHeight());
+ if (getLinesVisible() == true) {
+ selectionExtent.y -= gridLineWidth;
+ }
+ }
+ return selectionExtent;
+}
+/**
+ * Answer the index of the first selected item of the receiver.
+ */
+public int getSelectionIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = -1;
+
+ if (getSelectionCount() > 0) {
+ index = getIndex(getSelection()[0]);
+ }
+ return index;
+}
+/**
+ * Answer the indices of the selected items of the receiver.
+ * @return an Array containing the indices of the selected items.
+ * An empty Array if no items are selected.
+ */
+public int [] getSelectionIndices() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TableItem[] items = getSelection();
+ int indices[] = new int[items.length];
+
+ for (int i = 0; i < items.length; i++) {
+ indices[i] = getIndex(items[i]);
+ }
+ return indices;
+}
+/**
+ * Answer the index of the first visible item in the receiver's
+ * client area.
+ * @return 0-based index of the first visible item in the
+ * receiver's client area.
+ */
+public int getTopIndex() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getTopIndex();
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Every item in a table widget should be visible.
+ */
+int getVisibleIndex(SelectableItem item) {
+ return getIndex(item);
+}
+/**
+ * Answer the SelectableItem located at 'itemIndex' in the receiver.
+ * @param itemIndex - location of the SelectableItem object to return
+ */
+SelectableItem getVisibleItem(int itemIndex) {
+ Vector items = getItemVector();
+ TableItem item = null;
+
+ if ((items != null) && (itemIndex >= 0) && (itemIndex < items.size())) {
+ item = (TableItem) items.elementAt(itemIndex);
+ }
+ return item;
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+int getVisibleRedrawY(SelectableItem item) {
+ int redrawY = -1;
+ int index = getTopIndex();
+ int bottomIndex = getBottomIndex();
+
+ if (item == null) {
+ return redrawY;
+ }
+ while (index < bottomIndex && item.equals(getVisibleItem(index)) == false) {
+ index++;
+ }
+ if (index < bottomIndex) {
+ redrawY = getRedrawY(item);
+ }
+ return redrawY;
+}
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.MouseMove:
+ if (event.widget == tableHeader) {
+ headerMouseMove(event);
+ }
+ else {
+ columnMouseMove(event);
+ }
+ break;
+ case SWT.MouseDown:
+ if (event.widget == tableHeader) {
+ headerMouseDown(event);
+ }
+ else {
+ columnMouseDown(event);
+ }
+ break;
+ case SWT.MouseDoubleClick:
+ columnMouseDoubleClick(event);
+ break;
+ case SWT.MouseUp:
+ mouseUp(event);
+ break;
+ case SWT.Paint:
+ paint(event);
+ break;
+ default:
+ super.handleEvents(event);
+ }
+}
+/**
+ * Answer true if any item in the first column has an image.
+ * Answer false otherwise.
+ */
+boolean hasFirstColumnImage() {
+ return firstColumnImage;
+}
+/**
+ * Answer whether the receiver has the input focus.
+ */
+public boolean isFocusControl() {
+ return hasColumnFocus;
+}
+/**
+ * The mouse pointer was pressed down on the receiver's header
+ * widget. Start a column resize operation if apropriate.
+ * @param event - the mouse event that occured over the header
+ * widget
+ */
+void headerMouseDown(Event event) {
+ TableColumn column = getColumnAtX(event.x);
+
+ if (isColumnResize(event) == true) {
+ startColumnResize(event);
+ }
+ else
+ if (column != null) {
+ column.notifyListeners(SWT.Selection, new Event());
+ }
+}
+/**
+ * The mouse pointer was moved over the receiver's header widget.
+ * If a column is currently being resized a vertical line indicating
+ * the new position of the resized column is drawn.
+ * Otherwise, if no column resize operation is in progress, the
+ * column resize cursor is displayed when the mouse is near the border
+ * of a column.
+ */
+void headerMouseMove(Event event) {
+ if (isColumnResizeStarted() == false) { // only check whether cursor is in resize
+ setColumnResizeCursor(isColumnResize(event)); // area if no resize operation is in progress
+ }
+ else
+ if (event.x >= getResizeColumn().getBounds().x) {
+ drawColumnResizeLine(event.x);
+ update(); // looks better if resize line is drawn immediately
+ }
+}
+/**
+ * Answer the index of 'column' in the receiver or -1 if 'column'
+ * does not exist in the receiver.
+ */
+public int indexOf(TableColumn column) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (column == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return internalGetColumnVector().indexOf(column);
+}
+/**
+ * Answer the index of 'item' in the receiver or -1 if 'item'
+ * does not exist in the receiver.
+ */
+public int indexOf(TableItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ return getIndex(item);
+}
+/**
+ * Initialize the receiver. Create a header widget and an empty column.
+ */
+void initialize() {
+ columns = new Vector();
+ setItemVector(new Vector());
+ focusProxy = new Button(this, SWT.NULL);
+ focusProxy.setBounds(0, 0, 0, 0); // make the focus proxy invisible
+ tableHeader = new Header(this);
+ tableHeader.setVisible(false); // SWT table header is invisible by default, too
+ fillColumn = TableColumn.createFillColumn(this);
+ setColumnPosition(fillColumn);
+ defaultColumn = TableColumn.createDefaultColumn(this); // Create the default column. Fix for 1FUSJY5
+ super.initialize();
+}
+/**
+ * Insert the new column 'column' into the table data at position
+ * 'index'.
+ */
+void insertColumnData(TableColumn column) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.insertColumn(column);
+ }
+}
+/**
+ * Insert the new column 'column'.
+ * Set the position and move the following columns to the right.
+ */
+void insertColumnVisual(TableColumn column) {
+ Rectangle columnBounds = column.getBounds();
+ Rectangle previousColumnBounds;
+ int index = column.getIndex();
+
+ if (index > 0) {
+ previousColumnBounds = getColumn(index - 1).getBounds();
+ columnBounds.x = previousColumnBounds.x + previousColumnBounds.width;
+ }
+ else {
+ columnBounds.x = 0;
+ }
+ column.setBounds(columnBounds);
+ setColumnPosition(column);
+}
+/**
+ * Set event listeners for the receiver.
+ */
+void installListeners() {
+ Header tableHeader = getHeader();
+ Control focusWindow = getFocusWindow();
+ Listener listener = getListener();
+
+ super.installListeners();
+ tableHeader.addListener(SWT.MouseMove, listener);
+ tableHeader.addListener(SWT.MouseDown, listener);
+ tableHeader.addListener(SWT.MouseUp, listener);
+
+ // HACK: All we're really interested in is focus change and key down
+ // for the table itself. Doesn't work that way because setFocus sets
+ // focus to the first child of the receiver (which is our focus window)
+ removeListener(SWT.FocusOut, listener);
+ removeListener(SWT.FocusIn, listener);
+ focusWindow.addListener(SWT.FocusOut, listener);
+ focusWindow.addListener(SWT.FocusIn, listener);
+ focusWindow.addListener(SWT.KeyDown, listener);
+
+ addListener(SWT.MouseMove, listener);
+ addListener(SWT.MouseDown, listener);
+ addListener(SWT.MouseDoubleClick, listener);
+ addListener(SWT.MouseUp, listener);
+ addListener(SWT.Paint, listener);
+}
+/**
+ * Answer the TableColumn at 'index'.
+ * If the user has not created any columns the default column is
+ * returned if index is 0.
+ * Fix for 1FUSJY5
+ */
+TableColumn internalGetColumn(int index) {
+ Vector columns = internalGetColumnVector();
+
+ if (columns == null) error(SWT.ERROR_CANNOT_GET_ITEM);
+ if (index < 0 || index >= columns.size()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+
+ return (TableColumn) columns.elementAt(index);
+
+}
+/**
+ * Answer the number of columns in the receiver.
+ * If the user has not created any columns, 1 is returned since there
+ * always is a default column.
+ * Fix for 1FUSJY5
+ */
+int internalGetColumnCount() {
+ Vector columns = internalGetColumnVector();
+ int count = 0;
+
+ if (columns != null) {
+ count = columns.size();
+ }
+ return count;
+}
+/**
+ * Return a Vector containing all columns of the receiver except
+ * the fill column to the right of all content columns.
+ * Return a Vector containing the default column if the user has
+ * not created any columns.
+ * Fix for 1FUSJY5
+ */
+Vector internalGetColumnVector() {
+ Vector internalColumnVector;
+ TableColumn defaultColumn;
+
+ if (columns.isEmpty() == false) {
+ internalColumnVector = columns;
+ }
+ else {
+ internalColumnVector = new Vector(1);
+ defaultColumn = getDefaultColumn();
+ if (defaultColumn != null) {
+ internalColumnVector.addElement(defaultColumn);
+ }
+ }
+ return internalColumnVector;
+}
+/**
+ * Answer whether the mouse pointer is at a position that can
+ * start a column resize operation. A column resize can be
+ * started if the mouse pointer is at either the left or right
+ * border of a column.
+ * @param event - mouse event specifying the location of the
+ * mouse pointer.
+ */
+boolean isColumnResize(Event event) {
+ TableColumn hotColumn = getColumnAtX(event.x);
+ Rectangle bounds = hotColumn.getBounds();
+ int hotColumnIndex = hotColumn.getIndex();
+ int columnX = event.x - bounds.x;
+ boolean isColumnResize = false;
+
+ if (columnX <= COLUMN_RESIZE_OFFSET && // mouse over left side of column? and
+ hotColumnIndex != TableColumn.FIRST) { // it's not the first column)
+ if (hotColumnIndex == TableColumn.FILL) {
+ hotColumn = (TableColumn) internalGetColumnVector().lastElement();
+ }
+ else {
+ hotColumn = internalGetColumn(hotColumnIndex - 1);
+ }
+ isColumnResize = hotColumn.getResizable(); // check whether left column can be resized
+ }
+ else
+ if (columnX >= bounds.width - COLUMN_RESIZE_OFFSET && // mouse over right side of column and
+ hotColumn != getFillColumn()) { // column is a real one (not the right hand fill column)?
+ isColumnResize = hotColumn.getResizable(); // check whether column under cursor can be resized
+ }
+ return isColumnResize;
+}
+/**
+ * Answer whether a column of the receiver is being resized.
+ */
+boolean isColumnResizeStarted() {
+ return (getResizeColumn() != null);
+}
+/**
+ * Answer whether the item identified by 'index' is selected.
+ * @return
+ * true=item identified by 'index' is selected
+ * false=item identified by 'index' is not selected.
+ */
+public boolean isSelected(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TableItem item = getItem(index);
+
+ return (item != null && item.isSelected() == true);
+}
+/**
+ * 'changedItem' has changed. Update the default column width.
+ * @param changedItem - the item that has changed
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ // call super.itemChanged first to make sure that table image size is
+ // calculated if necessary. Fixes 1FYPBBG.
+ super.itemChanged(changedItem, repaintStartX, repaintWidth);
+ // remember if any item ever had an image in the first column.
+ if (firstColumnImage == false && changedItem.getImage() != null) {
+ firstColumnImage = true;
+ }
+ setFirstColumnWidth((TableItem) changedItem);
+}
+/**
+ * A mouse button was released.
+ * Update the display if a column has been resized.
+ * @param event - the mouse event for the button up action
+ */
+void mouseUp(Event event) {
+ TableColumn resizeColumn = getResizeColumn();
+ Rectangle oldColumnBounds;
+ int resizeXPosition;
+ int widthChange;
+
+ if (isColumnResizeStarted() == true) {
+ oldColumnBounds = resizeColumn.getBounds();
+ resizeXPosition = getColumnResizeX();
+ widthChange = resizeXPosition - (oldColumnBounds.x + oldColumnBounds.width);
+ if (widthChange != 0) {
+ if (widthChange > 0) {
+ redraw(resizeXPosition, 0, 1, getClientArea().height, false); // remove resize line
+ update(); // to avoid cheese caused by scrolling the resize line
+ }
+ resizeColumn.setWidth(oldColumnBounds.width + widthChange);
+ }
+ setResizeColumn(null);
+ }
+}
+/**
+ * Adjust the position of all columns starting at 'startIndex'.
+ * @param startIndex - index at which the column move should begin
+ * If this is the index of the fill column all columns are moved,
+ * including the fill column
+ * @param moveDistance - distance that the columns should be moved.
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void moveColumns(int startIndex, int moveDistance) {
+ Vector columns = internalGetColumnVector();
+ TableColumn moveColumn;
+ Rectangle columnBounds;
+
+ if (startIndex == TableColumn.FILL) {
+ moveColumn = getFillColumn();
+ columnBounds = moveColumn.getBounds();
+ columnBounds.x += moveDistance;
+ moveColumn.setBounds(columnBounds);
+ startIndex = 0; // continue with first data column
+ }
+ for (int i = startIndex; i < columns.size(); i++) {
+ moveColumn = (TableColumn) columns.elementAt(i);
+ columnBounds = moveColumn.getBounds();
+ columnBounds.x += moveDistance;
+ moveColumn.setBounds(columnBounds);
+ }
+}
+/**
+ * Adjust the y position of all columns including the fill column.
+ */
+void moveColumnsVertical() {
+ Enumeration columns = internalGetColumnVector().elements();
+ TableColumn column;
+
+ setColumnPosition(getFillColumn());
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ setColumnPosition(column);
+ }
+}
+/**
+ * A paint event has occurred. Paint the invalidated items.
+ * @param event - paint event specifying the invalidated area.
+ */
+void paint(Event event) {
+ int visibleRange[];
+ int headerHeight = getHeaderHeight();
+ Vector paintColumns = getPaintColumns(event.getBounds());
+ TableItem focusItem = null;
+
+ if (paintColumns.size() > 0) {
+ event.y -= headerHeight;
+ visibleRange = getIndexRange(event.getBounds());
+ event.y += headerHeight;
+ // When the top index is > 0 and the receiver is resized
+ // higher so that the top index becomes 0 the invalidated
+ // rectangle doesn't start below the header widget but at
+ // y position 0. Subtraction of the header height (it is
+ // not above the receiver but on top) causes event.y and
+ // subsequently visibleRange[0] to be negative.
+ // Hack to prevent visibleRange[0] from becoming negative.
+ // Need to find out why the invalidated area starts at 0
+ // in the first place.
+ if (visibleRange[0] < 0) {
+ visibleRange[0] = 0;
+ }
+ //
+ visibleRange[1] = Math.min(visibleRange[1], getItemCount()-1-getTopIndex());
+ focusItem = paintItems(event, visibleRange[0], visibleRange[1], paintColumns);
+ }
+ if (getLinesVisible() == true) {
+ drawGridLines(event, paintColumns.elements());
+ }
+ if (focusItem != null) {
+ // draw focus on top of drawing grid lines so that focus rectangle
+ // is not obscured by grid. Fixes 1G5X20B
+ drawSelectionFocus(focusItem, event.gc);
+ }
+}
+
+/**
+ * Paint items of the receiver starting at index 'topPaintIndex' and
+ * ending at 'bottomPaintIndex'.
+ * @param event - holds the GC to draw on and the clipping rectangle
+ * @param topPaintIndex - index of the first item to draw
+ * @param bottomPaintIndex - index of the last item to draw
+ * @param paintColumns - the table columns that should be painted
+ * @return the item that has focus if it was among the rendered items.
+ * null if the focus item was not rendered or if no item has focus (ie.
+ * because the widget does not have focus)
+ */
+TableItem paintItems(Event event, int topPaintIndex, int bottomPaintIndex, Vector paintColumns) {
+ Enumeration columns;
+ TableColumn column;
+ TableItem paintItem;
+ TableItem focusItem = null;
+ Point selectionExtent;
+ Point selectionPosition;
+ int itemHeight = getItemHeight();
+
+ topPaintIndex += getTopIndex();
+ bottomPaintIndex += getTopIndex();
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ paintItem = (TableItem) getVisibleItem(i);
+ selectionExtent = paintItem.getSelectionExtent();
+ if (selectionExtent != null) {
+ selectionPosition = new Point(paintItem.getSelectionX(), getRedrawY(paintItem));
+ drawSelection(paintItem, event.gc, selectionPosition, selectionExtent);
+ }
+ columns = paintColumns.elements();
+ while (columns.hasMoreElements() == true) {
+ column = (TableColumn) columns.nextElement();
+ paintSubItem(event, paintItem, column, i * itemHeight);
+ }
+ if (hasFocus(paintItem)) {
+ focusItem = paintItem;
+ }
+ }
+ return focusItem;
+}
+
+/**
+ * Paint the table item 'paintItem' in 'column' at y position
+ * 'paintYPosition' of the receiver.
+ * @param event - holds the GC to draw on and the clipping
+ * rectangle.
+ * @param paintItem - the item to draw
+ * @param column - column to draw 'paintItem' in
+ * @param paintYPosition - y position in the receiver to draw
+ * 'paintItem' at.
+ */
+void paintSubItem(Event event, TableItem paintItem, TableColumn column, int paintYPosition) {
+ Rectangle columnBounds = column.getBounds();
+ int gridLineWidth = getGridLineWidth();
+ int itemDrawStopX = columnBounds.x + columnBounds.width - gridLineWidth;
+ int clipX;
+
+ if (event.x + event.width > itemDrawStopX) { // does the invalidated area stretch past the current column's right border?
+ clipX = Math.max(columnBounds.x, event.x);
+ event.gc.setClipping( // clip the drawing area
+ clipX, event.y,
+ itemDrawStopX - clipX, event.height);
+ }
+ column.paint(paintItem, event.gc, paintYPosition);
+ if (event.x + event.width > itemDrawStopX) {
+ event.gc.setClipping(event.x, event.y, event.width, event.height); // restore original clip rectangle
+ }
+}
+/**
+ * Reindex all columns starting at 'startIndex'.
+ * Reindexing is necessary when a new column has been inserted.
+ */
+void reindexColumns(int startIndex) {
+ Vector columns = getColumnVector();
+ TableColumn column;
+
+ for (int i = startIndex; i < getColumnCount(); i++) {
+ column = (TableColumn) columns.elementAt(i);
+ column.setIndex(i);
+ }
+}
+/**
+ * Remove the items identified by the indices stored in
+ * 'indices' from the receiver.
+ * @param indices - indices of the items to dispose
+ */
+public void remove(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+ int [] sortedIndices;
+ int last = -1;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ sortedIndices = new int[indices.length];
+ System.arraycopy (indices, 0, sortedIndices, 0, indices.length);
+ sort(sortedIndices); // sort indices in descending order
+ for (int i = 0; i < sortedIndices.length; i++) {
+ if (sortedIndices[i] != last) {
+ item = getVisibleItem(sortedIndices[i]);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ last = sortedIndices[i];
+ }
+ }
+}
+/**
+ * Remove the item identified by 'index'.
+ * @param index - index of the item to dispose
+ */
+public void remove(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+}
+/**
+ * Remove a range of items starting at index 'start' and
+ * stopping at index 'end'.
+ * This operation will fail when the index is out of range
+ * Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void remove(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ item.dispose();
+ }
+ else {
+ error(SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ }
+}
+/**
+ * Remove all items of the receiver.
+ */
+public void removeAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector items = getItemVector();
+
+ setRedraw(false);
+ setRemovingAll(true);
+ for (int i = 0; i < items.size(); i++) {
+ ((TableItem) items.elementAt(i)).dispose();
+ }
+ setItemVector(new Vector());
+ reset();
+ calculateVerticalScrollbar();
+ setRemovingAll(false);
+ setRedraw(true);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ TableColumn lastColumn;
+ int index = column.getIndex();
+ int columnWidth = column.getWidth();
+ int columnCount;
+
+ if (isRemovingAll() == true) {
+ getColumnVector().removeElementAt(index);
+ }
+ else {
+ getColumnVector().removeElementAt(index);
+ columnCount = getColumnCount();
+ // Never remove the data of the last user created column.
+ // SWT for Windows does the same.
+ if (columnCount > 0) {
+ removeColumnData(column);
+ }
+ removeColumnVisual(column);
+ if (index < columnCount) { // is there a column after the removed one?
+ reindexColumns(index);
+ }
+ // last user created column is about to be removed.
+ if (columnCount == 0) {
+ TableColumn defaultColumn = getDefaultColumn();
+ defaultColumn.pack(); // make sure the default column has the right size...
+ setColumnPosition(defaultColumn); // ...and is at the right position
+ }
+ // Fixes for 1G1L0UT
+ // Reduce the content width by the width of the removed column
+ setContentWidth(getContentWidth() - columnWidth);
+ // claim free space
+ claimRightFreeSpace();
+ //
+ }
+}
+/**
+ * Remove the column 'column' from the table data.
+ */
+void removeColumnData(TableColumn column) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.removeColumn(column);
+ }
+}
+/**
+ * Remove the column 'column'.
+ * Set the position of the following columns.
+ */
+void removeColumnVisual(TableColumn column) {
+ int columnWidth = column.getWidth();
+
+ // move following columns to the left
+ moveColumns(column.getIndex() + 1, columnWidth * -1);
+ redraw();
+ getHeader().redraw();
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - item that should be removed from the receiver
+ */
+void removeItem(TableItem item) {
+ Vector items = getItemVector();
+ int index = items.indexOf(item);
+
+ if (index != -1) {
+ if (isRemovingAll() == false) {
+ removingItem(item);
+ }
+ items.removeElementAt(index);
+ for (int i = index; i < items.size(); i++) {
+ TableItem anItem = (TableItem) items.elementAt(i);
+ anItem.setIndex(anItem.getIndex() - 1);
+ }
+ if (isRemovingAll() == false) {
+ removedItem(item);
+ }
+ }
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+ * Reset cached data of column at 'columnIndex' for the items of the receiver.
+ * @param columnIndex - index of the column for which the item data should be
+ * reset.
+ */
+void resetTableItems(int columnIndex) {
+ Enumeration tableItems = getItemVector().elements();
+ TableItem tableItem;
+
+ while (tableItems.hasMoreElements() == true ) {
+ tableItem = (TableItem) tableItems.nextElement();
+ tableItem.reset(columnIndex);
+ }
+}
+/**
+ * The receiver has been resized. Resize the fill column
+ * and the header widget.
+ */
+void resize(Event event) {
+ TableColumn fillColumn = getFillColumn();
+ Rectangle fillColumnBounds;
+
+ super.resize(event);
+ // the x position may change in super.resize.
+ // get the column bounds after calling super.resize. Fixes 1G7ALGG
+ fillColumnBounds = fillColumn.getBounds();
+ fillColumnBounds.width = Math.max(0, getClientArea().width - getContentWidth());
+ fillColumn.setBounds(fillColumnBounds);
+ resizeHeader();
+}
+/**
+ * Resize the header widget to occupy the whole width of the
+ * receiver.
+ */
+void resizeHeader() {
+ Header tableHeader = getHeader();
+ Point size = tableHeader.getSize();
+
+ size.x = Math.max(getContentWidth(), getClientArea().width);
+ tableHeader.setSize(size);
+}
+/**
+ * Redraw 'column' after its width has been changed.
+ * @param column - column whose width has changed.
+ * @param oldColumnWidth - column width before resize
+ * @param oldColumnWidth - column width after resize
+ */
+void resizeRedraw(TableColumn column, int oldColumnWidth, int newColumnWidth) {
+ Rectangle columnBounds = column.getBounds();
+ int columnIndex = column.getIndex();
+ int oldRedrawStartX[] = getResizeRedrawX(columnIndex, oldColumnWidth);
+ int newRedrawStartX[] = getResizeRedrawX(columnIndex, newColumnWidth);
+ int itemHeight = getItemHeight();
+ int widthChange = newColumnWidth - oldColumnWidth;
+ int topIndex = getTopIndex();
+
+ for (int i = 0; i < newRedrawStartX.length; i++) {
+ if (newRedrawStartX[i] != oldRedrawStartX[i]) {
+ if (widthChange > 0) {
+ newRedrawStartX[i] = oldRedrawStartX[i];
+ }
+ redraw(
+ columnBounds.x + newRedrawStartX[i], columnBounds.y + itemHeight * (i + topIndex),
+ columnBounds.width - newRedrawStartX[i], itemHeight, false);
+ }
+ }
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void scrollHorizontal(int numPixel) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ getHeader().scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+ moveColumns(TableColumn.FILL, numPixel);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+void scrollVertical(int scrollIndexCount) {
+ int scrollAmount = scrollIndexCount * getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int destY;
+ int sourceY;
+ boolean scrollUp = scrollIndexCount < 0;
+ Rectangle clientArea = getClientArea();
+
+ if (scrollIndexCount == 0) {
+ return;
+ }
+ if (scrollUp == true) {
+ destY = headerHeight - scrollAmount;
+ sourceY = headerHeight;
+ }
+ else {
+ destY = headerHeight;
+ sourceY = destY + scrollAmount;
+ }
+ scroll(
+ 0, destY, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll items down to make space for a new item added to
+ * the receiver at position 'index'.
+ * @param index - position at which space for one new item
+ * should be made. This index is relative to the first item
+ * of the receiver.
+ */
+void scrollVerticalAddingItem(int index) {
+ int itemHeight = getItemHeight();
+ int sourceY = getHeaderHeight();
+ Rectangle clientArea = getClientArea();
+
+ if (index >= getTopIndex()) {
+ sourceY += (index-getTopIndex()) * itemHeight;
+ }
+ scroll(
+ 0, sourceY + itemHeight, // destination x, y
+ 0, sourceY, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll the items below the item at position 'index' up
+ * so that they cover the removed item.
+ * @param index - index of the removed item
+ */
+void scrollVerticalRemovedItem(int index) {
+ int itemHeight = getItemHeight();
+ int headerHeight = getHeaderHeight();
+ int destY;
+ Rectangle clientArea = getClientArea();
+
+ destY = Math.max(headerHeight, headerHeight + (index - getTopIndex()) * itemHeight);
+ scroll(
+ 0, destY, // destination x, y
+ 0, destY + itemHeight, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select the items identified by the indices stored in
+ * 'indices'.
+ * A SWT.Selection event will not be sent.
+ * @param indices - indices of the items to select
+ */
+public void select(int indices[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+ int selectionCount;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ selectionCount = indices.length;
+ if (isMultiSelect() == false && selectionCount > 1) {
+ selectionCount = 1;
+ deselectAllExcept(getVisibleItem(indices[0]));
+ }
+ for (int i = selectionCount - 1; i >= 0; --i) {
+ item = getVisibleItem(indices[i]);
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select the item identified by 'index'.
+ * A SWT.Selection event will not be sent.
+ * @param index - index of the item to select
+ */
+public void select(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = getVisibleItem(index);
+
+ if (isMultiSelect() == false) {
+ deselectAllExcept(getVisibleItem(index));
+ }
+ if (item != null) {
+ select(item);
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select a range of items starting at index 'start' and
+ * stopping at index 'end'. Indices that are out of range
+ * are ignored. Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void select(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item = null;
+ int selectionCount = 1;
+
+ if (isMultiSelect() == false) {
+ if (start < 0 && end >= 0) {
+ start = 0;
+ }
+ end = start;
+ deselectAllExcept(getVisibleItem(end));
+ }
+ // select in the same order as all the other selection and deslection methods.
+ // Otherwise setLastSelection repeatedly changes the lastSelectedItem for repeated
+ // selections of the items, causing flash.
+ for (int i = end; i >= start; i--) {
+ item = getVisibleItem(i);
+ if (item != null) {
+ select(item);
+ }
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Select all items of the receiver if it is in multiple
+ * selection mode.
+ * A SWT.Selection event will not be sent.
+ * Do nothing if the receiver is in single selection mode.
+ */
+public void selectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Enumeration items = getItemVector().elements();
+ TableItem item = null;
+
+ if (isMultiSelect() == false) {
+ return;
+ }
+ while (items.hasMoreElements() == true) {
+ item = (TableItem) items.nextElement();
+ select(item);
+ }
+ if (item != null) {
+ setLastSelection(item, false);
+ }
+}
+/**
+ * Set the y position of 'column'.
+ * @param column - the TableColumn that should be set to
+ * a new y position.
+ */
+void setColumnPosition(TableColumn column) {
+ Rectangle bounds = column.getBounds();
+
+ bounds.y = getHeaderHeight() - getTopIndex() * getItemHeight();
+ column.setBounds(bounds);
+}
+/**
+ * Change the cursor of the receiver.
+ * @param isColumnResizeCursor - indicates whether the column
+ * resize cursor or the regular cursor should be set.
+ */
+void setColumnResizeCursor(boolean isColumnResizeCursor) {
+ if (isColumnResizeCursor != this.isColumnResizeCursor) {
+ this.isColumnResizeCursor = isColumnResizeCursor;
+ if (isColumnResizeCursor == true) {
+ setCursor(getColumnResizeCursor());
+ }
+ else {
+ setCursor(null);
+ }
+ }
+}
+/**
+ * Set the current position of the resized column to 'xPosition'.
+ * @param xPosition - the current position of the resized column
+ */
+void setColumnResizeX(int xPosition) {
+ columnResizeX = xPosition;
+}
+/**
+ * Set the width of the receiver's contents to 'newWidth'.
+ * Content width is used to calculate the horizontal scrollbar.
+ */
+void setContentWidth(int newWidth) {
+ TableColumn fillColumn = getFillColumn();
+ Rectangle fillColumnBounds;
+ int widthDiff = newWidth - getContentWidth();
+
+ super.setContentWidth(newWidth);
+ if (fillColumn != null) {
+ fillColumnBounds = fillColumn.getBounds();
+ fillColumnBounds.x += widthDiff;
+ fillColumnBounds.width = Math.max(0, getClientArea().width - newWidth);
+ fillColumn.setBounds(fillColumnBounds);
+ }
+}
+/**
+ * Set the width of the first column to fit 'item' if it is longer than
+ * the current column width.
+ * Do nothing if the user has already set a width.
+ */
+void setFirstColumnWidth(TableItem item) {
+ int newWidth;
+ TableColumn column;
+
+ if (internalGetColumnCount() > 0) {
+ column = internalGetColumn(TableColumn.FIRST);
+ if (column.isDefaultWidth() == true) {
+ newWidth = Math.max(column.getWidth(), item.getPreferredWidth(TableColumn.FIRST));
+ column.setWidth(newWidth);
+ column.setDefaultWidth(true); // reset to true so that we know when the user has set
+ // the width instead of us setting a default width.
+ }
+ }
+}
+/**
+ * The font is changing. Trigger a recalculation of the item
+ * height using all items of the receiver.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SelectableItem item;
+ int itemCount = getItemCount();
+
+ if (font == null || font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+ for (int i = 0; i < itemCount; i++) {
+ itemChanged(getItem(i), 0, getClientArea().width);
+ }
+ setRedraw(true); // re-enable redraw
+ getHeader().setFont(font);
+}
+/**
+ * Set whether or not the header is visible.
+ * @param headerVisible -
+ * true = header is visible. false = header is not visible
+ */
+public void setHeaderVisible(boolean headerVisible) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (headerVisible != getHeaderVisible()) {
+ getHeader().setLocation(0, 0);
+ getHeader().setVisible(headerVisible);
+ // Windows resets scrolling so do we
+ setTopIndex(0, true);
+ moveColumnsVertical();
+ resizeVerticalScrollbar();
+ redraw();
+ }
+}
+/**
+ * Set the vector that stores the items of the receiver
+ * to 'newVector'.
+ * @param newVector - Vector to use for storing the items of
+ * the receiver.
+ */
+void setItemVector(Vector newVector) {
+ items = newVector;
+}
+/**
+ * Set whether the receiver is drawing grid lines to
+ * 'drawGridLines'.
+ * @param drawGridLines -
+ * true = receiver draws grid lines
+ * false = receiver does not draw grid lines
+ */
+public void setLinesVisible(boolean drawGridLines) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (this.drawGridLines != drawGridLines) {
+ this.drawGridLines = drawGridLines;
+ redraw();
+ }
+}
+/**
+ * Set whether the receiver and it's children should be
+ * drawn or not.
+ * @param redraw -
+ * true = redraw the receiver and its children
+ * false = do not draw the receiver or its children
+ */
+public void setRedraw(boolean redraw) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setRedraw(redraw);
+ getHeader().setRedraw(redraw);
+}
+/**
+ * Set the column that is being resized to 'column'.
+ * @param column - the TableColumn that is being resized.
+ * A null value indicates that no column resize operation is
+ * in progress.
+ */
+void setResizeColumn(TableColumn column) {
+ resizeColumn = column;
+}
+/**
+* Sets the selection.
+* <p>
+* The previous selection is cleared
+* before new items are selected.
+*
+* @see Table#deselectAll()
+* @see Table#select(int [])
+*
+* @param indices the indices of the items
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setSelection(int [] indices) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector keepSelected;
+
+ if (indices == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ keepSelected = new Vector(indices.length);
+ for (int i = 0; i < indices.length; i++) {
+ SelectableItem item = getVisibleItem(indices[i]);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(indices);
+}
+/**
+ * Select the items stored in 'items'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+public void setSelection(TableItem selectionItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * Set the selection to the item identified by 'index'.
+ * SWT.Selection events are not going to be sent.
+ * @param index - index of the item that should be selected
+ */
+public void setSelection(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ deselectAllExcept(getVisibleItem(index));
+ select(index);
+}
+/**
+ * Set the selection to a range of items starting at index
+ * 'start' and stopping at index 'end'. Indices that are out
+ * of range are ignored. Indexing is zero based.
+ * @param start - the start of the range
+ * @param end - the end of the range
+ */
+public void setSelection(int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector keepSelected = new Vector(end - start + 1);
+
+ for (int i = start; i <= end; i++) {
+ SelectableItem item = getVisibleItem(i);
+ if (item != null) {
+ keepSelected.addElement(item);
+ }
+ }
+ deselectAllExcept(keepSelected);
+ select(start, end);
+}
+/**
+ * Scroll the item at position 'index' to the top of the receiver.
+ * If the scroll operation would result in empty space being
+ * displayed below the last item of the receiver, the last item is
+ * scrolled into view. This results in the specified item not being
+ * displayed at the top of the receiver but after the top item.
+ * @param index - 0-based index of the item that should be
+ * displayed at the top of the receiver's client area.
+ */
+public void setTopIndex(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemCount = getItemCount();
+ int itemCountWhole = getItemCountWhole();
+
+ if (index < 0 || itemCount == 0) {
+ return;
+ }
+ if (index >= itemCount) {
+ index = itemCount - itemCountWhole;
+ }
+ super.setTopIndex(index, true);
+}
+/**
+ * Set the index of the first visible item in the receiver's client
+ * area to 'index'.
+ * @param index - 0-based index of the first visible item in the
+ * receiver's client area.
+ * @param adjustScrollbar - true=set the position of the vertical
+ * scroll bar to the new top index.
+ * false=don't adjust the vertical scroll bar
+ */
+void setTopIndexNoScroll(int index, boolean adjustScrollbar) {
+ super.setTopIndexNoScroll(index, adjustScrollbar);
+ moveColumnsVertical();
+}
+/**
+ * Make 'item' visible by scrolling it into the receiver's
+ * client area if necessary.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+public void showItem(TableItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ showSelectableItem(item);
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.showSelection();
+}
+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;
+ }
+ }
+ }
+ }
+}
+/**
+ * Start a column resize operation.
+ * @param event - the mouse event that occured over the header
+ * widget
+ */
+void startColumnResize(Event event) {
+ Vector columns = internalGetColumnVector();
+ TableColumn hitColumn = getColumnAtX(event.x);
+ Rectangle hitColumnBounds;
+ int hitIndex = hitColumn.getIndex();
+
+ if (hitColumn == getFillColumn()) { // clicked on the fill column?
+ hitColumn = (TableColumn) columns.lastElement(); // resize the last real column
+ }
+ else
+ if ((event.x - hitColumn.getBounds().x <= COLUMN_RESIZE_OFFSET) && // check if left side of a column was clicked
+ (hitIndex > 0)) {
+ hitColumn = (TableColumn) columns.elementAt(hitIndex - 1); // resize the preceding column
+ }
+ hitColumnBounds = hitColumn.getBounds();
+ setColumnResizeX(hitColumnBounds.x + hitColumnBounds.width);
+ setResizeColumn(hitColumn);
+}
+/**
+ * Return 'text' after it has been checked to be no longer than 'maxWidth'
+ * when drawn on 'gc'.
+ * If it is too long it will be truncated up to the last character.
+ * @param text - the String that should be checked for length
+ * @param maxWidth - maximum width of 'text'
+ * @param gc - GC to use for String measurement
+ */
+String trimItemText(String text, int maxWidth, GC gc) {
+ int textWidth;
+ int dotsWidth;
+
+ if (text != null && text.length() > 1) {
+ textWidth = gc.stringExtent(text).x;
+ if (textWidth >= maxWidth) {
+ dotsWidth = getDotsWidth(gc);
+ while (textWidth + dotsWidth >= maxWidth && text.length() > 1) {
+ text = text.substring(0, text.length() - 1); // chop off one character at the end
+ textWidth = gc.stringExtent(text).x;
+ }
+ text = text.concat(Table.DOT_STRING);
+ }
+ }
+ return text;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java
new file mode 100755
index 0000000000..55c9ba604c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableColumn.java
@@ -0,0 +1,461 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * A TableColumn stores such data as column label, label alignmentand size.
+ * It routes paint requests to the corresponding table item.
+ */
+public /*final*/ class TableColumn extends Item {
+ static final int FIRST = 0; // index of the first column
+ static final int FILL = -1; // index that identifies the column used to
+ // fill space not used by other columns.
+ private static final int DEFAULT_WIDTH = 10;
+
+ private Table parent;
+ private int index; // 0-based column index
+ private Rectangle bounds = new Rectangle(0, 0, 0, 0);
+ private boolean isDefaultWidth = true;
+ private boolean resize = true;
+/**
+ * Create a new TableColumn without adding it to the parent.
+ * Currently used to create fill columns and default columns.
+ * @see createFillColumn
+ * @see createDefaultColumn
+ * @param parent - Table widget the new instance will be a child of.
+ */
+TableColumn(Table parent) {
+ super(parent, SWT.NULL);
+ this.parent = parent;
+}
+/**
+ * Create a new instance of TableColumn and append it to the existing
+ * columns in 'parent'.
+ * @param parent - Table widget the new instance will be a child of.
+ * @param syle - style of the new TableColumn
+ */
+public TableColumn(Table parent, int style) {
+ this(parent, style, checkNull(parent).getColumnCount());
+}
+/**
+ * Create a new instance of TableColumn at position 'index' in the Table
+ * identified by 'parent'.
+ * @param parent - Table widget the new instance will be a child of.
+ * @param index - position in the 'parent' at which the new instance will
+ * be located relative to the other columns.
+ * @param syle - style of the new TableColumn
+ */
+public TableColumn(Table parent, int style, int index) {
+ super(parent, checkStyle (style), index);
+
+ this.parent = parent;
+ if (index < 0 || index > parent.getColumnCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ setIndex(index);
+ parent.addColumn(this);
+ setWidth(DEFAULT_WIDTH);
+ setDefaultWidth(true);
+ addListener(SWT.Dispose, new Listener() {
+ public void handleEvent(Event event) {disposeColumn();}
+ });
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 receive events.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
+ */
+static Table checkNull(Table table) {
+ if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return table;
+}
+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);
+}
+/**
+ * Create a new instance of TableColumn that acts as a default column
+ * if the user does not create a TableColumn.
+ * @param parent - Table widget the new instance will be a child of.
+ */
+static TableColumn createDefaultColumn(Table parent) {
+ TableColumn defaultColumn = new TableColumn(parent);
+
+ defaultColumn.setIndex(FIRST);
+ defaultColumn.setWidth(DEFAULT_WIDTH);
+ defaultColumn.setDefaultWidth(true);
+ return defaultColumn;
+}
+/**
+ * Create a new instance of TableColumn that acts as the rightmost
+ * fill column in a Table. The new object is not added to the parent
+ * like a regular column is.
+ * @param parent - Table widget the new instance will be a child of.
+ */
+static TableColumn createFillColumn(Table parent) {
+ TableColumn fillColumn = new TableColumn(parent);
+
+ fillColumn.setIndex(FILL);
+ return fillColumn;
+}
+/**
+ * Remove the receiver from its parent
+ */
+void disposeColumn() {
+ getParent().removeColumn(this);
+}
+/**
+* Gets the alignment.
+* <p>
+* The alignment of a widget controls the position of the
+* text or image in the widget. The alignment may be one
+* of LEFT, RIGHT or CENTER.
+*
+* @return the alignment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getAlignment () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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;
+}
+
+/**
+ * Answer the bounding rectangle of the receiver.
+ */
+Rectangle getBounds() {
+ return new Rectangle(bounds.x, bounds.y, bounds.width, bounds.height); // copy the object to prevent changes
+}
+/**
+ * Gets the Display.
+ */
+public Display getDisplay() {
+ if (parent == null) { // access parent field directly to prevent endless recursion
+ error(SWT.ERROR_WIDGET_DISPOSED);
+ }
+ return parent.getDisplay();
+}
+/**
+ * Answer the index of the receiver. Specifies the position of the
+ * receiver relative to other columns in the parent.
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Table getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return parent;
+}
+/**
+* Gets the resize attribute.
+* <p>
+* @return the resize attribute
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public boolean getResizable() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return resize;
+}
+/**
+* Gets the width.
+* <p>
+* @return the width
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getBounds().width;
+}
+/**
+ * Set the colun bounds.
+ */
+void internalSetBounds(Rectangle newBounds) {
+ bounds = newBounds;
+}
+/**
+ * Answer whether the column has a default width or if a width has been
+ * set by the user.
+ * @return
+ * true=column width is a default width set internally
+ * false=column width has been set by the user.
+ */
+boolean isDefaultWidth() {
+ return isDefaultWidth;
+}
+/**
+* Packs the widget.
+* <p>
+* Packing a widget causes it to be resized to the
+* preferred size for the widget.
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void pack() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ int index = parent.indexOf(this);
+
+ if (getIndex() != TableColumn.FILL && index != -1) {
+ setWidth(parent.getPreferredColumnWidth(index));
+ }
+}
+/**
+ * Draw the 'item' at 'yPosition' in the receiver column.
+ * @param item - TableItem that should be drawn.
+ * @param gc - GC to draw on
+ * @param yPosition - y position to draw at in the column.
+ */
+void paint(TableItem item, GC gc, int yPosition) {
+ Rectangle bounds = getBounds();
+ Point paintPosition = new Point(bounds.x, bounds.y + yPosition);
+
+ item.paint(gc, paintPosition, this);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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.
+* <p>
+*
+* @param listener the listener
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when listener is null
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener(SWT.Selection, listener);
+ removeListener(SWT.DefaultSelection, listener);
+}
+/**
+* Sets the alignment.
+* <p>
+* The alignment of a widget controls the position of the
+* text or image in the widget. The alignement may be one
+* of LEFT, RIGHT or CENTER.
+*
+* @param alignment the new alignment
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setAlignment(int alignment) {
+ if (!isValidThread ()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error(SWT.ERROR_WIDGET_DISPOSED);
+ int index = getIndex();
+
+ if ((alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER)) != 0 && index != 0) { // ignore calls for the first column to match Windows behavior
+ style &= ~(SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ style |= alignment & (SWT.LEFT | SWT.RIGHT | SWT.CENTER);
+ getParent().getHeader().redraw(index);
+ }
+}
+/**
+ * Set the bounding rectangle of the receiver to 'newBounds'.
+ * Notify the table widget if the column width changes.
+ * @param newBounds - the new bounding rectangle of the receiver,
+ * consisting of x, y, width, height
+ */
+void setBounds(Rectangle newBounds) {
+ if (newBounds.width != bounds.width) {
+ if (isDefaultWidth() == true) {
+ setDefaultWidth(false);
+ }
+ getParent().columnChange(this, newBounds);
+ }
+ else {
+ // columnChange causes update (via scroll) which may flush redraw
+ // based on old bounds. Setting bounds after notifying table fixes 1GABZR5
+ // Table sets column bounds at appropriate time when called above with
+ // width change. Only set bounds when table was not called. Fixes 1GCGDPB
+ bounds = newBounds;
+ }
+}
+/**
+ * Set whether the column has a default width or if a width has been
+ * set by the user.
+ * @param isDefaultWidth
+ * true=column width is a default width set internally
+ * false=column width has been set by the user
+ */
+void setDefaultWidth(boolean isDefaultWidth) {
+ this.isDefaultWidth = isDefaultWidth;
+}
+/**
+ * Set the index of the receiver to 'newIndex'. The index specifies the
+ * position of the receiver relative to other columns in the parent.
+ */
+void setIndex(int newIndex) {
+ this.index = newIndex;
+}
+/**
+* Sets the resize attribute.
+* <p>
+* @param resizee the resize attribute
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setResizable(boolean resize) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ this.resize = resize;
+}
+/**
+ * Set the text of the receiver to 'text'.
+ */
+public void setText(String newText) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int index = getIndex();
+
+ if (newText == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (index != FILL && (text == null || text.equals(newText) == false)) {
+ super.setText(newText);
+ getParent().getHeader().redraw(index);
+ }
+}
+/**
+* Sets the width.
+* <p>
+* @param width the width
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setWidth(int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ Rectangle bounds = getBounds();
+ int oldWidth = bounds.width;
+ int redrawX;
+
+ if (width != oldWidth) {
+ redrawX = bounds.x;
+ bounds.width = width;
+ setBounds(bounds);
+ // redraw at old column position if column was resized wider.
+ // fixes focus rectangle.
+ redrawX += Math.min(width, oldWidth);
+ parent.redraw(
+ redrawX - 2, 0,
+ 2, parent.getClientArea().height, false); // redraw 2 pixels wide to redraw item focus rectangle and grid line
+ }
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
new file mode 100755
index 0000000000..6919d84766
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TableItem.java
@@ -0,0 +1,1032 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * A table item is a selectable user interface object
+ * that represents an item in a table.
+ * Table items can consist of multiple columns called sub items.
+ */
+public /*final*/ class TableItem extends SelectableItem {
+ private static final int FIRST_COLUMN_IMAGE_INDENT = 2; // Space in front of image - first column only
+ private static final int FIRST_COLUMN_TEXT_INDENT = 4; // Space in front of text - first column only
+ private static final int TEXT_INDENT_NO_IMAGE = 2; // Space in front of item text when no item in the column has an image - first column only
+ private static final int TEXT_INDENT = 6; // Space in front of item text - all other columns
+ private static final int SELECTION_PADDING = 6; // Space behind text in a selected item
+
+ private Vector dataLabels = new Vector(); // Original text set by the user. Items that don't
+ // have a label are represented by a null slot
+ private String[] trimmedLabels = new String[0]; // Text that is actually displayed, may be trimmed
+ // to fit the column
+ private Vector images = new Vector(); // Item images. Items that don't have an image
+ // are represented by a null slot
+ private Point selectionExtent; // Size of the rectangle drawn to indicate a
+ // selected item.
+ private int imageIndent = 0; // the factor by which the item image and check box, if any,
+ // are indented. The multiplier is the image width.
+ private int index; // index of the item in the parent widget
+/**
+ * Create a table item in the table widget 'parent'. Append the new
+ * item to the existing items in 'parent'.
+ * @param parent - table widget the new item is added to.
+ * @param style - widget style. See Widget class for details
+ */
+public TableItem(Table parent, int style) {
+ this(parent, style, checkNull(parent).getItemCount());
+}
+/**
+ * Create a table item in the table widget 'parent'. Add the new
+ * item at position 'index' to the existing items in 'parent'.
+ * @param parent - table widget the new item is added to.
+ * @param style - widget style. See Widget class for details
+ * @param index - position the new item is inserted at in 'parent'
+ */
+public TableItem(Table parent, int style, int index) {
+ super(parent, style);
+ parent.addItem(this, index);
+}
+/**
+ * Calculate the size of the rectangle drawn to indicate a selected
+ * item. This is also used to draw the selection focus rectangle.
+ * The selection extent is calculated for the first column only (the
+ * only column the selection is drawn in).
+ */
+void calculateSelectionExtent() {
+ Table parent = getParent();
+ TableColumn column = parent.internalGetColumn(TableColumn.FIRST);
+ GC gc = new GC(parent);
+ String trimmedText = getText(gc, column);
+ int gridLineWidth = parent.getGridLineWidth();
+
+ if (trimmedText != null) {
+ selectionExtent = new Point(gc.stringExtent(trimmedText).x, parent.getItemHeight());
+ selectionExtent.x += getTextIndent(TableColumn.FIRST) + SELECTION_PADDING;
+ selectionExtent.x = Math.min(
+ selectionExtent.x, column.getWidth() - getImageStopX(column.getIndex()) - gridLineWidth);
+ if (parent.getLinesVisible() == true) {
+ selectionExtent.y -= gridLineWidth;
+ }
+ }
+ gc.dispose();
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'table' is null.
+ * Otherwise return 'table'
+ */
+static Table checkNull(Table table) {
+ if (table == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return table;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * The receiver is destroyed. Remove it from its parent widget.
+ */
+void disposeItem() {
+ getParent().removeItem(this);
+ dataLabels = null;
+ trimmedLabels = null;
+ images = null;
+ selectionExtent = null;
+ super.disposeItem();
+}
+/**
+ * Draw the image of the receiver for column 'index' at
+ * 'destinationPosition' using 'gc'.
+ * Stretch/shrink the image to the fixed image size of the receiver's
+ * parent.
+ * @param gc - GC to draw on.
+ * @param destinationPosition - position on the GC to draw at.
+ * @param index - index of the image to draw
+ * @return Answer the position where drawing stopped.
+ */
+Point drawImage(GC gc, Point destinationPosition, int index) {
+ Table parent = getParent();
+ Image image = getImage(index);
+ Rectangle sourceImageBounds;
+ Point destinationImageExtent = parent.getImageExtent();
+
+ if (image != null) {
+ sourceImageBounds = image.getBounds();
+ // full row select would obscure transparent images in all but the first column
+ // so always clear the image area in this case. Fixes 1FYNITC
+ if ((parent.getStyle() & SWT.FULL_SELECTION) != 0 && index != TableColumn.FIRST) {
+ gc.fillRectangle(
+ destinationPosition.x, destinationPosition.y,
+ destinationImageExtent.x, destinationImageExtent.y);
+ }
+ gc.drawImage(
+ image, 0, 0, // source x, y
+ sourceImageBounds.width, sourceImageBounds.height, // source width, height
+ destinationPosition.x, destinationPosition.y, // destination x, y
+ destinationImageExtent.x, destinationImageExtent.y); // destination width, height
+ }
+ if (((index == TableColumn.FIRST && // always add the image width for the first column
+ parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
+ (index != TableColumn.FIRST && // add the image width if it's not the first column
+ image != null)) && // only when the item actually has an image
+ destinationImageExtent != null) {
+ destinationPosition.x += destinationImageExtent.x;
+ }
+ return destinationPosition;
+}
+/**
+ * Draw the label of the receiver for column 'index' at 'position'
+ * using 'gc'.
+ * The background color is set to the selection background color if
+ * the item is selected and the text is drawn for the first column.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @param index - specifies which subitem text to draw
+ */
+void drawText(String label, GC gc, Point position, int index) {
+ Table parent = getParent();
+ boolean drawSelection;
+ int textOffset;
+ int textHeight;
+
+ if (label != null) {
+ drawSelection = (index == TableColumn.FIRST || (parent.getStyle() & SWT.FULL_SELECTION) != 0);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ }
+ textHeight = gc.stringExtent(label).y;
+ textOffset = (parent.getItemHeight() - textHeight) / 2; // vertically center the text
+ gc.drawString(label, position.x, position.y + textOffset);
+ if (isSelected() == true && drawSelection == true) {
+ gc.setBackground(parent.getBackground());
+ gc.setForeground(parent.getForeground());
+ }
+ }
+}
+
+/**
+* Gets the item bounds at an index
+* <p>
+* @return the item bounds
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Rectangle getBounds(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Rectangle itemBounds;
+ Rectangle columnBounds;
+ Rectangle checkboxBounds;
+ Table parent = getParent();
+ TableColumn column;
+ int itemIndex = parent.indexOf(this);
+ int itemHeight = parent.getItemHeight();
+ int gridLineWidth = parent.getGridLineWidth();
+ int itemYPos;
+
+ if (itemIndex == -1 || index < 0 || index >= parent.internalGetColumnCount()) {
+ itemBounds = new Rectangle(0, 0, 0, 0);
+ }
+ else {
+ column = parent.internalGetColumn(index);
+ columnBounds = column.getBounds();
+ itemYPos = columnBounds.y + itemHeight * itemIndex;
+ itemBounds = new Rectangle(
+ columnBounds.x, itemYPos,
+ columnBounds.width - gridLineWidth, itemHeight - gridLineWidth);
+ if (index == TableColumn.FIRST) {
+ if (isCheckable() == true) {
+ checkboxBounds = getCheckboxBounds();
+ itemBounds.x += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING; // add checkbox start, width and space behind checkbox
+ itemBounds.width -= itemBounds.x;
+ }
+ else {
+ itemBounds.x += getImageIndentPixel();
+ }
+ }
+ }
+ return itemBounds;
+}
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getChecked();
+}
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return getImageIndentPixel();
+}
+/**
+ * Answer the item labels set by the user.
+ * These may not be the same as those drawn on the screen. The latter
+ * may be trimmed to fit the column. Items that don't have a label are
+ * represented by a null slot in the vector.
+ * @return Vector - the item labels set by the user.
+ */
+Vector getDataLabels() {
+ return dataLabels;
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ return super.getDisplay();
+}
+/**
+ * Return the position at which the string starts that is used
+ * to indicate a truncated item text.
+ * @param columnIndex - index of the column for which the position of
+ * the truncation replacement should be calculated
+ * @param columnWidth - width of the column for which the position of
+ * the truncation replacement should be calculated
+ * @return -1 when the item text is not truncated
+ */
+int getDotStartX(int columnIndex, int columnWidth) {
+ GC gc;
+ Table parent = getParent();
+ String label = getText(columnIndex);
+ int dotStartX = -1;
+ int maxWidth;
+
+ if (label != null) {
+ gc = new GC(parent);
+ maxWidth = getMaxTextWidth(columnIndex, columnWidth);
+ label = parent.trimItemText(label, maxWidth, gc);
+ if (label.endsWith(Table.DOT_STRING) == true) {
+ dotStartX = gc.stringExtent(label).x - parent.getDotsWidth(gc);
+ // add indents, margins and image width
+ dotStartX += getImageStopX(columnIndex);
+ dotStartX += getTextIndent(columnIndex);
+ }
+ gc.dispose();
+ }
+ return dotStartX;
+}
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <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 boolean getGrayed() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getGrayed();
+}
+/**
+ * Answer the item image of the first column.
+ */
+public Image getImage() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getImage(0);
+}
+/**
+ * Answer the item image of the column identified by 'columnIndex' or
+ * null if no image has been set for that column.
+ * @param columnIndex - the column whose image should be answered
+ */
+public Image getImage(int columnIndex) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Image image = null;
+ Vector images = getImages();
+ int itemIndex = getParent().indexOf(this);
+
+ if (itemIndex != -1 && columnIndex >= 0 && columnIndex < images.size()) {
+ image = (Image) images.elementAt(columnIndex);
+ }
+ return image;
+}
+/**
+* Gets the image bounds at an index
+* <p>
+* @return the item icon's bounds
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public Rectangle getImageBounds(int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ int itemIndex = parent.indexOf (this);
+ int imageWidth = 0;
+ Point imageExtent = parent.getImageExtent();
+ Rectangle checkboxBounds;
+ Rectangle imageBounds = getBounds(index);
+
+ if (itemIndex == -1) {
+ imageBounds = new Rectangle(0, 0, 0, 0);
+ }
+ else
+ if (imageExtent != null) {
+ if (index == TableColumn.FIRST || getImage(index) != null) {
+ imageWidth = imageExtent.x;
+ }
+ }
+ imageBounds.width = imageWidth;
+ return imageBounds;
+}
+/**
+* Gets the image indent.
+* <p>
+* @return the indent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public int getImageIndent() {
+ if (isValidThread() == false) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isValidWidget() == false) error(SWT.ERROR_WIDGET_DISPOSED);
+ int index = getParent().indexOf(this);
+
+ if (index == -1) {
+ return 0;
+ }
+ return imageIndent;
+}
+/**
+ * Answer the number of pixels the image in the first column is
+ * indented. Calculation starts at the column start and counts
+ * all pixels except the check box.
+ */
+int getImageIndentPixel() {
+ int indentPixel = FIRST_COLUMN_IMAGE_INDENT;
+ Point imageExtent = getParent().getImageExtent();
+
+ if (imageExtent != null) {
+ indentPixel += imageExtent.x * getImageIndent();
+ }
+ return indentPixel;
+}
+/**
+ * Answer the item images set by the user. Items that don't have an
+ * image are represented by a null slot in the vector.
+ */
+Vector getImages() {
+ return images;
+}
+/**
+ * Calculate the x coordinate where the item image of column
+ * 'columnIndex' stops.
+ * @param columnIndex - the column for which the stop position of the
+ * image should be calculated.
+ */
+int getImageStopX(int columnIndex) {
+ int imageStopX = 0;
+ Table parent = getParent();
+ Rectangle checkboxBounds;
+
+ if (columnIndex == TableColumn.FIRST) {
+ if (isCheckable() == true) {
+ checkboxBounds = getCheckboxBounds();
+ imageStopX += checkboxBounds.x + checkboxBounds.width + CHECKBOX_PADDING;
+ }
+ else {
+ imageStopX = getImageIndentPixel();
+ }
+ }
+ if (((columnIndex == TableColumn.FIRST && // always add the image width for the first column
+ parent.hasFirstColumnImage() == true) || // if any item in the first column has an image
+ (columnIndex != TableColumn.FIRST && // add the image width if it's not the first column
+ getImage(columnIndex) != null)) && // only when the item actually has an image
+ parent.getImageExtent() != null) {
+ imageStopX += parent.getImageExtent().x;
+ }
+ return imageStopX;
+}
+/**
+ * Return the index of the item in its parent widget.
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Return the item extent in the specified column
+ * The extent includes the actual width of the item including checkbox,
+ * image and text.
+ */
+Point getItemExtent(TableColumn column) {
+ Table parent = getParent();
+ int columnIndex = column.getIndex();
+ Point extent = new Point(getImageStopX(columnIndex), parent.getItemHeight() - parent.getGridLineWidth());
+ GC gc = new GC(parent);
+ String trimmedText = getText(gc, column);
+
+ if (trimmedText != null && trimmedText.length() > 0) {
+ extent.x += gc.stringExtent(trimmedText).x + getTextIndent(columnIndex);
+ }
+ if (columnIndex == TableColumn.FIRST) {
+ extent.x += SELECTION_PADDING;
+ }
+ gc.dispose();
+ return extent;
+}
+/**
+ * Answer the maximum width in pixel of the text that fits in the
+ * column identified by 'columnIndex' without trimming the text.
+ * @param columnIndex - the column for which the maximum text width
+ * should be calculated.
+ * @param columnWidth - width of the column 'columnIndex'
+ */
+int getMaxTextWidth(int columnIndex, int columnWidth) {
+ int itemWidth = getImageStopX(columnIndex) + getTextIndent(columnIndex) * 2;
+
+ return columnWidth - itemWidth;
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Table getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return (Table) super.getSelectableParent();
+}
+/**
+ * Answer the width of the item required to display the complete contents.
+ */
+int getPreferredWidth(int index) {
+ int size = getImageStopX(index);
+ String text = getText(index);
+
+ if (text != null) {
+ size += getParent().getTextWidth(text) + getTextIndent(index) * 2 + 1;
+ }
+ return size;
+}
+/**
+ * Return the size of the rectangle drawn to indicate a selected item.
+ * This is also used to draw the selection focus rectangle and drop
+ * insert marker.
+ * Implements SelectableItem#getSelectionExtent
+ */
+Point getSelectionExtent() {
+ Table parent = getParent();
+ Point extent;
+
+ if ((parent.getStyle() & SWT.FULL_SELECTION) == 0) { // regular, first column, selection?
+ if (selectionExtent == null) {
+ calculateSelectionExtent();
+ }
+ extent = selectionExtent;
+ }
+ else {
+ extent = parent.getFullSelectionExtent(this);
+ }
+ return extent;
+}
+/**
+ * Return the x position of the selection rectangle
+ * Implements SelectableItem#getSelectionX
+ */
+int getSelectionX() {
+ return getImageStopX(TableColumn.FIRST) + getParent().getHorizontalOffset();
+}
+/**
+ * Answer the item text of the first column.
+ */
+public String getText() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getText(0);
+}
+/**
+ * Answer the item tezt of the column identified by 'columnIndex'.
+ * Answer null if no text has been set for that column.
+ * @param columnIndex - the column whose text should be answered.
+ * null if no text has been set for that column.
+ */
+public String getText(int columnIndex) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int itemIndex = getParent().indexOf(this);
+ Vector labels = getDataLabels();
+ String label = null;
+
+ if (itemIndex == -1) {
+ error(SWT.ERROR_CANNOT_GET_TEXT);
+ }
+ if (columnIndex >= 0 && columnIndex < labels.size()) {
+ label = (String) labels.elementAt(columnIndex);
+ }
+ if (label == null) {
+ label = ""; // label vector is initialized with null instead of empty Strings
+ }
+ return label;
+}
+/**
+ * Answer the text that is going to be drawn in 'column'. This
+ * text may be a trimmed copy of the original text set by the
+ * user if it doesn't fit into the column. In that case the last
+ * characters are replaced with Table.DOT_STRING.
+ * A cached copy of the trimmed text is returned if available.
+ * @param gc - GC to use for measuring the text extent
+ * @param column - TableColumn for which the text should be returned
+ */
+String getText(GC gc, TableColumn column) {
+ int columnIndex = column.getIndex();
+ String label = getTrimmedText(columnIndex);
+ int maxWidth;
+
+ if (label == null) {
+ maxWidth = getMaxTextWidth(columnIndex, column.getWidth());
+ label = getParent().trimItemText(getText(columnIndex), maxWidth, gc);
+ }
+ return label;
+}
+/**
+ * Answer the indent of the text in column 'columnIndex' in pixel.
+ * This indent is used in front of and behind the item text.
+ * @param columnIndex - specifies the column for which the indent
+ * should be calculated.
+ */
+int getTextIndent(int columnIndex) {
+ int textIndent;
+
+ if (columnIndex == TableColumn.FIRST) {
+ if (getParent().hasFirstColumnImage() == false) {
+ textIndent = TEXT_INDENT_NO_IMAGE;
+ }
+ else {
+ textIndent = FIRST_COLUMN_TEXT_INDENT;
+ }
+ }
+ else {
+ textIndent = TEXT_INDENT;
+ }
+ return textIndent;
+}
+/**
+ * Answer the cached trimmed text for column 'columnIndex'.
+ * Answer null if it hasn't been calculated yet.
+ * @param columnIndex - specifies the column for which the
+ * trimmed text should be answered.
+ */
+String getTrimmedText(int columnIndex) {
+ String label = null;
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ label = labels[columnIndex];
+ }
+ return label;
+}
+/**
+ * Answer an array of cached trimmed labels.
+ */
+String [] getTrimmedTexts() {
+ return trimmedLabels;
+}
+/**
+ * Ensure that the image and label vectors have at least
+ * 'newSize' number of elements.
+ */
+void growVectors(int newSize) {
+ Vector images = getImages();
+ Vector labels = getDataLabels();
+
+ if (newSize > images.size()){
+ images.setSize(newSize);
+ }
+ if (newSize > labels.size()){
+ labels.setSize(newSize);
+ }
+}
+/**
+ * Insert 'column' into the receiver.
+ */
+void insertColumn(TableColumn column) {
+ Vector data = getDataLabels();
+ Vector images = getImages();
+ String stringData[];
+ Image imageData[];
+ int index = column.getIndex();
+
+ if (index < data.size()) {
+ data.insertElementAt(null, index);
+ }
+ else {
+ data.addElement(null);
+ }
+ stringData = new String[data.size()];
+ data.copyInto(stringData);
+ setText(stringData);
+
+ if (index < images.size()) {
+ images.insertElementAt(null, index);
+ }
+ else {
+ images.addElement(null);
+ }
+ imageData = new Image[images.size()];
+ images.copyInto(imageData);
+ setImage(imageData);
+}
+/**
+ * Sets the image at an index.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+void internalSetImage(int columnIndex, Image image) {
+ Vector images = getImages();
+ boolean imageWasNull = false;
+ Table parent = getParent();
+
+ if (columnIndex >= 0 &&
+ columnIndex < parent.internalGetColumnCount()) {
+ if (columnIndex >= images.size()) {
+ growVectors(columnIndex + 1);
+ }
+ if (((Image) images.elementAt(columnIndex)) == null && image != null) {
+ imageWasNull = true;
+ }
+ images.setElementAt(image, columnIndex);
+ reset(columnIndex); // new image may cause text to no longer fit in the column
+ notifyImageChanged(columnIndex, imageWasNull);
+ }
+}
+/**
+* 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
+*
+*/
+void internalSetText(int columnIndex, String string) {
+ Vector labels = getDataLabels();
+ Table parent = getParent();
+ String oldText;
+
+ if (columnIndex >= 0 &&
+ columnIndex < parent.internalGetColumnCount()) {
+ if (columnIndex >= labels.size()) {
+ growVectors(columnIndex + 1);
+ }
+ oldText = (String) labels.elementAt(columnIndex);
+ if (string.equals(oldText) == false) {
+ labels.setElementAt(string, columnIndex);
+ reset(columnIndex);
+ notifyTextChanged(columnIndex, oldText == null);
+ }
+ }
+}
+/**
+ * Answer whether the click at 'xPosition' on the receiver is a
+ * selection click.
+ * A selection click occurred when the click was behind the image
+ * and before the end of the item text.
+ * @return
+ * true - 'xPosition' is a selection click.
+ * false - otherwise
+ */
+boolean isSelectionHit(int xPosition) {
+ int itemStopX = getImageStopX(TableColumn.FIRST);
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent != null) {
+ itemStopX += selectionExtent.x;
+ }
+ return (xPosition > getCheckboxBounds().x + getCheckboxBounds().width) && (xPosition <= itemStopX);
+}
+/**
+ * The image for the column identified by 'columnIndex' has changed.
+ * Notify the parent widget and supply redraw coordinates, if possible.
+ * @param columnIndex - index of the column that has a new image.
+ */
+void notifyImageChanged(int columnIndex, boolean imageWasNull) {
+ Table parent = getParent();
+ Rectangle changedColumnBounds;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ changedColumnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ redrawStartX = Math.max(0, getImageBounds(columnIndex).x);
+ if (parent.getImageExtent() != null && imageWasNull == false) {
+ redrawWidth = getImageStopX(columnIndex);
+ }
+ else {
+ redrawWidth = changedColumnBounds.width;
+ }
+ redrawWidth += changedColumnBounds.x - redrawStartX;
+ }
+ parent.itemChanged(this, redrawStartX, redrawWidth);
+}
+
+/**
+ * The label for the column identified by 'columnIndex' has changed.
+ * Notify the parent widget and supply redraw coordinates, if possible.
+ * @param columnIndex - index of the column that has a new label.
+ */
+void notifyTextChanged(int columnIndex, boolean textWasNull) {
+ Table parent = getParent();
+ String text;
+ Rectangle columnBounds;
+ int redrawStartX = 0;
+ int redrawWidth = 0;
+ int columnCount = parent.internalGetColumnCount();
+
+ if (columnIndex >= 0 && columnIndex < columnCount && parent.getVisibleRedrawY(this) != -1) {
+ text = (String) getDataLabels().elementAt(columnIndex);
+ columnBounds = parent.internalGetColumn(columnIndex).getBounds();
+ redrawStartX = columnBounds.x;
+ if (getImage(columnIndex) != null) {
+ redrawStartX += getImageStopX(columnIndex);
+ }
+ redrawStartX = Math.max(0, redrawStartX);
+ // don't redraw if text changed from null to empty string
+ if (textWasNull == false || text.length() > 0) {
+ redrawWidth = columnBounds.x + columnBounds.width - redrawStartX;
+ }
+ }
+ parent.itemChanged(this, redrawStartX, redrawWidth);
+}
+/**
+ * Draw the receiver at 'paintPosition' in the column identified by
+ * 'columnIndex' using 'gc'.
+ * @param gc - GC to use for drawing
+ * @param paintPosition - position where the receiver should be drawing.
+ * @param column - the column to draw in
+ */
+void paint(GC gc, Point paintPosition, TableColumn column) {
+ int columnIndex = column.getIndex();
+ String label = getText(gc, column);
+ String oldLabel = getTrimmedText(columnIndex);
+
+ if (label != null && label.equals(oldLabel) == false) {
+ setTrimmedText(label, columnIndex);
+ selectionExtent = null; // force a recalculation next time the selection extent is needed
+ }
+ if (columnIndex == TableColumn.FIRST) {
+ paintPosition.x += getImageIndentPixel();
+ if (isCheckable() == true) {
+ paintPosition = drawCheckbox(gc, paintPosition);
+ }
+ }
+ paintPosition = drawImage(gc, paintPosition, columnIndex);
+ paintPosition.x += getTextIndent(columnIndex);
+ drawText(label, gc, paintPosition, columnIndex);
+}
+/**
+ * Remove 'column' from the receiver.
+ */
+void removeColumn(TableColumn column) {
+ Vector data = getDataLabels();
+ Vector images = getImages();
+ String stringData[];
+ Image imageData[];
+ int index = column.getIndex();
+
+ if (index < data.size()) {
+ data.removeElementAt(index);
+ stringData = new String[data.size()];
+ data.copyInto(stringData);
+ setText(stringData);
+ }
+ if (index < images.size()) {
+ images.removeElementAt(index);
+ imageData = new Image[images.size()];
+ images.copyInto(imageData);
+ setImage(imageData);
+ }
+}
+/**
+ * Reset the cached trimmed label for the sub item identified by
+ * 'index'.
+ * @param index - index of the label that should be reset.
+ */
+void reset(int index) {
+ String trimmedLabels[] = getTrimmedTexts();
+
+ if (index >= 0 && index < trimmedLabels.length) {
+ trimmedLabels[index] = null;
+ }
+ if (index == TableColumn.FIRST) {
+ selectionExtent = null;
+ }
+}
+/**
+* Warning: API under construction.
+*/
+public void setImage(Image [] images) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (images == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) == -1) {
+ return;
+ }
+ for (int i = 0; i < images.length; i++) {
+ internalSetImage(i, images[i]);
+ }
+}
+/**
+ * Sets the image at an index.
+ * <p>
+ * @param image the new image (or null)
+ *
+ * @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+ * when called from the wrong thread
+ * @exception SWTError(ERROR_WIDGET_DISPOSED)
+ * when the widget has been disposed
+ */
+public void setImage(int columnIndex, Image image) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (getParent().indexOf(this) != -1) {
+ internalSetImage(columnIndex, image);
+ }
+}
+/**
+ * Set the item image of the first column to 'image'.
+ * @param image - the item image of the first column. Image
+ * will be removed if this is null.
+ */
+public void setImage(Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ setImage(0, image);
+}
+/**
+* Sets the image indent.
+* <p>
+* @param indent the new indent
+*
+* @exception SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+*/
+public void setImageIndent(int indent) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+ Table parent = getParent();
+ TableColumn column;
+ int index = parent.indexOf(this);
+
+ if (index != -1 && indent >= 0 && indent != imageIndent) {
+ imageIndent = indent;
+ column = parent.internalGetColumn(TableColumn.FIRST);
+ parent.redraw(
+ 0, parent.getRedrawY(this),
+ column.getWidth(), parent.getItemHeight(), false);
+ }
+}
+/**
+ * Warning: API under construction.
+ */
+public void setText(String [] strings) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (strings == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) == -1) {
+ return;
+ }
+ for (int i = 0; i < strings.length; i++) {
+ String string = strings[i];
+ if (string != null) {
+ internalSetText(i, string);
+ }
+ }
+}
+/**
+* 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 SWTError(ERROR_THREAD_INVALID_ACCESS)
+* when called from the wrong thread
+* @exception SWTError(ERROR_WIDGET_DISPOSED)
+* when the widget has been disposed
+* @exception SWTError(ERROR_NULL_ARGUMENT)
+* when string is null
+*/
+public void setText (int columnIndex, String string) {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+
+ if (string == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ if (getParent().indexOf(this) != -1) {
+ internalSetText(columnIndex, string);
+ }
+}
+/**
+ * Set the item text of the first column to 'text'.
+ * @param text - the item text of the first column. May be null if the
+ * text label should be removed.
+ */
+public void setText(String text) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (text == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setText(0, text);
+}
+/**
+ * Set the trimmed text of column 'columnIndex' to label. The trimmed
+ * text is the one that is displayed in a column. It may be shorter than
+ * the text originally set by the user via setText(...) to fit the
+ * column.
+ * @param label - the text label of column 'columnIndex'. May be trimmed
+ * to fit the column.
+ * @param columnIndex - specifies the column whose text label should be
+ * set.
+ */
+void setTrimmedText(String label, int columnIndex) {
+ String labels[] = getTrimmedTexts();
+
+ if (columnIndex < labels.length) {
+ labels[columnIndex] = label;
+ }
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setChecked(checked);
+}
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <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 setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setGrayed(grayed);
+}
+/**
+ * Set the index of this item in its parent widget to 'newIndex'.
+ */
+void setIndex(int newIndex) {
+ index = newIndex;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
new file mode 100755
index 0000000000..407924fdc7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Text.java
@@ -0,0 +1,619 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public class Text extends Scrollable {
+ char echoCharacter;
+ boolean ignoreChange;
+ String hiddenText;
+ int lastModifiedText;
+ PtTextCallback_t textVerify;
+
+ public static final int LIMIT;
+ public static final 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";
+ }
+
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ 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;
+}
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t ();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize (handle, dim);
+ int width = dim.w, height = dim.h;
+ if ((style & SWT.MULTI) != 0) {
+ int child = OS.PtWidgetChildBack (handle);
+ OS.PtWidgetPreferredSize (child, dim);
+ width += dim.w - 1;
+ height += dim.h - 1;
+ }
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ ScrollBar scroll;
+ if (wHint != SWT.DEFAULT) {
+ width = area.size_w;
+ if ((scroll = getVerticalBar ()) != null) width += scroll.getSize().x;
+ }
+ if (hHint != SWT.DEFAULT) {
+ height = area.size_h;
+ if ((scroll = getHorizontalBar ()) != null) height += scroll.getSize().y;
+ }
+ }
+ return new Point(width, height);
+}
+public void clearSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [] {0}, new int [] {0});
+}
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+ int textFlags = (style & SWT.READ_ONLY) != 0 ? 0 : OS.Pt_EDITABLE;
+ if ((style & SWT.SINGLE) != 0) {
+ int clazz = display.PtText;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
+ OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ return;
+ }
+ int clazz = display.PtMultiText;
+ int wrapFlags = (style & SWT.WRAP) != 0 ? OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR : 0;
+ int [] args = {
+ OS.Pt_ARG_FLAGS, OS.Pt_CALLBACKS_ACTIVE, OS.Pt_CALLBACKS_ACTIVE,
+ OS.Pt_ARG_TEXT_FLAGS, textFlags, OS.Pt_EDITABLE,
+ OS.Pt_ARG_MULTITEXT_WRAP_FLAGS, wrapFlags, OS.Pt_EMT_WORD | OS.Pt_EMT_CHAR,
+ OS.Pt_ARG_SCROLLBAR_X_DISPLAY, (style & SWT.H_SCROLL) != 0 ? OS.Pt_ALWAYS : OS.Pt_NEVER, 0,
+ OS.Pt_ARG_SCROLLBAR_Y_DISPLAY, (style & SWT.V_SCROLL) != 0 ? OS.Pt_ALWAYS : OS.Pt_NEVER, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (clazz, parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ createScrollBars();
+}
+
+public void addModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Modify, typedListener);
+}
+
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Selection,typedListener);
+ addListener (SWT.DefaultSelection,typedListener);
+}
+
+public void addVerifyListener (VerifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Verify, typedListener);
+}
+
+public void append (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ OS.PtTextModifyText (handle, 0, 0, -1, buffer, buffer.length);
+}
+
+public void copy () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] start = new int [1], end = new int [1];
+ int length = OS.PtTextGetSelection (handle, start, end);
+ if (length <= 0) return;
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ byte[] buffer = new byte[length + 1];
+ OS.memmove (buffer, args [1] + start [0], length);
+ int ig = OS.PhInputGroup (0);
+ OS.PhClipboardCopyString((short)ig, buffer);
+}
+
+public void cut () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int [] start = new int [1], end = new int [1];
+ int length = OS.PtTextGetSelection (handle, start, end);
+ if (length <= 0) return;
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ byte[] buffer = new byte[length + 1];
+ OS.memmove (buffer, args [1] + start [0], length);
+ int ig = OS.PhInputGroup (0);
+ OS.PhClipboardCopyString((short)ig, buffer);
+ buffer = new byte[0];
+ OS.PtTextModifyText (handle, start [0], end [0], start [0], buffer, buffer.length);
+}
+
+public int getCaretLineNumber () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public Point getCaretLocation () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return null;
+}
+
+public int getCaretPosition () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getCharCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return 0;
+ return OS.strlen (args [1]);
+}
+
+public boolean getDoubleClickEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return false;
+}
+
+public char getEchoChar () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return echoCharacter;
+}
+
+public boolean getEditable () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_TEXT_FLAGS, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return (args [1] & OS.Pt_EDITABLE) != 0;
+}
+
+public int getLineCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return 1;
+ int [] args = {OS.Pt_ARG_MULTITEXT_NUM_LINES, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return args [1];
+}
+
+public String getLineDelimiter () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return "\n";
+}
+
+public int getLineHeight () {
+ if ((style & SWT.SINGLE) != 0) {
+ PhDim_t dim = new PhDim_t ();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidget (handle);
+ OS.PtWidgetPreferredSize (handle, dim);
+ PhRect_t extent = new PhRect_t ();
+ OS.PtWidgetExtent(handle, extent);
+ PhRect_t canvas = new PhRect_t ();
+ OS.PtWidgetCanvas (handle, canvas);
+ int topBorder = canvas.ul_y - extent.ul_y;
+ int bottomBorder = extent.lr_y - canvas.lr_y;
+ return dim.h - topBorder - bottomBorder;
+ }
+ int ptr = OS.malloc (20);
+ int [] args = {
+ OS.Pt_ARG_MULTITEXT_QUERY_LINE, ptr, 1,
+ OS.Pt_ARG_MULTITEXT_LINE_SPACING, 0, 0
+ };
+ OS.PtGetResources (handle, args.length / 3, args);
+ int [] line = new int [1];
+ OS.memmove (line, args [1] + 8, 4);
+ PhRect_t extent = new PhRect_t ();
+ OS.memmove (extent, line [0] + 10, 8);
+ OS.free(ptr);
+ return extent.lr_y - extent.ul_y + 1 + args [4];
+}
+
+public Point getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (textVerify != null) {
+ return new Point (textVerify.start_pos, textVerify.end_pos);
+ }
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ return new Point (start [0], end [0]);
+}
+
+public int getSelectionCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point selection = getSelection ();
+ return selection.y - selection.x;
+}
+
+public String getSelectionText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ Point selection = getSelection ();
+ return getText ().substring (selection.x, selection.y);
+}
+
+public int getTabs () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+public String getText (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ //NOT DONE - use OS in SINGLE text
+ return getText ().substring (start, end + 1);
+}
+
+public String getText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter != '\0') return hiddenText;
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] == 0) return "";
+ int length = OS.strlen (args [1]);
+ byte [] buffer = new byte [length];
+ OS.memmove (buffer, args [1], length);
+ char [] unicode = Converter.mbcsToWcs (null, buffer);
+ return new String (unicode);
+}
+
+public int getTextLimit () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getTopIndex () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return 0;
+ int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, 0, 0};
+ OS.PtGetResources(handle, args.length / 3, args);
+ return args [1];
+}
+
+public int getTopPixel () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE - NOT NEEDED
+ return 0;
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ if ((style & SWT.MULTI) != 0) {
+ OS.PtAddFilterCallback (handle, OS.Ph_EV_KEY, windowProc, SWT.KeyDown);
+ }
+ OS.PtAddCallback (handle, OS.Pt_CB_MODIFY_VERIFY, windowProc, SWT.Verify);
+ OS.PtAddCallback (handle, OS.Pt_CB_TEXT_CHANGED, windowProc, SWT.Modify);
+}
+
+public void insert (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, false);
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ OS.PtTextModifyText (handle, start [0], end [0], start [0], buffer, buffer.length);
+}
+
+public void paste () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ int ig = OS.PhInputGroup (0);
+ int ptr = OS.PhClipboardPasteString((short)ig);
+ if (ptr == 0) return;
+ int length = OS.strlen (ptr);
+ int [] start = new int [1], end = new int [1];
+ OS.PtTextGetSelection (handle, start, end);
+ if (start [0] == -1) {
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ start [0] = end [0] = args [1];
+ }
+ OS.PtTextModifyText (handle, start [0], end [0], end [0], ptr, length);
+ OS.free(ptr);
+}
+
+int processModify (int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ if (!ignoreChange) sendEvent (SWT.Modify);
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ if ((style & SWT.SINGLE) != 0) {
+ OS.PtSuperClassDraw (OS.PtText (), handle, damage);
+ } else {
+ OS.PtSuperClassDraw (OS.PtMultiText (), handle, damage);
+ }
+ return super.processPaint (damage);
+}
+
+int processVerify (int info) {
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+ super.processVerify (info);
+ if (echoCharacter == '\0' && !hooks (SWT.Verify)) return 0;
+ PtCallbackInfo_t cbinfo = new PtCallbackInfo_t ();
+ OS.memmove (cbinfo, info, PtCallbackInfo_t.sizeof);
+ PtTextCallback_t textVerify = new PtTextCallback_t ();
+ OS.memmove (textVerify, cbinfo.cbdata, PtTextCallback_t.sizeof);
+ byte [] buffer = new byte [textVerify.length];
+ OS.memmove (buffer, textVerify.text, buffer.length);
+ String text = new String (Converter.mbcsToWcs (null, buffer));
+ String newText = text;
+ if (!ignoreChange) {
+ Event event = new Event ();
+ event.start = textVerify.start_pos;
+ event.end = textVerify.end_pos;
+ event.doit = textVerify.doit != 0;
+ event.text = text;
+ sendEvent (SWT.Verify, event);
+ newText = event.text;
+ textVerify.doit = (event.doit && newText != null) ? 1 : 0;
+ }
+ if (newText != null) {
+ if (echoCharacter != '\0' && (textVerify.doit != 0)) {
+ String prefix = hiddenText.substring (0, textVerify.start_pos);
+ String suffix = hiddenText.substring (textVerify.end_pos, hiddenText.length ());
+ hiddenText = prefix + newText + suffix;
+ char [] charBuffer = new char [newText.length ()];
+ for (int i=0; i<charBuffer.length; i++) {
+ charBuffer [i] = echoCharacter;
+ }
+ newText = new String (charBuffer);
+ }
+ if (newText != text) {
+ byte [] buffer2 = Converter.wcsToMbcs (null, newText, true);
+ int length = buffer2.length - 1;
+ if (length == textVerify.length) {
+ OS.memmove(textVerify.text, buffer2, length);
+ } else {
+ int ptr = OS.malloc (length);
+ OS.memmove (ptr, buffer2, buffer2.length);
+ textVerify.new_insert += length - textVerify.length;
+ textVerify.text = ptr;
+ textVerify.length = length;
+ lastModifiedText = ptr;
+ }
+ }
+ }
+ OS.memmove (cbinfo.cbdata, textVerify, PtTextCallback_t.sizeof);
+ textVerify = null;
+ return 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (lastModifiedText != 0) {
+ OS.free (lastModifiedText);
+ lastModifiedText = 0;
+ }
+}
+
+public void removeModifyListener (ModifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Modify, listener);
+}
+
+public void removeSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void removeVerifyListener (VerifyListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Verify, listener);
+}
+
+public void selectAll () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [0], new int [] {-1});
+}
+
+public void setEchoChar (char echo) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (echoCharacter == echo) return;
+ String newText;
+ if (echo == 0) {
+ newText = hiddenText;
+ hiddenText = null;
+ } else {
+ newText = hiddenText = getText();
+ }
+ echoCharacter = echo;
+ Point selection = getSelection();
+ boolean oldValue = ignoreChange;
+ ignoreChange = true;
+ setText(newText);
+ setSelection(selection.x, selection.y);
+ ignoreChange = oldValue;
+}
+
+public void setDoubleClickEnabled (boolean doubleClick) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE - NOT NEEDED
+}
+
+public void setEditable (boolean editable) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ style &= ~SWT.READ_ONLY;
+ if (!editable) style |= SWT.READ_ONLY;
+ int [] args = {OS.Pt_ARG_TEXT_FLAGS, editable ? OS.Pt_EDITABLE : 0, OS.Pt_EDITABLE};
+ OS.PtSetResources(handle, args.length / 3, args);
+}
+
+public void setSelection (int position) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_CURSOR_POSITION, position, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setSelection (Point selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setSelection (selection.x, selection.y);
+}
+
+public void setSelection (int start, int end) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ OS.PtTextSetSelection (handle, new int [] {start}, new int [] {end});
+}
+
+public void setTabs (int tabs) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (tabs < 0) return;
+
+ //NOT DONE - NOT NEEDED
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ int ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, ptr, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ OS.free (ptr);
+}
+
+public void setTextLimit (int limit) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ int [] args = new int [] {OS.Pt_ARG_MAX_LENGTH, limit, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setTopIndex (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SINGLE) != 0) return;
+ int [] args = {OS.Pt_ARG_MULTITEXT_TOP_LINE, index + 1, 0};
+ OS.PtSetResources(handle, args.length / 3, args);
+}
+
+public void showSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ //NOT DONE - NOT NEEDED
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
new file mode 100755
index 0000000000..5b61c7394e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolBar.java
@@ -0,0 +1,155 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+public /*final*/ class ToolBar extends Composite {
+ int itemCount;
+ ToolItem [] items;
+
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+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) {
+// if (layout != null) return super.computeSize (wHint, hHint, changed);
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhDim_t dim = new PhDim_t();
+ if (!OS.PtWidgetIsRealized (handle)) OS.PtExtentWidgetFamily (handle);
+ OS.PtWidgetPreferredSize(handle, dim);
+ int width = dim.w, height = dim.h;
+ if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) {
+ PhRect_t rect = new PhRect_t ();
+ PhArea_t area = new PhArea_t ();
+ rect.lr_x = (short) (wHint - 1);
+ rect.lr_y = (short) (hHint - 1);
+ OS.PtSetAreaFromWidgetCanvas (handle, rect, area);
+ if (wHint != SWT.DEFAULT) width = area.size_w;
+ if (hHint != SWT.DEFAULT) height = area.size_h;
+ }
+ return new Point(width, height);
+}
+
+void createHandle (int index) {
+ Display display = getDisplay ();
+ int parentHandle = parent.handle;
+
+ int [] args = {
+ OS.Pt_ARG_RESIZE_FLAGS, 0, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (OS.PtToolbar (), parentHandle, args.length / 3, args);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createItem (ToolItem item, int index) {
+ if (!(0 <= index && index <= itemCount)) error (SWT.ERROR_INVALID_RANGE);
+ if (itemCount == items.length) {
+ ToolItem [] newItems = new ToolItem [itemCount + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ item.createWidget (index);
+ System.arraycopy (items, index, items, index + 1, itemCount++ - index);
+ items [index] = item;
+}
+
+void createWidget (int index) {
+ super.createWidget (index);
+ items = new ToolItem [4];
+ itemCount = 0;
+}
+
+void destroyItem (ToolItem 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;
+}
+
+public int getItemCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return itemCount;
+}
+
+public ToolItem [] getItems () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] result = new ToolItem [itemCount];
+ System.arraycopy (items, 0, result, 0, itemCount);
+ return result;
+}
+
+public ToolItem getItem (int index) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int count = itemCount;
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ return items [index];
+}
+
+public ToolItem getItem (Point pt) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ ToolItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ Rectangle rect = items [i].getBounds ();
+ if (rect.contains (pt)) return items [i];
+ }
+ return null;
+}
+
+public int getRowCount () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 1;
+}
+
+public int indexOf (ToolItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = itemCount;
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseWidget ();
+ }
+ }
+ items = null;
+ super.releaseWidget ();
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
new file mode 100755
index 0000000000..d8e1d10127
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/ToolItem.java
@@ -0,0 +1,325 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class ToolItem extends Item {
+ ToolBar parent;
+ Control control;
+ String toolTipText;
+ Image hotImage, disabledImage;
+
+public ToolItem (ToolBar parent, int style) {
+ this(parent, style, parent.getItemCount ());
+}
+
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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) {
+ int count = parent.getItemCount();
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int parentHandle = parent.handle;
+
+ if ((style & SWT.SEPARATOR) != 0) {
+ int [] args = {
+// OS.Pt_ARG_SEP_FLAGS, OS.Pt_SEP_VERTICAL, OS.Pt_SEP_VERTICAL | OS.Pt_SEP_HORIZONTAL,
+// OS.Pt_ARG_SEP_TYPE, OS.Pt_NOLINE, 0,
+ OS.Pt_ARG_WIDTH, 2, 0,
+ OS.Pt_ARG_RESIZE_FLAGS, OS.Pt_RESIZE_Y_ALWAYS, OS.Pt_RESIZE_XY_BITS,
+ };
+ handle = OS.PtCreateWidget (OS.PtContainer (), parentHandle, args.length / 3, args);
+ } else {
+ boolean rightAligned = (parent.style & SWT.RIGHT) != 0;
+ boolean toggle = (style & (SWT.CHECK | SWT.RADIO)) != 0;
+ int [] args = {
+ OS.Pt_ARG_BALLOON_POSITION, rightAligned ? OS.Pt_BALLOON_RIGHT : OS.Pt_BALLOON_BOTTOM, 0,
+ OS.Pt_ARG_FLAGS, toggle ? OS.Pt_TOGGLE : 0, OS.Pt_TOGGLE,
+ };
+ handle = OS.PtCreateWidget (OS.PtButton (), parentHandle, args.length / 3, args);
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if (index != count) {
+ int i = 0;
+ int child = OS.PtWidgetChildBack (parentHandle);
+ /*
+ * Feature in Photon. Tool bars have an extra widget which
+ * is the parent of all tool items. PtValidParent() can not be
+ * used, since it does not return that widget.
+ */
+ if (child != 0) child = OS.PtWidgetChildBack (child);
+ while (i != index && child != 0) {
+ child = OS.PtWidgetBrotherInFront (child);
+ i++;
+ }
+ OS.PtWidgetInsert (topHandle (), child, 1);
+ }
+ if (OS.PtWidgetIsRealized (parentHandle)) {
+ OS.PtRealizeWidget (topHandle ());
+ }
+}
+
+public Rectangle getBounds () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ PhArea_t area = new PhArea_t ();
+ OS.PtWidgetArea (handle, area);
+ return new Rectangle (area.pos_x, area.pos_y, area.size_w, area.size_h);
+}
+
+public Control getControl () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return control;
+}
+
+public Image getDisabledImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return disabledImage;
+}
+
+public Display getDisplay () {
+ ToolBar parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+public boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_BLOCKED) == 0;
+}
+
+public Image getHotImage () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hotImage;
+}
+
+public ToolBar getParent () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+public boolean getSelection () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return false;
+ int [] args = {OS.Pt_ARG_FLAGS, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return (args [1] & OS.Pt_SET) != 0;
+}
+
+public String getToolTipText () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return toolTipText;
+}
+
+public int getWidth () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {OS.Pt_ARG_WIDTH, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ return args [1];
+}
+
+void hookEvents () {
+ super.hookEvents ();
+ int windowProc = getDisplay ().windowProc;
+ OS.PtAddCallback (handle, OS.Pt_CB_ACTIVATE, windowProc, SWT.Selection);
+}
+
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+int processSelection (int info) {
+ if ((style & SWT.RADIO) != 0) {
+ setSelection (true);
+ ToolItem [] items = parent.getItems ();
+ int index = 0;
+ while (index < items.length && items [index] != this) index++;
+ ToolItem item;
+ int i = index;
+ while (--i >= 0 && ((item = items [i]).style & SWT.RADIO) != 0) {
+ item.setSelection (false);
+ }
+ i = index;
+ while (++i < items.length && ((item = items [i]).style & SWT.RADIO) != 0) {
+ item.setSelection (false);
+ }
+ }
+ postEvent (SWT.Selection);
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ control = null;
+ hotImage = null;
+ disabledImage = null;
+}
+
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+public void setControl (Control control) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ Control oldControl = this.control;
+ this.control = control;
+ if (oldControl != null) {
+ OS.PtReParentWidget(oldControl.handle, parent.handle);
+ }
+ if (control != null && !control.isDisposed ()) {
+ OS.PtReParentWidget(control.handle, handle);
+ control.setBounds (getBounds ());
+ }
+}
+
+public void setDisabledImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+}
+
+public void setEnabled (boolean enabled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int [] args = {
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_BLOCKED, OS.Pt_BLOCKED,
+ OS.Pt_ARG_FLAGS, enabled ? 0 : OS.Pt_GHOST, OS.Pt_GHOST,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setHotImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ hotImage = image;
+}
+
+public void setImage (Image image) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int imageHandle = 0;
+ int type = OS.Pt_Z_STRING;
+ if (image != null) {
+ imageHandle = copyPhImage (image.handle);
+ int [] args = {OS.Pt_ARG_TEXT_STRING, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] != 0 && OS.strlen (args [1]) > 0) type = OS.Pt_TEXT_IMAGE;
+ else type = OS.Pt_IMAGE;
+ }
+ int [] args = {
+ OS.Pt_ARG_LABEL_IMAGE, imageHandle, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (imageHandle != 0) OS.free (imageHandle);
+}
+
+public void setSelection (boolean selected) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) == 0) return;
+ int [] args = {OS.Pt_ARG_FLAGS, selected ? OS.Pt_SET : 0, OS.Pt_SET};
+ OS.PtSetResources (handle, args.length / 3, args);
+}
+
+public void setText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ int ptr = 0;
+ int type = OS.Pt_IMAGE;
+ if (string != null) {
+ byte [] buffer = Converter.wcsToMbcs (null, string, true);
+ ptr = OS.malloc (buffer.length);
+ OS.memmove (ptr, buffer, buffer.length);
+ int [] args = {OS.Pt_ARG_LABEL_IMAGE, 0, 0};
+ OS.PtGetResources (handle, args.length / 3, args);
+ if (args [1] != 0) type = OS.Pt_TEXT_IMAGE;
+ else type = OS.Pt_Z_STRING;
+ }
+ int [] args = {
+ OS.Pt_ARG_TEXT_STRING, ptr, 0,
+ OS.Pt_ARG_LABEL_TYPE, type, 0,
+ };
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (ptr != 0) OS.free (ptr);
+}
+
+public void setToolTipText (String string) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ toolTipText = string;
+}
+
+public void setWidth (int width) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if ((style & SWT.SEPARATOR) == 0) return;
+ if (width < 0) return;
+ int [] args = {OS.Pt_ARG_WIDTH, width, 0};
+ OS.PtSetResources (handle, args.length / 3, args);
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
new file mode 100755
index 0000000000..13657ad4b0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tracker.java
@@ -0,0 +1,115 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+public /*final*/ class Tracker extends Widget {
+ Composite parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles = new Rectangle [0];
+
+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 = style;
+ this.display = display;
+}
+
+public Tracker (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ this.display = parent.getDisplay ();
+}
+public void addControlListener(ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Move,typedListener);
+}
+public void close () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ tracking = false;
+}
+public Display getDisplay () {
+ return display;
+}
+
+public Rectangle [] getRectangles () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return rectangles;
+}
+public boolean getStippled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return stippled;
+}
+public boolean open () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+// int handle = parent.handle;
+ PhRect_t r = new PhRect_t ();
+ OS.PhWindowQueryVisible (OS.Ph_QUERY_GRAPHICS, 0, 1, r);
+ int width = (short) (r.lr_x - r.ul_x + 1);
+ int height = (short) (r.lr_y - r.ul_y + 1);
+ int [] args = {
+ OS.Pt_ARG_WIDTH, 200 /*width*/, 0,
+ OS.Pt_ARG_HEIGHT, 200 /*height*/, 0,
+ OS.Pt_ARG_REGION_OPAQUE, 0, ~0,
+// OS.Pt_ARG_REGION_SENSE, OS.Ph_EV_BUT_PRESS | OS.Ph_EV_DRAG, ~0,
+// OS.Pt_ARG_FILL_COLOR, OS.Pg_TRANSPARENT, 0,
+ };
+ OS.PtSetParentWidget (0);
+ int handle = OS.PtCreateWidget (OS.PtRegion (), 0, args.length / 3, args);
+ OS.PtRealizeWidget (handle);
+ int rid = OS.PtWidgetRid (handle);
+ int input_group = OS.PhInputGroup (0);
+ PhRect_t rect1 = new PhRect_t ();
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle rect = rectangles [i];
+ PhRect_t rect2 = new PhRect_t ();
+ rect2.ul_x = (short) rect.x;
+ rect2.ul_y = (short) rect.y;
+ rect2.lr_x = (short) (rect.x + rect.width - 1);
+ rect2.lr_y = (short) (rect.y + rect.height - 1);
+ if (i == 0) rect1 = rect2;
+ OS.PhRectUnion (rect1, rect2);
+ }
+ rect1.ul_x = rect1.ul_y = 10;
+ rect1.lr_x = rect1.lr_y = 100;
+ int result = OS.PhInitDrag (rid, OS.Ph_DRAG_KEY_MOTION | OS.Ph_TRACK_DRAG, rect1, null, input_group, null, null, null, null /*pos*/, null);
+ return result == 0;
+}
+public void removeControlListener (ControlListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Move, listener);
+}
+public void setRectangles (Rectangle [] rectangles) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ this.rectangles = rectangles;
+}
+public void setStippled (boolean stippled) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.stippled = stippled;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java
new file mode 100755
index 0000000000..463f425b91
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Tree.java
@@ -0,0 +1,1469 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+import org.eclipse.swt.graphics.*;
+import java.io.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * Displays a hierarchy of items that can be selected.
+ * Sub hierarchies can be expanded and collapsed.
+ */
+public /*final*/ class Tree extends SelectableItemWidget {
+ // These constants are used internally for item hit test on mouse click
+ private static final int ActionNone = 0; // The mouse event was not handled
+ private static final int ActionExpandCollapse = 1; // Do an expand/collapse
+ private static final int ActionSelect = 2; // Select the item
+ private static final int ActionCheck = 3; // Toggle checked state of the item
+ private static ImageData CollapsedImageData; // collapsed sub tree image data. used to create an image at run time
+ private static ImageData ExpandedImageData; // expanded sub tree image data. used to create an image at run time
+ static {
+ initializeImageData();
+ }
+
+ private TreeRoots root;
+ private TreeItem expandingItem;
+
+ private Image collapsedImage;
+ private Image expandedImage;
+
+ // The following fields are needed for painting tree items
+ final Color CONNECTOR_LINE_COLOR; // Color constant used during painting. Can't keep this in TreeItem
+ // because we only need one instance per tree widget/display and can't
+ // have it static. Initialized in c'tor and freed in dispose();
+ Rectangle hierarchyIndicatorRect = null; // bounding rectangle of the hierarchy indication image (plus/minus)
+
+/**
+ * Create a new instance of the receiver with 'parent'
+ * as its parent widget.
+ */
+public Tree(Composite parent, int style) {
+ super(parent, checkStyle (style));
+ CONNECTOR_LINE_COLOR = new Color(getDisplay(), 170, 170, 170); // Light gray;
+}
+/**
+ * Add 'item' to the list of root items.
+ * @param 'item' - the tree item that should be added as a root.
+ * @param index - position that 'item' will be inserted at
+ * in the receiver.
+ */
+void addItem(TreeItem item, int index) {
+ if (index < 0 || index > getItemCount()) {
+ error(SWT.ERROR_INVALID_RANGE);
+ }
+ getRoot().add(item, index);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void addSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Selection, typedListener);
+ addListener(SWT.DefaultSelection, typedListener);
+}
+/**
+* Adds the listener to receive events.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void addTreeListener(TreeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TypedListener typedListener;
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ typedListener = new TypedListener(listener);
+ addListener(SWT.Expand, typedListener);
+ addListener(SWT.Collapse, typedListener);
+}
+/**
+ * The SelectableItem 'item' has been added to the tree.
+ * Prevent screen updates when 'item' is inserted due to an
+ * expand operation.
+ * @param item - item that has been added to the receiver.
+ */
+void addedItem(SelectableItem item, int index) {
+ super.addedItem(item, index);
+ redrawAfterModify(item, index); // redraw plus/minus image, hierarchy lines
+}
+/**
+ * Answer the y position of both the first child of 'item' and
+ * the item following the last child of 'item'.
+ * Used to scroll items on expand/collapse.
+ * @param item - TreeItem to use for calculating the y boundary
+ * of child items.
+ * @return Array - first element is the position of the first
+ * child of 'item'. Second element is the position of the item
+ * following the last child of 'item'.
+ * Both elements are -1 if 'item' is not a child of the receiver.
+ */
+int[] calculateChildrenYPos(TreeItem item) {
+ int itemIndex = item.getVisibleIndex();
+ int itemCount = item.getVisibleItemCount();
+ int itemHeight = getItemHeight();
+ int yPos;
+ int[] yPosition = new int[] {-1, -1};
+
+ if (itemIndex != -1) {
+ itemIndex -= getTopIndex();
+ yPos = (itemIndex + itemCount + 1) * itemHeight; // y position of the item following
+ // the last child of 'item'
+ yPosition = new int[] {yPos - (itemCount * itemHeight), yPos};
+ }
+ return yPosition;
+}
+/**
+ * Calculate the widest of the children of 'item'.
+ * Items that are off screen and that may be scrolled into view are
+ * included in the calculation.
+ * @param item - the tree item that was expanded
+ */
+void calculateWidestExpandingItem(TreeItem item) {
+ int itemIndex = item.getVisibleIndex();
+ int newMaximumItemWidth = getContentWidth();
+ int stopIndex = itemIndex + item.getVisibleItemCount();
+
+ for (int i = itemIndex + 1; i <= stopIndex; i++) {
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+/**
+ * Calculate the width of new items as they are scrolled into view.
+ * Precondition:
+ * topIndex has already been set to the new index.
+ * @param topIndexDifference - difference between old and new top
+ * index.
+ */
+void calculateWidestScrolledItem(int topIndexDifference) {
+ int visibleItemCount = getItemCountTruncated(getClientArea());
+ int newMaximumItemWidth = getContentWidth();
+ int topIndex = getTopIndex();
+ int stopIndex = topIndex;
+
+ if (topIndexDifference < 0) { // scrolled up?
+ if (Math.abs(topIndexDifference) > visibleItemCount) { // scrolled down more than one page (via quick thumb dragging)?
+ topIndexDifference = visibleItemCount * -1;
+ }
+ for (int i = stopIndex - topIndexDifference; i >= stopIndex; i--) { // check item width from old top index up to new one
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ }
+ else
+ if (topIndexDifference > 0) { // scrolled down?
+ if (topIndexDifference > visibleItemCount) { // scrolled down more than one page (via quick thumb dragging)?
+ topIndexDifference = visibleItemCount;
+ }
+ stopIndex += visibleItemCount;
+ for (int i = stopIndex - topIndexDifference; i < stopIndex; i++) {
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, getContentWidth(i));
+ }
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+/**
+ * Calculate the maximum item width of all displayed items.
+ */
+void calculateWidestShowingItem() {
+ TreeItem visibleItem;
+ int newMaximumItemWidth = 0;
+ int bottomIndex = getBottomIndex();
+ int paintStopX;
+
+ // add one to the loop end index because otherwise an item covered
+ // by the horizontal scroll bar would not be taken into acount and
+ // may become visible after this calculation. We're in trouble if
+ // that item is wider than the client area.
+ if (getHorizontalBar().getVisible() == true) {
+ bottomIndex++;
+ }
+ for (int i = getTopIndex(); i < bottomIndex; i++) {
+ visibleItem = getRoot().getVisibleItem(i);
+ if (visibleItem != null) {
+ paintStopX = visibleItem.getPaintStopX();
+ newMaximumItemWidth = Math.max(newMaximumItemWidth, paintStopX);
+ }
+ }
+ setContentWidth(newMaximumItemWidth);
+}
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Collapse the tree item identified by 'item' if it is not
+ * already collapsed. Move the selection to the parent item
+ * if one of the collapsed items is currently selected.
+ * @param item - item that should be collapsed.
+ * @param notifyListeners -
+ * true=a Collapse event is sent
+ * false=no event is sent
+ */
+void collapse(TreeItem item, boolean notifyListeners) {
+ Event event;
+ int itemIndex;
+
+ if (item.getExpanded() == false) {
+ return;
+ }
+ collapseNoRedraw(item);
+ itemIndex = item.getVisibleIndex();
+ if (itemIndex != -1) { // if the item's parent is not collapsed (and the item is thus visible) do the screen updates
+ item.redrawExpanded(itemIndex - getTopIndex());
+ showSelectableItem(item);
+ calculateVerticalScrollbar();
+ calculateWidestShowingItem();
+ claimRightFreeSpace();
+ claimBottomFreeSpace();
+ }
+ if (notifyListeners == true) {
+ event = new Event();
+ event.item = item;
+ notifyListeners(SWT.Collapse, event);
+ }
+}
+
+/**
+ * Collapse the tree item identified by 'item' if it is not
+ * already collapsed. Move the selection to the parent item
+ * if one of the collapsed items is currently selected.
+ * This method is used to hide the children if an item is deleted.
+ * certain redraw and scroll operations are not needed for this
+ * case.
+ * @param item - item that should be collapsed.
+ */
+void collapseNoRedraw(TreeItem item) {
+ int itemIndex;
+
+ if (item.getExpanded() == false) {
+ return;
+ }
+ if (isSelectedItemCollapsing(item) == true) {
+ deselectAllExcept(item);
+ selectNotify(item);
+ update(); // call update to make sure that new selection is
+ // drawn before items are collapsed (looks better)
+ }
+ scrollForCollapse(item);
+ item.internalSetExpanded(false);
+}
+
+/**
+ * Answer the size of the receiver needed to display all or
+ * the first 50 items whichever is less.
+ */
+public Point computeSize(int wHint, int hHint, boolean changed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Point size = super.computeSize(wHint, hHint, changed);
+ GC gc;
+ final int WidthCalculationCount = 50; // calculate item width for the first couple of items only
+ TreeRoots root = getRoot();
+ TreeItem item;
+ Image itemImage;
+ String itemText;
+ int width;
+ int newItemWidth = 0;
+
+ if (getContentWidth() == 0 && getItemCount() > 0) {
+ gc = new GC(this);
+ for (int i = 0; i < WidthCalculationCount; i++) {
+ item = root.getVisibleItem(i);
+ if (item == null) {
+ break; // no more items
+ }
+ itemImage = item.getImage();
+ itemText = item.getText();
+ width = 0;
+ if (itemImage != null) {
+ width += itemImage.getBounds().width;
+ }
+ if (itemText != null) {
+ width += gc.stringExtent(itemText).x;
+ }
+ newItemWidth = Math.max(newItemWidth, width);
+ }
+ if (newItemWidth > 0) {
+ size.x = newItemWidth;
+ }
+ gc.dispose();
+ }
+ return size;
+}
+/**
+ * Deselect all items of the receiver.
+ */
+public void deselectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ getRoot().deselectAll();
+ getSelectionVector().removeAllElements();
+ redraw();
+}
+/**
+ * Modifier Key Action
+ * None Collapse the selected item if expanded. Select
+ * parent item if selected item is already
+ * collapsed and if it's not the root item.
+ * Ctrl super.doArrowLeft(int);
+ * Shift see None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowLeft(int keyMask) {
+ TreeItem focusItem = (TreeItem) getLastFocus();
+ TreeItem parentItem;
+
+ if (focusItem == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ super.doArrowLeft(keyMask);
+ }
+ else
+ if (focusItem.getExpanded() == true) { // collapse if expanded
+ collapse(focusItem, true);
+ }
+ else
+ if (focusItem.isRoot() == false) { // go to the parent if there is one
+ parentItem = focusItem.getParentItem();
+ deselectAllExcept(parentItem);
+ selectNotify(parentItem);
+ }
+}
+/**
+ * Modifier Key Action
+ * None Expand selected item if collapsed. Select
+ * first child item if selected item is
+ * already expanded and there is a child item.
+ * Ctrl super.doArrowRight(keyMask);
+ * Shift see None above
+ * @param keyMask - the modifier key that was pressed
+ */
+void doArrowRight(int keyMask) {
+ TreeItem focusItem = (TreeItem) getLastFocus();
+ TreeItem childItem;
+
+ if (focusItem == null) {
+ return;
+ }
+ if (keyMask == SWT.CTRL) {
+ super.doArrowRight(keyMask);
+ }
+ else
+ if (focusItem.isLeaf() == false) {
+ if (focusItem.getExpanded() == false) { // expand if collapsed
+ expand(focusItem, true);
+ }
+ else { // go to the first child if there is one
+ childItem = focusItem.getItems()[0];
+ deselectAllExcept(childItem);
+ selectNotify(childItem);
+ }
+ }
+}
+/**
+ * Expand the selected item and all of its children.
+ */
+void doAsterix() {
+ expandAll((TreeItem) getLastFocus());
+}
+/**
+ * Free resources.
+ */
+void doDispose() {
+ super.doDispose();
+ if (collapsedImage != null) {
+ collapsedImage.dispose();
+ }
+ if (expandedImage != null) {
+ expandedImage.dispose();
+ }
+ getRoot().dispose();
+ CONNECTOR_LINE_COLOR.dispose();
+ resetHierarchyIndicatorRect();
+}
+/**
+ * Collapse the selected item if it is expanded.
+ */
+void doMinus() {
+ TreeItem selectedItem = (TreeItem) getLastFocus();
+
+ if (selectedItem != null) {
+ collapse(selectedItem, true);
+ }
+}
+/**
+ * Expand the selected item if it is collapsed and if it
+ * has children.
+ */
+void doPlus() {
+ TreeItem selectedItem = (TreeItem) getLastFocus();
+
+ if (selectedItem != null && selectedItem.isLeaf() == false) {
+ expand(selectedItem, true);
+ }
+}
+/**
+ * Expand the tree item identified by 'item' if it is not already
+ * expanded. Scroll the expanded items into view.
+ * @param item - item that should be expanded
+ * @param notifyListeners -
+ * true=an Expand event is sent
+ * false=no event is sent
+ */
+void expand(TreeItem item, boolean notifyListeners) {
+ Event event = new Event();
+ int indexFromTop;
+ boolean nestedExpand = expandingItem != null;
+
+ if (item.getExpanded() == true) {
+ return;
+ }
+ if (nestedExpand == false) {
+ setExpandingItem(item);
+ }
+ scrollForExpand(item);
+ item.internalSetExpanded(true);
+ if (notifyListeners == true) {
+ event.item = item;
+ notifyListeners(SWT.Expand, event);
+ }
+ // redraw hierarchy image
+ item.redrawExpanded(item.getVisibleIndex() - getTopIndex());
+ calculateVerticalScrollbar();
+ if (nestedExpand == false && isVisible() == true) {
+ // Save the index here because showSelectableItem may change it
+ indexFromTop = item.getVisibleIndex() - getTopIndex();
+ showSelectableItem(item); // make expanded item visible. Could be invisible if the expand was caused by a key press.
+ calculateWidestExpandingItem(item);
+ scrollExpandedItemsIntoView(item);
+ }
+ if (nestedExpand == false) {
+ setExpandingItem(null);
+ }
+}
+/**
+ * Expand 'item' and all its children.
+ */
+void expandAll(TreeItem item) {
+ TreeItem items[];
+
+ if (item != null && item.isLeaf() == false) {
+ expand(item, true);
+ update();
+ items = item.getItems();
+ for (int i = 0; i < items.length; i++) {
+ expandAll(items[i]);
+ }
+ }
+}
+/**
+ * Answer the image that is used as a hierarchy indicator
+ * for a collapsed hierarchy.
+ */
+Image getCollapsedImage() {
+ if (collapsedImage == null) {
+ collapsedImage = new Image(getDisplay(), CollapsedImageData);
+ }
+ return collapsedImage;
+}
+/**
+ * Answer the width of the item identified by 'itemIndex'.
+ */
+int getContentWidth(int itemIndex) {
+ TreeItem item = getRoot().getVisibleItem(itemIndex);
+ int paintStopX = 0;
+
+ if (item != null) {
+ paintStopX = item.getPaintStopX();
+ }
+ return paintStopX;
+}
+/**
+ * Answer the image that is used as a hierarchy indicator
+ * for an expanded hierarchy.
+ */
+Image getExpandedImage() {
+ if (expandedImage == null) {
+ expandedImage = new Image(getDisplay(), ExpandedImageData);
+ }
+ return expandedImage;
+}
+/**
+ * Answer the rectangle enclosing the hierarchy indicator of a tree item.
+ *
+ * Note:
+ * Assumes that the hierarchy indicators for expanded and
+ * collapsed state are the same size.
+ * @return
+ * The rectangle enclosing the hierarchy indicator.
+ */
+Rectangle getHierarchyIndicatorRect() {
+ int itemHeight = getItemHeight();
+ Image hierarchyImage;
+ Rectangle imageBounds;
+
+ if (hierarchyIndicatorRect == null && itemHeight != -1) {
+ hierarchyImage = getCollapsedImage();
+ if (hierarchyImage != null) {
+ imageBounds = hierarchyImage.getBounds();
+ }
+ else {
+ imageBounds = new Rectangle(0, 0, 0, 0);
+ }
+ hierarchyIndicatorRect = new Rectangle(
+ 0,
+ (itemHeight - imageBounds.height) / 2 + (itemHeight - imageBounds.height) % 2,
+ imageBounds.width,
+ imageBounds.height);
+ }
+ return hierarchyIndicatorRect;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ */
+int getIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null) {
+ index = ((TreeItem) item).getGlobalIndex();
+ }
+ return index;
+}
+/**
+ * Answer the number of root items.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return getRoot().getItemCount();
+}
+/**
+ * Answer the height of an item in the receiver.
+ * The item height is the greater of the item icon height and
+ * text height of the first item that has text or an image
+ * respectively.
+ * Calculate a default item height based on the font height if
+ * no item height has been calculated yet.
+ */
+public int getItemHeight() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemHeight();
+}
+/**
+ * Answer the root items of the receiver as an Array.
+ */
+public TreeItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TreeItem childrenArray[] = new TreeItem[getItemCount()];
+
+ getRoot().getChildren().copyInto(childrenArray);
+ return childrenArray;
+}
+/**
+ * Answer the number of sub items of 'item' that do not fit in the
+ * tree client area.
+ */
+int getOffScreenItemCount(TreeItem item) {
+ int itemIndexFromTop = item.getVisibleIndex() - getTopIndex();
+ int spaceRemaining = getItemCountWhole()-(itemIndexFromTop+1);
+ int expandedItemCount = item.getVisibleItemCount();
+
+ return expandedItemCount - spaceRemaining;
+}
+/**
+ * Answer the parent item of the receiver.
+ * This is null because the Tree widget does not have a parent item.
+ */
+public TreeItem getParentItem() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return null;
+}
+/**
+ * Answer the object that holds the root items of the receiver.
+ */
+TreeRoots getRoot() {
+ return root;
+}
+/**
+ * Answer the selected tree items.
+ * @return an Array of DrawnTreeItems containing the selected items.
+ * An empty Array if no items are selected.
+ */
+public TreeItem [] getSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selectionVector = getSelectionVector();
+ TreeItem[] selectionArray = new TreeItem[selectionVector.size()];
+
+ selectionVector.copyInto(selectionArray);
+ sort(selectionArray, 0, selectionArray.length);
+ return selectionArray;
+}
+/**
+ * Answer the index of 'item' in the receiver.
+ * Answer -1 if the item is not visible.
+ * The returned index must refer to a visible item.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Collapsed items are not visible.
+ */
+int getVisibleIndex(SelectableItem item) {
+ int index = -1;
+
+ if (item != null) {
+ index = ((AbstractTreeItem) item).getVisibleIndex();
+ }
+ return index;
+}
+/**
+ * Answer the SelectableItem located at 'itemIndex'
+ * in the receiver.
+ * @param itemIndex - location of the SelectableItem
+ * object to return
+ */
+SelectableItem getVisibleItem(int itemIndex) {
+ return getRoot().getVisibleItem(itemIndex);
+}
+/**
+ * Answer the number of visible items of the receiver.
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. It only means that the item
+ * would be displayed if it is located inside the receiver's
+ * client area.
+ * Collapsed items are not visible.
+ */
+int getVisibleItemCount() {
+ return getRoot().getVisibleItemCount();
+}
+/**
+ * Answer the y coordinate at which 'item' is drawn.
+ * @param item - SelectableItem for which the paint position
+ * should be returned
+ * @return the y coordinate at which 'item' is drawn.
+ * Return -1 if 'item' is null or outside the client area
+ */
+int getVisibleRedrawY(SelectableItem item) {
+ int redrawY = getRedrawY(item);
+
+ if (redrawY < 0 || redrawY > getClientArea().height) {
+ redrawY = -1;
+ }
+ return redrawY;
+}
+/**
+ * Handle the events the receiver is listening to.
+ */
+void handleEvents(Event event) {
+ switch (event.type) {
+ case SWT.Paint:
+ paint(event);
+ break;
+ case SWT.MouseDown:
+ mouseDown(event);
+ break;
+ case SWT.MouseDoubleClick:
+ mouseDoubleClick(event);
+ break;
+ default:
+ super.handleEvents(event);
+ }
+}
+/**
+ * Initialize the receiver.
+ */
+void initialize() {
+ resetRoot(); // has to be at very top because super class uses
+ // functionality that relies on the TreeRoots object
+ super.initialize();
+}
+/**
+ * Initialize the ImageData used for the expanded/collapsed images.
+ */
+static void initializeImageData() {
+ PaletteData fourBit = new PaletteData(
+ new RGB[] {new RGB(0, 0, 0), new RGB (128, 0, 0), new RGB (0, 128, 0), new RGB (128, 128, 0), new RGB (0, 0, 128), new RGB (128, 0, 128), new RGB (0, 128, 128), new RGB (128, 128, 128), new RGB (192, 192, 192), new RGB (255, 0, 0), new RGB (0, 255, 0), new RGB (255, 255, 0), new RGB (0, 0, 255), new RGB (255, 0, 255), new RGB (0, 255, 255), new RGB (255, 255, 255)});
+
+ CollapsedImageData = new ImageData(
+ 9, 9, 4, // width, height, depth
+ fourBit, 4,
+ new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, 15, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});
+ CollapsedImageData.transparentPixel = 15; // use white for transparency
+ ExpandedImageData = new ImageData(
+ 9, 9, 4, // width, height, depth
+ fourBit, 4,
+ new byte[] {119, 119, 119, 119, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, 0, 0, 15, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 127, -1, -1, -1, 112, 0, 0, 0, 119, 119, 119, 119, 112, 0, 0, 0});
+ ExpandedImageData.transparentPixel = 15; // use white for transparency
+}
+/**
+ * Set event listeners for the receiver.
+ */
+void installListeners() {
+ Listener listener = getListener();
+
+ super.installListeners();
+ addListener(SWT.Paint, listener);
+ addListener(SWT.MouseDown, listener);
+ addListener(SWT.MouseDoubleClick, listener);
+}
+/**
+ * Answer whether the receiver is currently expanding a sub tree
+ * with 'item' in it.
+ * Used for performance optimizations.
+ */
+boolean isExpandingItem(SelectableItem item) {
+ TreeItem parentItem;
+
+ if (expandingItem == null || item == null || (item instanceof TreeItem) == false) {
+ return false;
+ }
+ parentItem = ((TreeItem) item).getParentItem();
+ return (parentItem == expandingItem || isExpandingItem(parentItem));
+}
+/**
+ * Answer whether the children of 'collapsingItem' contain
+ * at least one selected item.
+ */
+boolean isSelectedItemCollapsing(TreeItem collapsingItem) {
+ Enumeration selection = getSelectionVector().elements();
+ TreeItem item;
+ int selectedItemIndex;
+ int collapsingItemIndex = collapsingItem.getVisibleIndex();
+ int lastCollapsedItemIndex = collapsingItemIndex + collapsingItem.getVisibleItemCount();
+
+ if (collapsingItemIndex == -1) { // is the collapsing item in a collapsed subtree?
+ return false; // then neither it nor its children are selected
+ }
+ while (selection.hasMoreElements() == true) {
+ item = (TreeItem) selection.nextElement();
+ selectedItemIndex = item.getVisibleIndex();
+ if ((selectedItemIndex > collapsingItemIndex) &&
+ (selectedItemIndex <= lastCollapsedItemIndex)) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Test whether the mouse click specified by 'event' was a
+ * valid selection or expand/collapse click.
+ * @return
+ * One of ActionExpandCollapse, ActionSelect, ActionNone, ActionCheck
+ * specifying the action to be taken on the click.
+ */
+int itemAction(TreeItem item, int x, int y) {
+ int action = ActionNone;
+ int itemHeight = getItemHeight();
+ int offsetX;
+ int offsetY;
+ Point offsetPoint;
+
+ if (item != null) {
+ offsetX = x - item.getPaintStartX();
+ offsetY = y - itemHeight * (y / itemHeight);
+ offsetPoint = new Point(offsetX, offsetY);
+ if ((item.isLeaf() == false) &&
+ (getHierarchyIndicatorRect().contains(offsetPoint) == true)) {
+ action |= ActionExpandCollapse;
+ }
+ else
+ if (item.isSelectionHit(offsetPoint) == true) {
+ action |= ActionSelect;
+ }
+ else
+ if (item.isCheckHit(new Point(x, y)) == true) {
+ action |= ActionCheck;
+ }
+ }
+ return action;
+}
+/**
+ * The table item 'changedItem' has changed. Redraw the whole
+ * item in that column. Include the text in the redraw because
+ * an image set to null requires a redraw of the whole item anyway.
+ */
+void itemChanged(SelectableItem changedItem, int repaintStartX, int repaintWidth) {
+ int oldItemHeight = getItemHeight();
+ Point oldImageExtent = getImageExtent();
+
+ if (isExpandingItem(changedItem) == false) {
+ super.itemChanged(changedItem, repaintStartX, repaintWidth);
+ }
+ else {
+ calculateItemHeight(changedItem);
+ }
+ if ((oldItemHeight != getItemHeight()) || // only reset items if the item height or
+ (oldImageExtent != getImageExtent())) { // image size has changed. The latter will only change once,
+ // from null to a value-so it's safe to test using !=
+ getRoot().reset(); // reset cached data of all items in the receiver
+ resetHierarchyIndicatorRect();
+ redraw(); // redraw all items if the image extent has changed. Fixes 1FRIHPZ
+ }
+ else {
+ ((AbstractTreeItem) changedItem).reset(); // reset the item that has changed when the tree item
+ // height has not changed (otherwise the item caches old data)
+ // Fixes 1FF6B42
+ }
+ if (repaintWidth != 0) {
+ calculateWidestShowingItem();
+ claimRightFreeSpace(); // otherwise scroll bar may be reset, but not horizontal offset
+ // Fixes 1G4SBJ3
+ }
+}
+/**
+ * A key was pressed.
+ * Call the appropriate key handler method.
+ * @param event - the key event
+ */
+void keyDown(Event event) {
+ super.keyDown(event);
+ switch (event.character) {
+ case '+':
+ doPlus();
+ break;
+ case '-':
+ doMinus();
+ break;
+ case '*':
+ doAsterix();
+ break;
+ }
+}
+
+/**
+ * A mouse double clicked occurred over the receiver.
+ * Expand/collapse the clicked item. Do nothing if no item was clicked.
+ */
+void mouseDoubleClick(Event event) {
+ int hitItemIndex = event.y / getItemHeight();
+ TreeItem hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ Event newEvent;
+
+ if (hitItem == null) {
+ return;
+ }
+ if (hooks(SWT.DefaultSelection) == true) {
+ newEvent = new Event();
+ newEvent.item = hitItem;
+ notifyListeners(SWT.DefaultSelection, newEvent);
+ return;
+ }
+ if (hitItem.getItemCount() == 0) {
+ return; // an item was hit but it does not have children
+ }
+ if (itemAction(hitItem, event.x, event.y) == ActionSelect) {
+ if (hitItem.getExpanded() == true) {
+ collapse(hitItem, true);
+ }
+ else {
+ expand(hitItem, true);
+ }
+ }
+}
+/**
+ * The mouse pointer was pressed down on the receiver.
+ * Handle the event according to the position of the mouse click.
+ */
+void mouseDown(Event event) {
+ int hitItemIndex;
+ TreeItem hitItem;
+ SelectableItem selectionItem = getLastSelection();
+ int itemAction;
+
+ if (event.button != 1) { // only react to button one clicks.
+ return;
+ }
+ hitItemIndex = event.y / getItemHeight();
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem == null) {
+ return;
+ }
+ switch (itemAction = itemAction(hitItem, event.x, event.y)) {
+ case ActionExpandCollapse:
+ if (hitItem.getExpanded() == true) {
+ collapse(hitItem, true);
+ }
+ else {
+ expand(hitItem, true);
+ }
+ break;
+ case ActionSelect:
+ doMouseSelect(hitItem, hitItemIndex + getTopIndex(), event.stateMask, event.button);
+ break;
+ case ActionCheck:
+ doCheckItem(hitItem);
+ break;
+ }
+ if (itemAction != ActionSelect && selectionItem == null) {
+ selectionItem = getRoot().getVisibleItem(getTopIndex()); // select the top item if no item was selected before
+ selectNotify(selectionItem);
+ }
+}
+/**
+ * A paint event has occurred. Display the invalidated items.
+ * @param event - expose event specifying the invalidated area.
+ */
+void paint(Event event) {
+ int visibleRange[] = getIndexRange(event.getBounds());
+
+ paintItems(event.gc, visibleRange[0], visibleRange[1] + 1); // + 1 to paint the vertical line
+ // connection the last item we really
+ // want to paint with the item after that.
+}
+/**
+ * Paint tree items on 'gc' starting at index 'topPaintIndex' and
+ * stopping at 'bottomPaintIndex'.
+ * @param gc - GC to draw tree items on.
+ * @param topPaintIndex - index of the first item to draw
+ * @param bottomPaintIndex - index of the last item to draw
+ */
+void paintItems(GC gc, int topPaintIndex, int bottomPaintIndex) {
+ TreeItem visibleItem;
+ int itemHeight = getItemHeight();
+
+ for (int i = topPaintIndex; i <= bottomPaintIndex; i++) {
+ visibleItem = getRoot().getVisibleItem(i + getTopIndex());
+ if (visibleItem != null) {
+ visibleItem.paint(gc, i * itemHeight);
+ }
+ }
+}
+/**
+ * 'item' has been added to or removed from the receiver.
+ * Repaint part of the tree to update the vertical hierarchy
+ * connectors and hierarchy image.
+ * @param modifiedItem - the added/removed item
+ * @param modifiedIndex - index of the added/removed item
+ */
+void redrawAfterModify(SelectableItem modifiedItem, int modifiedIndex) {
+ int redrawStartY;
+ int redrawStopY;
+ int itemChildIndex = ((TreeItem) modifiedItem).getIndex();
+ int topIndex = getTopIndex();
+ int itemHeight = getItemHeight();
+ int redrawItemIndex;
+ int itemCount;
+ AbstractTreeItem parentItem = ((TreeItem) modifiedItem).getParentItem();
+ AbstractTreeItem redrawItem = null;
+
+ if (redrawParentItem(modifiedItem) == false) {
+ return;
+ }
+ if (parentItem == null) { // a root item is added/removed
+ parentItem = getRoot();
+ }
+ itemCount = parentItem.getItemCount();
+ // redraw hierarchy decorations of preceeding item if the last item at a tree
+ // level was added/removed
+ // otherwise, if the first item was removed, redraw the parent to update hierarchy icon
+ if (itemChildIndex > 0) { // more than one item left at this tree level
+ // added/removed last item at this tree level? have to test >=.
+ // when removing last item, item index is outside itemCount
+ if (itemChildIndex >= itemCount - 1) {
+ redrawItem = (AbstractTreeItem) parentItem.getChildren().elementAt(itemChildIndex - 1);
+ }
+ }
+ else
+ if (getVisibleItemCount() > 0 && itemCount < 2) { // last item at this level removed/first item added?
+ redrawItem = parentItem; // redraw parent item to update hierarchy icon
+ }
+ if (redrawItem != null) {
+ redrawItemIndex = redrawItem.getVisibleIndex();
+ if (modifiedIndex == -1) {
+ modifiedIndex = redrawItemIndex + 1;
+ }
+ redrawStartY = (redrawItemIndex - topIndex) * itemHeight;
+ redrawStopY = (modifiedIndex - topIndex) * itemHeight;
+ redraw(
+ 0,
+ redrawStartY,
+ redrawItem.getCheckboxXPosition(), // only redraw up to and including hierarchy icon to avoid flashing
+ redrawStopY - redrawStartY, false);
+ }
+ if (modifiedIndex == 0) { // added/removed first item ?
+ redraw(0, 0, getClientArea().width, getItemHeight() * 2, false);// redraw new first two items to
+ // fix vertical hierarchy line
+ }
+}
+
+/**
+ * Determine if part of the tree hierarchy needs to be redrawn.
+ * The hierarchy icon of the parent item of 'item' needs to be redrawn if
+ * 'item' is added as the first child or removed as the last child.
+ * Hierarchy lines need to be redrawn if 'item' is the last in a series of
+ * children.
+ * @param item - tree item that is added or removed.
+ * @return true=tree hierarchy needs to be redrawn. false=no redraw necessary
+ */
+boolean redrawParentItem(SelectableItem item) {
+ TreeItem parentItem = ((TreeItem) item).getParentItem();
+ TreeItem parentItem2;
+ boolean redraw = false;
+
+ // determine if only the hierarchy icon needs to be redrawn
+ if (parentItem != null) {
+ parentItem2 = parentItem.getParentItem();
+ if ((parentItem2 == null || parentItem2.getExpanded() == true) && parentItem.getChildren().size() < 2) {
+ redraw = true;
+ }
+ }
+ // redraw is only neccessary when the receiver is not currently
+ // expanding 'item' or a parent item or if the parent item is expanded
+ // or if the hierarchy icon of the parent item needs to be redrawn
+ if (isExpandingItem(item) == false && parentItem == null || parentItem.getExpanded() == true || redraw == true) {
+ redraw = true;
+ }
+ else {
+ redraw = false;
+ }
+ return redraw;
+}
+
+/**
+ * Remove all items of the receiver.
+ */
+public void removeAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ setRedraw(false);
+ getRoot().dispose();
+ resetRoot();
+ reset();
+ calculateWidestShowingItem();
+ calculateVerticalScrollbar();
+ setRedraw(true);
+}
+/**
+ * Remove 'item' from the receiver.
+ * @param item - tree item that should be removed from the
+ * receiver-must be a root item.
+ */
+void removeItem(TreeItem item) {
+ getRoot().removeItem(item);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeSelectionListener(SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener (SWT.Selection, listener);
+ removeListener (SWT.DefaultSelection, listener);
+}
+/**
+* Removes the listener.
+* <p>
+*
+* @param listener the listener
+*
+*/
+public void removeTreeListener(TreeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (listener == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ removeListener (SWT.Expand, listener);
+ removeListener (SWT.Collapse, listener);
+}
+/**
+ * 'item' has been removed from the receiver.
+ * Recalculate the content width.
+ */
+void removedItem(SelectableItem item) {
+ if (isExpandingItem(item) == false) {
+ super.removedItem(item);
+ }
+ calculateWidestShowingItem();
+ claimRightFreeSpace();
+}
+/**
+ * Notification that 'item' is about to be removed from the tree.
+ * Update the item selection if neccessary.
+ * @param item - item that is about to be removed from the tree.
+ */
+void removingItem(SelectableItem item) {
+ Vector selection = getSelectionVector();
+ TreeItem parentItem = ((TreeItem) item).getParentItem();
+ TreeItem newSelectionItem = null;
+ boolean isLastSelected = (selection.size() == 1) && (selection.elementAt(0) == item);
+ int itemIndex = getVisibleIndex(item);
+
+ if (isLastSelected == true) {
+ // try selecting the following item
+ newSelectionItem = (TreeItem) getVisibleItem(itemIndex + 1);
+ if (newSelectionItem == null || newSelectionItem.getParentItem() != parentItem) {
+ // select parent item if there is no item following the removed
+ // one on the same tree level
+ newSelectionItem = parentItem;
+ }
+ if (newSelectionItem != null) {
+ selectNotify(newSelectionItem);
+ }
+ }
+ super.removingItem(item);
+ if (isExpandingItem(item) == false) {
+ // redraw plus/minus image, hierarchy lines,
+ // redrawing here assumes that no update happens between now and
+ // after the item has actually been removed. Otherwise this call
+ // would need to be in removedItem and we would need to store the
+ // "itemIndex" here to redraw correctly.
+ redrawAfterModify(item, itemIndex);
+ }
+}
+/**
+ * Reset the rectangle enclosing the hierarchy indicator to null.
+ * Forces a recalculation next time getHierarchyIndicatorRect is called.
+ */
+void resetHierarchyIndicatorRect() {
+ hierarchyIndicatorRect = null;
+}
+/**
+ * Reset state that is dependent on or calculated from the items
+ * of the receiver.
+ */
+void resetItemData() {
+ setContentWidth(0);
+ resetHierarchyIndicatorRect();
+ super.resetItemData();
+}
+/**
+ * Reset the object holding the root items of the receiver.
+ */
+void resetRoot() {
+ root = new TreeRoots(this);
+}
+/**
+ * The receiver has been resized. Recalculate the content width.
+ */
+void resize(Event event) {
+ int oldItemCount = getVerticalBar().getPageIncrement();
+
+ super.resize(event);
+ if (getItemCountWhole() > oldItemCount) { // window resized higher?
+ calculateWidestShowingItem(); // recalculate widest item since a longer item may be visible now
+ }
+}
+/**
+ * Display as many expanded tree items as possible.
+ * Scroll the last expanded child to the bottom if all expanded
+ * children can be displayed.
+ * Otherwise scroll the expanded item to the top.
+ * @param item - the tree item that was expanded
+ */
+void scrollExpandedItemsIntoView(TreeItem item) {
+ int itemCountOffScreen = getOffScreenItemCount(item);
+ int newTopIndex = getTopIndex() + itemCountOffScreen;
+
+ if (itemCountOffScreen > 0) {
+ newTopIndex = Math.min(item.getVisibleIndex(), newTopIndex); // make sure the expanded item is never scrolled out of view
+ setTopIndex(newTopIndex, true);
+ }
+}
+/**
+ * Scroll the items following the children of 'collapsedItem'
+ * below 'collapsedItem' to cover the collapsed children.
+ * @param collapsedItem - item that has been collapsed
+ */
+void scrollForCollapse(TreeItem collapsedItem) {
+ Rectangle clientArea = getClientArea();
+ int topIndex = getTopIndex();
+ int itemCount = collapsedItem.getVisibleItemCount();
+ int scrollYPositions[] = calculateChildrenYPos(collapsedItem);
+
+ if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {
+ return;
+ }
+ if (topIndex + getItemCountWhole() == getVisibleItemCount() && itemCount < topIndex) {
+ // scroll from top if last item is at bottom and will stay at
+ // bottom after collapse. Avoids flash caused by too much bit
+ // blitting (which force update and thus premature redraw)
+ int height = scrollYPositions[1] - scrollYPositions[0];
+ scroll(
+ 0, 0, // destination x, y
+ 0, -height, // source x, y
+ clientArea.width, scrollYPositions[0]+height, true);
+ setTopIndexNoScroll(topIndex - itemCount, true);
+ }
+ else {
+ scroll(
+ 0, scrollYPositions[0], // destination x, y
+ 0, scrollYPositions[1], // source x, y
+ clientArea.width, clientArea.height - scrollYPositions[0], true);
+ }
+}
+/**
+ * Scroll the items following 'expandedItem' down to make
+ * space for the children of 'expandedItem'.
+ * @param expandedItem - item that has been expanded.
+ */
+void scrollForExpand(TreeItem expandedItem) {
+ int scrollYPositions[];
+ Rectangle clientArea = getClientArea();
+
+ expandedItem.internalSetExpanded(true);
+ scrollYPositions = calculateChildrenYPos(expandedItem);
+ expandedItem.internalSetExpanded(false);
+ if (scrollYPositions[0] == -1 && scrollYPositions[1] == -1) {
+ return;
+ }
+ scroll(
+ 0, scrollYPositions[1], // destination x, y
+ 0, scrollYPositions[0], // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll horizontally by 'numPixel' pixel.
+ * @param numPixel - the number of pixel to scroll
+ * < 0 = columns are going to be moved left.
+ * > 0 = columns are going to be moved right.
+ */
+void scrollHorizontal(int numPixel) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ numPixel, 0, // destination x, y
+ 0, 0, // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Scroll vertically by 'scrollIndexCount' items.
+ * @param scrollIndexCount - the number of items to scroll.
+ * scrollIndexCount > 0 = scroll up. scrollIndexCount < 0 = scroll down
+ */
+void scrollVertical(int scrollIndexCount) {
+ Rectangle clientArea = getClientArea();
+
+ scroll(
+ 0, 0, // destination x, y
+ 0, scrollIndexCount * getItemHeight(), // source x, y
+ clientArea.width, clientArea.height, true);
+}
+/**
+ * Select all items of the receiver if it is in multiple
+ * selection mode.
+ * A SWT.Selection event will not be sent.
+ * Do nothing if the receiver is in single selection mode.
+ */
+public void selectAll() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Vector selection = getSelectionVector();
+
+ if (isMultiSelect() == true) {
+ selection = getRoot().selectAll(selection);
+ setSelectionVector(selection);
+ }
+}
+/**
+ * Set the item that is currently being expanded to 'item'.
+ * Used for performance optimizations.
+ */
+void setExpandingItem(TreeItem item) {
+ expandingItem = item;
+}
+/**
+ * The font is changing. Reset and recalculate the item
+ * height using all items of the receiver.
+ */
+public void setFont(Font font) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Stack children = new Stack(); // traverse the tree depth first
+ Enumeration elements;
+ AbstractTreeItem item;
+
+ if (font != null && font.equals(getFont()) == true) {
+ return;
+ }
+ setRedraw(false); // disable redraw because itemChanged() triggers undesired redraw
+ resetItemData();
+ super.setFont(font);
+
+ // Call itemChanged for all tree items
+ elements = getRoot().getChildren().elements();
+ while (elements.hasMoreElements() == true) {
+ children.push(elements.nextElement());
+ }
+ while (children.empty() == false) {
+ item = (AbstractTreeItem) children.pop();
+ itemChanged(item, 0, getClientArea().width);
+ elements = item.getChildren().elements();
+ while (elements.hasMoreElements() == true) {
+ children.push(elements.nextElement());
+ }
+ }
+ setRedraw(true); // re-enable redraw
+}
+/**
+ * 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.
+ * <p>
+ * @param item the insert item. Null will clear the insertion mark.
+ * @param after true places the insert mark above 'item'. false places
+ * the insert mark below 'item'.
+ */
+public void setInsertMark(TreeItem item, boolean before){
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ motif_setInsertMark(item, !before);
+}
+/**
+ * Select the items stored in 'selectionItems'.
+ * A SWT.Selection event is not going to be sent.
+ * @param selectionItems - Array containing the items that should
+ * be selected
+ */
+public void setSelection(TreeItem selectionItems[]) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (selectionItems == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ setSelectableSelection(selectionItems);
+}
+/**
+ * Set the index of the first visible item in the tree client area
+ * to 'index'.
+ * Scroll the new top item to the top of the tree.
+ * @param index - 0-based index of the first visible item in the
+ * tree's client area.
+ * @param adjustScrollbar -
+ * true = the vertical scroll bar is set to reflect the new top index.
+ * false = the vertical scroll bar position is not modified.
+ */
+void setTopIndex(int index, boolean adjustScrollbar) {
+ int indexDiff = index-getTopIndex();
+
+ super.setTopIndex(index, adjustScrollbar);
+ calculateWidestScrolledItem(indexDiff);
+}
+/**
+ * Make 'item' visible by expanding its parent items and scrolling
+ * it into the receiver's client area if necessary.
+ * An SWT.Expand event is going to be sent for every parent item
+ * that is expanded to make 'item' visible.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+public void showItem(TreeItem item) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (item == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ showSelectableItem(item);
+}
+/**
+ * Make 'item' visible by expanding its parent items and scrolling
+ * it into the receiver's client area if necessary.
+ * An SWT.Expand event is going to be sent for every parent item
+ * that is expanded to make 'item' visible.
+ * @param item - the item that should be made visible to the
+ * user.
+ */
+void showSelectableItem(SelectableItem item) {
+ if (item.getSelectableParent() != this) {
+ return;
+ }
+ if (((TreeItem) item).isVisible() == false) {
+ ((TreeItem) item).makeVisible();
+ }
+ super.showSelectableItem(item);
+}
+/**
+ * Return the item at the specified location in the widget.
+ * Return null if there is no item at the specified location
+ * or if the location is outside the widget client area.
+ */
+public TreeItem getItem(Point point) {
+ int itemHeight;
+ int hitItemIndex;
+ TreeItem hitItem;
+
+ if (getClientArea().contains(point) == false) {
+ return null;
+ }
+ itemHeight = getItemHeight();
+ hitItemIndex = point.y / itemHeight;
+ hitItem = getRoot().getVisibleItem(hitItemIndex + getTopIndex());
+ if (hitItem != null) {
+ point.x -= hitItem.getPaintStartX();
+ point.y -= itemHeight * hitItemIndex;
+ if (hitItem.isSelectionHit(point) == false) {
+ hitItem = null;
+ }
+ }
+ return hitItem;
+}
+/**
+ * Answer the number of selected items in the receiver.
+ */
+public int getSelectionCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getSelectionCount();
+}
+/**
+ * Show the selection. If there is no selection or the
+ * selection is already visible, this method does nothing.
+ * If the selection is not visible, the top index of the
+ * widget is changed such that the selection becomes visible.
+ */
+public void showSelection() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.showSelection();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
new file mode 100755
index 0000000000..cb0aba6a89
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeItem.java
@@ -0,0 +1,1146 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class represents leaf, non-leaf and root tree items.
+ * leaf items don't have any children. non-leaf items have one
+ * or more children.
+ * Root items don't have a parent item. Root items are either
+ * leaf or non-leaf items.
+ *
+ * This class caches geometrical data for drawing..
+ * A description of the cached data follows:
+ *
+ * | 1 || 5 |
+ * | 2 | | 6 |
+ * |3 7|
+ * _____ | 4 |f| |8
+ * | | ____
+ * | - | ===== {image} root 9
+ * |_____| |
+ * |b|c| |d|
+ * | e |
+ *
+ * Widths are measured between vertical lines.
+ *
+ * Cached item rendering data:
+ * 1 = getDecorationsWidth
+ * 2 = getHierarchyIndicatorRect
+ * 3 = getPaintStartX
+ * 4 = getItemConnectorWidth
+ * 5 = getItemWidth
+ * 6 = getSelectionWidth
+ * 7 = getPaintStopX
+ * 8 - getTextXPos
+ * 9 = getTextYPosition
+ *
+ * Rendering constants:
+ * 4 = DEFAULT_ITEM_CONNECTOR_WIDTH, used when no image is set in the tree.
+ * Otherwise it is the image width.
+ * b = IMAGE_PADDING
+ * c = TEXT_INDENT
+ * d = SELECTION_PADDING
+ * e = ITEM_NOIMAGE_OFFSET
+ * f = ITEM_CONNECTOR_PADDING;
+
+ */
+public /*final*/ class TreeItem extends AbstractTreeItem {
+ private static final int DEFAULT_ITEM_CONNECTOR_WIDTH = 8; // Default width of the horizontal line connecting
+ // items with the vertical lines. Only used when
+ // no image is set in the tree. Normally connector
+ // line width is half the image width.
+ private static final int ITEM_CONNECTOR_PADDING = 2; // Added to the calculated item connector width
+ private static final int IMAGE_PADDING = 3; // Space behind bitmap
+ private static final int ITEM_NOIMAGE_OFFSET = 8; // Offset added to the calculated paint position where
+ // an item starts drawing. To be used when no item
+ // image has been set. Otherwise children would start
+ // drawing at the end of the horizontal item connector
+ // of their parent.
+ private static final int ROOT_INDENT = 5; // Indent of root items
+ private static final int SELECTION_PADDING = 2; // Space behind text
+ private static final int TEXT_INDENT = 2; // Identation of the item label
+
+ // basic item info
+ private TreeItem parentItem;
+ private int index; // index in the parent item
+
+ // geometrical item info
+ private int paintStartX = -1; // X coordinate of the upper-left corner of the
+ // receivers bounding rectangle
+ private Point itemExtent; // Size of the item (image + label)
+ private Point imageExtent; // original size of the item image
+ private int textYPosition = -1; // Centered y position of the item text
+/**
+ * Create a root item and add it to the tree widget identified
+ * by 'parent'.
+ * @param parent - Tree widget the receiver is added to
+ * @param swtStyle - widget style. see Widget class for details
+ */
+public TreeItem(Tree parent, int swtStyle) {
+ this(parent, swtStyle, checkNull(parent).getItemCount());
+}
+/**
+ * Create a root item and add it to the tree widget identified
+ * by 'parent'.
+ * @param parent - Tree widget the receiver is added to.
+ * @param swtStyle - widget style. see Widget class for details
+ * @param position - position in 'parentItem' the receiver will
+ * be inserted at
+ */
+public TreeItem(Tree parent, int swtStyle, int position) {
+ super(parent, swtStyle);
+ parent.addItem(this, position);
+}
+/**
+ * Create a root item with 'parentItem' as the parent item.
+ * @param parentItem - the parent item of the receiver
+ * @param swtStyle - widget style. see Widget class for details
+ */
+public TreeItem(TreeItem parentItem, int swtStyle) {
+ this(parentItem, swtStyle, checkNull(parentItem).getItemCount());
+}
+/**
+ * Create a root item with 'parentItem' as the parent item.
+ * @param parentItem - the parent item of the receiver
+ * @param swtStyle - widget style. see Widget class for details
+ * @param position - position in 'parentItem' the receiver will
+ * be inserted at
+ */
+public TreeItem(TreeItem parentItem, int swtStyle, int position) {
+ super(checkNull(parentItem).getParent(), swtStyle);
+ setParentItem(parentItem);
+ parentItem.add(this, position);
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+void calculateVisibleItemCount() {
+ Vector children;
+ TreeItem child;
+ int visibleItemCount = 0;
+
+ // check isExpanded field directly for performance
+ if (internalGetExpanded() == true) {
+ children = getChildren();
+ visibleItemCount = children.size();
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ visibleItemCount += child.getVisibleItemCount();
+ }
+ }
+ setVisibleItemCount(visibleItemCount);
+ calculateVisibleItemCountParent();
+}
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+void calculateVisibleItemCountParent() {
+ TreeItem parentItem = getParentItem();
+
+ if (parentItem != null) {
+ parentItem.calculateVisibleItemCount();
+ }
+ else {
+ getParent().getRoot().calculateVisibleItemCount();
+ }
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'tree' is null.
+ * Otherwise return 'tree'
+ */
+static Tree checkNull(Tree tree) {
+ if (tree == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return tree;
+}
+/**
+ * Throw an SWT.ERROR_NULL_ARGUMENT exception if 'item' is null.
+ * Otherwise return 'item'
+ */
+static TreeItem checkNull(TreeItem item) {
+ if (item == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+/**
+ * Notify the parent that the receiver is being removed.
+ * Reset cached data.
+ */
+void doDispose() {
+ TreeItem parentItem = getParentItem();
+
+ if (parentItem != null) {
+ parentItem.removeItem(this);
+ }
+ else {
+ getParent().removeItem(this);
+ }
+ setParentItem(null);
+ setImageExtent(null);
+ setItemExtent(null);
+ setIndex(-1);
+ setPaintStartX(-1);
+ setTextYPosition(-1);
+}
+/**
+ * Draw the hierarchy indicator at 'position'.
+ *
+ * Note:
+ * Assumes that the hierarchy indicators for the expanded and
+ * collapsed state are the same size.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawHierarchyIndicator(GC gc, Point position) {
+ Tree parent = getParent();
+ Image hierarchyImage;
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int x = position.x;
+ int y = position.y;
+ int yCenter = y + parent.getItemHeight() / 2;
+ Point connectorLinePosition;
+
+ if (isLeaf() == false) {
+ if (getExpanded() == true) {
+ hierarchyImage = parent.getExpandedImage();
+ }
+ else {
+ hierarchyImage = parent.getCollapsedImage();
+ }
+ if (hierarchyImage != null) {
+ gc.drawImage(hierarchyImage, x + indicatorRectangle.x, y + indicatorRectangle.y);
+ }
+ connectorLinePosition = new Point(x + indicatorRectangle.width, yCenter);
+ }
+ else {
+ connectorLinePosition = new Point(
+ x + indicatorRectangle.width / 2
+ + indicatorRectangle.width % 2, yCenter); // % 2 in order to not start the next hierarchy
+ // component at the middle of the icon but after.
+ }
+ return connectorLinePosition;
+}
+/**
+ * Draw a horizontal line connecting the item image (or label
+ * if there is no image) to the vertical line connecting to
+ * the parent.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawHorizontalItemConnector(GC gc, Point position) {
+ int itemConnectorEndPos = position.x + getItemConnectorWidth() - 1; // -1 because the position of the last pixel needs to be calculated
+
+ gc.drawLine(position.x, position.y, itemConnectorEndPos, position.y);
+ return new Point(itemConnectorEndPos + 1, position.y); // + 1 in order to resume drawing after line not on end of line
+}
+/**
+ * Display the item image at 'position' using 'gc'.
+ * @param gc - GC to draw on
+ * @param position - position on the GC to draw at
+ * @return position to continue drawing
+ */
+Point drawImage(GC gc, Point destinationPosition) {
+ Tree parent = getParent();
+ Image image = getImage();
+ Point sourceImageExtent;
+ Point destinationImageExtent = parent.getImageExtent();
+ int yCenter;
+
+ if (image != null) {
+ sourceImageExtent = getImageExtent();
+ yCenter = (parent.getItemHeight() - destinationImageExtent.y) / 2;
+ gc.drawImage(
+ image,
+ 0, 0, // source x, y
+ sourceImageExtent.x, sourceImageExtent.y, // source width, height
+ destinationPosition.x, destinationPosition.y + yCenter, // destination x, y
+ destinationImageExtent.x, destinationImageExtent.y); // destination width, height
+ }
+ if (destinationImageExtent != null) {
+ destinationPosition.x += destinationImageExtent.x + IMAGE_PADDING;
+ }
+ return destinationPosition;
+}
+/**
+ * Draw a filled rectangle indicating the item selection state
+ * The rectangle will be filled with the selection color if the
+ * receiver is selected. Otherwise the rectangle will be filled
+ * in the background color to remove the selection.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawSelection(GC gc, Point position) {
+ Tree parent = getParent();
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ }
+ gc.fillRectangle(position.x, position.y, selectionExtent.x, selectionExtent.y);
+ if (isSelected() == true) {
+ gc.setBackground(parent.getBackground());
+ }
+}
+/**
+ * Draw a rectangle enclosing the item label. The rectangle
+ * indicates that the receiver was selected last and that it has
+ * the input focus.
+ * The rectangle will only be drawn if the receiver is selected.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawSelectionFocus(GC gc, Point position) {
+ Point selectionExtent = getSelectionExtent();
+
+ if (selectionExtent == null) {
+ return;
+ }
+ if (getParent().hasFocus(this) == true) {
+ gc.drawFocus(
+ position.x, position.y,
+ selectionExtent.x, selectionExtent.y);
+ }
+}
+/**
+ * Draw the item label at 'position' using 'gc'.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ */
+void drawText(GC gc, Point position) {
+ Tree parent = getParent();
+ String text = getText();
+
+ if (text != null) {
+ if (isSelected() == true) {
+ gc.setBackground(getSelectionBackgroundColor());
+ gc.setForeground(getSelectionForegroundColor());
+ }
+ gc.drawString(text, position.x, position.y);
+ if (isSelected() == true) {
+ gc.setBackground(parent.getBackground());
+ gc.setForeground(parent.getForeground());
+ }
+ }
+}
+/**
+ * Draw a vertical line connecting the horizontal connector line
+ * with that of the previous item.
+ * Called recursively to draw the lines on all tree levels.
+ * @param gc - GC to draw on.
+ * @param yPosition - y position of the upper side of the
+ * receiver's bounding box.
+ * @param isFirstChild - method is called to draw a vertical
+ * line for the first child. Leave room for the hierarchy icon.
+ */
+void drawVerticalItemConnector(GC gc, int yPosition, boolean isFirstChild) {
+ Tree parent = getParent();
+ TreeItem nextDrawItem = getParentItem();
+ AbstractTreeItem parentItem = nextDrawItem;
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int itemHeight = parent.getItemHeight();
+ int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;
+ int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;
+ int lineX = getPaintStartX() + indicatorRectangle.width / 2;
+ int lineStartY = yPosition - itemHeightDiv2;
+ int lineEndY = yPosition + itemHeightDiv2;
+
+ if (parentItem == null) {
+ parentItem = parent.getRoot();
+ }
+ if (getIndex() != parentItem.getItemCount()-1) { // if item is not the last child
+ if (isFirstChild == true) {
+ lineStartY += indicatorHeightDiv2; // leave space for the hierarchy image
+ }
+ gc.drawLine(lineX, lineStartY, lineX, lineEndY);
+ }
+
+ if (nextDrawItem != null) {
+ nextDrawItem.drawVerticalItemConnector(gc, yPosition, false);
+ }
+}
+/**
+ * Draw a vertical line connecting the horizontal connector line
+ * with that of the previous item.
+ * Do this on all tree levels up to the root level.
+ * @param gc - GC to draw on.
+ * @param position - position on the GC to draw at.
+ * @return position to continue drawing
+ */
+Point drawVerticalItemConnector(GC gc, Point position) {
+ Tree parent = getParent();
+ TreeItem parentItem = getParentItem();
+ Rectangle indicatorRectangle = parent.getHierarchyIndicatorRect();
+ int itemHeight = parent.getItemHeight();
+ int itemHeightDiv2 = itemHeight / 2 + itemHeight % 2;
+ int indicatorHeightDiv2 = indicatorRectangle.height / 2 + indicatorRectangle.height % 2;
+ int lineX = position.x + indicatorRectangle.width / 2;
+ int lineStartY = position.y - itemHeightDiv2;
+ int lineEndY = position.y + itemHeightDiv2 - itemHeight % 2;
+ TreeItem predecessor;
+ boolean isFirstChild = false;
+
+ if (isRoot() == true) {
+ if (getIndex() == 0) {
+ return position; // first root, don't draw vertical line
+ }
+ }
+ else
+ if (getIndex() == 0) { // if item is first child
+ lineStartY += itemHeightDiv2;
+ isFirstChild = true;
+ }
+ predecessor = getPredecessor();
+ if (predecessor != null && predecessor.isLeaf() == false) {
+ lineStartY += indicatorHeightDiv2; // leave space for the hierarchy image
+ }
+ if (isLeaf() == false) {
+ lineEndY -= indicatorHeightDiv2;
+ }
+ gc.drawLine(lineX, lineStartY, lineX, lineEndY);
+ if (parentItem != null) {
+ parentItem.drawVerticalItemConnector(gc, position.y, isFirstChild);
+ }
+ return position;
+}
+
+/**
+ * Gets the widget bounds.
+ * The widget bounds is the rectangle around the item text. It is
+ * the same as the selection rectangle.
+ * <p>
+ * @return a rectangle that is the widget bounds.
+ *
+ * @exception SWTError <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 Rectangle getBounds() {
+ if (!isValidThread()) error(SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget()) error(SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ Point extent = getItemExtent();
+ int x = getTextXPos() - TEXT_INDENT;
+
+ return new Rectangle(x, parent.getRedrawY(this), extent.x - (x - getItemStartX()), extent.y);
+}
+
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return getPaintStartX() + getDecorationsWidth();
+}
+/**
+ * Answer the combined width of the hierarchy indicator and
+ * the horizontal item connector line.
+ */
+int getDecorationsWidth() {
+ int indicatorWidth = getParent().getHierarchyIndicatorRect().width;
+ int width = indicatorWidth + getItemConnectorWidth();
+
+ if (isLeaf() == true) {
+ width -= indicatorWidth / 2;
+ }
+ return width;
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * @return
+ * The index of the receiver relative to the first root item.
+ */
+int getGlobalIndex() {
+ int globalItemIndex = getIndex();
+ AbstractTreeItem item = null;
+
+ if (isRoot() == false) {
+ item = getParentItem();
+ globalItemIndex++; // adjust for 0-based non-root items
+ }
+ else {
+ item = getParent().getRoot();
+ }
+
+ globalItemIndex += item.getVisibleIndex(getIndex());
+ return globalItemIndex;
+}
+/**
+ * Answer the original size of the image of the receiver.
+ */
+Point getImageExtent() {
+ Image image = getImage();
+ Rectangle imageBounds;
+
+ if (imageExtent == null && image != null) {
+ imageBounds = image.getBounds();
+ imageExtent = new Point(imageBounds.width, imageBounds.height);
+ }
+ return imageExtent;
+}
+/**
+ * Answer the receiver's index into its parent's list of children
+ */
+int getIndex() {
+ return index;
+}
+/**
+ * Answer the width of the horizontal item connector line.
+ */
+int getItemConnectorWidth() {
+ Tree parent = getParent();
+ Point imageExtent = parent.getImageExtent();
+ int itemConnectorWidth;
+ int indicatorWidth = parent.getHierarchyIndicatorRect().width;
+
+ if (imageExtent != null) {
+ itemConnectorWidth = imageExtent.x / 2 + ITEM_CONNECTOR_PADDING;
+ }
+ else {
+ itemConnectorWidth = DEFAULT_ITEM_CONNECTOR_WIDTH;
+ }
+ if (isLeaf() == false) { // has children = has hierarchy indicator = shorter connector
+ itemConnectorWidth -= indicatorWidth / 2;
+ }
+ return itemConnectorWidth;
+}
+/**
+ * Return the number of children.
+ */
+public int getItemCount() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getItemCount();
+}
+/**
+ * Answer the size of the receiver as displayed on the screen.
+ */
+Point getItemExtent() {
+ Tree parent;
+ Point imageExtent;
+ String text;
+ int itemWidth;
+
+ if (itemExtent == null) {
+ parent = getParent();
+ imageExtent = parent.getImageExtent();
+ text = getText();
+ itemWidth = SELECTION_PADDING;
+ if (text != null) {
+ itemWidth += parent.getTextWidth(text) + TEXT_INDENT;
+ }
+ if (imageExtent != null) {
+ itemWidth += imageExtent.x + IMAGE_PADDING;
+ }
+ itemExtent = new Point(itemWidth, parent.getItemHeight());
+ }
+ return itemExtent;
+}
+/**
+ * Answer the x position at which painting of the receiver's
+ * contents (ie. image, text) can begin.
+ */
+int getItemStartX() {
+ int itemStartX = getPaintStartX() + getDecorationsWidth();
+
+ if (isCheckable() == true) {
+ itemStartX += getCheckboxBounds().width + CHECKBOX_PADDING;
+ }
+ return itemStartX;
+}
+/**
+ * Answer the child items of the receiver as an Array.
+ */
+public TreeItem [] getItems() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ TreeItem childrenArray[] = new TreeItem[getItemCount()];
+
+ getChildren().copyInto(childrenArray);
+ return childrenArray;
+}
+/**
+ * Answer the x position where the receiver is drawn.
+ */
+int getPaintStartX() {
+ Tree parent = getParent();
+ Point imageExtent;
+ TreeItem parentItem;
+
+ if (paintStartX == -1) {
+ if (isRoot() == true) {
+ paintStartX = ROOT_INDENT;
+ }
+ else {
+ parentItem = getParentItem();
+ // subtract parent.getHorizontalOffset() to calculate the cached start
+ // position independent of the horizontal scroll offset. Fixes 1G1L7EU.
+ paintStartX = parentItem.getPaintStartX()
+ - parent.getHorizontalOffset()
+ + parentItem.getDecorationsWidth()
+ - parent.getHierarchyIndicatorRect().width / 2;
+ imageExtent = parent.getImageExtent();
+ if (imageExtent != null) {
+ paintStartX += imageExtent.x / 2;
+ }
+ else {
+ paintStartX += ITEM_NOIMAGE_OFFSET;
+ }
+ }
+ }
+ return paintStartX + parent.getHorizontalOffset();
+}
+/**
+ * Answer the pixel at which the receiver stops drawing.
+ */
+int getPaintStopX() {
+ return (getItemStartX() + getItemExtent().x - getParent().getHorizontalOffset());
+}
+/**
+ * Answer the parent widget of the receiver.
+ */
+public Tree getParent() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return (Tree) super.getSelectableParent();
+}
+/**
+ * Answer the parent item of the receiver or null if the
+ * receiver is a root.
+ */
+public TreeItem getParentItem() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return parentItem;
+}
+/**
+ * Answer the item that directly precedes the receiver.
+ * Answer null if this is the first item in a hierarchy level
+ * or if there are expanded children in the previous item.
+ */
+TreeItem getPredecessor() {
+ AbstractTreeItem parentItem = getParentItem();
+ Vector children;
+ int previousIndex = getIndex() - 1;
+ TreeItem previousItem = null;
+
+ if (parentItem == null) {
+ parentItem = getParent().getRoot();
+ }
+ if (previousIndex >= 0) {
+ children = parentItem.getChildren();
+ previousItem = (TreeItem) children.elementAt(previousIndex);
+ if (previousItem.isLeaf() == false && previousItem.getExpanded() == true) {
+ previousItem = null; // no immediate predecessor because there are expanded children
+ }
+ }
+ return previousItem;
+}
+/**
+ * Answer the size of the rectangle drawn to indicate the
+ * selected state of the receiver.
+ * This is also used to draw the selection focus rectangle.
+ */
+Point getSelectionExtent() {
+ Point selectionExtent = getItemExtent();
+ Point imageExtent = getParent().getImageExtent();
+ int x = selectionExtent.x;
+
+ if (imageExtent != null) {
+ x -= imageExtent.x + IMAGE_PADDING;
+ }
+ return new Point(x, selectionExtent.y);
+}
+/**
+ * Return the x position of the selection rectangle
+ */
+int getSelectionX() {
+ return getTextXPos() - TEXT_INDENT;
+}
+/**
+ * Answer the x position where the receiver draws the item text.
+ * This position is relative to the item start position.
+ */
+int getTextXPos() {
+ Point imageExtent = getParent().getImageExtent();
+ int textXPos = getItemStartX() + TEXT_INDENT;
+
+ if (imageExtent != null) {
+ textXPos += imageExtent.x + IMAGE_PADDING;
+ }
+ return textXPos;
+}
+/**
+ * Answer the y position of the receiver's text.
+ * @param
+ * gc - GC to use for calculating the text y position
+ */
+int getTextYPosition(GC gc) {
+ String text;
+
+ if (textYPosition == -1) {
+ text = getText();
+ if (text != null) {
+ textYPosition = (getParent().getItemHeight() - gc.stringExtent(text).y) / 2;
+ }
+ else {
+ textYPosition = 0;
+ }
+ }
+ return textYPosition;
+}
+/**
+ * Answer the index of the receiver relative to the first root
+ * item.
+ * If 'anIndex' is the index of the expanded item 'anItem'
+ * then the following expressions are true:
+ * 'anItem == theRoot.getVisibleItem(anIndex)' and
+ * 'anIndex == anItem.getVisibleIndex()'
+ * @return
+ * The index of the receiver relative to the first root item.
+ * Answer -1 if the receiver is not visible (because the parent
+ * is collapsed).
+ */
+int getVisibleIndex() {
+ int visibleItemIndex = getIndex();
+ AbstractTreeItem item = null;
+
+ if (isRoot() == false) {
+ if (isVisible() == false) {
+ return -1;
+ }
+ item = getParentItem();
+ visibleItemIndex++; // adjust for 0-based non-root items
+ }
+ else {
+ item = getParent().getRoot();
+ }
+
+ visibleItemIndex += item.getVisibleIndex(getIndex());
+ return visibleItemIndex;
+}
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+int getVisibleIndex(int childIndex) {
+ Enumeration children = getChildren().elements();
+ TreeItem child;
+ int visibleItemIndex = getIndex();
+
+ if (isRoot() == false) {
+ visibleItemIndex++; // adjust for 0-based non-root items
+ }
+
+ while (children.hasMoreElements() == true) {
+ child = (TreeItem) children.nextElement();
+ if (child.getIndex() == childIndex) {
+ if (isRoot() == false) {
+ visibleItemIndex += getParentItem().getVisibleIndex(getIndex());
+ }
+ else {
+ visibleItemIndex += getParent().getRoot().getVisibleIndex(getIndex());
+ }
+ break;
+ }
+ visibleItemIndex += child.getVisibleItemCount();
+ }
+ return visibleItemIndex;
+}
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the widget client area.
+ */
+TreeItem getVisibleItem(int searchIndex) {
+ TreeItem child;
+ TreeItem foundItem = null;
+ Enumeration children = getChildren().elements();
+
+ if (searchIndex == 0) {
+ return this;
+ }
+ else
+ if (getExpanded() == false) { // trying to find a child when this item isn't expanded ?
+ return null;
+ }
+
+ // Search for expanded items first. Count all subitems in the process.
+ while (children.hasMoreElements() == true && foundItem == null) {
+ child = (TreeItem) children.nextElement();
+ searchIndex--;
+ if (child.getExpanded() == true) {
+ searchIndex -= child.getVisibleItemCount(); // count children of all expanded items
+ }
+ if (searchIndex <= 0) { // is searched item past child ?
+ // add back children of current item (that's what we want to search)
+ foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());
+ }
+ }
+
+ return foundItem;
+}
+/**
+ * Answer whether 'item' is a child, direct or indirect, of the receiver.
+ * It is an indirect child if it is a child of one of the receiver's children.
+ */
+boolean isChild(TreeItem item) {
+ Vector children = getChildren();
+ TreeItem child;
+
+ if (children.contains(item) == true) {
+ return true;
+ }
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ if (child.isChild(item) == true) {
+ return true;
+ }
+ }
+ return false;
+}
+/**
+ * Answer whether the receiver is a root item.
+ * The receiver is a root item when it does not have a parent item.
+ * @return
+ * true - the receiver is a root item.
+ * false - the receiver is not a root item.
+ */
+boolean isRoot() {
+ return (getParentItem() == null);
+}
+/**
+ * Answer whether the click at 'position' on the receiver is a selection
+ * click.
+ * @param position - location of the mouse click relative to the
+ * upper left corner of the receiver.
+ * @return true - receiver was clicked.
+ * false - receiver was not clicked.
+ */
+boolean isSelectionHit(Point position) {
+ Point itemExtent = getItemExtent();
+
+ if (itemExtent == null) { // neither image nor text have been set
+ return false;
+ }
+ return (new Rectangle(
+ getItemStartX() - getPaintStartX(), 0,
+ itemExtent.x, itemExtent.y)).contains(position);
+}
+/**
+ * Answer whether the receiver is visible
+ * An item is visible when its parent item is visible and
+ * expanded. Root items are always visible.
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the receiver's parent's
+ * client area.
+ * @return
+ * true - the receiver is visible
+ * false - the receiver is not visible
+ */
+boolean isVisible() {
+ boolean isVisible = true;
+ TreeItem parentItem = getParentItem();
+
+ if (isRoot() == false) {
+ isVisible = parentItem.getExpanded();
+ if (isVisible == true) {
+ isVisible = parentItem.isVisible();
+ }
+ }
+ return isVisible;
+}
+/**
+ * Make this item visible by expanding its parent item.
+ */
+void makeVisible() {
+ TreeItem parentItem = getParentItem();
+
+ if (isVisible() == false && parentItem != null) {
+ getParent().expand(parentItem, true); // have to call Tree.expand directly in order to trigger Expand event
+ parentItem.makeVisible();
+ }
+}
+/**
+ * Draw the receiver at 'yPosition' in the client area of the parent.
+ * @param gc - GC to draw on.
+ * @param yPosition - y coordinate where the receiver should draw at.
+ */
+void paint(GC gc, int yPosition) {
+ Tree parent = getParent();
+ Point paintPosition = new Point(getPaintStartX(), yPosition);
+
+ if (isVisible() == false) {
+ return;
+ }
+ gc.setForeground(parent.CONNECTOR_LINE_COLOR);
+ paintPosition = drawVerticalItemConnector(gc, paintPosition);
+ paintPosition = drawHierarchyIndicator(gc, paintPosition);
+ paintPosition = drawHorizontalItemConnector(gc, paintPosition);
+ gc.setForeground(parent.getForeground());
+ // paint the rest
+ if (isCheckable() == true) {
+ paintPosition = drawCheckbox(gc, new Point(paintPosition.x, yPosition));
+ }
+ paintPosition = drawImage(gc, new Point(paintPosition.x, yPosition));
+ drawSelection(gc, paintPosition);
+ if (this == parent.getInsertItem()) {
+ drawInsertMark(gc, paintPosition);
+ }
+ drawText(gc, new Point(getTextXPos(), paintPosition.y + getTextYPosition(gc)));
+ drawSelectionFocus(gc, paintPosition);
+}
+/**
+ * Update the display to reflect the expanded state of the
+ * receiver.
+ * @param itemIndex - index position in the receiver's client
+ * area where should be drawn.
+ */
+void redrawExpanded(int itemIndex) {
+ Tree parent = getParent();
+ int indicatorWidth = parent.getHierarchyIndicatorRect().width;
+ int itemHeight = parent.getItemHeight();
+
+ parent.redraw(
+ getPaintStartX(), itemIndex * itemHeight,
+ indicatorWidth, itemHeight, false);
+}
+/**
+ * Reset cached size and position data.
+ */
+void reset() {
+ super.reset();
+ setImageExtent(null);
+ setItemExtent(null);
+ setPaintStartX(-1);
+ setTextYPosition(-1);
+}
+/**
+ * Set whether the receiver is expanded or not.
+ * If the receiver is expanded its child items are visible.
+ * @param expand -
+ * true=the receiver will be expanded, making its child items
+ * visible.
+ * false=the receiver will be collapsed, making its child items
+ * invisible
+ */
+public void setExpanded(boolean expand) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ if (isLeaf() == false && expand == true) {
+ getParent().expand(this, false);
+ }
+ else {
+ getParent().collapse(this, false);
+ }
+}
+/**
+ * Set the image of the receiver to 'newImage'.
+ * Reset cached data and notify the parent if the image has changed.
+ */
+public void setImage(Image newImage) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ Image oldImage = getImage();
+ boolean isSameImage;
+ int imageWidth = 0;
+ int redrawX = 0;
+
+ super.setImage(newImage);
+ if (newImage != null && oldImage != null) {
+ isSameImage = newImage.equals(oldImage);
+ }
+ else {
+ isSameImage = newImage == oldImage;
+ }
+ if (isSameImage == false) {
+ if (parent.getVisibleRedrawY(this) != -1) {
+ if (parent.getImageExtent() != null) {
+ imageWidth = parent.getImageExtent().x;
+ }
+ else
+ if (newImage != null) {
+ imageWidth = newImage.getBounds().x;
+ }
+ redrawX = getItemStartX();
+ }
+ parent.itemChanged(this, redrawX, imageWidth);
+ }
+}
+/**
+ * Set the size of the original image of the receiver to 'imageExtent'.
+ */
+void setImageExtent(Point imageExtent) {
+ this.imageExtent = imageExtent;
+}
+/**
+ * Set the index of the receiver to 'index'.
+ * This index is used to reference children in their parent.
+ */
+void setIndex(int index) {
+ this.index = index;
+}
+/**
+ * Set the size of the receiver to 'extent'.
+ */
+void setItemExtent(Point extent) {
+ itemExtent = extent;
+}
+/**
+ * Set the x position where the receiver is drawn to 'startX'.
+ * @param startX - the x position where the receiver is drawn
+ */
+void setPaintStartX(int startX) {
+ paintStartX = startX;
+}
+/**
+ * Set the parent item of the receiver to 'parentItem'.
+ * @param parentItem - the receiver's parent item.
+ * Receiver is a root if this is null.
+ */
+void setParentItem(TreeItem parentItem) {
+ this.parentItem = parentItem;
+}
+/**
+ * Set the label text of the receiver to 'string'.
+ * Reset cached data and notify the parent if the text has
+ * changed.
+ * This label will be displayed to the right of the bitmap,
+ * or, if the receiver doesn't have a bitmap to the right of
+ * the horizontal hierarchy connector line.
+ */
+public void setText(String newText) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ Tree parent = getParent();
+ String oldText = getText();
+ int redrawX = 0;
+ int redrawWidth = 0;
+
+ if (newText == null) {
+ error(SWT.ERROR_NULL_ARGUMENT);
+ }
+ super.setText(newText);
+ if (newText.equals(oldText) == false) {
+ if (parent.getVisibleRedrawY(this) != -1) {
+ redrawX = getTextXPos();
+ redrawWidth = parent.getClientArea().width - redrawX;
+ }
+ parent.itemChanged(this, redrawX, redrawWidth);
+ }
+}
+/**
+ * Set the y position of the receiver's text to 'yPosition'.
+ */
+void setTextYPosition(int yPosition) {
+ textYPosition = yPosition;
+}
+/**
+ * Destroy all children of the receiver
+ * Collapsing the item speeds up deleting the children.
+ */
+void disposeItem() {
+ Tree parent = getParent();
+
+ // if the tree is being disposed don't bother collapsing the item since all
+ // items in the tree will be deleted and redraws will not be processed anyway
+ if (parent.isRemovingAll() == false) {
+ parent.collapseNoRedraw(this);
+ }
+ super.disposeItem();
+}
+/**
+ * Return whether or not the receiver is checked.
+ * Always return false if the parent of the receiver does not
+ * have the CHECK style.
+ */
+public boolean getChecked() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getChecked();
+}
+/**
+ * Answer the display of the receiver's parent widget.
+ */
+public Display getDisplay() {
+ return super.getDisplay();
+}
+/**
+ * Gets the grayed state.
+ * <p>
+ * @return the item grayed state.
+ *
+ * @exception SWTError <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 boolean getGrayed() {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ return super.getGrayed();
+}
+/**
+ * Set the checked state to 'checked' if the parent of the
+ * receiver has the CHECK style.
+ */
+public void setChecked(boolean checked) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setChecked(checked);
+}
+/**
+ * Sets the grayed state.
+ * <p>
+ * @param grayed the new grayed state.
+ *
+ * @exception SWTError <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 setGrayed (boolean grayed) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ super.setGrayed(grayed);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
new file mode 100755
index 0000000000..c9e4dea7ab
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/TreeRoots.java
@@ -0,0 +1,157 @@
+package org.eclipse.swt.widgets;
+
+import org.eclipse.swt.graphics.*;
+import java.util.*;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+/**
+ * This class is used to store tree root items.
+ * Instances of this class are never displayed.
+ */
+class TreeRoots extends AbstractTreeItem {
+/**
+ * Create a tree item that holds one or more root items
+ * @param parent - Tree widget the receiver belongs to
+ */
+TreeRoots(Tree parent) {
+ super(parent, 0);
+ initialize();
+}
+/**
+ * Calculate the number of expanded children.
+ * Recurse up in the tree to the root item.
+ */
+void calculateVisibleItemCount() {
+ Vector children = getChildren();
+ TreeItem child;
+ int visibleItemCount = children.size();
+
+ for (int i = 0; i < children.size(); i++) {
+ child = (TreeItem) children.elementAt(i);
+ visibleItemCount += child.getVisibleItemCount();
+ }
+ setVisibleItemCount(visibleItemCount);
+}
+/**
+ * Calculate the number of expanded children for the parent item
+ * of this item.
+ */
+void calculateVisibleItemCountParent() {}
+/**
+ * Destroy all children of the receiver
+ */
+void disposeItem() {
+ Tree parent = (Tree) getSelectableParent();
+
+ // all tree items are removed so we don't need to do
+ // time consuming screen updates for each removed item
+ parent.setRemovingAll(true);
+ super.disposeItem();
+ parent.setRemovingAll(false);
+}
+/**
+ * Answer the x position of the item check box
+ */
+int getCheckboxXPosition() {
+ return 0;
+}
+/**
+ * Implements SelectableItem#getSelectionExtent
+ * Should never be called since objects of this type are never
+ * rendered
+ */
+Point getSelectionExtent() {
+ return new Point(0, 0);
+}
+/**
+ * Implements SelectableItem#getSelectionX
+ * Should never be called since objects of this type are never
+ * rendered
+ */
+int getSelectionX() {
+ return 0;
+}
+/**
+ * Always answer -1 to indicate that the receiver is not visible.
+ */
+int getVisibleIndex() {
+ return -1;
+}
+/**
+ * Answer the index of the child item identified by 'childIndex'
+ * relative to the first root item.
+ */
+int getVisibleIndex(int childIndex) {
+ Enumeration children = getChildren().elements();
+ TreeItem child;
+ int globalItemIndex = 0;
+
+ while (children.hasMoreElements() == true) {
+ child = (TreeItem) children.nextElement();
+ if (child.getIndex() == childIndex) {
+ break;
+ }
+ globalItemIndex += child.getVisibleItemCount();
+ }
+ return globalItemIndex;
+}
+/**
+ * Answer the item at 'searchIndex' relativ to the receiver.
+ * When this method is called for the root item, 'searchIndex'
+ * represents the global index into all items of the tree.
+ * searchIndex=0 returns the receiver.
+ * searchIndex=1 returns the first visible child.
+ * Note: searchIndex must be >= 0
+ *
+ * Note:
+ * Visible in this context does not neccessarily mean that the
+ * item is displayed on the screen. Visible here means that all
+ * the parents of the item are expanded. An item is only
+ * visible on screen if it is within the widget client area.
+ */
+TreeItem getVisibleItem(int searchIndex) {
+ TreeItem child;
+ TreeItem foundItem = null;
+ Enumeration children = getChildren().elements();
+
+ searchIndex++; // skip this fake root item
+
+ // Search for expanded items first. Count all subitems in the process.
+ while (children.hasMoreElements() == true && foundItem == null) {
+ child = (TreeItem) children.nextElement();
+ searchIndex--;
+ if (child.internalGetExpanded() == true) {
+ searchIndex -= child.getVisibleItemCount(); // count children of all expanded items
+ }
+ if (searchIndex <= 0) { // is searched item past child ?
+ // add back children of current item (that's what we want to search)
+ foundItem = child.getVisibleItem(searchIndex + child.getVisibleItemCount());
+ }
+ }
+ return foundItem;
+}
+/**
+ * Initialize the receiver
+ */
+void initialize() {
+ internalSetExpanded(true);
+}
+
+/**
+ * Select the receiver and all children
+ */
+Vector selectAll(Vector selectedItems) {
+ Enumeration children = getChildren().elements();
+ AbstractTreeItem treeItem;
+
+ while (children.hasMoreElements() == true) {
+ treeItem = (AbstractTreeItem) children.nextElement();
+ selectedItems = treeItem.selectAll(selectedItems);
+ }
+ return selectedItems;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
new file mode 100755
index 0000000000..7f80b5e68d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/Widget.java
@@ -0,0 +1,441 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+import java.util.EventListener;
+
+public abstract class Widget {
+ public int handle;
+ int style;
+ EventTable eventTable;
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+
+ static final char Mnemonic = '&';
+
+Widget () {
+ /* Do nothing */
+}
+
+public Widget (Widget parent, int style) {
+ checkSubclass ();
+ checkParent (parent);
+ this.style = style;
+}
+
+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;
+}
+
+void checkParent (Widget parent) {
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (!parent.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+protected void checkWidget () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+int copyPhImage(int image) {
+ if (image == 0) return 0;
+ int imageHandle = OS.PiDuplicateImage (image, 0);
+ /* Bug in Photon - The image returned by PiDuplicateImage
+ has the same mask_bm as the original image.
+ */
+ PhImage_t phImage = new PhImage_t();
+ OS.memmove (phImage, imageHandle, PhImage_t.sizeof);
+ if (phImage.mask_bm != 0) {
+ int length = phImage.mask_bpl * phImage.size_h;
+ int ptr = OS.malloc (length);
+ OS.memmove(ptr, phImage.mask_bm, length);
+ phImage.mask_bm = ptr;
+ OS.memmove (imageHandle, phImage, PhImage_t.sizeof);
+ }
+ return imageHandle;
+}
+
+public void addListener (int eventType, Listener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, handler);
+}
+
+public void addDisposeListener (DisposeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TypedListener typedListener = new TypedListener (listener);
+ addListener (SWT.Dispose, typedListener);
+}
+
+void createHandle (int index) {
+ /* Do nothing */
+}
+
+void createWidget (int index) {
+ createHandle (index);
+ hookEvents ();
+ register ();
+}
+
+void deregister () {
+ if (handle == 0) return;
+ WidgetTable.remove (handle);
+}
+
+void destroyWidget () {
+ int topHandle = topHandle ();
+ releaseHandle ();
+ if (topHandle != 0) {
+ OS.PtDestroyWidget (topHandle);
+ }
+}
+
+public void dispose () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+
+static void error (int code) {
+ SWT.error(code);
+}
+
+public Object getData () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return data;
+}
+
+public Object getData (String key) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (keys == null) return null;
+ for (int i=0; i<keys.length; i++) {
+ if (keys [i].equals (key)) return values [i];
+ }
+ return null;
+}
+
+public abstract Display getDisplay ();
+
+String getName () {
+ String string = getClass ().getName ();
+ int index = string.length ();
+ while (--index > 0 && string.charAt (index) != '.');
+ return string.substring (index + 1, string.length ());
+}
+
+String getNameText () {
+ return "";
+}
+
+public int getStyle () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return style;
+}
+
+boolean hooks (int eventType) {
+ if (eventTable == null) return false;
+ return eventTable.hooks (eventType);
+}
+
+void hookEvents () {
+ /* Do nothing */
+}
+
+public boolean isDisposed () {
+ return handle == 0;
+}
+
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+
+protected boolean isListening (int eventType) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return hooks (eventType);
+}
+
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+
+boolean isValidWidget () {
+ return true /*handle != 0*/;
+}
+
+public void notifyListeners (int eventType, Event event) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ eventTable.sendEvent (event);
+}
+
+void postEvent (int eventType) {
+ if (eventTable == null) return;
+ postEvent (eventType, new Event ());
+}
+
+void postEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = (int) System.currentTimeMillis ();
+ }
+ getDisplay ().postEvent (event);
+}
+
+int processDefaultSelection (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusIn (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processFocusOut (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processHide (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processKey (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processEvent (int data, int info) {
+ switch (data) {
+// case SWT.Arm: return processArm (info);
+// case SWT.Dispose: return processDispose (info);
+ case SWT.DefaultSelection: return processDefaultSelection (info);
+ case SWT.FocusIn: return processFocusIn (info);
+ case SWT.FocusOut: return processFocusOut (info);
+// case SWT.Help: return processHelp (info);
+ case SWT.Hide: return processHide (info);
+ case SWT.KeyDown:
+ case SWT.KeyUp: return processKey (info);
+ case SWT.Modify: return processModify (info);
+ case SWT.MouseDown:
+ case SWT.MouseMove:
+ case SWT.MouseUp: return processMouse (info);
+ case SWT.MouseEnter: return processMouseEnter (info);
+// case SWT.MouseExit: return processMouseOut (info);
+ case SWT.Move: return processMove (info);
+// case SWT.Paint: return processPaint (info);
+ case SWT.Resize: return processResize (info);
+ case SWT.Show: return processShow (info);
+ case SWT.Selection: return processSelection (info);
+ case SWT.Verify: return processVerify (info);
+ case -1: return processShellResize (info);
+ }
+ return OS.Pt_CONTINUE;
+}
+
+int processModify (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processMouse (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processMouseEnter (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processMove (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processPaint (int damage) {
+ return OS.Pt_CONTINUE;
+}
+
+int processResize (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processShow (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processShellResize (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processSelection (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+int processVerify (int info) {
+ return OS.Pt_CONTINUE;
+}
+
+void releaseChild () {
+ /* Do nothing */
+}
+
+void register () {
+ if (handle == 0) return;
+ WidgetTable.put (handle, this);
+}
+
+void releaseHandle () {
+ handle = 0;
+// state |= DISPOSED;
+}
+
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+// state |= DISPOSED;
+ eventTable = null;
+ data = null;
+}
+
+public void removeListener (int eventType, Listener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
+protected void removeListener (int eventType, EventListener handler) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (handler == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, handler);
+}
+
+public void removeDisposeListener (DisposeListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+
+void sendEvent (int eventType) {
+ if (eventTable == null) return;
+ sendEvent (eventType, new Event ());
+}
+
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.widget = this;
+ event.type = eventType;
+ if (event.time == 0) {
+ event.time = (int) System.currentTimeMillis ();
+ }
+ eventTable.sendEvent (event);
+}
+
+public void setData (Object data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ this.data = data;
+}
+
+public void setData (String key, Object value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* 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;
+}
+
+public String toString () {
+ String string = "*Disposed*";
+ if (!isDisposed ()) {
+ string = "*Wrong Thread*";
+ if (isValidThread ()) string = getNameText ();
+ }
+ return getName () + " {" + string + "}";
+}
+
+int topHandle () {
+ return handle;
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
new file mode 100755
index 0000000000..570e5b3c78
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/photon/org/eclipse/swt/widgets/WidgetTable.java
@@ -0,0 +1,101 @@
+package org.eclipse.swt.widgets;
+
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.photon.*;
+
+class WidgetTable {
+ static int FreeSlot = 0;
+ static int GrowSize = 1024;
+ static int [] IndexTable = new int [GrowSize];
+ static Widget [] WidgetTable = new Widget [GrowSize];
+ static int ArgPtr = OS.malloc (4);
+ static int [] ArgBuffer = new int [1];
+ static int [] SetArgs = new int [] {OS.Pt_ARG_USER_DATA, ArgPtr, 4};
+ static int [] GetArgs = new int [] {OS.Pt_ARG_USER_DATA, 0, 0};
+ static {
+ for (int i=0; i<GrowSize-1; i++) IndexTable [i] = i + 1;
+ IndexTable [GrowSize - 1] = -1;
+ }
+public static synchronized Widget get (int handle) {
+ if (handle == 0) return null;
+ GetArgs [1] = 0;
+ OS.PtGetResources (handle, GetArgs.length / 3, GetArgs);
+ if (GetArgs [1] == 0) return null;
+ OS.memmove (ArgBuffer, GetArgs [1], 4);
+ if (ArgBuffer [0] == 0) return null;
+ int index = ArgBuffer [0] - 1;
+ if (0 <= index && index < WidgetTable.length) return WidgetTable [index];
+ return null;
+}
+public synchronized static void put(int handle, Widget widget) {
+ if (handle == 0) return;
+ if (FreeSlot == -1) {
+ int length = (FreeSlot = IndexTable.length) + GrowSize;
+ 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;
+ }
+ ArgBuffer [0] = FreeSlot + 1;
+ OS.memmove (ArgPtr, ArgBuffer, 4);
+ OS.PtSetResources (handle, SetArgs.length / 3, SetArgs);
+ int oldSlot = FreeSlot;
+ FreeSlot = IndexTable[oldSlot];
+ IndexTable [oldSlot] = -2;
+ WidgetTable [oldSlot] = widget;
+}
+public static synchronized Widget remove (int handle) {
+ if (handle == 0) return null;
+ GetArgs [1] = 0;
+ OS.PtGetResources (handle, GetArgs.length / 3, GetArgs);
+ if (GetArgs [1] == 0) return null;
+ OS.memmove (ArgBuffer, GetArgs [1], 4);
+ if (ArgBuffer [0] == 0) return null;
+ int index = ArgBuffer [1] - 1;
+ Widget widget = null;
+ if (0 <= index && index < WidgetTable.length) {
+ widget = WidgetTable [index];
+ WidgetTable [index] = null;
+ IndexTable [index] = FreeSlot;
+ FreeSlot = index;
+ ArgBuffer [0] = 0;
+ OS.memmove (ArgPtr, ArgBuffer, 4);
+ OS.PtSetResources (handle, SetArgs.length / 3, SetArgs);
+ }
+ return widget;
+}
+public static synchronized Shell [] shells () {
+ int length = 0;
+ for (int i=0; i<WidgetTable.length; i++) {
+ Widget widget = WidgetTable [i];
+ if (widget != null && widget instanceof Shell) length++;
+ }
+ int index = 0;
+ Shell [] result = new Shell [length];
+ for (int i=0; i<WidgetTable.length; i++) {
+ Widget widget = WidgetTable [i];
+ if (widget != null && widget instanceof Shell) {
+ result [index++] = (Shell) widget;
+ }
+ }
+ return result;
+}
+public static synchronized int size () {
+ int size = 0;
+ for (int i=0; i<WidgetTable.length; i++) {
+ if (WidgetTable [i] != null) size++;
+ }
+ return size;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/build.bat b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/build.bat
new file mode 100755
index 0000000000..1432829290
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/build.bat
@@ -0,0 +1,23 @@
+@echo off
+
+IF NOT "%JAVA_HOME%"=="" GOTO MAKE
+
+rem *****
+rem Javah
+rem *****
+set JAVA_HOME=j:\teamswt\swt-builddir\ive\bin
+set path=%JAVA_HOME%;%path%
+
+rem ********
+rem MSVC 6.0
+rem ********
+call k:\dev\products\msvc60\vc98\bin\vcvars32.bat
+
+rem ******
+rem MS-SDK - TEMPORARY UNTIL TRENT INSTALLS NEW SDK
+rem ******
+set Mssdk=j:\teamswt\swt-builddir\mssdk
+call %mssdk%\setenv.bat
+
+:MAKE
+nmake makefile.mak
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/library.c b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/library.c
new file mode 100755
index 0000000000..3bcd6f49df
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/library.c
@@ -0,0 +1,28 @@
+/**
+ * library.c
+ *
+ * This file contains the implementation of the
+ * shared libraries functions.
+ *
+ */
+
+#include <windows.h>
+
+unsigned int OpenLibrary(char *name)
+{
+ UINT prevMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
+ HINSTANCE handle = LoadLibrary ((LPCSTR)name);
+ SetErrorMode(prevMode);
+ return (unsigned int)handle;
+}
+
+unsigned int LibraryLookupName(unsigned int handle, char *name)
+{
+ if (handle == 0) return 0;
+ return (unsigned int)GetProcAddress ((HINSTANCE)handle, (LPCSTR)name);
+}
+
+void CloseLibrary(unsigned int handle)
+{
+ if (handle != 0) FreeLibrary ((HINSTANCE)handle);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak
new file mode 100755
index 0000000000..80237ef4bc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/makefile.mak
@@ -0,0 +1,67 @@
+# Makefile for module 'swt'
+# (C) Copyright 1999 OTI Object Technology International Inc.
+#
+# Autogenerated Code
+
+# The major and minor version numbers and the build numbers are
+# returned by the DllGetVersion call so the os can query the swt
+# version number
+
+APPVER=5.0
+!include <win32.mak>
+
+maj_ver=0
+min_ver=105
+bld_num=0
+
+pgm_ver_str="SWT $(maj_ver).0$(min_ver) for Windows"
+timestamp_str=__DATE__\" \"__TIME__\" (EST)\"
+copyright = "Copyright (C) IBM Corporation 1999, 2000. All rights reserved."
+
+# assumes JAVA_HOME is set in the environment from which nmake is run
+
+DLLPREFIX=swt
+DLLNAME=$(DLLPREFIX)$(maj_ver)$(min_ver).dll
+
+LIBNAME=swt# declaration
+
+LINK_LIBS = ole32.lib comctl32.lib user32.lib gdi32.lib comdlg32.lib kernel32.lib shell32.lib oleaut32.lib advapi32.lib imm32.lib winspool.lib
+
+# note: thoroughly test all examples after changing any optimization flags
+cflags = -c -W3 -G6 -GD -O1 -DSWT_LIBRARY_MAJOR_VERSION=$(maj_ver) -DSWT_LIBRARY_MINOR_VERSION=$(min_ver) -DSWT_LIBRARY_BUILD_NUM=$(bld_num) -nologo -D_X86_=1 -D_WIN32 -D_WIN95 -D_WIN32_WINDOWS=0x0400 -D_MT -MT -DWIN32 -D_WIN32_DCOM /I$(JAVA_HOME)\include /I.
+# no optimizations
+#cflags = -c -W3 -G6 -GD -Odi -DSWT_LIBRARY_MAJOR_VERSION=$(maj_ver) -DSWT_LIBRARY_MINOR_VERSION=$(min_ver) -DSWT_LIBRARY_BUILD_NUM=$(bld_num) -nologo -D_X86_=1 -D_WIN32 -D_WIN95 -D_WIN32_WINDOWS=0x0400 -D_MT -MT -DWIN32 /I..\include /I$(JAVA_HOME)\include /I$(JAVA_HOME)\include\win32
+
+linkflags = /INCREMENTAL:NO /PDB:NONE /RELEASE /NOLOGO -entry:_DllMainCRTStartup@12 -dll /BASE:0x10000000 /comment:$(pgm_ver_str) /comment:$(copyright) /DLL
+
+SWTOBJS = swt.obj swtole.obj structs.obj callback.obj globals.obj library.obj
+
+all: $(SWTOBJS) \
+ $(DLLPREFIX)
+
+$(DLLPREFIX): $(SWTOBJS)
+
+$(DLLPREFIX): swt.res $(DLLPREFIX).obj
+ echo $(LINK_LIBS) >templrf
+ echo $(linkflags) >>templrf
+ echo swt.res >>templrf
+ echo -machine:IX86 >>templrf
+ echo -subsystem:windows >>templrf
+ echo -out:$(DLLNAME) >>templrf
+ echo $(SWTOBJS) >>templrf
+ link @templrf
+ del templrf
+
+clean:
+ del *.obj
+ del *.res
+ del *.dll
+ del *.exp
+
+.c.obj:
+ cl $(cflags) $*.c
+
+.rc.res:
+ rc -r -fo swt.res swt.rc
+
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c
new file mode 100755
index 0000000000..3db163c809
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.c
@@ -0,0 +1,3976 @@
+/**
+ * JNI SWT object field getters and setters declarations for Windows structs
+ */
+
+#include <jni.h>
+#include "structs.h"
+
+/* ----------- fid and class caches ----------- */
+/*
+ * Used for Java objects passed into JNI that are
+ * declared like:
+ *
+ * nativeFunction (Rectangle p1, Rectangle p2, Rectangle p3)
+ *
+ * and not like this
+ *
+ * nativeFunction (Object p1, Object p2, Object p3)
+ *
+ *
+ */
+void cacheAccelFids(JNIEnv *env, jobject lpAccel, PACCEL_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->accelClass = (*env)->GetObjectClass(env,lpAccel);
+ lpCache->fVirt = (*env)->GetFieldID(env,lpCache->accelClass,"fVirt","B");
+ lpCache->key = (*env)->GetFieldID(env,lpCache->accelClass,"key","S");
+ lpCache->cmd = (*env)->GetFieldID(env,lpCache->accelClass,"cmd","S");
+ lpCache->cached = 1;
+}
+
+void cacheBitmapFids(JNIEnv *env, jobject lpBitmap, PBITMAP_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->bitmapClass = (*env)->GetObjectClass(env,lpBitmap);
+ lpCache->bmType = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmType","I");
+ lpCache->bmWidth = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmWidth","I");
+ lpCache->bmHeight = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmHeight","I");
+ lpCache->bmWidthBytes = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmWidthBytes","I");
+ lpCache->bmPlanes = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmPlanes","S");
+ lpCache->bmBitsPixel = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmBitsPixel","S");
+ lpCache->bmBits = (*env)->GetFieldID(env,lpCache->bitmapClass,"bmBits","I");
+ lpCache->cached = 1;
+}
+
+void cacheBrowseinfoFids(JNIEnv *env, jobject lpBrowseinfo, PBROWSEINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->browseinfoClass = (*env)->GetObjectClass(env,lpBrowseinfo);
+ lpCache->hwndOwner = (*env)->GetFieldID(env,lpCache->browseinfoClass,"hwndOwner","I");
+ lpCache->pidlRoot = (*env)->GetFieldID(env,lpCache->browseinfoClass,"pidlRoot","I");
+ lpCache->pszDisplayName = (*env)->GetFieldID(env,lpCache->browseinfoClass,"pszDisplayName","I");
+ lpCache->lpszTitle = (*env)->GetFieldID(env,lpCache->browseinfoClass,"lpszTitle","I");
+ lpCache->ulFlags = (*env)->GetFieldID(env,lpCache->browseinfoClass,"ulFlags","I");
+ lpCache->lpfn = (*env)->GetFieldID(env,lpCache->browseinfoClass,"lpfn","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->browseinfoClass,"lParam","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->browseinfoClass,"iImage","I");
+ lpCache->cached = 1;
+}
+/*
+void cacheCharformatFids(JNIEnv *env, jobject lpCharformat, PCHARFORMAT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->charformatClass = (*env)->GetObjectClass(env,lpCharformat);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->charformatClass,"cbSize","I");
+ lpCache->dwMask = (*env)->GetFieldID(env,lpCache->charformatClass,"dwMask","I");
+ lpCache->dwEffects = (*env)->GetFieldID(env,lpCache->charformatClass,"dwEffects","I");
+ lpCache->yHeight = (*env)->GetFieldID(env,lpCache->charformatClass,"yHeight","I");
+ lpCache->yOffset = (*env)->GetFieldID(env,lpCache->charformatClass,"yOffset","I");
+ lpCache->crTextColor = (*env)->GetFieldID(env,lpCache->charformatClass,"crTextColor","I");
+ lpCache->bCharSet = (*env)->GetFieldID(env,lpCache->charformatClass,"bCharSet","B");
+ lpCache->bPitchAndFamily = (*env)->GetFieldID(env,lpCache->charformatClass,"bPitchAndFamily","B");
+ lpCache->szFaceName0 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName0","B");
+ lpCache->szFaceName1 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName1","B");
+ lpCache->szFaceName2 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName2","B");
+ lpCache->szFaceName3 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName3","B");
+ lpCache->szFaceName4 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName4","B");
+ lpCache->szFaceName5 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName5","B");
+ lpCache->szFaceName6 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName6","B");
+ lpCache->szFaceName7 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName7","B");
+ lpCache->szFaceName8 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName8","B");
+ lpCache->szFaceName9 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName9","B");
+ lpCache->szFaceName10 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName10","B");
+ lpCache->szFaceName11 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName11","B");
+ lpCache->szFaceName12 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName12","B");
+ lpCache->szFaceName13 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName13","B");
+ lpCache->szFaceName14 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName14","B");
+ lpCache->szFaceName15 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName15","B");
+ lpCache->szFaceName16 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName16","B");
+ lpCache->szFaceName17 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName17","B");
+ lpCache->szFaceName18 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName18","B");
+ lpCache->szFaceName19 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName19","B");
+ lpCache->szFaceName20 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName20","B");
+ lpCache->szFaceName21 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName21","B");
+ lpCache->szFaceName22 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName22","B");
+ lpCache->szFaceName23 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName23","B");
+ lpCache->szFaceName24 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName24","B");
+ lpCache->szFaceName25 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName25","B");
+ lpCache->szFaceName26 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName26","B");
+ lpCache->szFaceName27 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName27","B");
+ lpCache->szFaceName28 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName28","B");
+ lpCache->szFaceName29 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName29","B");
+ lpCache->szFaceName30 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName30","B");
+ lpCache->szFaceName31 = (*env)->GetFieldID(env,lpCache->charformatClass,"szFaceName31","B");
+ lpCache->cached = 1;
+}
+
+void cacheCharformat2Fids(JNIEnv *env, jobject lpCharformat2, PCHARFORMAT2_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->charformat2Class = (*env)->GetObjectClass(env,lpCharformat2);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->charformat2Class,"cbSize","I");
+ lpCache->dwMask = (*env)->GetFieldID(env,lpCache->charformat2Class,"dwMask","I");
+ lpCache->dwEffects = (*env)->GetFieldID(env,lpCache->charformat2Class,"dwEffects","I");
+ lpCache->yHeight = (*env)->GetFieldID(env,lpCache->charformat2Class,"yHeight","I");
+ lpCache->yOffset = (*env)->GetFieldID(env,lpCache->charformat2Class,"yOffset","I");
+ lpCache->crTextColor = (*env)->GetFieldID(env,lpCache->charformat2Class,"crTextColor","I");
+ lpCache->bCharSet = (*env)->GetFieldID(env,lpCache->charformat2Class,"bCharSet","B");
+ lpCache->bPitchAndFamily = (*env)->GetFieldID(env,lpCache->charformat2Class,"bPitchAndFamily","B");
+ lpCache->szFaceName0 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName0","B");
+ lpCache->szFaceName1 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName1","B");
+ lpCache->szFaceName2 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName2","B");
+ lpCache->szFaceName3 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName3","B");
+ lpCache->szFaceName4 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName4","B");
+ lpCache->szFaceName5 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName5","B");
+ lpCache->szFaceName6 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName6","B");
+ lpCache->szFaceName7 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName7","B");
+ lpCache->szFaceName8 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName8","B");
+ lpCache->szFaceName9 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName9","B");
+ lpCache->szFaceName10 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName10","B");
+ lpCache->szFaceName11 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName11","B");
+ lpCache->szFaceName12 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName12","B");
+ lpCache->szFaceName13 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName13","B");
+ lpCache->szFaceName14 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName14","B");
+ lpCache->szFaceName15 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName15","B");
+ lpCache->szFaceName16 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName16","B");
+ lpCache->szFaceName17 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName17","B");
+ lpCache->szFaceName18 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName18","B");
+ lpCache->szFaceName19 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName19","B");
+ lpCache->szFaceName20 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName20","B");
+ lpCache->szFaceName21 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName21","B");
+ lpCache->szFaceName22 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName22","B");
+ lpCache->szFaceName23 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName23","B");
+ lpCache->szFaceName24 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName24","B");
+ lpCache->szFaceName25 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName25","B");
+ lpCache->szFaceName26 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName26","B");
+ lpCache->szFaceName27 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName27","B");
+ lpCache->szFaceName28 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName28","B");
+ lpCache->szFaceName29 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName29","B");
+ lpCache->szFaceName30 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName30","B");
+ lpCache->szFaceName31 = (*env)->GetFieldID(env,lpCache->charformat2Class,"szFaceName31","B");
+ lpCache->wWeight = (*env)->GetFieldID(env,lpCache->charformat2Class,"wWeight","S");
+ lpCache->sSpacing = (*env)->GetFieldID(env,lpCache->charformat2Class,"sSpacing","S");
+ lpCache->crBackColor = (*env)->GetFieldID(env,lpCache->charformat2Class,"crBackColor","I");
+ lpCache->lcid = (*env)->GetFieldID(env,lpCache->charformat2Class,"lcid","I");
+ lpCache->dwReserved = (*env)->GetFieldID(env,lpCache->charformat2Class,"dwReserved","I");
+ lpCache->sStyle = (*env)->GetFieldID(env,lpCache->charformat2Class,"sStyle","S");
+ lpCache->wKerning = (*env)->GetFieldID(env,lpCache->charformat2Class,"wKerning","S");
+ lpCache->bUnderlineType = (*env)->GetFieldID(env,lpCache->charformat2Class,"bUnderlineType","B");
+ lpCache->bAnimation = (*env)->GetFieldID(env,lpCache->charformat2Class,"bAnimation","B");
+ lpCache->bRevAuthor = (*env)->GetFieldID(env,lpCache->charformat2Class,"bRevAuthor","B");
+ lpCache->bReserved1 = (*env)->GetFieldID(env,lpCache->charformat2Class,"bReserved1","B");
+ lpCache->cached = 1;
+}
+*/
+void cacheChoosecolorFids(JNIEnv *env, jobject lpChoosecolor, PCHOOSECOLOR_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->choosecolorClass = (*env)->GetObjectClass(env,lpChoosecolor);
+ lpCache->lStructSize = (*env)->GetFieldID(env,lpCache->choosecolorClass,"lStructSize","I");
+ lpCache->hwndOwner = (*env)->GetFieldID(env,lpCache->choosecolorClass,"hwndOwner","I");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->choosecolorClass,"hInstance","I");
+ lpCache->rgbResult = (*env)->GetFieldID(env,lpCache->choosecolorClass,"rgbResult","I");
+ lpCache->lpCustColors = (*env)->GetFieldID(env,lpCache->choosecolorClass,"lpCustColors","I");
+ lpCache->Flags = (*env)->GetFieldID(env,lpCache->choosecolorClass,"Flags","I");
+ lpCache->lCustData = (*env)->GetFieldID(env,lpCache->choosecolorClass,"lCustData","I");
+ lpCache->lpfnHook = (*env)->GetFieldID(env,lpCache->choosecolorClass,"lpfnHook","I");
+ lpCache->lpTemplateName = (*env)->GetFieldID(env,lpCache->choosecolorClass,"lpTemplateName","I");
+ lpCache->cached = 1;
+}
+
+void cacheChoosefontFids(JNIEnv *env, jobject lpChoosefont, PCHOOSEFONT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->choosefontClass = (*env)->GetObjectClass(env,lpChoosefont);
+ lpCache->lStructSize = (*env)->GetFieldID(env,lpCache->choosefontClass,"lStructSize","I");
+ lpCache->hwndOwner = (*env)->GetFieldID(env,lpCache->choosefontClass,"hwndOwner","I");
+ lpCache->hDC = (*env)->GetFieldID(env,lpCache->choosefontClass,"hDC","I");
+ lpCache->lpLogFont = (*env)->GetFieldID(env,lpCache->choosefontClass,"lpLogFont","I");
+ lpCache->iPointSize = (*env)->GetFieldID(env,lpCache->choosefontClass,"iPointSize","I");
+ lpCache->Flags = (*env)->GetFieldID(env,lpCache->choosefontClass,"Flags","I");
+ lpCache->rgbColors = (*env)->GetFieldID(env,lpCache->choosefontClass,"rgbColors","I");
+ lpCache->lCustData = (*env)->GetFieldID(env,lpCache->choosefontClass,"lCustData","I");
+ lpCache->lpfnHook = (*env)->GetFieldID(env,lpCache->choosefontClass,"lpfnHook","I");
+ lpCache->lpTemplateName = (*env)->GetFieldID(env,lpCache->choosefontClass,"lpTemplateName","I");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->choosefontClass,"hInstance","I");
+ lpCache->lpszStyle = (*env)->GetFieldID(env,lpCache->choosefontClass,"lpszStyle","I");
+ lpCache->nFontType = (*env)->GetFieldID(env,lpCache->choosefontClass,"nFontType","S");
+ lpCache->___MISSING_ALIGNMENT__ = (*env)->GetFieldID(env,lpCache->choosefontClass,"___MISSING_ALIGNMENT__","S");
+ lpCache->nSizeMin = (*env)->GetFieldID(env,lpCache->choosefontClass,"nSizeMin","I");
+ lpCache->nSizeMax = (*env)->GetFieldID(env,lpCache->choosefontClass,"nSizeMax","I");
+ lpCache->cached = 1;
+}
+
+void cacheCompositionformFids(JNIEnv *env, jobject lpCompositionform, PCOMPOSITIONFORM_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->compositionformClass = (*env)->GetObjectClass(env,lpCompositionform);
+ lpCache->dwStyle = (*env)->GetFieldID(env,lpCache->compositionformClass,"dwStyle","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->compositionformClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->compositionformClass,"y","I");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->compositionformClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->compositionformClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->compositionformClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->compositionformClass,"bottom","I");
+ lpCache->cached = 1;
+}
+
+void cacheCreatestructFids(JNIEnv *env, jobject lpCreatestruct, PCREATESTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->createstructClass = (*env)->GetObjectClass(env,lpCreatestruct);
+ lpCache->lpCreateParams = (*env)->GetFieldID(env,lpCache->createstructClass,"lpCreateParams","I");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->createstructClass,"hInstance","I");
+ lpCache->hMenu = (*env)->GetFieldID(env,lpCache->createstructClass,"hMenu","I");
+ lpCache->hwndParent = (*env)->GetFieldID(env,lpCache->createstructClass,"hwndParent","I");
+ lpCache->cx = (*env)->GetFieldID(env,lpCache->createstructClass,"cx","I");
+ lpCache->cy = (*env)->GetFieldID(env,lpCache->createstructClass,"cy","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->createstructClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->createstructClass,"y","I");
+ lpCache->style = (*env)->GetFieldID(env,lpCache->createstructClass,"style","I");
+ lpCache->lpszName = (*env)->GetFieldID(env,lpCache->createstructClass,"lpszName","I");
+ lpCache->lpszClass = (*env)->GetFieldID(env,lpCache->createstructClass,"lpszClass","I");
+ lpCache->dwExStyle = (*env)->GetFieldID(env,lpCache->createstructClass,"dwExStyle","I");
+ lpCache->cached = 1;
+}
+
+void cacheDibsectionFids(JNIEnv *env, jobject lpDibsection, PDIBSECTION_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->dibsectionClass = (*env)->GetObjectClass(env,lpDibsection);
+ lpCache->bmType = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmType","I");
+ lpCache->bmWidth = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmWidth","I");
+ lpCache->bmHeight = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmHeight","I");
+ lpCache->bmWidthBytes = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmWidthBytes","I");
+ lpCache->bmPlanes = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmPlanes","S");
+ lpCache->bmBitsPixel = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmBitsPixel","S");
+ lpCache->bmBits = (*env)->GetFieldID(env,lpCache->dibsectionClass,"bmBits","I");
+ lpCache->biSize = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biSize","I");
+ lpCache->biWidth = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biWidth","I");
+ lpCache->biHeight = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biHeight","I");
+ lpCache->biPlanes = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biPlanes","S");
+ lpCache->biBitCount = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biBitCount","S");
+ lpCache->biCompression = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biCompression","I");
+ lpCache->biSizeImage = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biSizeImage","I");
+ lpCache->biXPelsPerMeter = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biXPelsPerMeter","I");
+ lpCache->biYPelsPerMeter = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biYPelsPerMeter","I");
+ lpCache->biClrUsed = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biClrUsed","I");
+ lpCache->biClrImportant = (*env)->GetFieldID(env,lpCache->dibsectionClass,"biClrImportant","I");
+ lpCache->dsBitfields0 = (*env)->GetFieldID(env,lpCache->dibsectionClass,"dsBitfields0","I");
+ lpCache->dsBitfields1 = (*env)->GetFieldID(env,lpCache->dibsectionClass,"dsBitfields1","I");
+ lpCache->dsBitfields2 = (*env)->GetFieldID(env,lpCache->dibsectionClass,"dsBitfields2","I");
+ lpCache->dshSection = (*env)->GetFieldID(env,lpCache->dibsectionClass,"dshSection","I");
+ lpCache->dsOffset = (*env)->GetFieldID(env,lpCache->dibsectionClass,"dsOffset","I");
+ lpCache->cached = 1;
+}
+
+void cacheDllversioninfoFids(JNIEnv *env, jobject lpDllversioninfo, PDLLVERSIONINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->dllversioninfoClass = (*env)->GetObjectClass(env,lpDllversioninfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->dllversioninfoClass,"cbSize","I");
+ lpCache->dwMajorVersion = (*env)->GetFieldID(env,lpCache->dllversioninfoClass,"dwMajorVersion","I");
+ lpCache->dwMinorVersion = (*env)->GetFieldID(env,lpCache->dllversioninfoClass,"dwMinorVersion","I");
+ lpCache->dwBuildNumber = (*env)->GetFieldID(env,lpCache->dllversioninfoClass,"dwBuildNumber","I");
+ lpCache->dwPlatformID = (*env)->GetFieldID(env,lpCache->dllversioninfoClass,"dwPlatformID","I");
+ lpCache->cached = 1;
+}
+
+void cacheDocinfoFids(JNIEnv *env, jobject lpDocinfo, PDOCINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->docinfoClass = (*env)->GetObjectClass(env,lpDocinfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->docinfoClass,"cbSize","I");
+ lpCache->lpszDocName = (*env)->GetFieldID(env,lpCache->docinfoClass,"lpszDocName","I");
+ lpCache->lpszOutput = (*env)->GetFieldID(env,lpCache->docinfoClass,"lpszOutput","I");
+ lpCache->lpszDatatype = (*env)->GetFieldID(env,lpCache->docinfoClass,"lpszDatatype","I");
+ lpCache->fwType = (*env)->GetFieldID(env,lpCache->docinfoClass,"fwType","I");
+ lpCache->cached = 1;
+}
+
+void cacheDrawitemstructFids(JNIEnv *env, jobject lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->drawitemstructClass = (*env)->GetObjectClass(env,lpDrawitemstruct);
+ lpCache->CtlType = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"CtlType","I");
+ lpCache->CtlID = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"CtlID","I");
+ lpCache->itemID = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"itemID","I");
+ lpCache->itemAction = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"itemAction","I");
+ lpCache->itemState = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"itemState","I");
+ lpCache->hwndItem = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"hwndItem","I");
+ lpCache->hDC = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"hDC","I");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"bottom","I");
+ lpCache->itemData = (*env)->GetFieldID(env,lpCache->drawitemstructClass,"itemData","I");
+ lpCache->cached = 1;
+}
+
+void cacheHditemFids(JNIEnv *env, jobject lpHditem, PHDITEM_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->hditemClass = (*env)->GetObjectClass(env,lpHditem);
+ lpCache->mask = (*env)->GetFieldID(env,lpCache->hditemClass,"mask","I");
+ lpCache->cxy = (*env)->GetFieldID(env,lpCache->hditemClass,"cxy","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->hditemClass,"pszText","I");
+ lpCache->hbm = (*env)->GetFieldID(env,lpCache->hditemClass,"hbm","I");
+ lpCache->cchTextMax = (*env)->GetFieldID(env,lpCache->hditemClass,"cchTextMax","I");
+ lpCache->fmt = (*env)->GetFieldID(env,lpCache->hditemClass,"fmt","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->hditemClass,"lParam","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->hditemClass,"iImage","I");
+ lpCache->iOrder = (*env)->GetFieldID(env,lpCache->hditemClass,"iOrder","I");
+ lpCache->cached = 1;
+}
+
+void cacheHdlayoutFids(JNIEnv *env, jobject lpHdlayout, PHDLAYOUT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->hdlayoutClass = (*env)->GetObjectClass(env,lpHdlayout);
+ lpCache->prc = (*env)->GetFieldID(env,lpCache->hdlayoutClass,"prc","I");
+ lpCache->pwpos = (*env)->GetFieldID(env,lpCache->hdlayoutClass,"pwpos","I");
+ lpCache->cached = 1;
+}
+
+void cacheHelpinfoFids(JNIEnv *env, jobject lpHelpinfo, PHELPINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->helpinfoClass = (*env)->GetObjectClass(env,lpHelpinfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->helpinfoClass,"cbSize","I");
+ lpCache->iContextType = (*env)->GetFieldID(env,lpCache->helpinfoClass,"iContextType","I");
+ lpCache->iCtrlId = (*env)->GetFieldID(env,lpCache->helpinfoClass,"iCtrlId","I");
+ lpCache->hItemHandle = (*env)->GetFieldID(env,lpCache->helpinfoClass,"hItemHandle","I");
+ lpCache->dwContextId = (*env)->GetFieldID(env,lpCache->helpinfoClass,"dwContextId","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->helpinfoClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->helpinfoClass,"y","I");
+ lpCache->cached = 1;
+}
+
+void cacheIconinfoFids(JNIEnv *env, jobject lpIconinfo, PICONINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->iconinfoClass = (*env)->GetObjectClass(env,lpIconinfo);
+ lpCache->fIcon = (*env)->GetFieldID(env,lpCache->iconinfoClass,"fIcon","Z");
+ lpCache->xHotspot = (*env)->GetFieldID(env,lpCache->iconinfoClass,"xHotspot","I");
+ lpCache->yHotspot = (*env)->GetFieldID(env,lpCache->iconinfoClass,"yHotspot","I");
+ lpCache->hbmMask = (*env)->GetFieldID(env,lpCache->iconinfoClass,"hbmMask","I");
+ lpCache->hbmColor = (*env)->GetFieldID(env,lpCache->iconinfoClass,"hbmColor","I");
+ lpCache->cached = 1;
+}
+
+void cacheInitcommoncontrolsexFids(JNIEnv *env, jobject lpInitcommoncontrolsex, PINITCOMMONCONTROLSEX_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->initcommoncontrolsexClass = (*env)->GetObjectClass(env,lpInitcommoncontrolsex);
+ lpCache->dwSize = (*env)->GetFieldID(env,lpCache->initcommoncontrolsexClass,"dwSize","I");
+ lpCache->dwICC = (*env)->GetFieldID(env,lpCache->initcommoncontrolsexClass,"dwICC","I");
+ lpCache->cached = 1;
+}
+
+void cacheLogbrushFids(JNIEnv *env, jobject lpLogbrush, PLOGBRUSH_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->logbrushClass = (*env)->GetObjectClass(env,lpLogbrush);
+ lpCache->lbStyle = (*env)->GetFieldID(env,lpCache->logbrushClass,"lbStyle","I");
+ lpCache->lbColor = (*env)->GetFieldID(env,lpCache->logbrushClass,"lbColor","I");
+ lpCache->lbHatch = (*env)->GetFieldID(env,lpCache->logbrushClass,"lbHatch","I");
+ lpCache->cached = 1;
+}
+
+void cacheLogfontFids(JNIEnv *env, jobject lpLogfont, PLOGFONT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->logfontClass = (*env)->GetObjectClass(env,lpLogfont);
+ lpCache->lfHeight = (*env)->GetFieldID(env,lpCache->logfontClass,"lfHeight","I");
+ lpCache->lfWidth = (*env)->GetFieldID(env,lpCache->logfontClass,"lfWidth","I");
+ lpCache->lfEscapement = (*env)->GetFieldID(env,lpCache->logfontClass,"lfEscapement","I");
+ lpCache->lfOrientation = (*env)->GetFieldID(env,lpCache->logfontClass,"lfOrientation","I");
+ lpCache->lfWeight = (*env)->GetFieldID(env,lpCache->logfontClass,"lfWeight","I");
+ lpCache->lfItalic = (*env)->GetFieldID(env,lpCache->logfontClass,"lfItalic","B");
+ lpCache->lfUnderline = (*env)->GetFieldID(env,lpCache->logfontClass,"lfUnderline","B");
+ lpCache->lfStrikeOut = (*env)->GetFieldID(env,lpCache->logfontClass,"lfStrikeOut","B");
+ lpCache->lfCharSet = (*env)->GetFieldID(env,lpCache->logfontClass,"lfCharSet","B");
+ lpCache->lfOutPrecision = (*env)->GetFieldID(env,lpCache->logfontClass,"lfOutPrecision","B");
+ lpCache->lfClipPrecision = (*env)->GetFieldID(env,lpCache->logfontClass,"lfClipPrecision","B");
+ lpCache->lfQuality = (*env)->GetFieldID(env,lpCache->logfontClass,"lfQuality","B");
+ lpCache->lfPitchAndFamily = (*env)->GetFieldID(env,lpCache->logfontClass,"lfPitchAndFamily","B");
+ /* the calling function must get these byte array elements */
+ lpCache->lfFaceName0 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName0","B");
+ lpCache->lfFaceName1 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName1","B");
+ lpCache->lfFaceName2 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName2","B");
+ lpCache->lfFaceName3 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName3","B");
+ lpCache->lfFaceName4 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName4","B");
+ lpCache->lfFaceName5 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName5","B");
+ lpCache->lfFaceName6 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName6","B");
+ lpCache->lfFaceName7 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName7","B");
+ lpCache->lfFaceName8 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName8","B");
+ lpCache->lfFaceName9 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName9","B");
+ lpCache->lfFaceName10 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName10","B");
+ lpCache->lfFaceName11 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName11","B");
+ lpCache->lfFaceName12 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName12","B");
+ lpCache->lfFaceName13 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName13","B");
+ lpCache->lfFaceName14 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName14","B");
+ lpCache->lfFaceName15 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName15","B");
+ lpCache->lfFaceName16 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName16","B");
+ lpCache->lfFaceName17 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName17","B");
+ lpCache->lfFaceName18 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName18","B");
+ lpCache->lfFaceName19 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName19","B");
+ lpCache->lfFaceName20 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName20","B");
+ lpCache->lfFaceName21 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName21","B");
+ lpCache->lfFaceName22 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName22","B");
+ lpCache->lfFaceName23 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName23","B");
+ lpCache->lfFaceName24 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName24","B");
+ lpCache->lfFaceName25 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName25","B");
+ lpCache->lfFaceName26 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName26","B");
+ lpCache->lfFaceName27 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName27","B");
+ lpCache->lfFaceName28 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName28","B");
+ lpCache->lfFaceName29 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName29","B");
+ lpCache->lfFaceName30 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName30","B");
+ lpCache->lfFaceName31 = (*env)->GetFieldID(env,lpCache->logfontClass,"lfFaceName31","B");
+ lpCache->cached = 1;
+}
+
+void cacheLogpenFids(JNIEnv *env, jobject lpLogpen, PLOGPEN_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->logpenClass = (*env)->GetObjectClass(env,lpLogpen);
+ lpCache->lopnStyle = (*env)->GetFieldID(env,lpCache->logpenClass,"lopnStyle","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->logpenClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->logpenClass,"y","I");
+ lpCache->lopnColor = (*env)->GetFieldID(env,lpCache->logpenClass,"lopnColor","I");
+ lpCache->cached = 1;
+}
+/*
+void cacheExtlogpenFids(JNIEnv *env, jobject lpExtlogpen, PEXTLOGPEN_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->extlogpenClass = (*env)->GetObjectClass(env,lpExtlogpen);
+ lpCache->elpPenStyle = (*env)->GetFieldID(env,lpCache->extlogpenClass,"elpPenStyle","I");
+ lpCache->elpWidth = (*env)->GetFieldID(env,lpCache->extlogpenClass,"elpWidth","I");
+ lpCache->elpBrushStyle = (*env)->GetFieldID(env,lpCache->extlogpenClass,"elpBrushStyle","I");
+ lpCache->elpColor = (*env)->GetFieldID(env,lpCache->extlogpenClass,"elpColor","I");
+ lpCache->elpHatch = (*env)->GetFieldID(env,lpCache->extlogpenClass,"elpHatch","I");
+ lpCache->elpNumEntries = (*env)->GetFieldID(env,lpCache->extlogpenClass,"elpNumEntries","I");
+ lpCache->cached = 1;
+}
+*/
+void cacheLvcolumnFids(JNIEnv *env, jobject lpLvcolumn, PLVCOLUMN_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->lvcolumnClass = (*env)->GetObjectClass(env,lpLvcolumn);
+ lpCache->mask = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"mask","I");
+ lpCache->fmt = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"fmt","I");
+ lpCache->cx = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"cx","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"pszText","I");
+ lpCache->cchTextMax = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"cchTextMax","I");
+ lpCache->iSubItem = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"iSubItem","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"iImage","I");
+ lpCache->iOrder = (*env)->GetFieldID(env,lpCache->lvcolumnClass,"iOrder","I");
+ lpCache->cached = 1;
+}
+
+void cacheLvhittestinfoFids(JNIEnv *env, jobject lpLvhittestinfo, PLVHITTESTINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->lvhittestinfoClass = (*env)->GetObjectClass(env,lpLvhittestinfo);
+ lpCache->x = (*env)->GetFieldID(env,lpCache->lvhittestinfoClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->lvhittestinfoClass,"y","I");
+ lpCache->flags = (*env)->GetFieldID(env,lpCache->lvhittestinfoClass,"flags","I");
+ lpCache->iItem = (*env)->GetFieldID(env,lpCache->lvhittestinfoClass,"iItem","I");
+ lpCache->iSubItem = (*env)->GetFieldID(env,lpCache->lvhittestinfoClass,"iSubItem","I");
+ lpCache->cached = 1;
+}
+
+void cacheLvitemFids(JNIEnv *env, jobject lpLvitem, PLVITEM_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->lvitemClass = (*env)->GetObjectClass(env,lpLvitem);
+ lpCache->mask = (*env)->GetFieldID(env,lpCache->lvitemClass,"mask","I");
+ lpCache->iItem = (*env)->GetFieldID(env,lpCache->lvitemClass,"iItem","I");
+ lpCache->iSubItem = (*env)->GetFieldID(env,lpCache->lvitemClass,"iSubItem","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->lvitemClass,"state","I");
+ lpCache->stateMask = (*env)->GetFieldID(env,lpCache->lvitemClass,"stateMask","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->lvitemClass,"pszText","I");
+ lpCache->cchTextMax = (*env)->GetFieldID(env,lpCache->lvitemClass,"cchTextMax","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->lvitemClass,"iImage","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->lvitemClass,"lParam","I");
+ lpCache->iIndent = (*env)->GetFieldID(env,lpCache->lvitemClass,"iIndent","I");
+ lpCache->cached = 1;
+}
+
+void cacheMeasureitemstructFids(JNIEnv *env, jobject lpMeasureitemstruct, PMEASUREITEMSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->measureitemstructClass = (*env)->GetObjectClass(env,lpMeasureitemstruct);
+ lpCache->CtlType = (*env)->GetFieldID(env,lpCache->measureitemstructClass,"CtlType","I");
+ lpCache->CtlID = (*env)->GetFieldID(env,lpCache->measureitemstructClass,"CtlID","I");
+ lpCache->itemID = (*env)->GetFieldID(env,lpCache->measureitemstructClass,"itemID","I");
+ lpCache->itemWidth = (*env)->GetFieldID(env,lpCache->measureitemstructClass,"itemWidth","I");
+ lpCache->itemHeight = (*env)->GetFieldID(env,lpCache->measureitemstructClass,"itemHeight","I");
+ lpCache->itemData = (*env)->GetFieldID(env,lpCache->measureitemstructClass,"itemData","I");
+ lpCache->cached = 1;
+}
+
+void cacheMenuinfoFids(JNIEnv *env, jobject lpMenuinfo, PMENUINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->menuinfoClass = (*env)->GetObjectClass(env,lpMenuinfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->menuinfoClass,"cbSize","I");
+ lpCache->fMask = (*env)->GetFieldID(env,lpCache->menuinfoClass,"fMask","I");
+ lpCache->dwStyle = (*env)->GetFieldID(env,lpCache->menuinfoClass,"dwStyle","I");
+ lpCache->cyMax = (*env)->GetFieldID(env,lpCache->menuinfoClass,"cyMax","I");
+ lpCache->hbrBack = (*env)->GetFieldID(env,lpCache->menuinfoClass,"hbrBack","I");
+ lpCache->dwContextHelpID = (*env)->GetFieldID(env,lpCache->menuinfoClass,"dwContextHelpID","I");
+ lpCache->dwMenuData = (*env)->GetFieldID(env,lpCache->menuinfoClass,"dwMenuData","I");
+ lpCache->cached = 1;
+}
+
+void cacheMenuiteminfoFids(JNIEnv *env, jobject lpMenuiteminfo, PMENUITEMINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->menuiteminfoClass = (*env)->GetObjectClass(env,lpMenuiteminfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"cbSize","I");
+ lpCache->fMask = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"fMask","I");
+ lpCache->fType = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"fType","I");
+ lpCache->fState = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"fState","I");
+ lpCache->wID = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"wID","I");
+ lpCache->hSubMenu = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"hSubMenu","I");
+ lpCache->hbmpChecked = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"hbmpChecked","I");
+ lpCache->hbmpUnchecked = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"hbmpUnchecked","I");
+ lpCache->dwItemData = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"dwItemData","I");
+ lpCache->dwTypeData = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"dwTypeData","I");
+ lpCache->cch = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"cch", "I");
+#ifdef USE_2000_CALLS
+ lpCache->hbmpItem = (*env)->GetFieldID(env,lpCache->menuiteminfoClass,"hbmpItem", "I");
+#endif
+ lpCache->cached = 1;
+}
+
+void cacheMsgFids(JNIEnv *env, jobject lpMsg, PMSG_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->msgClass = (*env)->GetObjectClass(env,lpMsg);
+ lpCache->hwnd = (*env)->GetFieldID(env,lpCache->msgClass,"hwnd","I");
+ lpCache->message = (*env)->GetFieldID(env,lpCache->msgClass,"message","I");
+ lpCache->wParam = (*env)->GetFieldID(env,lpCache->msgClass,"wParam","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->msgClass,"lParam","I");
+ lpCache->time = (*env)->GetFieldID(env,lpCache->msgClass,"time","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->msgClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->msgClass,"y","I");
+ lpCache->cached = 1;
+}
+
+void cacheMsgfilterFids(JNIEnv *env, jobject lpMsgfilter, PMSGFILTER_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->msgfilterClass = (*env)->GetObjectClass(env,lpMsgfilter);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->msgfilterClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->msgfilterClass,"idFrom","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->msgfilterClass,"code","I");
+ lpCache->msg = (*env)->GetFieldID(env,lpCache->msgfilterClass,"msg","I");
+ lpCache->wParam = (*env)->GetFieldID(env,lpCache->msgfilterClass,"wParam","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->msgfilterClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheNmhdrFids(JNIEnv *env, jobject lpNmhdr, PNMHDR_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->nmhdrClass = (*env)->GetObjectClass(env,lpNmhdr);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->nmhdrClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->nmhdrClass,"idFrom","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->nmhdrClass,"code","I");
+ lpCache->cached = 1;
+}
+
+void cacheNmheaderFids(JNIEnv *env, jobject lpNmheader, PNMHEADER_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->nmheaderClass = (*env)->GetObjectClass(env,lpNmheader);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->nmheaderClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->nmheaderClass,"idFrom","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->nmheaderClass,"code","I");
+ lpCache->iItem = (*env)->GetFieldID(env,lpCache->nmheaderClass,"iItem","I");
+ lpCache->iButton = (*env)->GetFieldID(env,lpCache->nmheaderClass,"iButton","I");
+ lpCache->pitem = (*env)->GetFieldID(env,lpCache->nmheaderClass,"pitem","I");
+ lpCache->cached = 1;
+}
+
+void cacheNmlistviewFids(JNIEnv *env, jobject lpNmlistview, PNMLISTVIEW_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->nmlistviewClass = (*env)->GetObjectClass(env,lpNmlistview);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"idFrom","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"code","I");
+ lpCache->iItem = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"iItem","I");
+ lpCache->iSubItem = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"iSubItem","I");
+ lpCache->uNewState = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"uNewState","I");
+ lpCache->uOldState = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"uOldState","I");
+ lpCache->uChanged = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"uChanged","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"y","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->nmlistviewClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheNmtoolbarFids(JNIEnv *env, jobject lpNmtoolbar, PNMTOOLBAR_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->nmtoolbarClass = (*env)->GetObjectClass(env,lpNmtoolbar);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"idFrom","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"code","I");
+ lpCache->iItem = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"iItem","I");
+ lpCache->iBitmap = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"iBitmap","I");
+ lpCache->idCommand = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"idCommand","I");
+ lpCache->fsState = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"fsState","B");
+ lpCache->fsStyle = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"fsStyle","B");
+ lpCache->___MISSING_ALIGNMENT__ = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"___MISSING_ALIGNMENT__","S");
+ lpCache->dwData = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"dwData","I");
+ lpCache->iString = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"iString","I");
+ lpCache->cchText = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"cchText","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"pszText","I");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->nmtoolbarClass,"bottom","I");
+ lpCache->cached = 1;
+}
+
+void cacheNmttdispinfoFids(JNIEnv *env, jobject lpNmttdispinfo, PNMTTDISPINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->nmttdispinfoClass = (*env)->GetObjectClass(env,lpNmttdispinfo);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"idFrom","I");
+ lpCache->lpszText = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"lpszText","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"code","I");
+ lpCache->pad0 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad0","I");
+ lpCache->pad1 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad1","I");
+ lpCache->pad2 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad2","I");
+ lpCache->pad3 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad3","I");
+ lpCache->pad4 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad4","I");
+ lpCache->pad5 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad5","I");
+ lpCache->pad6 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad6","I");
+ lpCache->pad7 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad7","I");
+ lpCache->pad8 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad8","I");
+ lpCache->pad9 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad9","I");
+ lpCache->pad10 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad10","I");
+ lpCache->pad11 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad11","I");
+ lpCache->pad12 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad12","I");
+ lpCache->pad13 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad13","I");
+ lpCache->pad14 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad14","I");
+ lpCache->pad15 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad15","I");
+ lpCache->pad16 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad16","I");
+ lpCache->pad17 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad17","I");
+ lpCache->pad18 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad18","I");
+ lpCache->pad19 = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"pad19","I");
+ lpCache->hinst = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"hinst","I");
+ lpCache->uFlags = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"uFlags","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->nmttdispinfoClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheNmtvcustomdrawFids(JNIEnv *env, jobject lpNmtvcustomdraw, PNMTVCUSTOMDRAW_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->nmtvcustomdrawClass = (*env)->GetObjectClass(env,lpNmtvcustomdraw);
+ lpCache->hwndFrom = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"hwndFrom","I");
+ lpCache->idFrom = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"idFrom","I");
+ lpCache->code = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"code","I");
+ lpCache->dwDrawStage = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"dwDrawStage","I");
+ lpCache->hdc = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"hdc","I");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"bottom","I");
+ lpCache->dwItemSpec = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"dwItemSpec","I");
+ lpCache->uItemState = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"uItemState","I");
+ lpCache->lItemlParam = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"lItemlParam","I");
+ lpCache->clrText = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"clrText","I");
+ lpCache->clrTextBk = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"clrTextBk","I");
+ lpCache->iLevel = (*env)->GetFieldID(env,lpCache->nmtvcustomdrawClass,"iLevel","I");
+ lpCache->cached = 1;
+}
+
+void cacheOpenfilenameFids(JNIEnv *env, jobject lpOpenfilename, POPENFILENAME_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->openfilenameClass = (*env)->GetObjectClass(env,lpOpenfilename);
+ lpCache->lStructSize = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lStructSize","I");
+ lpCache->hwndOwner = (*env)->GetFieldID(env,lpCache->openfilenameClass,"hwndOwner","I");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->openfilenameClass,"hInstance","I");
+ lpCache->lpstrFilter = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrFilter","I");
+ lpCache->lpstrCustomFilter = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrCustomFilter","I");
+ lpCache->nMaxCustFilter = (*env)->GetFieldID(env,lpCache->openfilenameClass,"nMaxCustFilter","I");
+ lpCache->nFilterIndex = (*env)->GetFieldID(env,lpCache->openfilenameClass,"nFilterIndex","I");
+ lpCache->lpstrFile = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrFile","I");
+ lpCache->nMaxFile = (*env)->GetFieldID(env,lpCache->openfilenameClass,"nMaxFile","I");
+ lpCache->lpstrFileTitle = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrFileTitle","I");
+ lpCache->nMaxFileTitle = (*env)->GetFieldID(env,lpCache->openfilenameClass,"nMaxFileTitle","I");
+ lpCache->lpstrInitialDir = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrInitialDir","I");
+ lpCache->lpstrTitle = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrTitle","I");
+ lpCache->Flags = (*env)->GetFieldID(env,lpCache->openfilenameClass,"Flags","I");
+ lpCache->nFileOffset = (*env)->GetFieldID(env,lpCache->openfilenameClass,"nFileOffset","S");
+ lpCache->nFileExtension = (*env)->GetFieldID(env,lpCache->openfilenameClass,"nFileExtension","S");
+ lpCache->lpstrDefExt = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpstrDefExt","I");
+ lpCache->lCustData = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lCustData","I");
+ lpCache->lpfnHook = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpfnHook","I");
+ lpCache->lpTemplateName = (*env)->GetFieldID(env,lpCache->openfilenameClass,"lpTemplateName","I");
+ lpCache->cached = 1;
+}
+
+void cachePaintstructFids(JNIEnv *env, jobject lpPaint, PPAINTSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->paintClass = (*env)->GetObjectClass(env,lpPaint);
+ lpCache->hdc = (*env)->GetFieldID(env,lpCache->paintClass,"hdc","I");
+ lpCache->fErase = (*env)->GetFieldID(env,lpCache->paintClass,"fErase","Z");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->paintClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->paintClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->paintClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->paintClass,"bottom","I");
+ lpCache->fRestore = (*env)->GetFieldID(env,lpCache->paintClass,"fRestore","Z");
+ lpCache->fIncUpdate = (*env)->GetFieldID(env,lpCache->paintClass,"fIncUpdate","Z");
+ lpCache->cached = 1;
+}
+
+void cachePagesetupdlgFids(JNIEnv *env, jobject lpPagesetupdlg, PPAGESETUPDLG_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->pagesetupdlgClass = (*env)->GetObjectClass(env,lpPagesetupdlg);
+ lpCache->lStructSize = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"lStructSize","I");
+ lpCache->hwndOwner = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"hwndOwner","I");
+ lpCache->hDevMode = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"hDevMode","I");
+ lpCache->hDevNames = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"hDevNames","I");
+ lpCache->Flags = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"Flags","I");
+ lpCache->ptPaperSize_x = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"ptPaperSize_x","I");
+ lpCache->ptPaperSize_y = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"ptPaperSize_y","I");
+ lpCache->rtMinMargin_left = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMinMargin_left","I");
+ lpCache->rtMinMargin_top = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMinMargin_top","I");
+ lpCache->rtMinMargin_right = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMinMargin_right","I");
+ lpCache->rtMinMargin_bottom = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMinMargin_bottom","I");
+ lpCache->rtMargin_left = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMargin_left","I");
+ lpCache->rtMargin_top = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMargin_top","I");
+ lpCache->rtMargin_right = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMargin_right","I");
+ lpCache->rtMargin_bottom = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"rtMargin_bottom","I");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"hInstance","I");
+ lpCache->lCustData = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"lCustData","I");
+ lpCache->lpfnPageSetupHook = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"lpfnPageSetupHook","I");
+ lpCache->lpfnPagePaintHook = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"lpfnPagePaintHook","I");
+ lpCache->lpPageSetupTemplateName = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"lpPageSetupTemplateName","I");
+ lpCache->hPageSetupTemplate = (*env)->GetFieldID(env,lpCache->pagesetupdlgClass,"hPageSetupTemplate","I");
+ lpCache->cached = 1;
+}
+/*
+void cacheParaformatFids(JNIEnv *env, jobject lpParaformat, PPARAFORMAT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->paraformatClass = (*env)->GetObjectClass(env,lpParaformat);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->paraformatClass,"cbSize","I");
+ lpCache->dwMask = (*env)->GetFieldID(env,lpCache->paraformatClass,"dwMask","I");
+ lpCache->wNumbering = (*env)->GetFieldID(env,lpCache->paraformatClass,"wNumbering","S");
+ lpCache->wEffects = (*env)->GetFieldID(env,lpCache->paraformatClass,"wEffects","S");
+ lpCache->dxStartIndent = (*env)->GetFieldID(env,lpCache->paraformatClass,"dxStartIndent","I");
+ lpCache->dxRightIndent = (*env)->GetFieldID(env,lpCache->paraformatClass,"dxRightIndent","I");
+ lpCache->dxOffset = (*env)->GetFieldID(env,lpCache->paraformatClass,"dxOffset","I");
+ lpCache->wAlignment = (*env)->GetFieldID(env,lpCache->paraformatClass,"wAlignment","S");
+ lpCache->cTabCount = (*env)->GetFieldID(env,lpCache->paraformatClass,"cTabCount","S");
+ lpCache->rgxTabs0 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs0","I");
+ lpCache->rgxTabs1 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs1","I");
+ lpCache->rgxTabs2 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs2","I");
+ lpCache->rgxTabs3 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs3","I");
+ lpCache->rgxTabs4 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs4","I");
+ lpCache->rgxTabs5 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs5","I");
+ lpCache->rgxTabs6 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs6","I");
+ lpCache->rgxTabs7 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs7","I");
+ lpCache->rgxTabs8 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs8","I");
+ lpCache->rgxTabs9 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs9","I");
+ lpCache->rgxTabs10 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs10","I");
+ lpCache->rgxTabs11 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs11","I");
+ lpCache->rgxTabs12 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs12","I");
+ lpCache->rgxTabs13 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs13","I");
+ lpCache->rgxTabs14 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs14","I");
+ lpCache->rgxTabs15 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs15","I");
+ lpCache->rgxTabs16 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs16","I");
+ lpCache->rgxTabs17 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs17","I");
+ lpCache->rgxTabs18 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs18","I");
+ lpCache->rgxTabs19 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs19","I");
+ lpCache->rgxTabs20 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs20","I");
+ lpCache->rgxTabs21 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs21","I");
+ lpCache->rgxTabs22 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs22","I");
+ lpCache->rgxTabs23 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs23","I");
+ lpCache->rgxTabs24 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs24","I");
+ lpCache->rgxTabs25 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs25","I");
+ lpCache->rgxTabs26 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs26","I");
+ lpCache->rgxTabs27 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs27","I");
+ lpCache->rgxTabs28 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs28","I");
+ lpCache->rgxTabs29 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs29","I");
+ lpCache->rgxTabs30 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs30","I");
+ lpCache->rgxTabs31 = (*env)->GetFieldID(env,lpCache->paraformatClass,"rgxTabs31","I");
+ lpCache->cached = 1;
+}
+*/
+void cachePointFids(JNIEnv *env, jobject lpPoint, PPOINT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->pointClass = (*env)->GetObjectClass(env, lpPoint);
+ lpCache->x = (*env)->GetFieldID(env,lpCache->pointClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->pointClass,"y","I");
+ lpCache->cached = 1;
+}
+
+void cachePrintdlgFids(JNIEnv *env, jobject lpPrintdlg, PPRINTDLG_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->printdlgClass = (*env)->GetObjectClass(env, lpPrintdlg);
+ lpCache->lStructSize = (*env)->GetFieldID(env,lpCache->printdlgClass,"lStructSize","I");
+ lpCache->hwndOwner = (*env)->GetFieldID(env,lpCache->printdlgClass,"hwndOwner","I");
+ lpCache->hDevMode = (*env)->GetFieldID(env,lpCache->printdlgClass,"hDevMode","I");
+ lpCache->hDevNames = (*env)->GetFieldID(env,lpCache->printdlgClass,"hDevNames","I");
+ lpCache->hDC = (*env)->GetFieldID(env,lpCache->printdlgClass,"hDC","I");
+ lpCache->Flags = (*env)->GetFieldID(env,lpCache->printdlgClass,"Flags","I");
+ lpCache->nFromPage = (*env)->GetFieldID(env,lpCache->printdlgClass,"nFromPage","S");
+ lpCache->nToPage = (*env)->GetFieldID(env,lpCache->printdlgClass,"nToPage","S");
+ lpCache->nMinPage = (*env)->GetFieldID(env,lpCache->printdlgClass,"nMinPage","S");
+ lpCache->nMaxPage = (*env)->GetFieldID(env,lpCache->printdlgClass,"nMaxPage","S");
+ lpCache->nCopies = (*env)->GetFieldID(env,lpCache->printdlgClass,"nCopies","S");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->printdlgClass,"hInstance","I");
+ lpCache->lCustData = (*env)->GetFieldID(env,lpCache->printdlgClass,"lCustData","I");
+ lpCache->lpfnPrintHook = (*env)->GetFieldID(env,lpCache->printdlgClass,"lpfnPrintHook","I");
+ lpCache->lpfnSetupHook = (*env)->GetFieldID(env,lpCache->printdlgClass,"lpfnSetupHook","I");
+ lpCache->lpPrintTemplateName = (*env)->GetFieldID(env,lpCache->printdlgClass,"lpPrintTemplateName","I");
+ lpCache->lpSetupTemplateName = (*env)->GetFieldID(env,lpCache->printdlgClass,"lpSetupTemplateName","I");
+ lpCache->hPrintTemplate = (*env)->GetFieldID(env,lpCache->printdlgClass,"hPrintTemplate","I");
+ lpCache->hSetupTemplate = (*env)->GetFieldID(env,lpCache->printdlgClass,"hSetupTemplate","I");
+ lpCache->cached = 1;
+}
+
+void cacheRebarbandinfoFids(JNIEnv *env, jobject lpRebarbandinfo, PREBARBANDINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->rebarbandinfoClass = (*env)->GetObjectClass(env, lpRebarbandinfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cbSize","I");
+ lpCache->fMask = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"fMask","I");
+ lpCache->fStyle = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"fStyle","I");
+ lpCache->clrFore = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"clrFore","I");
+ lpCache->clrBack = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"clrBack","I");
+ lpCache->lpText = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"lpText","I");
+ lpCache->cch = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cch","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"iImage","I");
+ lpCache->hwndChild = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"hwndChild","I");
+ lpCache->cxMinChild = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cxMinChild","I");
+ lpCache->cyMinChild = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cyMinChild","I");
+ lpCache->cx = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cx","I");
+ lpCache->hbmBack = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"hbmBack","I");
+ lpCache->wID = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"wID","I");
+ lpCache->cyChild = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cyChild","I");
+ lpCache->cyMaxChild = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cyMaxChild","I");
+ lpCache->cyIntegral = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cyIntegral","I");
+ lpCache->cxIdeal = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cxIdeal","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"lParam","I");
+ lpCache->cxHeader = (*env)->GetFieldID(env,lpCache->rebarbandinfoClass,"cxHeader","I");
+ lpCache->cached = 1;
+}
+
+void cacheRectFids(JNIEnv *env, jobject lpRect, PRECT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->rectClass = (*env)->GetObjectClass(env,lpRect);
+ lpCache->left = (*env)->GetFieldID(env,lpCache->rectClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->rectClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->rectClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->rectClass,"bottom","I");
+ lpCache->cached = 1;
+}
+
+void cacheScrollinfoFids(JNIEnv *env, jobject lpScrollinfo, PSCROLLINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->scrollinfoClass = (*env)->GetObjectClass(env,lpScrollinfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"cbSize","I");
+ lpCache->fMask = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"fMask","I");
+ lpCache->nMin = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"nMin","I");
+ lpCache->nMax = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"nMax","I");
+ lpCache->nPage = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"nPage","I");
+ lpCache->nPos = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"nPos","I");
+ lpCache->nTrackPos = (*env)->GetFieldID(env,lpCache->scrollinfoClass,"nTrackPos","I");
+ lpCache->cached = 1;
+}
+
+void cacheSizeFids(JNIEnv *env, jobject lpSize, PSIZE_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->sizeClass = (*env)->GetObjectClass(env,lpSize);
+ lpCache->cx = (*env)->GetFieldID(env,lpCache->sizeClass,"cx","I");
+ lpCache->cy = (*env)->GetFieldID(env,lpCache->sizeClass,"cy","I");
+ lpCache->cached = 1;
+}
+
+void cacheTbbuttonFids(JNIEnv *env, jobject lpTbbutton, PTBBUTTON_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->tbbuttonClass = (*env)->GetObjectClass(env,lpTbbutton);
+ lpCache->iBitmap = (*env)->GetFieldID(env,lpCache->tbbuttonClass,"iBitmap","I");
+ lpCache->idCommand = (*env)->GetFieldID(env,lpCache->tbbuttonClass,"idCommand","I");
+ lpCache->fsState = (*env)->GetFieldID(env,lpCache->tbbuttonClass,"fsState","B");
+ lpCache->fsStyle = (*env)->GetFieldID(env,lpCache->tbbuttonClass,"fsStyle","B");
+ lpCache->dwData = (*env)->GetFieldID(env,lpCache->tbbuttonClass,"dwData","I");
+ lpCache->iString = (*env)->GetFieldID(env,lpCache->tbbuttonClass,"iString","I");
+ lpCache->cached = 1;
+}
+
+void cacheTbbuttoninfoFids(JNIEnv *env, jobject lpTbbuttoninfo, PTBBUTTONINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->tbbuttoninfoClass = (*env)->GetObjectClass(env,lpTbbuttoninfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"cbSize","I");
+ lpCache->dwMask = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"dwMask","I");
+ lpCache->idCommand = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"idCommand","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"iImage","I");
+ lpCache->fsState = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"fsState","B");
+ lpCache->fsStyle = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"fsStyle","B");
+ lpCache->cx = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"cx","S");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"lParam","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"pszText","I");
+ lpCache->cchText = (*env)->GetFieldID(env,lpCache->tbbuttoninfoClass,"cchText","I");
+ lpCache->cached = 1;
+}
+
+void cacheTcitemFids(JNIEnv *env, jobject lpTcitem, PTCITEM_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->tcitemClass = (*env)->GetObjectClass(env,lpTcitem);
+ lpCache->mask = (*env)->GetFieldID(env,lpCache->tcitemClass,"mask","I");
+ lpCache->dwState = (*env)->GetFieldID(env,lpCache->tcitemClass,"dwState","I");
+ lpCache->dwStateMask = (*env)->GetFieldID(env,lpCache->tcitemClass,"dwStateMask","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->tcitemClass,"pszText","I");
+ lpCache->cchTextMax = (*env)->GetFieldID(env,lpCache->tcitemClass,"cchTextMax","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->tcitemClass,"iImage","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->tcitemClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheTextmetricFids(JNIEnv *env, jobject lpTextmetric, PTEXTMETRIC_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->textmetricClass = (*env)->GetObjectClass(env,lpTextmetric);
+ lpCache->tmHeight = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmHeight","I");
+ lpCache->tmAscent = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmAscent","I");
+ lpCache->tmDescent = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmDescent","I");
+ lpCache->tmInternalLeading = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmInternalLeading","I");
+ lpCache->tmExternalLeading = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmExternalLeading","I");
+ lpCache->tmAveCharWidth = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmAveCharWidth","I");
+ lpCache->tmMaxCharWidth = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmMaxCharWidth","I");
+ lpCache->tmWeight = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmWeight","I");
+ lpCache->tmOverhang = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmOverhang","I");
+ lpCache->tmDigitizedAspectX = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmDigitizedAspectX","I");
+ lpCache->tmDigitizedAspectY = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmDigitizedAspectY","I");
+ lpCache->tmFirstChar = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmFirstChar","B");
+ lpCache->tmLastChar = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmLastChar","B");
+ lpCache->tmDefaultChar = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmDefaultChar","B");
+ lpCache->tmBreakChar = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmBreakChar","B");
+ lpCache->tmItalic = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmItalic","B");
+ lpCache->tmUnderlined = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmUnderlined","B");
+ lpCache->tmStruckOut = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmStruckOut","B");
+ lpCache->tmPitchAndFamily = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmPitchAndFamily","B");
+ lpCache->tmCharSet = (*env)->GetFieldID(env,lpCache->textmetricClass,"tmCharSet","B");
+ lpCache->cached = 1;
+}
+
+void cacheToolinfoFids(JNIEnv *env, jobject lpToolinfo, PTOOLINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->toolinfoClass = (*env)->GetObjectClass(env,lpToolinfo);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->toolinfoClass,"cbSize","I");
+ lpCache->uFlags = (*env)->GetFieldID(env,lpCache->toolinfoClass,"uFlags","I");
+ lpCache->hwnd = (*env)->GetFieldID(env,lpCache->toolinfoClass,"hwnd","I");
+ lpCache->uId = (*env)->GetFieldID(env,lpCache->toolinfoClass,"uId","I");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->toolinfoClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->toolinfoClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->toolinfoClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->toolinfoClass,"bottom","I");
+ lpCache->hinst = (*env)->GetFieldID(env,lpCache->toolinfoClass,"hinst","I");
+ lpCache->lpszText = (*env)->GetFieldID(env,lpCache->toolinfoClass,"lpszText","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->toolinfoClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheTrackmouseeventFids(JNIEnv *env, jobject lpTrackmouseevent, PTRACKMOUSEEVENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->trackmouseeventClass = (*env)->GetObjectClass(env,lpTrackmouseevent);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->trackmouseeventClass,"cbSize","I");
+ lpCache->dwFlags = (*env)->GetFieldID(env,lpCache->trackmouseeventClass,"dwFlags","I");
+ lpCache->hwndTrack = (*env)->GetFieldID(env,lpCache->trackmouseeventClass,"hwndTrack","I");
+ lpCache->dwHoverTime = (*env)->GetFieldID(env,lpCache->trackmouseeventClass,"dwHoverTime","I");
+ lpCache->cached = 1;
+}
+
+void cacheTvhittestinfoFids(JNIEnv *env, jobject lpTvhittestinfo, PTVHITTESTINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->tvhittestinfoClass = (*env)->GetObjectClass(env,lpTvhittestinfo);
+ lpCache->x = (*env)->GetFieldID(env,lpCache->tvhittestinfoClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->tvhittestinfoClass,"y","I");
+ lpCache->flags = (*env)->GetFieldID(env,lpCache->tvhittestinfoClass,"flags","I");
+ lpCache->hItem = (*env)->GetFieldID(env,lpCache->tvhittestinfoClass,"hItem","I");
+ lpCache->cached = 1;
+}
+
+void cacheTvinsertstructFids(JNIEnv *env, jobject lpTvinsertstruct, PTVINSERTSTRUCT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->tvinsertstructClass = (*env)->GetObjectClass(env,lpTvinsertstruct);
+ lpCache->hParent = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"hParent","I");
+ lpCache->hInsertAfter = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"hInsertAfter","I");
+ lpCache->mask = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"mask","I");
+ lpCache->hItem = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"hItem","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"state","I");
+ lpCache->stateMask = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"stateMask","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"pszText","I");
+ lpCache->cchTextMax = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"cchTextMax","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"iImage","I");
+ lpCache->iSelectedImage = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"iSelectedImage","I");
+ lpCache->cChildren = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"cChildren","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->tvinsertstructClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheTvitemFids(JNIEnv *env, jobject lpTvitem, PTVITEM_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->tvitemClass = (*env)->GetObjectClass(env,lpTvitem);
+ lpCache->mask = (*env)->GetFieldID(env,lpCache->tvitemClass,"mask","I");
+ lpCache->hItem = (*env)->GetFieldID(env,lpCache->tvitemClass,"hItem","I");
+ lpCache->state = (*env)->GetFieldID(env,lpCache->tvitemClass,"state","I");
+ lpCache->stateMask = (*env)->GetFieldID(env,lpCache->tvitemClass,"stateMask","I");
+ lpCache->pszText = (*env)->GetFieldID(env,lpCache->tvitemClass,"pszText","I");
+ lpCache->cchTextMax = (*env)->GetFieldID(env,lpCache->tvitemClass,"cchTextMax","I");
+ lpCache->iImage = (*env)->GetFieldID(env,lpCache->tvitemClass,"iImage","I");
+ lpCache->iSelectedImage = (*env)->GetFieldID(env,lpCache->tvitemClass,"iSelectedImage","I");
+ lpCache->cChildren = (*env)->GetFieldID(env,lpCache->tvitemClass,"cChildren","I");
+ lpCache->lParam = (*env)->GetFieldID(env,lpCache->tvitemClass,"lParam","I");
+ lpCache->cached = 1;
+}
+
+void cacheWindowplacementFids(JNIEnv *env, jobject lpWindowplacement, PWINDOWPLACEMENT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->windowplacementClass = (*env)->GetObjectClass(env,lpWindowplacement);
+ lpCache->length = (*env)->GetFieldID(env,lpCache->windowplacementClass,"length","I");
+ lpCache->flags = (*env)->GetFieldID(env,lpCache->windowplacementClass,"flags","I");
+ lpCache->showCmd = (*env)->GetFieldID(env,lpCache->windowplacementClass,"showCmd","I");
+ lpCache->ptMinPosition_x = (*env)->GetFieldID(env,lpCache->windowplacementClass,"ptMinPosition_x","I");
+ lpCache->ptMinPosition_y = (*env)->GetFieldID(env,lpCache->windowplacementClass,"ptMinPosition_y","I");
+ lpCache->ptMaxPosition_x = (*env)->GetFieldID(env,lpCache->windowplacementClass,"ptMaxPosition_x","I");
+ lpCache->ptMaxPosition_y = (*env)->GetFieldID(env,lpCache->windowplacementClass,"ptMaxPosition_y","I");
+ lpCache->left = (*env)->GetFieldID(env,lpCache->windowplacementClass,"left","I");
+ lpCache->top = (*env)->GetFieldID(env,lpCache->windowplacementClass,"top","I");
+ lpCache->right = (*env)->GetFieldID(env,lpCache->windowplacementClass,"right","I");
+ lpCache->bottom = (*env)->GetFieldID(env,lpCache->windowplacementClass,"bottom","I");
+ lpCache->cached = 1;
+}
+
+void cacheWindowposFids(JNIEnv *env, jobject lpWindowpos, PWINDOWPOS_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->windowposClass = (*env)->GetObjectClass(env,lpWindowpos);
+ lpCache->hwnd = (*env)->GetFieldID(env,lpCache->windowposClass,"hwnd","I");
+ lpCache->hwndInsertAfter = (*env)->GetFieldID(env,lpCache->windowposClass,"hwndInsertAfter","I");
+ lpCache->x = (*env)->GetFieldID(env,lpCache->windowposClass,"x","I");
+ lpCache->y = (*env)->GetFieldID(env,lpCache->windowposClass,"y","I");
+ lpCache->cx = (*env)->GetFieldID(env,lpCache->windowposClass,"cx","I");
+ lpCache->cy = (*env)->GetFieldID(env,lpCache->windowposClass,"cy","I");
+ lpCache->flags = (*env)->GetFieldID(env,lpCache->windowposClass,"flags","I");
+ lpCache->cached = 1;
+}
+
+void cacheWndclassexFids(JNIEnv *env, jobject lpWndclassex, PWNDCLASSEX_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->wndclassexClass = (*env)->GetObjectClass(env,lpWndclassex);
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->wndclassexClass,"cbSize","I");
+ lpCache->style = (*env)->GetFieldID(env,lpCache->wndclassexClass,"style","I");
+ lpCache->lpfnWndProc = (*env)->GetFieldID(env,lpCache->wndclassexClass,"lpfnWndProc","I");
+ lpCache->cbClsExtra = (*env)->GetFieldID(env,lpCache->wndclassexClass,"cbClsExtra","I");
+ lpCache->cbWndExtra = (*env)->GetFieldID(env,lpCache->wndclassexClass,"cbWndExtra","I");
+ lpCache->hInstance = (*env)->GetFieldID(env,lpCache->wndclassexClass,"hInstance","I");
+ lpCache->hIcon = (*env)->GetFieldID(env,lpCache->wndclassexClass,"hIcon","I");
+ lpCache->hCursor = (*env)->GetFieldID(env,lpCache->wndclassexClass,"hCursor","I");
+ lpCache->hbrBackground = (*env)->GetFieldID(env,lpCache->wndclassexClass,"hbrBackground","I");
+ lpCache->lpszMenuName = (*env)->GetFieldID(env,lpCache->wndclassexClass,"lpszMenuName","I");
+ lpCache->lpszClassName = (*env)->GetFieldID(env,lpCache->wndclassexClass,"lpszClassName","I");
+ lpCache->hIconSm = (*env)->GetFieldID(env,lpCache->wndclassexClass,"hIconSm","I");
+ lpCache->cached = 1;
+}
+
+/*
+* NOTE: Untested - szDisplayName and szTypeName don't work
+*/
+/*
+void cacheShfileinfoFids(JNIEnv *env, jobject lpShfileinfo, PSHFILEINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->shfileinfoClass = (*env)->GetObjectClass(env,lpShfileinfo);
+ lpCache->hIcon = (*env)->GetFieldID(env,lpCache->shfileinfoClass,"hIcon","I");
+ lpCache->iIcon = (*env)->GetFieldID(env,lpCache->shfileinfoClass,"iIcon","I");
+ lpCache->dwAttributes = (*env)->GetFieldID(env,lpCache->shfileinfoClass,"dwAttributes","I");
+ lpCache->szDisplayName = (*env)->GetFieldID(env,lpCache->shfileinfoClass,"szDisplayName","[B");
+ lpCache->szTypeName = (*env)->GetFieldID(env,lpCache->shfileinfoClass,"szTypeName","[B");
+ lpCache->cached = 1;
+}
+*/
+
+/* ----------- ole fid and class caches ----------- */
+
+void cacheCauuidFids(JNIEnv *env, jobject lpCauuid, PCAUUID_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->cauuidClass = (*env)->GetObjectClass(env,lpCauuid);
+ lpCache->cElems = (*env)->GetFieldID(env,lpCache->cauuidClass,"cElems","I");
+ lpCache->pElems = (*env)->GetFieldID(env,lpCache->cauuidClass,"pElems","I");
+ lpCache->cached = 1;
+}
+
+void cacheCoserverinfoFids(JNIEnv *env, jobject lpCoservinfo, PCOSERVERINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->coserverinfoClass = (*env)->GetObjectClass(env,lpCoservinfo);
+ lpCache->dwReserved1 = (*env)->GetFieldID(env,lpCache->coserverinfoClass,"dwReserved1","I");
+ lpCache->pwszName = (*env)->GetFieldID(env,lpCache->coserverinfoClass,"pwszName","I");
+ lpCache->pAuthInfo = (*env)->GetFieldID(env,lpCache->coserverinfoClass,"pAuthInfo","I");
+ lpCache->dwReserved2 = (*env)->GetFieldID(env,lpCache->coserverinfoClass,"dwReserved2","I");
+ lpCache->cached = 1;
+}
+
+void cacheControlinfoFids(JNIEnv *env, jobject lpControlinfo, PCONTROLINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->controlinfoClass = (*env)->GetObjectClass(env,lpControlinfo);
+ lpCache->cb = (*env)->GetFieldID(env,lpCache->controlinfoClass,"cb","I");
+ lpCache->hAccel = (*env)->GetFieldID(env,lpCache->controlinfoClass,"hAccel","I");
+ lpCache->cAccel = (*env)->GetFieldID(env,lpCache->controlinfoClass,"cAccel","S");
+ lpCache->filler = (*env)->GetFieldID(env,lpCache->controlinfoClass,"filler","S");
+ lpCache->dwFlags = (*env)->GetFieldID(env,lpCache->controlinfoClass,"dwFlags","I");
+ lpCache->cached = 1;
+}
+
+void cacheDispparamsFids(JNIEnv *env, jobject lpDispparams, PDISPPARAMS_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->dispparamsClass = (*env)->GetObjectClass(env,lpDispparams);
+ lpCache->rgvarg = (*env)->GetFieldID(env,lpCache->dispparamsClass,"rgvarg","I");
+ lpCache->rgdispidNamedArgs = (*env)->GetFieldID(env,lpCache->dispparamsClass,"rgdispidNamedArgs","I");
+ lpCache->cArgs = (*env)->GetFieldID(env,lpCache->dispparamsClass,"cArgs","I");
+ lpCache->cNamedArgs = (*env)->GetFieldID(env,lpCache->dispparamsClass,"cNamedArgs","I");
+ lpCache->cached = 1;
+}
+
+void cacheDropfilesFids(JNIEnv *env, jobject lpDropfiles, PDROPFILES_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->dropfilesClass = (*env)->GetObjectClass(env,lpDropfiles);
+ lpCache->pFiles = (*env)->GetFieldID(env,lpCache->dropfilesClass,"pFiles","I");
+ lpCache->pt_x = (*env)->GetFieldID(env,lpCache->dropfilesClass,"pt_x","I");
+ lpCache->pt_y = (*env)->GetFieldID(env,lpCache->dropfilesClass,"pt_y","I");
+ lpCache->fNC = (*env)->GetFieldID(env,lpCache->dropfilesClass,"fNC","I");
+ lpCache->fWide = (*env)->GetFieldID(env,lpCache->dropfilesClass,"fWide","I");
+ lpCache->cached = 1;
+}
+
+void cacheDvaspectinfoFids(JNIEnv *env, jobject lpDvaspectinfo, PDVASPECTINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->dvaspectinfoClass = (*env)->GetObjectClass(env,lpDvaspectinfo);
+ lpCache->cb = (*env)->GetFieldID(env,lpCache->dvaspectinfoClass,"cb","I");
+ lpCache->dwFlags = (*env)->GetFieldID(env,lpCache->dvaspectinfoClass,"dwFlags","I");
+ lpCache->cached = 1;
+}
+
+void cacheDvtargetdeviceFids(JNIEnv *env, jobject lpDvtargetdevice, PDVTARGETDEVICE_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->dvtargetdeviceClass = (*env)->GetObjectClass(env,lpDvtargetdevice);
+ lpCache->tdSize = (*env)->GetFieldID(env,lpCache->dvtargetdeviceClass,"tdSize","I");
+ lpCache->tdDriverNameOffset = (*env)->GetFieldID(env,lpCache->dvtargetdeviceClass,"tdDriverNameOffset","S");
+ lpCache->tdDeviceNameOffset = (*env)->GetFieldID(env,lpCache->dvtargetdeviceClass,"tdDeviceNameOffset","S");
+ lpCache->tdPortNameOffset = (*env)->GetFieldID(env,lpCache->dvtargetdeviceClass,"tdPortNameOffset","S");
+ lpCache->tdExtDevmodeOffset = (*env)->GetFieldID(env,lpCache->dvtargetdeviceClass,"tdExtDevmodeOffset","S");
+ lpCache->tdData = (*env)->GetFieldID(env,lpCache->dvtargetdeviceClass,"tdData","B");
+ lpCache->cached = 1;
+}
+
+void cacheExcepinfoFids(JNIEnv *env, jobject lpExcepinfo, PEXCEPINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->excepinfoClass = (*env)->GetObjectClass(env,lpExcepinfo);
+ lpCache->wCode = (*env)->GetFieldID(env,lpCache->excepinfoClass,"wCode","S");
+ lpCache->wReserved = (*env)->GetFieldID(env,lpCache->excepinfoClass,"wReserved","S");
+ lpCache->bstrSource = (*env)->GetFieldID(env,lpCache->excepinfoClass,"bstrSource","I");
+ lpCache->bstrDescription = (*env)->GetFieldID(env,lpCache->excepinfoClass,"bstrDescription","I");
+ lpCache->bstrHelpFile = (*env)->GetFieldID(env,lpCache->excepinfoClass,"bstrHelpFile","I");
+ lpCache->dwHelpContext = (*env)->GetFieldID(env,lpCache->excepinfoClass,"dwHelpContext","I");
+ lpCache->pvReserved = (*env)->GetFieldID(env,lpCache->excepinfoClass,"pvReserved","I");
+ lpCache->pfnDeferredFillIn = (*env)->GetFieldID(env,lpCache->excepinfoClass,"pfnDeferredFillIn","I");
+ lpCache->scode = (*env)->GetFieldID(env,lpCache->excepinfoClass,"scode","I");
+ lpCache->cached = 1;
+}
+
+void cacheLicinfoFids(JNIEnv *env, jobject lpLicinfo, PLICINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->licinfoClass = (*env)->GetObjectClass(env,lpLicinfo);
+ lpCache->cbLicInfo = (*env)->GetFieldID(env,lpCache->licinfoClass,"cbLicInfo","I");
+ lpCache->fRuntimeKeyAvail = (*env)->GetFieldID(env,lpCache->licinfoClass,"fRuntimeKeyAvail","I");
+ lpCache->fLicVerified = (*env)->GetFieldID(env,lpCache->licinfoClass,"fLicVerified","I");
+ lpCache->cached = 1;
+}
+
+void cacheFiletimeFids(JNIEnv *env, jobject lpFiletime, PFILETIME_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->filetimeClass = (*env)->GetObjectClass(env,lpFiletime);
+ lpCache->dwLowDateTime = (*env)->GetFieldID(env,lpCache->filetimeClass,"dwLowDateTime","I");
+ lpCache->dwHighDateTime = (*env)->GetFieldID(env,lpCache->filetimeClass,"dwHighDateTime","I");
+ lpCache->cached = 1;
+}
+
+void cacheFormatetcFids(JNIEnv *env, jobject lpFormatetc, PFORMATETC_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->formatetcClass = (*env)->GetObjectClass(env,lpFormatetc);
+ lpCache->cfFormat = (*env)->GetFieldID(env,lpCache->formatetcClass,"cfFormat","I");
+ lpCache->ptd = (*env)->GetFieldID(env,lpCache->formatetcClass,"ptd","I");
+ lpCache->dwAspect = (*env)->GetFieldID(env,lpCache->formatetcClass,"dwAspect","I");
+ lpCache->lindex = (*env)->GetFieldID(env,lpCache->formatetcClass,"lindex","I");
+ lpCache->tymed = (*env)->GetFieldID(env,lpCache->formatetcClass,"tymed","I");
+ lpCache->cached = 1;
+}
+
+void cacheGuidFids(JNIEnv *env, jobject lpGuid, PGUID_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->guidClass = (*env)->GetObjectClass(env,lpGuid);
+ lpCache->data1 = (*env)->GetFieldID(env,lpCache->guidClass,"data1","I");
+ lpCache->data2 = (*env)->GetFieldID(env,lpCache->guidClass,"data2","S");
+ lpCache->data3 = (*env)->GetFieldID(env,lpCache->guidClass,"data3","S");
+ lpCache->b0 = (*env)->GetFieldID(env,lpCache->guidClass,"b0","B");
+ lpCache->b1 = (*env)->GetFieldID(env,lpCache->guidClass,"b1","B");
+ lpCache->b2 = (*env)->GetFieldID(env,lpCache->guidClass,"b2","B");
+ lpCache->b3 = (*env)->GetFieldID(env,lpCache->guidClass,"b3","B");
+ lpCache->b4 = (*env)->GetFieldID(env,lpCache->guidClass,"b4","B");
+ lpCache->b5 = (*env)->GetFieldID(env,lpCache->guidClass,"b5","B");
+ lpCache->b6 = (*env)->GetFieldID(env,lpCache->guidClass,"b6","B");
+ lpCache->b7 = (*env)->GetFieldID(env,lpCache->guidClass,"b7","B");
+ lpCache->cached = 1;
+}
+
+void cacheIdldescFids(JNIEnv *env, jobject lpIdldesc, PIDLDESC_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->idldescClass = (*env)->GetObjectClass(env,lpIdldesc);
+ lpCache->dwReserved = (*env)->GetFieldID(env,lpCache->idldescClass,"dwReserved","I");
+ lpCache->wIDLFlags = (*env)->GetFieldID(env,lpCache->idldescClass,"wIDLFlags","S");
+ lpCache->cached = 1;
+}
+
+void cacheMulti_qiFids(JNIEnv *env, jobject lpMulti_qi, PMULTI_QI_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->multi_qiClass = (*env)->GetObjectClass(env,lpMulti_qi);
+ lpCache->pIID = (*env)->GetFieldID(env,lpCache->multi_qiClass,"pIID","I");
+ lpCache->pItf = (*env)->GetFieldID(env,lpCache->multi_qiClass,"pItf","I");
+ lpCache->hr = (*env)->GetFieldID(env,lpCache->multi_qiClass,"hr","I");
+ lpCache->cached = 1;
+}
+
+void cacheOlecmdFids(JNIEnv *env, jobject lpOlecmd, POLECMD_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->olecmdClass = (*env)->GetObjectClass(env,lpOlecmd);
+ lpCache->cmdID = (*env)->GetFieldID(env,lpCache->olecmdClass,"cmdID","I");
+ lpCache->cmdf = (*env)->GetFieldID(env,lpCache->olecmdClass,"cmdf","I");
+ lpCache->cached = 1;
+}
+
+void cacheOlecmdtextFids(JNIEnv *env, jobject lpOlecmdtext, POLECMDTEXT_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->olecmdtextClass = (*env)->GetObjectClass(env,lpOlecmdtext);
+ lpCache->cmdtextf = (*env)->GetFieldID(env,lpCache->olecmdtextClass,"cmdtextf","I");
+ lpCache->cwActual = (*env)->GetFieldID(env,lpCache->olecmdtextClass,"cwActual","I");
+ lpCache->cwBuf = (*env)->GetFieldID(env,lpCache->olecmdtextClass,"cwBuf","I");
+ lpCache->rgwz = (*env)->GetFieldID(env,lpCache->olecmdtextClass,"rgwz","S");
+ lpCache->cached = 1;
+}
+
+void cacheOleinplaceframeinfoFids(JNIEnv *env, jobject lpOleinplaceframeinfo, POLEINPLACEFRAMEINFO_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->oleinplaceframeinfoClass = (*env)->GetObjectClass(env,lpOleinplaceframeinfo);
+ lpCache->cb = (*env)->GetFieldID(env,lpCache->oleinplaceframeinfoClass,"cb","I");
+ lpCache->fMDIApp = (*env)->GetFieldID(env,lpCache->oleinplaceframeinfoClass,"fMDIApp","I");
+ lpCache->hwndFrame = (*env)->GetFieldID(env,lpCache->oleinplaceframeinfoClass,"hwndFrame","I");
+ lpCache->haccel = (*env)->GetFieldID(env,lpCache->oleinplaceframeinfoClass,"haccel","I");
+ lpCache->cAccelEntries = (*env)->GetFieldID(env,lpCache->oleinplaceframeinfoClass,"cAccelEntries","I");
+ lpCache->cached = 1;
+}
+
+void cacheOleverbFids(JNIEnv *env, jobject lpOleverb, POLEVERB_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->oleverbClass = (*env)->GetObjectClass(env,lpOleverb);
+ lpCache->lVerb = (*env)->GetFieldID(env,lpCache->oleverbClass,"lVerb","I");
+ lpCache->lpszVerbName = (*env)->GetFieldID(env,lpCache->oleverbClass,"lpszVerbName","I");
+ lpCache->fuFlags = (*env)->GetFieldID(env,lpCache->oleverbClass,"fuFlags","I");
+ lpCache->grfAttribs = (*env)->GetFieldID(env,lpCache->oleverbClass,"grfAttribs","I");
+ lpCache->cached = 1;
+}
+
+void cacheStgmediumFids(JNIEnv *env, jobject lpStgmedium, PSTGMEDIUM_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->stgmediumClass = (*env)->GetObjectClass(env,lpStgmedium);
+ lpCache->tymed = (*env)->GetFieldID(env,lpCache->stgmediumClass,"tymed","I");
+ lpCache->unionField = (*env)->GetFieldID(env,lpCache->stgmediumClass,"unionField","I");
+ lpCache->pUnkForRelease = (*env)->GetFieldID(env,lpCache->stgmediumClass,"pUnkForRelease","I");
+ lpCache->cached = 1;
+}
+
+void cacheStatstgFids(JNIEnv *env, jobject lpStatstg, PSTATSTG_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->statstgClass = (*env)->GetObjectClass(env,lpStatstg);
+ lpCache->pwcsName = (*env)->GetFieldID(env,lpCache->statstgClass,"pwcsName","I");
+ lpCache->type = (*env)->GetFieldID(env,lpCache->statstgClass,"type","I");
+ lpCache->cbSize = (*env)->GetFieldID(env,lpCache->statstgClass,"cbSize","L");
+ lpCache->mtime_dwLowDateTime = (*env)->GetFieldID(env,lpCache->statstgClass,"mtime_dwLowDateTime","I");
+ lpCache->mtime_dwHighDateTime = (*env)->GetFieldID(env,lpCache->statstgClass,"mtime_dwHighDateTime","I");
+ lpCache->ctime_dwLowDateTime = (*env)->GetFieldID(env,lpCache->statstgClass,"ctime_dwLowDateTime","I");
+ lpCache->ctime_dwHighDateTime = (*env)->GetFieldID(env,lpCache->statstgClass,"ctime_dwHighDateTime","I");
+ lpCache->atime_dwLowDateTime = (*env)->GetFieldID(env,lpCache->statstgClass,"atime_dwLowDateTime","I");
+ lpCache->atime_dwHighDateTime = (*env)->GetFieldID(env,lpCache->statstgClass,"atime_dwHighDateTime","I");
+ lpCache->grfMode = (*env)->GetFieldID(env,lpCache->statstgClass,"grfMode","I");
+ lpCache->grfLocksSupported = (*env)->GetFieldID(env,lpCache->statstgClass,"grfLocksSupported","I");
+ lpCache->clsid_data1 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_data1","I");
+ lpCache->clsid_data2 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_data2","S");
+ lpCache->clsid_data3 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_data3","S");
+ lpCache->clsid_b0 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b0","B");
+ lpCache->clsid_b1 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b1","B");
+ lpCache->clsid_b2 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b2","B");
+ lpCache->clsid_b3 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b3","B");
+ lpCache->clsid_b4 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b4","B");
+ lpCache->clsid_b5 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b5","B");
+ lpCache->clsid_b6 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b6","B");
+ lpCache->clsid_b7 = (*env)->GetFieldID(env,lpCache->statstgClass,"clsid_b7","B");
+ lpCache->grfStateBits = (*env)->GetFieldID(env,lpCache->statstgClass,"grfStateBits","I");
+ lpCache->reserved = (*env)->GetFieldID(env,lpCache->statstgClass,"reserved","I");
+ lpCache->cached = 1;
+}
+
+void cacheTypeattrFids(JNIEnv *env, jobject lpTypeattr, PTYPEATTR_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->typeattrClass = (*env)->GetObjectClass(env,lpTypeattr);
+ lpCache->guid_data1 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_data1","I");
+ lpCache->guid_data2 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_data2","S");
+ lpCache->guid_data3 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_data3","S");
+ lpCache->guid_b0 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b0","B");
+ lpCache->guid_b1 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b1","B");
+ lpCache->guid_b2 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b2","B");
+ lpCache->guid_b3 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b3","B");
+ lpCache->guid_b4 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b4","B");
+ lpCache->guid_b5 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b5","B");
+ lpCache->guid_b6 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b6","B");
+ lpCache->guid_b7 = (*env)->GetFieldID(env,lpCache->typeattrClass,"guid_b7","B");
+ lpCache->lcid = (*env)->GetFieldID(env,lpCache->typeattrClass,"lcid","I");
+ lpCache->dwReserved = (*env)->GetFieldID(env,lpCache->typeattrClass,"dwReserved","I");
+ lpCache->memidConstructor = (*env)->GetFieldID(env,lpCache->typeattrClass,"memidConstructor","I");
+ lpCache->memidDestructor = (*env)->GetFieldID(env,lpCache->typeattrClass,"memidDestructor","I");
+ lpCache->lpstrSchema = (*env)->GetFieldID(env,lpCache->typeattrClass,"lpstrSchema","I");
+ lpCache->cbSizeInstance = (*env)->GetFieldID(env,lpCache->typeattrClass,"cbSizeInstance","I");
+ lpCache->typekind = (*env)->GetFieldID(env,lpCache->typeattrClass,"typekind","I");
+ lpCache->cFuncs = (*env)->GetFieldID(env,lpCache->typeattrClass,"cFuncs","S");
+ lpCache->cVars = (*env)->GetFieldID(env,lpCache->typeattrClass,"cVars","S");
+ lpCache->cImplTypes = (*env)->GetFieldID(env,lpCache->typeattrClass,"cImplTypes","S");
+ lpCache->cbSizeVft = (*env)->GetFieldID(env,lpCache->typeattrClass,"cbSizeVft","S");
+ lpCache->cbAlignment = (*env)->GetFieldID(env,lpCache->typeattrClass,"cbAlignment","S");
+ lpCache->wTypeFlags = (*env)->GetFieldID(env,lpCache->typeattrClass,"wTypeFlags","S");
+ lpCache->wMajorVerNum = (*env)->GetFieldID(env,lpCache->typeattrClass,"wMajorVerNum","S");
+ lpCache->wMinorVerNum = (*env)->GetFieldID(env,lpCache->typeattrClass,"wMinorVerNum","S");
+ lpCache->tdescAlias_unionField = (*env)->GetFieldID(env,lpCache->typeattrClass,"tdescAlias_unionField","I");
+ lpCache->tdescAlias_vt = (*env)->GetFieldID(env,lpCache->typeattrClass,"tdescAlias_vt","S");
+ lpCache->idldescType_dwReserved = (*env)->GetFieldID(env,lpCache->typeattrClass,"idldescType_dwReserved","I");
+ lpCache->idldescType_wIDLFlags = (*env)->GetFieldID(env,lpCache->typeattrClass,"idldescType_wIDLFlags","S");
+ lpCache->cached = 1;
+}
+
+void cacheTypedescFids(JNIEnv *env, jobject lpTypedesc, PTYPEDESC_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->typedescClass = (*env)->GetObjectClass(env,lpTypedesc);
+ lpCache->typedesc_union = (*env)->GetFieldID(env,lpCache->typedescClass,"typedesc_union","I");
+ lpCache->vt = (*env)->GetFieldID(env,lpCache->typedescClass,"vt","S");
+ lpCache->cached = 1;
+}
+
+void cacheFuncdesc1Fids(JNIEnv *env, jobject lpFuncdesc, PFUNCDESC1_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->funcdescClass = (*env)->GetObjectClass(env,lpFuncdesc);
+ lpCache->memid = (*env)->GetFieldID(env,lpCache->funcdescClass,"memid","I");
+ lpCache->lprgscode = (*env)->GetFieldID(env,lpCache->funcdescClass,"lprgscode","I");
+ lpCache->lprgelemdescParam = (*env)->GetFieldID(env,lpCache->funcdescClass,"lprgelemdescParam","I");
+ lpCache->funckind = (*env)->GetFieldID(env,lpCache->funcdescClass,"funckind","I");
+ lpCache->invkind = (*env)->GetFieldID(env,lpCache->funcdescClass,"invkind","I");
+ lpCache->callconv = (*env)->GetFieldID(env,lpCache->funcdescClass,"callconv","I");
+ lpCache->cParams = (*env)->GetFieldID(env,lpCache->funcdescClass,"cParams","S");
+ lpCache->cParamsOpt = (*env)->GetFieldID(env,lpCache->funcdescClass,"cParamsOpt","S");
+ lpCache->oVft = (*env)->GetFieldID(env,lpCache->funcdescClass,"oVft","S");
+ lpCache->cScodes = (*env)->GetFieldID(env,lpCache->funcdescClass,"cScodes","S");
+ lpCache->elemdescFunc_tdesc_union = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_tdesc_union","I");
+ lpCache->elemdescFunc_tdesc_vt = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_tdesc_vt","S");
+ lpCache->elemdescFunc_tdesc_filler = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_tdesc_filler","S");
+ lpCache->elemdescFunc_paramdesc_pparamdescex = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_paramdesc_pparamdescex","I");
+ lpCache->elemdescFunc_paramdesc_wParamFlags = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_paramdesc_wParamFlags","S");
+ lpCache->elemdescFunc_paramdesc_filler = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_paramdesc_filler","S");
+ lpCache->wFuncFlags = (*env)->GetFieldID(env,lpCache->funcdescClass,"wFuncFlags","S");
+ lpCache->cached = 1;
+ }
+
+void cacheFuncdesc2Fids(JNIEnv *env, jobject lpFuncdesc, PFUNCDESC2_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->funcdescClass = (*env)->GetObjectClass(env,lpFuncdesc);
+ lpCache->memid = (*env)->GetFieldID(env,lpCache->funcdescClass,"memid","I");
+ lpCache->lprgscode = (*env)->GetFieldID(env,lpCache->funcdescClass,"lprgscode","I");
+ lpCache->lprgelemdescParam = (*env)->GetFieldID(env,lpCache->funcdescClass,"lprgelemdescParam","I");
+ lpCache->funckind = (*env)->GetFieldID(env,lpCache->funcdescClass,"funckind","I");
+ lpCache->invkind = (*env)->GetFieldID(env,lpCache->funcdescClass,"invkind","I");
+ lpCache->callconv = (*env)->GetFieldID(env,lpCache->funcdescClass,"callconv","I");
+ lpCache->cParams = (*env)->GetFieldID(env,lpCache->funcdescClass,"cParams","S");
+ lpCache->cParamsOpt = (*env)->GetFieldID(env,lpCache->funcdescClass,"cParamsOpt","S");
+ lpCache->oVft = (*env)->GetFieldID(env,lpCache->funcdescClass,"oVft","S");
+ lpCache->cScodes = (*env)->GetFieldID(env,lpCache->funcdescClass,"cScodes","S");
+ lpCache->elemdescFunc_tdesc_union = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_tdesc_union","I");
+ lpCache->elemdescFunc_tdesc_vt = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_tdesc_vt","S");
+ lpCache->elemdescFunc_tdesc_filler = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_tdesc_filler","S");
+ lpCache->elemdescFunc_idldesc_dwReserved = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_idldesc_dwReserved","I");
+ lpCache->elemdescFunc_idldesc_wIDLFlags = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_idldesc_wIDLFlags","S");
+ lpCache->elemdescFunc_idldesc_filler = (*env)->GetFieldID(env,lpCache->funcdescClass,"elemdescFunc_idldesc_filler","S");
+ lpCache->wFuncFlags = (*env)->GetFieldID(env,lpCache->funcdescClass,"wFuncFlags","S");
+ lpCache->cached = 1;
+ }
+void cacheVardesc1Fids(JNIEnv *env, jobject lpVardesc, PVARDESC1_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->vardescClass = (*env)->GetObjectClass(env,lpVardesc);
+ lpCache->memid = (*env)->GetFieldID(env,lpCache->vardescClass,"memid","I");
+ lpCache->lpstrSchema = (*env)->GetFieldID(env,lpCache->vardescClass,"lpstrSchema","I");
+ lpCache->unionField = (*env)->GetFieldID(env,lpCache->vardescClass,"unionField","I");
+ lpCache->elemdescVar_tdesc_union = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_tdesc_union","I");
+ lpCache->elemdescVar_tdesc_vt = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_tdesc_vt","S");
+ lpCache->elemdescVar_tdesc_filler = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_tdesc_filler","S");
+ lpCache->elemdescVar_paramdesc_pparamdescex = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_paramdesc_pparamdescex","I");
+ lpCache->elemdescVar_paramdesc_wParamFlags = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_paramdesc_wParamFlags","S");
+ lpCache->elemdescVar_paramdesc_filler = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_paramdesc_filler","S");
+ lpCache->wVarFlags = (*env)->GetFieldID(env,lpCache->vardescClass,"wVarFlags","S");
+ lpCache->filler = (*env)->GetFieldID(env,lpCache->vardescClass,"filler","S");
+ lpCache->varkind = (*env)->GetFieldID(env,lpCache->vardescClass,"varkind","I");
+ lpCache->cached = 1;
+}
+
+void cacheVardesc2Fids(JNIEnv *env, jobject lpVardesc, PVARDESC2_FID_CACHE lpCache)
+{
+ if (lpCache->cached) return;
+ lpCache->vardescClass = (*env)->GetObjectClass(env,lpVardesc);
+ lpCache->memid = (*env)->GetFieldID(env,lpCache->vardescClass,"memid","I");
+ lpCache->lpstrSchema = (*env)->GetFieldID(env,lpCache->vardescClass,"lpstrSchema","I");
+ lpCache->unionField = (*env)->GetFieldID(env,lpCache->vardescClass,"unionField","I");
+ lpCache->elemdescVar_tdesc_union = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_tdesc_union","I");
+ lpCache->elemdescVar_tdesc_vt = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_tdesc_vt","S");
+ lpCache->elemdescVar_tdesc_filler = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_tdesc_filler","S");
+ lpCache->elemdescVar_idldesc_dwReserved = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_idldesc_dwReserved","I");
+ lpCache->elemdescVar_idldesc_wIDLFlags = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_idldesc_wIDLFlags","S");
+ lpCache->elemdescVar_idldesc_filler = (*env)->GetFieldID(env,lpCache->vardescClass,"elemdescVar_idldesc_filler","S");
+ lpCache->wVarFlags = (*env)->GetFieldID(env,lpCache->vardescClass,"wVarFlags","S");
+ lpCache->filler = (*env)->GetFieldID(env,lpCache->vardescClass,"filler","S");
+ lpCache->varkind = (*env)->GetFieldID(env,lpCache->vardescClass,"varkind","I");
+ lpCache->cached = 1;
+}
+
+/* ----------- swt getters and setters ----------- */
+/**
+ * These functions get or set object field ids assuming that the
+ * fids for these objects have already been cached.
+ *
+ */
+void getAccelFields(JNIEnv *env, jobject lpObject, ACCEL *lpAccel, ACCEL_FID_CACHE *lpAccelFc)
+{
+ lpAccel->fVirt = (*env)->GetByteField(env,lpObject,lpAccelFc->fVirt);
+ lpAccel->key = (*env)->GetShortField(env,lpObject,lpAccelFc->key);
+ lpAccel->cmd = (*env)->GetShortField(env,lpObject,lpAccelFc->cmd);
+}
+
+void setAccelFields(JNIEnv *env, jobject lpObject, ACCEL *lpAccel, ACCEL_FID_CACHE *lpAccelFc)
+{
+ (*env)->SetByteField(env,lpObject,lpAccelFc->fVirt, lpAccel->fVirt);
+ (*env)->SetShortField(env,lpObject,lpAccelFc->key, lpAccel->key);
+ (*env)->SetShortField(env,lpObject,lpAccelFc->cmd, lpAccel->cmd);
+}
+
+void getBitmapFields(JNIEnv *env, jobject lpObject, BITMAP *lpBitmap, BITMAP_FID_CACHE *lpBitmapFc)
+{
+ lpBitmap->bmType = (*env)->GetIntField(env,lpObject,lpBitmapFc->bmType);
+ lpBitmap->bmWidth = (*env)->GetIntField(env,lpObject,lpBitmapFc->bmWidth);
+ lpBitmap->bmHeight = (*env)->GetIntField(env,lpObject,lpBitmapFc->bmHeight);
+ lpBitmap->bmWidthBytes = (*env)->GetIntField(env,lpObject,lpBitmapFc->bmWidthBytes);
+ lpBitmap->bmPlanes = (*env)->GetShortField(env,lpObject,lpBitmapFc->bmPlanes);
+ lpBitmap->bmBitsPixel = (*env)->GetShortField(env,lpObject,lpBitmapFc->bmBitsPixel);
+ lpBitmap->bmBits = (void *)(*env)->GetIntField(env,lpObject,lpBitmapFc->bmBits);
+}
+
+void setBitmapFields(JNIEnv *env, jobject lpObject, BITMAP *lpBitmap, BITMAP_FID_CACHE *lpBitmapFc)
+{
+ (*env)->SetIntField(env,lpObject,lpBitmapFc->bmType, lpBitmap->bmType);
+ (*env)->SetIntField(env,lpObject,lpBitmapFc->bmWidth, lpBitmap->bmWidth);
+ (*env)->SetIntField(env,lpObject,lpBitmapFc->bmHeight, lpBitmap->bmHeight);
+ (*env)->SetIntField(env,lpObject,lpBitmapFc->bmWidthBytes, lpBitmap->bmWidthBytes);
+ (*env)->SetShortField(env,lpObject,lpBitmapFc->bmPlanes, lpBitmap->bmPlanes);
+ (*env)->SetShortField(env,lpObject,lpBitmapFc->bmBitsPixel, lpBitmap->bmBitsPixel);
+ (*env)->SetIntField(env,lpObject,lpBitmapFc->bmBits, (jint)lpBitmap->bmBits);
+}
+
+void getBrowseinfoFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpBrowseinfo, BROWSEINFO_FID_CACHE *lpBrowseinfoFc)
+{
+ lpBrowseinfo->hwndOwner = (HWND)(*env)->GetIntField(env,lpObject,lpBrowseinfoFc->hwndOwner);
+ lpBrowseinfo->pidlRoot = (LPCITEMIDLIST)(*env)->GetIntField(env,lpObject,lpBrowseinfoFc->pidlRoot);
+ lpBrowseinfo->pszDisplayName = (LPSTR)(*env)->GetIntField(env,lpObject,lpBrowseinfoFc->pszDisplayName);
+ lpBrowseinfo->lpszTitle = (LPCSTR)(*env)->GetIntField(env,lpObject,lpBrowseinfoFc->lpszTitle);
+ lpBrowseinfo->ulFlags = (*env)->GetIntField(env,lpObject,lpBrowseinfoFc->ulFlags);
+ lpBrowseinfo->lpfn = (BFFCALLBACK)(*env)->GetIntField(env,lpObject,lpBrowseinfoFc->lpfn);
+ lpBrowseinfo->lParam = (*env)->GetIntField(env,lpObject,lpBrowseinfoFc->lParam);
+ lpBrowseinfo->iImage = (*env)->GetIntField(env,lpObject,lpBrowseinfoFc->iImage);
+
+}
+
+void setBrowseinfoFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpBrowseinfo, BROWSEINFO_FID_CACHE *lpBrowseinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->hwndOwner, (jint)lpBrowseinfo->hwndOwner);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->pidlRoot, (jint)lpBrowseinfo->pidlRoot);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->pszDisplayName, (jint)lpBrowseinfo->pszDisplayName);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->lpszTitle, (jint)lpBrowseinfo->lpszTitle);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->ulFlags, lpBrowseinfo->ulFlags);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->lpfn, (jint)lpBrowseinfo->lpfn);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->lParam, lpBrowseinfo->lParam);
+ (*env)->SetIntField(env,lpObject,lpBrowseinfoFc->iImage, lpBrowseinfo->iImage);
+}
+/*
+void getCharformatFields(JNIEnv *env, jobject lpObject, CHARFORMAT *lpCharformat, CHARFORMAT_FID_CACHE *lpCharformatFc)
+{
+ lpCharformat->cbSize = (*env)->GetIntField(env,lpObject,lpCharformatFc->cbSize);
+ lpCharformat->dwMask = (*env)->GetIntField(env,lpObject,lpCharformatFc->dwMask);
+ lpCharformat->dwEffects = (*env)->GetIntField(env,lpObject,lpCharformatFc->dwEffects);
+ lpCharformat->yHeight = (*env)->GetIntField(env,lpObject,lpCharformatFc->yHeight);
+ lpCharformat->yOffset = (*env)->GetIntField(env,lpObject,lpCharformatFc->yOffset);
+ lpCharformat->crTextColor = (*env)->GetIntField(env,lpObject,lpCharformatFc->crTextColor);
+ lpCharformat->bCharSet = (*env)->GetByteField(env,lpObject,lpCharformatFc->bCharSet);
+ lpCharformat->bPitchAndFamily = (*env)->GetByteField(env,lpObject,lpCharformatFc->bPitchAndFamily);
+ lpCharformat->szFaceName[0] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName0);
+ lpCharformat->szFaceName[1] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName1);
+ lpCharformat->szFaceName[2] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName2);
+ lpCharformat->szFaceName[3] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName3);
+ lpCharformat->szFaceName[4] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName4);
+ lpCharformat->szFaceName[5] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName5);
+ lpCharformat->szFaceName[6] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName6);
+ lpCharformat->szFaceName[7] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName7);
+ lpCharformat->szFaceName[8] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName8);
+ lpCharformat->szFaceName[9] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName9);
+ lpCharformat->szFaceName[10] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName10);
+ lpCharformat->szFaceName[11] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName11);
+ lpCharformat->szFaceName[12] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName12);
+ lpCharformat->szFaceName[13] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName13);
+ lpCharformat->szFaceName[14] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName14);
+ lpCharformat->szFaceName[15] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName15);
+ lpCharformat->szFaceName[16] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName16);
+ lpCharformat->szFaceName[17] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName17);
+ lpCharformat->szFaceName[18] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName18);
+ lpCharformat->szFaceName[19] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName19);
+ lpCharformat->szFaceName[20] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName20);
+ lpCharformat->szFaceName[21] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName21);
+ lpCharformat->szFaceName[22] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName22);
+ lpCharformat->szFaceName[23] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName23);
+ lpCharformat->szFaceName[24] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName24);
+ lpCharformat->szFaceName[25] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName25);
+ lpCharformat->szFaceName[26] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName26);
+ lpCharformat->szFaceName[27] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName27);
+ lpCharformat->szFaceName[28] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName28);
+ lpCharformat->szFaceName[29] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName29);
+ lpCharformat->szFaceName[30] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName30);
+ lpCharformat->szFaceName[31] = (*env)->GetByteField(env,lpObject,lpCharformatFc->szFaceName31);
+}
+
+void setCharformatFields(JNIEnv *env, jobject lpObject, CHARFORMAT *lpCharformat, CHARFORMAT_FID_CACHE *lpCharformatFc)
+{
+ (*env)->SetIntField(env,lpObject,lpCharformatFc->cbSize, lpCharformat->cbSize);
+ (*env)->SetIntField(env,lpObject,lpCharformatFc->dwMask, lpCharformat->dwMask);
+ (*env)->SetIntField(env,lpObject,lpCharformatFc->dwEffects, lpCharformat->dwEffects);
+ (*env)->SetIntField(env,lpObject,lpCharformatFc->yHeight, lpCharformat->yHeight);
+ (*env)->SetIntField(env,lpObject,lpCharformatFc->yOffset, lpCharformat->yOffset);
+ (*env)->SetIntField(env,lpObject,lpCharformatFc->crTextColor, lpCharformat->crTextColor);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->bCharSet, lpCharformat->bCharSet);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->bPitchAndFamily, lpCharformat->bPitchAndFamily);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName0, lpCharformat->szFaceName[0]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName1, lpCharformat->szFaceName[1]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName2, lpCharformat->szFaceName[2]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName3, lpCharformat->szFaceName[3]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName4, lpCharformat->szFaceName[4]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName5, lpCharformat->szFaceName[5]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName6, lpCharformat->szFaceName[6]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName7, lpCharformat->szFaceName[7]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName8, lpCharformat->szFaceName[8]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName9, lpCharformat->szFaceName[9]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName10, lpCharformat->szFaceName[10]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName11, lpCharformat->szFaceName[11]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName12, lpCharformat->szFaceName[12]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName13, lpCharformat->szFaceName[13]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName14, lpCharformat->szFaceName[14]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName15, lpCharformat->szFaceName[15]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName16, lpCharformat->szFaceName[16]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName17, lpCharformat->szFaceName[17]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName18, lpCharformat->szFaceName[18]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName19, lpCharformat->szFaceName[19]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName20, lpCharformat->szFaceName[20]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName21, lpCharformat->szFaceName[21]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName22, lpCharformat->szFaceName[22]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName23, lpCharformat->szFaceName[23]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName24, lpCharformat->szFaceName[24]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName25, lpCharformat->szFaceName[25]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName26, lpCharformat->szFaceName[26]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName27, lpCharformat->szFaceName[27]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName28, lpCharformat->szFaceName[28]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName29, lpCharformat->szFaceName[29]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName30, lpCharformat->szFaceName[30]);
+ (*env)->SetByteField(env,lpObject,lpCharformatFc->szFaceName31, lpCharformat->szFaceName[31]);
+}
+*/
+/*
+void getCharformat2Fields(JNIEnv *env, jobject lpObject, CHARFORMAT2 *lpCharformat2, CHARFORMAT2_FID_CACHE *lpCharformat2Fc)
+{
+ lpCharformat2->cbSize = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->cbSize);
+ lpCharformat2->dwMask = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->dwMask);
+ lpCharformat2->dwEffects = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->dwEffects);
+ lpCharformat2->yHeight = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->yHeight);
+ lpCharformat2->yOffset = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->yOffset);
+ lpCharformat2->crTextColor = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->crTextColor);
+ lpCharformat2->bCharSet = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->bCharSet);
+ lpCharformat2->bPitchAndFamily = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->bPitchAndFamily);
+ lpCharformat2->szFaceName[0] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName0);
+ lpCharformat2->szFaceName[1] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName1);
+ lpCharformat2->szFaceName[2] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName2);
+ lpCharformat2->szFaceName[3] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName3);
+ lpCharformat2->szFaceName[4] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName4);
+ lpCharformat2->szFaceName[5] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName5);
+ lpCharformat2->szFaceName[6] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName6);
+ lpCharformat2->szFaceName[7] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName7);
+ lpCharformat2->szFaceName[8] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName8);
+ lpCharformat2->szFaceName[9] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName9);
+ lpCharformat2->szFaceName[10] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName10);
+ lpCharformat2->szFaceName[11] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName11);
+ lpCharformat2->szFaceName[12] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName12);
+ lpCharformat2->szFaceName[13] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName13);
+ lpCharformat2->szFaceName[14] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName14);
+ lpCharformat2->szFaceName[15] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName15);
+ lpCharformat2->szFaceName[16] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName16);
+ lpCharformat2->szFaceName[17] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName17);
+ lpCharformat2->szFaceName[18] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName18);
+ lpCharformat2->szFaceName[19] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName19);
+ lpCharformat2->szFaceName[20] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName20);
+ lpCharformat2->szFaceName[21] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName21);
+ lpCharformat2->szFaceName[22] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName22);
+ lpCharformat2->szFaceName[23] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName23);
+ lpCharformat2->szFaceName[24] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName24);
+ lpCharformat2->szFaceName[25] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName25);
+ lpCharformat2->szFaceName[26] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName26);
+ lpCharformat2->szFaceName[27] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName27);
+ lpCharformat2->szFaceName[28] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName28);
+ lpCharformat2->szFaceName[29] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName29);
+ lpCharformat2->szFaceName[30] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName30);
+ lpCharformat2->szFaceName[31] = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->szFaceName31);
+ lpCharformat2->wWeight = (*env)->GetShortField(env,lpObject,lpCharformat2Fc->wWeight);
+ lpCharformat2->sSpacing = (*env)->GetShortField(env,lpObject,lpCharformat2Fc->sSpacing);
+ lpCharformat2->crBackColor = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->crBackColor);
+ lpCharformat2->lcid = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->lcid);
+ lpCharformat2->dwReserved = (*env)->GetIntField(env,lpObject,lpCharformat2Fc->dwReserved);
+ lpCharformat2->sStyle = (*env)->GetShortField(env,lpObject,lpCharformat2Fc->sStyle);
+ lpCharformat2->wKerning = (*env)->GetShortField(env,lpObject,lpCharformat2Fc->wKerning);
+ lpCharformat2->bUnderlineType = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->bUnderlineType);
+ lpCharformat2->bAnimation = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->bAnimation);
+ lpCharformat2->bRevAuthor = (*env)->GetByteField(env,lpObject,lpCharformat2Fc->bRevAuthor);
+}
+
+void setCharformat2Fields(JNIEnv *env, jobject lpObject, CHARFORMAT2 *lpCharformat2, CHARFORMAT2_FID_CACHE *lpCharformat2Fc)
+{
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->cbSize, lpCharformat2->cbSize);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->dwMask, lpCharformat2->dwMask);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->dwEffects, lpCharformat2->dwEffects);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->yHeight, lpCharformat2->yHeight);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->yOffset, lpCharformat2->yOffset);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->crTextColor, lpCharformat2->crTextColor);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->bCharSet, lpCharformat2->bCharSet);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->bPitchAndFamily, lpCharformat2->bPitchAndFamily);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName0, lpCharformat2->szFaceName[0]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName1, lpCharformat2->szFaceName[1]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName2, lpCharformat2->szFaceName[2]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName3, lpCharformat2->szFaceName[3]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName4, lpCharformat2->szFaceName[4]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName5, lpCharformat2->szFaceName[5]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName6, lpCharformat2->szFaceName[6]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName7, lpCharformat2->szFaceName[7]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName8, lpCharformat2->szFaceName[8]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName9, lpCharformat2->szFaceName[9]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName10, lpCharformat2->szFaceName[10]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName11, lpCharformat2->szFaceName[11]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName12, lpCharformat2->szFaceName[12]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName13, lpCharformat2->szFaceName[13]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName14, lpCharformat2->szFaceName[14]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName15, lpCharformat2->szFaceName[15]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName16, lpCharformat2->szFaceName[16]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName17, lpCharformat2->szFaceName[17]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName18, lpCharformat2->szFaceName[18]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName19, lpCharformat2->szFaceName[19]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName20, lpCharformat2->szFaceName[20]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName21, lpCharformat2->szFaceName[21]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName22, lpCharformat2->szFaceName[22]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName23, lpCharformat2->szFaceName[23]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName24, lpCharformat2->szFaceName[24]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName25, lpCharformat2->szFaceName[25]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName26, lpCharformat2->szFaceName[26]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName27, lpCharformat2->szFaceName[27]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName28, lpCharformat2->szFaceName[28]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName29, lpCharformat2->szFaceName[29]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName30, lpCharformat2->szFaceName[30]);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->szFaceName31, lpCharformat2->szFaceName[31]);
+ (*env)->SetShortField(env,lpObject,lpCharformat2Fc->wWeight, lpCharformat2->wWeight);
+ (*env)->SetShortField(env,lpObject,lpCharformat2Fc->sSpacing, lpCharformat2->sSpacing);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->crBackColor, lpCharformat2->crBackColor);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->lcid, lpCharformat2->lcid);
+ (*env)->SetIntField(env,lpObject,lpCharformat2Fc->dwReserved, lpCharformat2->dwReserved);
+ (*env)->SetShortField(env,lpObject,lpCharformat2Fc->sStyle, lpCharformat2->sStyle);
+ (*env)->SetShortField(env,lpObject,lpCharformat2Fc->wKerning, lpCharformat2->wKerning);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->bUnderlineType, lpCharformat2->bUnderlineType);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->bAnimation, lpCharformat2->bAnimation);
+ (*env)->SetByteField(env,lpObject,lpCharformat2Fc->bRevAuthor, lpCharformat2->bRevAuthor);
+}
+*/
+void getChoosecolorFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpChoosecolor, CHOOSECOLOR_FID_CACHE *lpChoosecolorFc)
+{
+ lpChoosecolor->lStructSize = (*env)->GetIntField(env,lpObject,lpChoosecolorFc->lStructSize);
+ lpChoosecolor->hwndOwner = (HWND)(*env)->GetIntField(env,lpObject,lpChoosecolorFc->hwndOwner);
+ lpChoosecolor->hInstance = (HWND)(*env)->GetIntField(env,lpObject,lpChoosecolorFc->hInstance);
+ lpChoosecolor->rgbResult = (*env)->GetIntField(env,lpObject,lpChoosecolorFc->rgbResult);
+ lpChoosecolor->lpCustColors = (COLORREF *)(*env)->GetIntField(env,lpObject,lpChoosecolorFc->lpCustColors);
+ lpChoosecolor->Flags = (*env)->GetIntField(env,lpObject,lpChoosecolorFc->Flags);
+ lpChoosecolor->lCustData = (*env)->GetIntField(env,lpObject,lpChoosecolorFc->lCustData);
+ lpChoosecolor->lpfnHook = (LPCCHOOKPROC)(*env)->GetIntField(env,lpObject,lpChoosecolorFc->lpfnHook);
+ lpChoosecolor->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpChoosecolorFc->lpTemplateName);
+}
+
+void setChoosecolorFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpChoosecolor, CHOOSECOLOR_FID_CACHE *lpChoosecolorFc)
+{
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->lStructSize, lpChoosecolor->lStructSize);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->hwndOwner, (jint)lpChoosecolor->hwndOwner);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->hInstance, (jint)lpChoosecolor->hInstance);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->rgbResult, lpChoosecolor->rgbResult);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->lpCustColors, (jint)lpChoosecolor->lpCustColors);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->Flags, lpChoosecolor->Flags);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->lCustData, lpChoosecolor->lCustData);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->lpfnHook, (jint)lpChoosecolor->lpfnHook);
+ (*env)->SetIntField(env,lpObject,lpChoosecolorFc->lpTemplateName, (jint)lpChoosecolor->lpTemplateName);
+}
+
+void getChoosefontFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpChoosefont, CHOOSEFONT_FID_CACHE *lpChoosefontFc)
+{
+ lpChoosefont->lStructSize = (*env)->GetIntField(env,lpObject,lpChoosefontFc->lStructSize);
+ lpChoosefont->hwndOwner = (HWND)(*env)->GetIntField(env,lpObject,lpChoosefontFc->hwndOwner);
+ lpChoosefont->hDC = (HDC)(*env)->GetIntField(env,lpObject,lpChoosefontFc->hDC);
+ lpChoosefont->lpLogFont = (LPLOGFONT)(*env)->GetIntField(env,lpObject,lpChoosefontFc->lpLogFont);
+ lpChoosefont->iPointSize = (*env)->GetIntField(env,lpObject,lpChoosefontFc->iPointSize);
+ lpChoosefont->Flags = (*env)->GetIntField(env,lpObject,lpChoosefontFc->Flags);
+ lpChoosefont->rgbColors = (*env)->GetIntField(env,lpObject,lpChoosefontFc->rgbColors);
+ lpChoosefont->lCustData = (*env)->GetIntField(env,lpObject,lpChoosefontFc->lCustData);
+ lpChoosefont->lpfnHook = (LPCFHOOKPROC)(*env)->GetIntField(env,lpObject,lpChoosefontFc->lpfnHook);
+ lpChoosefont->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpChoosefontFc->lpTemplateName);
+ lpChoosefont->hInstance = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpChoosefontFc->hInstance);
+ lpChoosefont->lpszStyle = (LPTSTR)(*env)->GetIntField(env,lpObject,lpChoosefontFc->lpszStyle);
+ lpChoosefont->nFontType = (*env)->GetShortField(env,lpObject,lpChoosefontFc->nFontType);
+ lpChoosefont->___MISSING_ALIGNMENT__ = (*env)->GetShortField(env,lpObject,lpChoosefontFc->___MISSING_ALIGNMENT__);
+ lpChoosefont->nSizeMin = (*env)->GetIntField(env,lpObject,lpChoosefontFc->nSizeMin);
+ lpChoosefont->nSizeMax = (*env)->GetIntField(env,lpObject,lpChoosefontFc->nSizeMax);
+}
+
+void setChoosefontFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpChoosefont, CHOOSEFONT_FID_CACHE *lpChoosefontFc)
+{
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->lStructSize, lpChoosefont->lStructSize);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->hwndOwner, (jint)lpChoosefont->hwndOwner);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->hDC, (jint)lpChoosefont->hDC);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->lpLogFont, (jint)lpChoosefont->lpLogFont);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->iPointSize, lpChoosefont->iPointSize);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->Flags, lpChoosefont->Flags);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->rgbColors, lpChoosefont->rgbColors);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->lCustData, lpChoosefont->lCustData);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->lpfnHook, (jint)lpChoosefont->lpfnHook);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->lpTemplateName, (jint)lpChoosefont->lpTemplateName);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->hInstance, (jint)lpChoosefont->hInstance);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->lpszStyle, (jint)lpChoosefont->lpszStyle);
+ (*env)->SetShortField(env,lpObject,lpChoosefontFc->nFontType, lpChoosefont->nFontType);
+ (*env)->SetShortField(env,lpObject,lpChoosefontFc->___MISSING_ALIGNMENT__, lpChoosefont->___MISSING_ALIGNMENT__);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->nSizeMin, lpChoosefont->nSizeMin);
+ (*env)->SetIntField(env,lpObject,lpChoosefontFc->nSizeMax, lpChoosefont->nSizeMax);
+}
+
+void getCompositionformFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpCompositionform, COMPOSITIONFORM_FID_CACHE *lpCompositionformFc)
+{
+ lpCompositionform->dwStyle = (*env)->GetIntField(env,lpObject,lpCompositionformFc->dwStyle);
+ lpCompositionform->ptCurrentPos.x = (*env)->GetIntField(env,lpObject,lpCompositionformFc->x);
+ lpCompositionform->ptCurrentPos.y = (*env)->GetIntField(env,lpObject,lpCompositionformFc->y);
+ lpCompositionform->rcArea.left = (*env)->GetIntField(env,lpObject,lpCompositionformFc->left);
+ lpCompositionform->rcArea.top = (*env)->GetIntField(env,lpObject,lpCompositionformFc->top);
+ lpCompositionform->rcArea.right = (*env)->GetIntField(env,lpObject,lpCompositionformFc->right);
+ lpCompositionform->rcArea.bottom = (*env)->GetIntField(env,lpObject,lpCompositionformFc->bottom);
+}
+
+void setCompositionformFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpCompositionform, COMPOSITIONFORM_FID_CACHE *lpCompositionformFc)
+{
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->dwStyle, lpCompositionform->dwStyle);
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->x, lpCompositionform->ptCurrentPos.x);
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->y, lpCompositionform->ptCurrentPos.y);
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->left, lpCompositionform->rcArea.left);
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->top, lpCompositionform->rcArea.top);
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->right, lpCompositionform->rcArea.right);
+ (*env)->SetIntField(env,lpObject,lpCompositionformFc->bottom, lpCompositionform->rcArea.bottom);
+}
+
+void getCreatestructFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpCreatestruct, CREATESTRUCT_FID_CACHE *lpCreatestructFc)
+{
+ lpCreatestruct->lpCreateParams = (void *)(*env)->GetIntField(env,lpObject,lpCreatestructFc->lpCreateParams);
+ lpCreatestruct->hInstance = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpCreatestructFc->hInstance);
+ lpCreatestruct->hMenu = (HMENU)(*env)->GetIntField(env,lpObject,lpCreatestructFc->hMenu);
+ lpCreatestruct->hwndParent = (HWND)(*env)->GetIntField(env,lpObject,lpCreatestructFc->hwndParent);
+ lpCreatestruct->cx = (*env)->GetIntField(env,lpObject,lpCreatestructFc->cx);
+ lpCreatestruct->cy = (*env)->GetIntField(env,lpObject,lpCreatestructFc->cy);
+ lpCreatestruct->x = (*env)->GetIntField(env,lpObject,lpCreatestructFc->x);
+ lpCreatestruct->y = (*env)->GetIntField(env,lpObject,lpCreatestructFc->y);
+ lpCreatestruct->style = (*env)->GetIntField(env,lpObject,lpCreatestructFc->style);
+ lpCreatestruct->lpszName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpCreatestructFc->lpszName);
+ lpCreatestruct->lpszClass = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpCreatestructFc->lpszClass);
+ lpCreatestruct->dwExStyle = (*env)->GetIntField(env,lpObject,lpCreatestructFc->dwExStyle);
+}
+
+void setCreatestructFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpCreatestruct, CREATESTRUCT_FID_CACHE *lpCreatestructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->lpCreateParams, (jint)lpCreatestruct->lpCreateParams);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->hInstance, (jint)lpCreatestruct->hInstance);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->hMenu, (jint)lpCreatestruct->hMenu);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->hwndParent, (jint)lpCreatestruct->hwndParent);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->cx, lpCreatestruct->cx);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->cy, lpCreatestruct->cy);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->x, lpCreatestruct->x);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->y, lpCreatestruct->y);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->style, lpCreatestruct->style);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->lpszName, (jint)lpCreatestruct->lpszName);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->lpszClass, (jint)lpCreatestruct->lpszClass);
+ (*env)->SetIntField(env,lpObject,lpCreatestructFc->dwExStyle, lpCreatestruct->dwExStyle);
+}
+
+void getDibsectionFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpDibsection, DIBSECTION_FID_CACHE *lpDibsectionFc)
+{
+ lpDibsection->dsBm.bmType = (*env)->GetIntField(env,lpObject,lpDibsectionFc->bmType);
+ lpDibsection->dsBm.bmWidth = (*env)->GetIntField(env,lpObject,lpDibsectionFc->bmWidth);
+ lpDibsection->dsBm.bmHeight = (*env)->GetIntField(env,lpObject,lpDibsectionFc->bmHeight);
+ lpDibsection->dsBm.bmWidthBytes = (*env)->GetIntField(env,lpObject,lpDibsectionFc->bmWidthBytes);
+ lpDibsection->dsBm.bmPlanes = (*env)->GetShortField(env,lpObject,lpDibsectionFc->bmPlanes);
+ lpDibsection->dsBm.bmBitsPixel = (*env)->GetShortField(env,lpObject,lpDibsectionFc->bmBitsPixel);
+ lpDibsection->dsBm.bmBits = (void *)(*env)->GetIntField(env,lpObject,lpDibsectionFc->bmBits);
+
+ lpDibsection->dsBmih.biSize = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biSize);
+ lpDibsection->dsBmih.biWidth = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biWidth);
+ lpDibsection->dsBmih.biHeight = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biHeight);
+ lpDibsection->dsBmih.biPlanes = (*env)->GetShortField(env,lpObject,lpDibsectionFc->biPlanes);
+ lpDibsection->dsBmih.biBitCount = (*env)->GetShortField(env,lpObject,lpDibsectionFc->biBitCount);
+ lpDibsection->dsBmih.biCompression = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biCompression);
+ lpDibsection->dsBmih.biSizeImage = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biSizeImage);
+ lpDibsection->dsBmih.biXPelsPerMeter = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biXPelsPerMeter);
+ lpDibsection->dsBmih.biYPelsPerMeter = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biYPelsPerMeter);
+ lpDibsection->dsBmih.biClrUsed = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biClrUsed);
+ lpDibsection->dsBmih.biClrImportant = (*env)->GetIntField(env,lpObject,lpDibsectionFc->biClrImportant);
+
+ lpDibsection->dsBitfields[0] = (*env)->GetIntField(env,lpObject,lpDibsectionFc->dsBitfields0);
+ lpDibsection->dsBitfields[1] = (*env)->GetIntField(env,lpObject,lpDibsectionFc->dsBitfields1);
+ lpDibsection->dsBitfields[2] = (*env)->GetIntField(env,lpObject,lpDibsectionFc->dsBitfields2);
+ lpDibsection->dshSection = (HANDLE)(*env)->GetIntField(env,lpObject,lpDibsectionFc->dshSection);
+ lpDibsection->dsOffset = (*env)->GetIntField(env,lpObject,lpDibsectionFc->dsOffset);
+}
+
+void setDibsectionFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpDibsection, DIBSECTION_FID_CACHE *lpDibsectionFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->bmType, lpDibsection->dsBm.bmType);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->bmWidth, lpDibsection->dsBm.bmWidth);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->bmHeight, lpDibsection->dsBm.bmHeight);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->bmWidthBytes, lpDibsection->dsBm.bmWidthBytes);
+ (*env)->SetShortField(env,lpObject,lpDibsectionFc->bmPlanes, lpDibsection->dsBm.bmPlanes);
+ (*env)->SetShortField(env,lpObject,lpDibsectionFc->bmBitsPixel, lpDibsection->dsBm.bmBitsPixel);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->bmBits, (jint)lpDibsection->dsBm.bmBits);
+
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biSize, lpDibsection->dsBmih.biSize);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biWidth, lpDibsection->dsBmih.biWidth);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biHeight, lpDibsection->dsBmih.biHeight);
+ (*env)->SetShortField(env,lpObject,lpDibsectionFc->biPlanes, lpDibsection->dsBmih.biPlanes);
+ (*env)->SetShortField(env,lpObject,lpDibsectionFc->biBitCount, lpDibsection->dsBmih.biBitCount);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biCompression, lpDibsection->dsBmih.biCompression);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biSizeImage, lpDibsection->dsBmih.biSizeImage);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biXPelsPerMeter, lpDibsection->dsBmih.biXPelsPerMeter);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biYPelsPerMeter, lpDibsection->dsBmih.biYPelsPerMeter);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biClrUsed, lpDibsection->dsBmih.biClrUsed);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->biClrImportant, lpDibsection->dsBmih.biClrImportant);
+
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->dsBitfields0, lpDibsection->dsBitfields[0]);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->dsBitfields1, lpDibsection->dsBitfields[1]);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->dsBitfields2, lpDibsection->dsBitfields[2]);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->dshSection, (jint)lpDibsection->dshSection);
+ (*env)->SetIntField(env,lpObject,lpDibsectionFc->dsOffset, lpDibsection->dsOffset);
+}
+
+void getDllversioninfoFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpDllversioninfo, DLLVERSIONINFO_FID_CACHE *lpDllversioninfoFc)
+{
+ lpDllversioninfo->cbSize = (*env)->GetIntField(env,lpObject,lpDllversioninfoFc->cbSize);
+ lpDllversioninfo->dwMajorVersion = (*env)->GetIntField(env,lpObject,lpDllversioninfoFc->dwMajorVersion);
+ lpDllversioninfo->dwMinorVersion = (*env)->GetIntField(env,lpObject,lpDllversioninfoFc->dwMinorVersion);
+ lpDllversioninfo->dwBuildNumber = (*env)->GetIntField(env,lpObject,lpDllversioninfoFc->dwBuildNumber);
+ lpDllversioninfo->dwPlatformID = (*env)->GetIntField(env,lpObject,lpDllversioninfoFc->dwPlatformID);
+}
+
+void setDllversioninfoFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpDllversioninfo, DLLVERSIONINFO_FID_CACHE *lpDllversioninfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDllversioninfoFc->cbSize, lpDllversioninfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpDllversioninfoFc->dwMajorVersion, lpDllversioninfo->dwMajorVersion);
+ (*env)->SetIntField(env,lpObject,lpDllversioninfoFc->dwMinorVersion, lpDllversioninfo->dwMinorVersion);
+ (*env)->SetIntField(env,lpObject,lpDllversioninfoFc->dwBuildNumber, lpDllversioninfo->dwBuildNumber);
+ (*env)->SetIntField(env,lpObject,lpDllversioninfoFc->dwPlatformID, lpDllversioninfo->dwPlatformID);
+}
+
+void getDocinfoFields(JNIEnv *env, jobject lpObject, DOCINFO *lpDocinfo, DOCINFO_FID_CACHE *lpDocinfoFc)
+{
+ lpDocinfo->cbSize = (*env)->GetIntField(env,lpObject,lpDocinfoFc->cbSize);
+ lpDocinfo->lpszDocName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpDocinfoFc->lpszDocName);
+ lpDocinfo->lpszOutput = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpDocinfoFc->lpszOutput);
+ lpDocinfo->lpszDatatype = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpDocinfoFc->lpszDatatype);
+ lpDocinfo->fwType = (*env)->GetIntField(env,lpObject,lpDocinfoFc->fwType);
+}
+
+void setDocinfoFields(JNIEnv *env, jobject lpObject, DOCINFO *lpDocinfo, DOCINFO_FID_CACHE *lpDocinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDocinfoFc->cbSize, (jint)lpDocinfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpDocinfoFc->lpszDocName, (jint)lpDocinfo->lpszDocName);
+ (*env)->SetIntField(env,lpObject,lpDocinfoFc->lpszOutput, (jint)lpDocinfo->lpszOutput);
+ (*env)->SetIntField(env,lpObject,lpDocinfoFc->lpszDatatype, (jint)lpDocinfo->lpszDatatype);
+ (*env)->SetIntField(env,lpObject,lpDocinfoFc->fwType, lpDocinfo->fwType);
+}
+
+void getDrawitemstructFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpDrawitemstruct, DRAWITEMSTRUCT_FID_CACHE *lpDrawitemstructFc)
+{
+ lpDrawitemstruct->CtlType = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->CtlType);
+ lpDrawitemstruct->CtlID = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->CtlID);
+ lpDrawitemstruct->itemID = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->itemID);
+ lpDrawitemstruct->itemAction = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->itemAction);
+ lpDrawitemstruct->itemState = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->itemState);
+ lpDrawitemstruct->hwndItem = (HWND)(*env)->GetIntField(env,lpObject,lpDrawitemstructFc->hwndItem);
+ lpDrawitemstruct->hDC = (HDC)(*env)->GetIntField(env,lpObject,lpDrawitemstructFc->hDC);
+ lpDrawitemstruct->rcItem.left = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->left);
+ lpDrawitemstruct->rcItem.top = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->top);
+ lpDrawitemstruct->rcItem.right = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->right);
+ lpDrawitemstruct->rcItem.bottom = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->bottom);
+ lpDrawitemstruct->itemData = (*env)->GetIntField(env,lpObject,lpDrawitemstructFc->itemData);
+}
+
+void setDrawitemstructFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpDrawitemstruct, DRAWITEMSTRUCT_FID_CACHE *lpDrawitemstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->CtlType, lpDrawitemstruct->CtlType);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->CtlID, lpDrawitemstruct->CtlID);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->itemID, lpDrawitemstruct->itemID);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->itemAction, lpDrawitemstruct->itemAction);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->itemState, lpDrawitemstruct->itemState);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->hwndItem, (jint)lpDrawitemstruct->hwndItem);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->hDC, (jint)lpDrawitemstruct->hDC);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->left, lpDrawitemstruct->rcItem.left);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->top, lpDrawitemstruct->rcItem.top);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->right, lpDrawitemstruct->rcItem.right);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->bottom, lpDrawitemstruct->rcItem.bottom);
+ (*env)->SetIntField(env,lpObject,lpDrawitemstructFc->itemData, lpDrawitemstruct->itemData);
+}
+
+void getHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc)
+{
+ lpHditem->mask = (*env)->GetIntField(env,lpObject,lpHditemFc->mask);
+ lpHditem->cxy = (*env)->GetIntField(env,lpObject,lpHditemFc->cxy);
+ lpHditem->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpHditemFc->pszText);
+ lpHditem->hbm = (HBITMAP)(*env)->GetIntField(env,lpObject,lpHditemFc->hbm);
+ lpHditem->cchTextMax = (*env)->GetIntField(env,lpObject,lpHditemFc->cchTextMax);
+ lpHditem->fmt = (*env)->GetIntField(env,lpObject,lpHditemFc->fmt);
+ lpHditem->lParam = (*env)->GetIntField(env,lpObject,lpHditemFc->lParam);
+ lpHditem->iImage = (*env)->GetIntField(env,lpObject,lpHditemFc->iImage);
+ lpHditem->iOrder = (*env)->GetIntField(env,lpObject,lpHditemFc->iOrder);
+}
+
+void setHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc)
+{
+ (*env)->SetIntField(env,lpObject,lpHditemFc->mask, lpHditem->mask);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->cxy, lpHditem->cxy);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->pszText, (jint)lpHditem->pszText);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->hbm, (jint)lpHditem->hbm);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->cchTextMax, lpHditem->cchTextMax);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->fmt, lpHditem->fmt);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->lParam, lpHditem->lParam);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->iImage, lpHditem->iImage);
+ (*env)->SetIntField(env,lpObject,lpHditemFc->iOrder, lpHditem->iOrder);
+}
+
+void getHdlayoutFields(JNIEnv *env, jobject lpObject, HDLAYOUT *lpHdlayout, HDLAYOUT_FID_CACHE *lpHdlayoutFc)
+{
+ lpHdlayout->prc = (RECT FAR *)(*env)->GetIntField(env,lpObject,lpHdlayoutFc->prc);
+ lpHdlayout->pwpos = (WINDOWPOS FAR *)(*env)->GetIntField(env,lpObject,lpHdlayoutFc->pwpos);
+}
+
+void setHdlayoutFields(JNIEnv *env, jobject lpObject, HDLAYOUT *lpHdlayout, HDLAYOUT_FID_CACHE *lpHdlayoutFc)
+{
+ (*env)->SetIntField(env,lpObject,lpHdlayoutFc->prc, (jint)lpHdlayout->prc);
+ (*env)->SetIntField(env,lpObject,lpHdlayoutFc->pwpos, (jint)lpHdlayout->pwpos);
+}
+
+void getHelpinfoFields(JNIEnv *env, jobject lpObject, HELPINFO *lpHelpinfo, HELPINFO_FID_CACHE *lpHelpinfoFc)
+{
+ lpHelpinfo->cbSize = (*env)->GetIntField(env,lpObject,lpHelpinfoFc->cbSize);
+ lpHelpinfo->iContextType = (*env)->GetIntField(env,lpObject,lpHelpinfoFc->iContextType);
+ lpHelpinfo->iCtrlId = (*env)->GetIntField(env,lpObject,lpHelpinfoFc->iCtrlId);
+ lpHelpinfo->hItemHandle = (HANDLE)(*env)->GetIntField(env,lpObject,lpHelpinfoFc->hItemHandle);
+ lpHelpinfo->dwContextId = (*env)->GetIntField(env,lpObject,lpHelpinfoFc->dwContextId);
+ lpHelpinfo->MousePos.x = (*env)->GetIntField(env,lpObject,lpHelpinfoFc->x);
+ lpHelpinfo->MousePos.y = (*env)->GetIntField(env,lpObject,lpHelpinfoFc->y);
+}
+
+void setHelpinfoFields(JNIEnv *env, jobject lpObject, HELPINFO *lpHelpinfo, HELPINFO_FID_CACHE *lpHelpinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->cbSize, lpHelpinfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->iContextType, lpHelpinfo->iContextType);
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->iCtrlId, lpHelpinfo->iCtrlId);
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->hItemHandle, (jint)lpHelpinfo->hItemHandle);
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->dwContextId, lpHelpinfo->dwContextId);
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->x, lpHelpinfo->MousePos.x);
+ (*env)->SetIntField(env,lpObject,lpHelpinfoFc->y, lpHelpinfo->MousePos.y);
+}
+
+void getIconinfoFields(JNIEnv *env, jobject lpObject, ICONINFO *lpIconinfo, ICONINFO_FID_CACHE *lpIconinfoFc)
+{
+ lpIconinfo->fIcon = (*env)->GetBooleanField(env,lpObject,lpIconinfoFc->fIcon);
+ lpIconinfo->xHotspot = (*env)->GetIntField(env,lpObject,lpIconinfoFc->xHotspot);
+ lpIconinfo->yHotspot = (*env)->GetIntField(env,lpObject,lpIconinfoFc->yHotspot);
+ lpIconinfo->hbmMask = (HBITMAP)(*env)->GetIntField(env,lpObject,lpIconinfoFc->hbmMask);
+ lpIconinfo->hbmColor = (HBITMAP)(*env)->GetIntField(env,lpObject,lpIconinfoFc->hbmColor);
+}
+
+void setIconinfoFields(JNIEnv *env, jobject lpObject, ICONINFO *lpIconinfo, ICONINFO_FID_CACHE *lpIconinfoFc)
+{
+ (*env)->SetBooleanField(env,lpObject,lpIconinfoFc->fIcon, (jboolean)lpIconinfo->fIcon);
+ (*env)->SetIntField(env,lpObject,lpIconinfoFc->xHotspot, lpIconinfo->xHotspot);
+ (*env)->SetIntField(env,lpObject,lpIconinfoFc->yHotspot, lpIconinfo->yHotspot);
+ (*env)->SetIntField(env,lpObject,lpIconinfoFc->hbmMask, (jint)lpIconinfo->hbmMask);
+ (*env)->SetIntField(env,lpObject,lpIconinfoFc->hbmColor, (jint)lpIconinfo->hbmColor);
+}
+
+void getInitcommoncontrolsexFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpInitcommoncontrolsex, INITCOMMONCONTROLSEX_FID_CACHE *lpInitcommoncontrolsexFc)
+{
+ lpInitcommoncontrolsex->dwSize = (*env)->GetIntField(env,lpObject,lpInitcommoncontrolsexFc->dwSize);
+ lpInitcommoncontrolsex->dwICC = (*env)->GetIntField(env,lpObject,lpInitcommoncontrolsexFc->dwICC);
+}
+
+void setInitcommoncontrolsexFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpInitcommoncontrolsex, INITCOMMONCONTROLSEX_FID_CACHE *lpInitcommoncontrolsexFc)
+{
+ (*env)->SetIntField(env,lpObject,lpInitcommoncontrolsexFc->dwSize, lpInitcommoncontrolsex->dwSize);
+ (*env)->SetIntField(env,lpObject,lpInitcommoncontrolsexFc->dwICC, lpInitcommoncontrolsex->dwICC);
+}
+
+void getLogbrushFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpLogbrush, LOGBRUSH_FID_CACHE *lpLogbrushFc)
+{
+ lpLogbrush->lbStyle = (*env)->GetIntField(env,lpObject,lpLogbrushFc->lbStyle);
+ lpLogbrush->lbColor = (*env)->GetIntField(env,lpObject,lpLogbrushFc->lbColor);
+ lpLogbrush->lbHatch = (*env)->GetIntField(env,lpObject,lpLogbrushFc->lbHatch);
+}
+
+void setLogbrushFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpLogbrush, LOGBRUSH_FID_CACHE *lpLogbrushFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLogbrushFc->lbStyle, lpLogbrush->lbStyle);
+ (*env)->SetIntField(env,lpObject,lpLogbrushFc->lbColor, lpLogbrush->lbColor);
+ (*env)->SetIntField(env,lpObject,lpLogbrushFc->lbHatch, lpLogbrush->lbHatch);
+}
+
+void getLogfontFields(JNIEnv *env, jobject lpObject, LOGFONT *lpLogfont, LOGFONT_FID_CACHE *lpLogfontFc)
+{
+ lpLogfont->lfHeight = (*env)->GetIntField(env,lpObject,lpLogfontFc->lfHeight);
+ lpLogfont->lfWidth = (*env)->GetIntField(env,lpObject,lpLogfontFc->lfWidth);
+ lpLogfont->lfEscapement = (*env)->GetIntField(env,lpObject,lpLogfontFc->lfEscapement);
+ lpLogfont->lfOrientation = (*env)->GetIntField(env,lpObject,lpLogfontFc->lfOrientation);
+ lpLogfont->lfWeight = (*env)->GetIntField(env,lpObject,lpLogfontFc->lfWeight);
+ lpLogfont->lfItalic = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfItalic);
+ lpLogfont->lfUnderline = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfUnderline);
+ lpLogfont->lfStrikeOut = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfStrikeOut);
+ lpLogfont->lfCharSet = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfCharSet);
+ lpLogfont->lfOutPrecision = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfOutPrecision);
+ lpLogfont->lfClipPrecision = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfClipPrecision);
+ lpLogfont->lfQuality = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfQuality);
+ lpLogfont->lfPitchAndFamily = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfPitchAndFamily);
+ lpLogfont->lfFaceName[0] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName0);
+ lpLogfont->lfFaceName[1] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName1);
+ lpLogfont->lfFaceName[2] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName2);
+ lpLogfont->lfFaceName[3] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName3);
+ lpLogfont->lfFaceName[4] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName4);
+ lpLogfont->lfFaceName[5] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName5);
+ lpLogfont->lfFaceName[6] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName6);
+ lpLogfont->lfFaceName[7] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName7);
+ lpLogfont->lfFaceName[8] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName8);
+ lpLogfont->lfFaceName[9] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName9);
+ lpLogfont->lfFaceName[10] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName10);
+ lpLogfont->lfFaceName[11] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName11);
+ lpLogfont->lfFaceName[12] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName12);
+ lpLogfont->lfFaceName[13] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName13);
+ lpLogfont->lfFaceName[14] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName14);
+ lpLogfont->lfFaceName[15] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName15);
+ lpLogfont->lfFaceName[16] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName16);
+ lpLogfont->lfFaceName[17] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName17);
+ lpLogfont->lfFaceName[18] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName18);
+ lpLogfont->lfFaceName[19] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName19);
+ lpLogfont->lfFaceName[20] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName20);
+ lpLogfont->lfFaceName[21] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName21);
+ lpLogfont->lfFaceName[22] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName22);
+ lpLogfont->lfFaceName[23] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName23);
+ lpLogfont->lfFaceName[24] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName24);
+ lpLogfont->lfFaceName[25] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName25);
+ lpLogfont->lfFaceName[26] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName26);
+ lpLogfont->lfFaceName[27] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName27);
+ lpLogfont->lfFaceName[28] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName28);
+ lpLogfont->lfFaceName[29] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName29);
+ lpLogfont->lfFaceName[30] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName30);
+ lpLogfont->lfFaceName[31] = (*env)->GetByteField(env,lpObject,lpLogfontFc->lfFaceName31);
+}
+
+void setLogfontFields(JNIEnv *env, jobject lpObject, LOGFONT *lpLogfont, LOGFONT_FID_CACHE *lpLogfontFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLogfontFc->lfHeight, lpLogfont->lfHeight);
+ (*env)->SetIntField(env,lpObject,lpLogfontFc->lfWidth, lpLogfont->lfWidth);
+ (*env)->SetIntField(env,lpObject,lpLogfontFc->lfEscapement, lpLogfont->lfEscapement);
+ (*env)->SetIntField(env,lpObject,lpLogfontFc->lfOrientation, lpLogfont->lfOrientation);
+ (*env)->SetIntField(env,lpObject,lpLogfontFc->lfWeight, lpLogfont->lfWeight);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfItalic, lpLogfont->lfItalic);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfUnderline, lpLogfont->lfUnderline);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfStrikeOut, lpLogfont->lfStrikeOut);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfCharSet, lpLogfont->lfCharSet);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfOutPrecision, lpLogfont->lfOutPrecision);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfClipPrecision, lpLogfont->lfClipPrecision);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfQuality, lpLogfont->lfQuality);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfPitchAndFamily, lpLogfont->lfPitchAndFamily);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName0, lpLogfont->lfFaceName[0]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName1, lpLogfont->lfFaceName[1]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName2, lpLogfont->lfFaceName[2]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName3, lpLogfont->lfFaceName[3]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName4, lpLogfont->lfFaceName[4]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName5, lpLogfont->lfFaceName[5]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName6, lpLogfont->lfFaceName[6]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName7, lpLogfont->lfFaceName[7]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName8, lpLogfont->lfFaceName[8]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName9, lpLogfont->lfFaceName[9]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName10, lpLogfont->lfFaceName[10]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName11, lpLogfont->lfFaceName[11]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName12, lpLogfont->lfFaceName[12]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName13, lpLogfont->lfFaceName[13]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName14, lpLogfont->lfFaceName[14]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName15, lpLogfont->lfFaceName[15]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName16, lpLogfont->lfFaceName[16]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName17, lpLogfont->lfFaceName[17]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName18, lpLogfont->lfFaceName[18]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName19, lpLogfont->lfFaceName[19]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName20, lpLogfont->lfFaceName[20]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName21, lpLogfont->lfFaceName[21]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName22, lpLogfont->lfFaceName[22]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName23, lpLogfont->lfFaceName[23]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName24, lpLogfont->lfFaceName[24]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName25, lpLogfont->lfFaceName[25]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName26, lpLogfont->lfFaceName[26]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName27, lpLogfont->lfFaceName[27]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName28, lpLogfont->lfFaceName[28]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName29, lpLogfont->lfFaceName[29]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName30, lpLogfont->lfFaceName[30]);
+ (*env)->SetByteField(env,lpObject,lpLogfontFc->lfFaceName31, lpLogfont->lfFaceName[31]);
+}
+
+void getLogpenFields(JNIEnv *env, jobject lpObject, LOGPEN *lpLogpen, LOGPEN_FID_CACHE *lpLogpenFc)
+{
+ lpLogpen->lopnStyle = (*env)->GetIntField(env,lpObject,lpLogpenFc->lopnStyle);
+ lpLogpen->lopnWidth.x = (*env)->GetIntField(env,lpObject,lpLogpenFc->x);
+ lpLogpen->lopnWidth.y = (*env)->GetIntField(env,lpObject,lpLogpenFc->y);
+ lpLogpen->lopnColor = (*env)->GetIntField(env,lpObject,lpLogpenFc->lopnColor);
+}
+
+
+void setLogpenFields(JNIEnv *env, jobject lpObject, LOGPEN *lpLogpen, LOGPEN_FID_CACHE *lpLogpenFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLogpenFc->lopnStyle, lpLogpen->lopnStyle);
+ (*env)->SetIntField(env,lpObject,lpLogpenFc->x, lpLogpen->lopnWidth.x);
+ (*env)->SetIntField(env,lpObject,lpLogpenFc->y, lpLogpen->lopnWidth.y);
+ (*env)->SetIntField(env,lpObject,lpLogpenFc->lopnColor, lpLogpen->lopnColor);
+}
+/*
+void getExtlogpenFields(JNIEnv *env, jobject lpObject, EXTLOGPEN *lpExtlogpen, EXTLOGPEN_FID_CACHE *lpExtlogpenFc)
+{
+ lpExtlogpen->elpPenStyle = (*env)->GetIntField(env,lpObject,lpExtlogpenFc->elpPenStyle);
+ lpExtlogpen->elpWidth = (*env)->GetIntField(env,lpObject,lpExtlogpenFc->elpWidth);
+ lpExtlogpen->elpBrushStyle = (*env)->GetIntField(env,lpObject,lpExtlogpenFc->elpBrushStyle);
+ lpExtlogpen->elpColor = (*env)->GetIntField(env,lpObject,lpExtlogpenFc->elpColor);
+ lpExtlogpen->elpHatch = (*env)->GetIntField(env,lpObject,lpExtlogpenFc->elpHatch);
+ lpExtlogpen->elpNumEntries = (*env)->GetIntField(env,lpObject,lpExtlogpenFc->elpNumEntries);
+}
+
+void setExtlogpenFields(JNIEnv *env, jobject lpObject, EXTLOGPEN *lpExtlogpen, EXTLOGPEN_FID_CACHE *lpExtlogpenFc)
+{
+ (*env)->SetIntField(env,lpObject,lpExtlogpenFc->elpPenStyle, lpExtlogpen->elpPenStyle);
+ (*env)->SetIntField(env,lpObject,lpExtlogpenFc->elpWidth, lpExtlogpen->elpWidth);
+ (*env)->SetIntField(env,lpObject,lpExtlogpenFc->elpBrushStyle, lpExtlogpen->elpBrushStyle);
+ (*env)->SetIntField(env,lpObject,lpExtlogpenFc->elpColor, lpExtlogpen->elpColor);
+ (*env)->SetIntField(env,lpObject,lpExtlogpenFc->elpHatch, lpExtlogpen->elpHatch);
+ (*env)->SetIntField(env,lpObject,lpExtlogpenFc->elpNumEntries, lpExtlogpen->elpNumEntries);
+}
+*/
+void getLvcolumnFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpLvcolumn, PLVCOLUMN_FID_CACHE lpLvcolumnFc)
+{
+ lpLvcolumn->mask = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->mask);
+ lpLvcolumn->fmt = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->fmt);
+ lpLvcolumn->cx = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->cx);
+ lpLvcolumn->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpLvcolumnFc->pszText);
+ lpLvcolumn->cchTextMax = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->cchTextMax);
+ lpLvcolumn->iSubItem = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->iSubItem);
+ lpLvcolumn->iImage = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->iImage);
+ lpLvcolumn->iOrder = (*env)->GetIntField(env,lpObject,lpLvcolumnFc->iOrder);
+}
+
+void setLvcolumnFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpLvcolumn, PLVCOLUMN_FID_CACHE lpLvcolumnFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->mask, lpLvcolumn->mask);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->fmt, lpLvcolumn->fmt);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->cx, lpLvcolumn->cx);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->pszText, (jint)lpLvcolumn->pszText);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->cchTextMax, lpLvcolumn->cchTextMax);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->iSubItem, lpLvcolumn->iSubItem);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->iImage, lpLvcolumn->iImage);
+ (*env)->SetIntField(env,lpObject,lpLvcolumnFc->iOrder, lpLvcolumn->iOrder);
+}
+
+void getLvhittestinfoFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpLvhittestinfo, PLVHITTESTINFO_FID_CACHE lpLvhittestinfoFc)
+{
+ lpLvhittestinfo->pt.x = (*env)->GetIntField(env,lpObject,lpLvhittestinfoFc->x);
+ lpLvhittestinfo->pt.y = (*env)->GetIntField(env,lpObject,lpLvhittestinfoFc->y);
+ lpLvhittestinfo->flags = (*env)->GetIntField(env,lpObject,lpLvhittestinfoFc->flags);
+ lpLvhittestinfo->iItem = (*env)->GetIntField(env,lpObject,lpLvhittestinfoFc->iItem);
+ lpLvhittestinfo->iSubItem = (*env)->GetIntField(env,lpObject,lpLvhittestinfoFc->iSubItem);
+}
+
+void setLvhittestinfoFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpLvhittestinfo, PLVHITTESTINFO_FID_CACHE lpLvhittestinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLvhittestinfoFc->x, lpLvhittestinfo->pt.x);
+ (*env)->SetIntField(env,lpObject,lpLvhittestinfoFc->y, lpLvhittestinfo->pt.y);
+ (*env)->SetIntField(env,lpObject,lpLvhittestinfoFc->flags, lpLvhittestinfo->flags);
+ (*env)->SetIntField(env,lpObject,lpLvhittestinfoFc->iItem, lpLvhittestinfo->iItem);
+ (*env)->SetIntField(env,lpObject,lpLvhittestinfoFc->iSubItem, lpLvhittestinfo->iSubItem);
+}
+
+void getLvitemFields(JNIEnv *env, jobject lpObject, LVITEM *lpLvitem, LVITEM_FID_CACHE *lpLvitemFc)
+{
+ lpLvitem->mask = (*env)->GetIntField(env,lpObject,lpLvitemFc->mask);
+ lpLvitem->iItem = (*env)->GetIntField(env,lpObject,lpLvitemFc->iItem);
+ lpLvitem->iSubItem = (*env)->GetIntField(env,lpObject,lpLvitemFc->iSubItem);
+ lpLvitem->state = (*env)->GetIntField(env,lpObject,lpLvitemFc->state);
+ lpLvitem->stateMask = (*env)->GetIntField(env,lpObject,lpLvitemFc->stateMask);
+ lpLvitem->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpLvitemFc->pszText);
+ lpLvitem->cchTextMax = (*env)->GetIntField(env,lpObject,lpLvitemFc->cchTextMax);
+ lpLvitem->iImage = (*env)->GetIntField(env,lpObject,lpLvitemFc->iImage);
+ lpLvitem->lParam = (*env)->GetIntField(env,lpObject,lpLvitemFc->lParam);
+ lpLvitem->iIndent = (*env)->GetIntField(env,lpObject,lpLvitemFc->iIndent);
+}
+
+void setLvitemFields(JNIEnv *env, jobject lpObject, LVITEM *lpLvitem, LVITEM_FID_CACHE *lpLvitemFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->mask, lpLvitem->mask);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->iItem, lpLvitem->iItem);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->iSubItem, lpLvitem->iSubItem);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->state, lpLvitem->state);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->stateMask, lpLvitem->stateMask);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->pszText, (jint)lpLvitem->pszText);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->cchTextMax, lpLvitem->cchTextMax);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->iImage, lpLvitem->iImage);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->lParam, lpLvitem->lParam);
+ (*env)->SetIntField(env,lpObject,lpLvitemFc->iIndent, lpLvitem->iIndent);
+}
+
+void getMeasureitemstructFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpMeasureitemstruct, MEASUREITEMSTRUCT_FID_CACHE *lpMeasureitemstructFc)
+{
+ lpMeasureitemstruct->CtlType = (*env)->GetIntField(env,lpObject,lpMeasureitemstructFc->CtlType);
+ lpMeasureitemstruct->CtlID = (*env)->GetIntField(env,lpObject,lpMeasureitemstructFc->CtlID);
+ lpMeasureitemstruct->itemID = (*env)->GetIntField(env,lpObject,lpMeasureitemstructFc->itemID);
+ lpMeasureitemstruct->itemWidth = (*env)->GetIntField(env,lpObject,lpMeasureitemstructFc->itemWidth);
+ lpMeasureitemstruct->itemHeight = (*env)->GetIntField(env,lpObject,lpMeasureitemstructFc->itemHeight);
+ lpMeasureitemstruct->itemData = (*env)->GetIntField(env,lpObject,lpMeasureitemstructFc->itemData);
+}
+
+void setMeasureitemstructFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpMeasureitemstruct, MEASUREITEMSTRUCT_FID_CACHE *lpMeasureitemstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpMeasureitemstructFc->CtlType, lpMeasureitemstruct->CtlType);
+ (*env)->SetIntField(env,lpObject,lpMeasureitemstructFc->CtlID, lpMeasureitemstruct->CtlID);
+ (*env)->SetIntField(env,lpObject,lpMeasureitemstructFc->itemID, lpMeasureitemstruct->itemID);
+ (*env)->SetIntField(env,lpObject,lpMeasureitemstructFc->itemWidth, lpMeasureitemstruct->itemWidth);
+ (*env)->SetIntField(env,lpObject,lpMeasureitemstructFc->itemHeight, lpMeasureitemstruct->itemHeight);
+ (*env)->SetIntField(env,lpObject,lpMeasureitemstructFc->itemData, lpMeasureitemstruct->itemData);
+}
+
+#ifdef USE_2000_CALLS
+void getMenuinfoFields(JNIEnv *env, jobject lpObject, MENUINFO *lpMenuinfo, MENUINFO_FID_CACHE *lpMenuinfoFc)
+{
+ lpMenuinfo->cbSize = (*env)->GetIntField(env,lpObject,lpMenuinfoFc->cbSize);
+ lpMenuinfo->fMask = (*env)->GetIntField(env,lpObject,lpMenuinfoFc->fMask);
+ lpMenuinfo->dwStyle = (*env)->GetIntField(env,lpObject,lpMenuinfoFc->dwStyle);
+ lpMenuinfo->cyMax = (*env)->GetIntField(env,lpObject,lpMenuinfoFc->cyMax);
+ lpMenuinfo->hbrBack = (HBRUSH)(*env)->GetIntField(env,lpObject,lpMenuinfoFc->hbrBack);
+ lpMenuinfo->dwContextHelpID = (*env)->GetIntField(env,lpObject,lpMenuinfoFc->dwContextHelpID);
+ lpMenuinfo->dwMenuData = (*env)->GetIntField(env,lpObject,lpMenuinfoFc->dwMenuData);
+}
+
+void setMenuinfoFields(JNIEnv *env, jobject lpObject, MENUINFO *lpMenuinfo, MENUINFO_FID_CACHE *lpMenuinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->cbSize, lpMenuinfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->fMask, lpMenuinfo->fMask);
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->dwStyle, lpMenuinfo->dwStyle);
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->cyMax, lpMenuinfo->cyMax);
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->hbrBack, (jint)lpMenuinfo->hbrBack);
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->dwContextHelpID, lpMenuinfo->dwContextHelpID);
+ (*env)->SetIntField(env,lpObject,lpMenuinfoFc->dwMenuData, lpMenuinfo->dwMenuData);
+}
+#endif
+
+void getMenuiteminfoFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpMenuiteminfo, MENUITEMINFO_FID_CACHE *lpMenuiteminfoFc)
+{
+ lpMenuiteminfo->cbSize = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->cbSize);
+ lpMenuiteminfo->fMask = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->fMask);
+ lpMenuiteminfo->fType = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->fType);
+ lpMenuiteminfo->fState = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->fState);
+ lpMenuiteminfo->wID = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->wID);
+ lpMenuiteminfo->hSubMenu = (HMENU)(*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->hSubMenu);
+ lpMenuiteminfo->hbmpChecked = (HBITMAP)(*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->hbmpChecked);
+ lpMenuiteminfo->hbmpUnchecked = (HBITMAP)(*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->hbmpUnchecked);
+ lpMenuiteminfo->dwItemData = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->dwItemData);
+ lpMenuiteminfo->dwTypeData = (LPTSTR)(*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->dwTypeData);
+ lpMenuiteminfo->cch = (*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->cch);
+#ifdef USE_2000_CALLS
+ lpMenuiteminfo->hbmpItem = (HBITMAP)(*env)->GetIntField(env,lpObject,lpMenuiteminfoFc->hbmpItem);
+#endif
+}
+
+void setMenuiteminfoFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpMenuiteminfo, MENUITEMINFO_FID_CACHE *lpMenuiteminfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->cbSize, lpMenuiteminfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->fMask, lpMenuiteminfo->fMask);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->fType, lpMenuiteminfo->fType);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->fState, lpMenuiteminfo->fState);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->wID, lpMenuiteminfo->wID);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->hSubMenu, (jint)lpMenuiteminfo->hSubMenu);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->hbmpChecked, (jint)lpMenuiteminfo->hbmpChecked);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->hbmpUnchecked, (jint)lpMenuiteminfo->hbmpUnchecked);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->dwItemData, lpMenuiteminfo->dwItemData);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->dwTypeData, (jint)lpMenuiteminfo->dwTypeData);
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->cch, lpMenuiteminfo->cch);
+#ifdef USE_2000_CALLS
+ (*env)->SetIntField(env,lpObject,lpMenuiteminfoFc->hbmpItem, (jint)lpMenuiteminfo->hbmpItem);
+#endif
+}
+
+void getMsgFields(JNIEnv *env, jobject lpObject, MSG *lpMsg, MSG_FID_CACHE *lpMsgFc)
+{
+ lpMsg->hwnd = (HWND)(*env)->GetIntField(env,lpObject,lpMsgFc->hwnd);
+ lpMsg->message = (*env)->GetIntField(env,lpObject,lpMsgFc->message);
+ lpMsg->wParam = (*env)->GetIntField(env,lpObject,lpMsgFc->wParam);
+ lpMsg->lParam = (*env)->GetIntField(env,lpObject,lpMsgFc->lParam);
+ lpMsg->time = (*env)->GetIntField(env,lpObject,lpMsgFc->time);
+ lpMsg->pt.x = (*env)->GetIntField(env,lpObject,lpMsgFc->x);
+ lpMsg->pt.y = (*env)->GetIntField(env,lpObject,lpMsgFc->y);
+}
+
+void setMsgFields(JNIEnv *env, jobject lpObject, MSG *lpMsg, MSG_FID_CACHE *lpMsgFc)
+{
+ (*env)->SetIntField(env,lpObject,lpMsgFc->hwnd, (jint)lpMsg->hwnd);
+ (*env)->SetIntField(env,lpObject,lpMsgFc->message, lpMsg->message);
+ (*env)->SetIntField(env,lpObject,lpMsgFc->wParam, lpMsg->wParam);
+ (*env)->SetIntField(env,lpObject,lpMsgFc->lParam, lpMsg->lParam);
+ (*env)->SetIntField(env,lpObject,lpMsgFc->time, lpMsg->time);
+ (*env)->SetIntField(env,lpObject,lpMsgFc->x, lpMsg->pt.x);
+ (*env)->SetIntField(env,lpObject,lpMsgFc->y, lpMsg->pt.y);
+}
+
+void getMsgfilterFields(JNIEnv *env, jobject lpObject, MSGFILTER *lpMsgfilter, MSGFILTER_FID_CACHE *lpMsgfilterFc)
+{
+ lpMsgfilter->nmhdr.hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpMsgfilterFc->hwndFrom);
+ lpMsgfilter->nmhdr.idFrom = (*env)->GetIntField(env,lpObject,lpMsgfilterFc->idFrom);
+ lpMsgfilter->nmhdr.code = (*env)->GetIntField(env,lpObject,lpMsgfilterFc->code);
+ lpMsgfilter->msg = (*env)->GetIntField(env,lpObject,lpMsgfilterFc->msg);
+ lpMsgfilter->wParam = (*env)->GetIntField(env,lpObject,lpMsgfilterFc->lParam);
+ lpMsgfilter->wParam = (*env)->GetIntField(env,lpObject,lpMsgfilterFc->wParam);
+}
+
+void setMsgfilterFields(JNIEnv *env, jobject lpObject, MSGFILTER *lpMsgfilter, MSGFILTER_FID_CACHE *lpMsgfilterFc)
+{
+ (*env)->SetIntField(env,lpObject,lpMsgfilterFc->hwndFrom, (jint)lpMsgfilter->nmhdr.hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpMsgfilterFc->idFrom, lpMsgfilter->nmhdr.idFrom);
+ (*env)->SetIntField(env,lpObject,lpMsgfilterFc->code, lpMsgfilter->nmhdr.code);
+ (*env)->SetIntField(env,lpObject,lpMsgfilterFc->msg, (jint)lpMsgfilter->msg);
+ (*env)->SetIntField(env,lpObject,lpMsgfilterFc->wParam, (jint)lpMsgfilter->wParam);
+ (*env)->SetIntField(env,lpObject,lpMsgfilterFc->lParam, (jint)lpMsgfilter->lParam);
+}
+
+void getNmhdrFields(JNIEnv *env, jobject lpObject, NMHDR *lpNmhdr, NMHDR_FID_CACHE *lpNmhdrFc)
+{
+ lpNmhdr->hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpNmhdrFc->hwndFrom);
+ lpNmhdr->idFrom = (*env)->GetIntField(env,lpObject,lpNmhdrFc->idFrom);
+ lpNmhdr->code = (*env)->GetIntField(env,lpObject,lpNmhdrFc->code);
+}
+
+void setNmhdrFields(JNIEnv *env, jobject lpObject, NMHDR *lpNmhdr, NMHDR_FID_CACHE *lpNmhdrFc)
+{
+ (*env)->SetIntField(env,lpObject,lpNmhdrFc->hwndFrom, (jint)lpNmhdr->hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpNmhdrFc->idFrom, lpNmhdr->idFrom);
+ (*env)->SetIntField(env,lpObject,lpNmhdrFc->code, lpNmhdr->code);
+}
+
+void getNmheaderFields(JNIEnv *env, jobject lpObject, NMHEADER *lpNmheader, NMHEADER_FID_CACHE *lpNmheaderFc)
+{
+ lpNmheader->hdr.hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpNmheaderFc->hwndFrom);
+ lpNmheader->hdr.idFrom = (*env)->GetIntField(env,lpObject,lpNmheaderFc->idFrom);
+ lpNmheader->hdr.code = (*env)->GetIntField(env,lpObject,lpNmheaderFc->code);
+ lpNmheader->iItem = (*env)->GetIntField(env,lpObject,lpNmheaderFc->iItem);
+ lpNmheader->iButton = (*env)->GetIntField(env,lpObject,lpNmheaderFc->iButton);
+ lpNmheader->pitem = (HDITEM FAR *)(*env)->GetIntField(env,lpObject,lpNmheaderFc->pitem);
+}
+
+void setNmheaderFields(JNIEnv *env, jobject lpObject, NMHEADER *lpNmheader, NMHEADER_FID_CACHE *lpNmheaderFc)
+{
+ (*env)->SetIntField(env,lpObject,lpNmheaderFc->hwndFrom, (jint)lpNmheader->hdr.hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpNmheaderFc->idFrom, lpNmheader->hdr.idFrom);
+ (*env)->SetIntField(env,lpObject,lpNmheaderFc->code, lpNmheader->hdr.code);
+ (*env)->SetIntField(env,lpObject,lpNmheaderFc->iItem, (jint)lpNmheader->iItem);
+ (*env)->SetIntField(env,lpObject,lpNmheaderFc->iButton, (jint)lpNmheader->iButton);
+ (*env)->SetIntField(env,lpObject,lpNmheaderFc->pitem, (jint)lpNmheader->pitem);
+}
+
+void getNmlistviewFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpNmlistview, NMLISTVIEW_FID_CACHE *lpNmlistviewFc)
+{
+ lpNmlistview->hdr.hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpNmlistviewFc->hwndFrom);
+ lpNmlistview->hdr.idFrom = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->idFrom);
+ lpNmlistview->hdr.code = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->code);
+ lpNmlistview->iItem = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->iItem);
+ lpNmlistview->iSubItem = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->iSubItem);
+ lpNmlistview->uNewState = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->uNewState);
+ lpNmlistview->uOldState = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->uOldState);
+ lpNmlistview->uChanged = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->uChanged);
+ lpNmlistview->ptAction.x = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->x);
+ lpNmlistview->ptAction.y = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->y);
+ lpNmlistview->lParam = (*env)->GetIntField(env,lpObject,lpNmlistviewFc->lParam);
+}
+
+void setNmlistviewFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpNmlistview, NMLISTVIEW_FID_CACHE *lpNmlistviewFc)
+{
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->hwndFrom, (jint)lpNmlistview->hdr.hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->idFrom, lpNmlistview->hdr.idFrom);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->code, lpNmlistview->hdr.code);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->iItem, (jint)lpNmlistview->iItem);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->iSubItem, (jint)lpNmlistview->iSubItem);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->uNewState, (jint)lpNmlistview->uNewState);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->uOldState, (jint)lpNmlistview->uOldState);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->uChanged, (jint)lpNmlistview->uChanged);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->x, (jint)lpNmlistview->ptAction.x);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->y, (jint)lpNmlistview->ptAction.y);
+ (*env)->SetIntField(env,lpObject,lpNmlistviewFc->lParam, (jint)lpNmlistview->lParam);
+}
+
+void getNmtoolbarFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpNmtoolbar, NMTOOLBAR_FID_CACHE *lpNmtoolbarFc)
+{
+ lpNmtoolbar->hdr.hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpNmtoolbarFc->hwndFrom);
+ lpNmtoolbar->hdr.idFrom = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->idFrom);
+ lpNmtoolbar->hdr.code = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->code);
+ lpNmtoolbar->iItem = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->iItem);
+ lpNmtoolbar->tbButton.iBitmap = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->iBitmap);
+ lpNmtoolbar->tbButton.idCommand = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->idCommand);
+ lpNmtoolbar->tbButton.fsState = (*env)->GetByteField(env,lpObject,lpNmtoolbarFc->fsState);
+ lpNmtoolbar->tbButton.fsStyle = (*env)->GetByteField(env,lpObject,lpNmtoolbarFc->fsStyle);
+ lpNmtoolbar->tbButton.dwData = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->dwData);
+ lpNmtoolbar->tbButton.iString = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->iString);
+ lpNmtoolbar->cchText = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->cchText);
+ lpNmtoolbar->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpNmtoolbarFc->pszText);
+ lpNmtoolbar->rcButton.left = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->left);
+ lpNmtoolbar->rcButton.top = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->top);
+ lpNmtoolbar->rcButton.right = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->right);
+ lpNmtoolbar->rcButton.bottom = (*env)->GetIntField(env,lpObject,lpNmtoolbarFc->bottom);
+}
+
+void setNmtoolbarFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpNmtoolbar, NMTOOLBAR_FID_CACHE *lpNmtoolbarFc)
+{
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->hwndFrom, (jint)lpNmtoolbar->hdr.hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->idFrom, lpNmtoolbar->hdr.idFrom);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->code, lpNmtoolbar->hdr.code);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->iItem, lpNmtoolbar->iItem);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->iBitmap, lpNmtoolbar->tbButton.iBitmap);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->idCommand, lpNmtoolbar->tbButton.idCommand);
+ (*env)->SetByteField(env,lpObject,lpNmtoolbarFc->fsState, lpNmtoolbar->tbButton.fsState);
+ (*env)->SetByteField(env,lpObject,lpNmtoolbarFc->fsStyle, lpNmtoolbar->tbButton.fsStyle);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->dwData, lpNmtoolbar->tbButton.dwData);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->iString, lpNmtoolbar->tbButton.iString);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->cchText, lpNmtoolbar->cchText);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->pszText, (jint)lpNmtoolbar->pszText);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->left, lpNmtoolbar->rcButton.left);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->top, lpNmtoolbar->rcButton.top);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->right, lpNmtoolbar->rcButton.right);
+ (*env)->SetIntField(env,lpObject,lpNmtoolbarFc->bottom, lpNmtoolbar->rcButton.bottom);
+}
+
+void getNmttdispinfoFields(JNIEnv *env, jobject lpObject, NMTTDISPINFO *lpNmttdispinfo, NMTTDISPINFO_FID_CACHE *lpNmttdispinfoFc)
+{
+ jint *lpInt;
+
+ lpNmttdispinfo->hdr.hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->hwndFrom);
+ lpNmttdispinfo->hdr.idFrom = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->idFrom);
+ lpNmttdispinfo->hdr.code = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->code);
+ lpNmttdispinfo->lpszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->lpszText);
+ lpInt = (jint *)lpNmttdispinfo->szText;
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad0);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad1);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad2);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad3);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad4);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad5);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad6);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad7);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad8);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad9);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad10);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad11);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad12);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad13);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad14);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad15);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad16);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad17);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad18);
+ *lpInt++ = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->pad19);
+ lpNmttdispinfo->hinst = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->hinst);
+ lpNmttdispinfo->uFlags = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->uFlags);
+ lpNmttdispinfo->lParam = (*env)->GetIntField(env,lpObject,lpNmttdispinfoFc->lParam);
+}
+
+void setNmttdispinfoFields(JNIEnv *env, jobject lpObject, NMTTDISPINFO *lpNmttdispinfo, NMTTDISPINFO_FID_CACHE *lpNmttdispinfoFc)
+{
+ jint *lpInt;
+
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->hwndFrom, (jint)lpNmttdispinfo->hdr.hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->idFrom, lpNmttdispinfo->hdr.idFrom);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->code, lpNmttdispinfo->hdr.code);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->lpszText, (jint)lpNmttdispinfo->lpszText);
+ lpInt = (jint *)lpNmttdispinfo->szText;
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad0, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad1, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad2, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad3, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad4, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad5, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad6, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad7, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad8, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad9, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad10, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad11, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad12, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad13, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad14, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad15, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad16, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad17, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad18, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->pad19, *lpInt++);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->hinst, (jint)lpNmttdispinfo->hinst);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->uFlags, lpNmttdispinfo->uFlags);
+ (*env)->SetIntField(env,lpObject,lpNmttdispinfoFc->lParam, lpNmttdispinfo->lParam);
+}
+
+void getNmtvcustomdrawFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpNmtvcustomdraw, NMTVCUSTOMDRAW_FID_CACHE *lpNmtvcustomdrawFc)
+{
+ lpNmtvcustomdraw->nmcd.hdr.hwndFrom = (HWND)(*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->hwndFrom);
+ lpNmtvcustomdraw->nmcd.hdr.idFrom = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->idFrom);
+ lpNmtvcustomdraw->nmcd.hdr.code = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->code);
+ lpNmtvcustomdraw->nmcd.dwDrawStage = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->dwDrawStage);
+ lpNmtvcustomdraw->nmcd.hdc = (HDC)(*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->hdc);
+ lpNmtvcustomdraw->nmcd.rc.left = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->left);
+ lpNmtvcustomdraw->nmcd.rc.top = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->top);
+ lpNmtvcustomdraw->nmcd.rc.right = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->right);
+ lpNmtvcustomdraw->nmcd.rc.bottom = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->bottom);
+ lpNmtvcustomdraw->nmcd.dwItemSpec = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->dwItemSpec);
+ lpNmtvcustomdraw->nmcd.uItemState = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->uItemState);
+ lpNmtvcustomdraw->nmcd.lItemlParam = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->lItemlParam);
+ lpNmtvcustomdraw->clrText = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->clrText);
+ lpNmtvcustomdraw->clrTextBk = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->clrTextBk);
+ lpNmtvcustomdraw->iLevel = (*env)->GetIntField(env,lpObject,lpNmtvcustomdrawFc->iLevel);
+}
+
+void setNmtvcustomdrawFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpNmtvcustomdraw, NMTVCUSTOMDRAW_FID_CACHE *lpNmtvcustomdrawFc)
+{
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->hwndFrom, (jint)lpNmtvcustomdraw->nmcd.hdr.hwndFrom);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->idFrom, lpNmtvcustomdraw->nmcd.hdr.idFrom);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->code, lpNmtvcustomdraw->nmcd.hdr.code);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->dwDrawStage, lpNmtvcustomdraw->nmcd.dwDrawStage);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->hdc, (jint)lpNmtvcustomdraw->nmcd.hdc);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->left, lpNmtvcustomdraw->nmcd.rc.left);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->top, lpNmtvcustomdraw->nmcd.rc.top);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->right, lpNmtvcustomdraw->nmcd.rc.right);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->bottom, lpNmtvcustomdraw->nmcd.rc.bottom);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->dwItemSpec, lpNmtvcustomdraw->nmcd.dwItemSpec);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->uItemState, lpNmtvcustomdraw->nmcd.uItemState);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->lItemlParam, lpNmtvcustomdraw->nmcd.lItemlParam);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->clrText, lpNmtvcustomdraw->clrText);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->clrTextBk, lpNmtvcustomdraw->clrTextBk);
+ (*env)->SetIntField(env,lpObject,lpNmtvcustomdrawFc->iLevel, lpNmtvcustomdraw->iLevel);
+}
+
+void getOpenfilenameFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpOpenfilename, OPENFILENAME_FID_CACHE *lpOpenfilenameFc)
+{
+ lpOpenfilename->lStructSize = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lStructSize);
+ lpOpenfilename->hwndOwner = (HWND)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->hwndOwner);
+ lpOpenfilename->hInstance = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->hInstance);
+ lpOpenfilename->lpstrFilter = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrFilter);
+ lpOpenfilename->lpstrCustomFilter = (LPTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrCustomFilter);
+ lpOpenfilename->nMaxCustFilter = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->nMaxCustFilter);
+ lpOpenfilename->nFilterIndex = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->nFilterIndex);
+ lpOpenfilename->lpstrFile = (LPTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrFile);
+ lpOpenfilename->nMaxFile = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->nMaxFile);
+ lpOpenfilename->lpstrFileTitle = (LPTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrFileTitle);
+ lpOpenfilename->nMaxFileTitle = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->nMaxFileTitle);
+ lpOpenfilename->lpstrInitialDir = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrInitialDir);
+ lpOpenfilename->lpstrTitle = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrTitle);
+ lpOpenfilename->Flags = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->Flags);
+ lpOpenfilename->nFileOffset = (*env)->GetShortField(env,lpObject,lpOpenfilenameFc->nFileOffset);
+ lpOpenfilename->nFileExtension = (*env)->GetShortField(env,lpObject,lpOpenfilenameFc->nFileExtension);
+ lpOpenfilename->lpstrDefExt = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpstrDefExt);
+ lpOpenfilename->lCustData = (*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lCustData);
+ lpOpenfilename->lpfnHook = (LPOFNHOOKPROC)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpfnHook);
+ lpOpenfilename->lpTemplateName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpOpenfilenameFc->lpTemplateName);
+}
+
+void setOpenfilenameFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpOpenfilename, OPENFILENAME_FID_CACHE *lpOpenfilenameFc)
+{
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lStructSize, lpOpenfilename->lStructSize);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->hwndOwner, (jint)lpOpenfilename->hwndOwner);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->hInstance, (jint)lpOpenfilename->hInstance);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrFilter, (jint)lpOpenfilename->lpstrFilter);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrCustomFilter, (jint)lpOpenfilename->lpstrCustomFilter);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->nMaxCustFilter, lpOpenfilename->nMaxCustFilter);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->nFilterIndex, lpOpenfilename->nFilterIndex);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrFile, (jint)lpOpenfilename->lpstrFile);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->nMaxFile, lpOpenfilename->nMaxFile);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrFileTitle, (jint)lpOpenfilename->lpstrFileTitle);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->nMaxFileTitle, lpOpenfilename->nMaxFileTitle);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrInitialDir, (jint)lpOpenfilename->lpstrInitialDir);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrTitle, (jint)lpOpenfilename->lpstrTitle);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->Flags, lpOpenfilename->Flags);
+ (*env)->SetShortField(env,lpObject,lpOpenfilenameFc->nFileOffset, lpOpenfilename->nFileOffset);
+ (*env)->SetShortField(env,lpObject,lpOpenfilenameFc->nFileExtension, lpOpenfilename->nFileExtension);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpstrDefExt, (jint)lpOpenfilename->lpstrDefExt);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lCustData, lpOpenfilename->lCustData);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpfnHook, (jint)lpOpenfilename->lpfnHook);
+ (*env)->SetIntField(env,lpObject,lpOpenfilenameFc->lpTemplateName, (jint)lpOpenfilename->lpTemplateName);
+}
+
+void getPagesetupdlgFields(JNIEnv *env, jobject lpObject, PAGESETUPDLG *lpPagesetupdlg, PAGESETUPDLG_FID_CACHE *lpPagesetupdlgFc)
+{
+ lpPagesetupdlg->lStructSize = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->lStructSize);
+ lpPagesetupdlg->hwndOwner = (HWND)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->hwndOwner);
+ lpPagesetupdlg->hDevMode = (HGLOBAL)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->hDevMode);
+ lpPagesetupdlg->hDevNames = (HGLOBAL)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->hDevNames);
+ lpPagesetupdlg->Flags = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->Flags);
+ lpPagesetupdlg->ptPaperSize.x = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->ptPaperSize_x);
+ lpPagesetupdlg->ptPaperSize.y = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->ptPaperSize_y);
+ lpPagesetupdlg->rtMinMargin.left = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_left);
+ lpPagesetupdlg->rtMinMargin.top = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_top);
+ lpPagesetupdlg->rtMinMargin.right = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_right);
+ lpPagesetupdlg->rtMinMargin.bottom = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_bottom);
+ lpPagesetupdlg->rtMargin.left = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_left);
+ lpPagesetupdlg->rtMargin.top = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_top);
+ lpPagesetupdlg->rtMargin.right = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_right);
+ lpPagesetupdlg->rtMargin.bottom = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_bottom);
+ lpPagesetupdlg->hInstance = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->hInstance);
+ lpPagesetupdlg->lCustData = (*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->lCustData);
+ lpPagesetupdlg->lpfnPageSetupHook = (LPPAGESETUPHOOK)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->lpfnPageSetupHook);
+ lpPagesetupdlg->lpfnPagePaintHook = (LPPAGEPAINTHOOK)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->lpfnPagePaintHook);
+ lpPagesetupdlg->lpPageSetupTemplateName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->lpPageSetupTemplateName);
+ lpPagesetupdlg->hPageSetupTemplate = (HGLOBAL)(*env)->GetIntField(env,lpObject,lpPagesetupdlgFc->hPageSetupTemplate);
+}
+
+void setPagesetupdlgFields(JNIEnv *env, jobject lpObject, PAGESETUPDLG *lpPagesetupdlg, PAGESETUPDLG_FID_CACHE *lpPagesetupdlgFc)
+{
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->lStructSize, lpPagesetupdlg->lStructSize);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->hwndOwner, (jint)lpPagesetupdlg->hwndOwner);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->hDevMode, (jint)lpPagesetupdlg->hDevMode);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->hDevNames, (jint)lpPagesetupdlg->hDevNames);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->Flags, lpPagesetupdlg->Flags);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->ptPaperSize_x, lpPagesetupdlg->ptPaperSize.x);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->ptPaperSize_y, lpPagesetupdlg->ptPaperSize.y);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_left, lpPagesetupdlg->rtMinMargin.left);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_top, lpPagesetupdlg->rtMinMargin.top);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_right, lpPagesetupdlg->rtMinMargin.right);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMinMargin_bottom, lpPagesetupdlg->rtMinMargin.bottom);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_left, lpPagesetupdlg->rtMargin.left);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_top, lpPagesetupdlg->rtMargin.top);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_right, lpPagesetupdlg->rtMargin.right);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->rtMargin_bottom, lpPagesetupdlg->rtMargin.bottom);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->hInstance, (jint)lpPagesetupdlg->hInstance);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->lCustData, lpPagesetupdlg->lCustData);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->lpfnPageSetupHook, (jint)lpPagesetupdlg->lpfnPageSetupHook);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->lpfnPagePaintHook, (jint)lpPagesetupdlg->lpfnPagePaintHook);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->lpPageSetupTemplateName, (jint)lpPagesetupdlg->lpPageSetupTemplateName);
+ (*env)->SetIntField(env,lpObject,lpPagesetupdlgFc->hPageSetupTemplate, (jint)lpPagesetupdlg->hPageSetupTemplate);
+}
+
+void getPaintstructFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpPaint, PAINTSTRUCT_FID_CACHE *lpPaintstructFc)
+{
+ lpPaint->hdc = (HDC)(*env)->GetIntField(env,lpObject,lpPaintstructFc->hdc);
+ lpPaint->fErase = (*env)->GetBooleanField(env,lpObject,lpPaintstructFc->fErase);
+ lpPaint->rcPaint.left = (*env)->GetIntField(env,lpObject,lpPaintstructFc->left);
+ lpPaint->rcPaint.top = (*env)->GetIntField(env,lpObject,lpPaintstructFc->top);
+ lpPaint->rcPaint.right = (*env)->GetIntField(env,lpObject,lpPaintstructFc->right);
+ lpPaint->rcPaint.bottom = (*env)->GetIntField(env,lpObject,lpPaintstructFc->bottom);
+ lpPaint->fRestore = (*env)->GetBooleanField(env,lpObject,lpPaintstructFc->fRestore);
+ lpPaint->fIncUpdate = (*env)->GetBooleanField(env,lpObject,lpPaintstructFc->fIncUpdate);
+}
+
+void setPaintstructFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpPaint, PAINTSTRUCT_FID_CACHE *lpPaintstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpPaintstructFc->hdc, (jint)lpPaint->hdc);
+ (*env)->SetBooleanField(env,lpObject,lpPaintstructFc->fErase, (jboolean)lpPaint->fErase);
+ (*env)->SetIntField(env,lpObject,lpPaintstructFc->left, lpPaint->rcPaint.left);
+ (*env)->SetIntField(env,lpObject,lpPaintstructFc->top, lpPaint->rcPaint.top);
+ (*env)->SetIntField(env,lpObject,lpPaintstructFc->right, lpPaint->rcPaint.right);
+ (*env)->SetIntField(env,lpObject,lpPaintstructFc->bottom, lpPaint->rcPaint.bottom);
+ (*env)->SetBooleanField(env,lpObject,lpPaintstructFc->fRestore, (jboolean)lpPaint->fRestore);
+ (*env)->SetBooleanField(env,lpObject,lpPaintstructFc->fIncUpdate, (jboolean)lpPaint->fIncUpdate);
+}
+/*
+void getParaformatFields(JNIEnv *env, jobject lpObject, PARAFORMAT *lpParaformat, PARAFORMAT_FID_CACHE *lpParaformatFc)
+{
+ lpParaformat->cbSize = (*env)->GetIntField(env,lpObject,lpParaformatFc->cbSize);
+ lpParaformat->dwMask = (*env)->GetIntField(env,lpObject,lpParaformatFc->dwMask);
+ lpParaformat->wNumbering = (*env)->GetShortField(env,lpObject,lpParaformatFc->wNumbering);
+ lpParaformat->wEffects = (*env)->GetShortField(env,lpObject,lpParaformatFc->wEffects);
+ lpParaformat->dxStartIndent = (*env)->GetIntField(env,lpObject,lpParaformatFc->dxStartIndent);
+ lpParaformat->dxRightIndent = (*env)->GetIntField(env,lpObject,lpParaformatFc->dxRightIndent);
+ lpParaformat->dxOffset = (*env)->GetIntField(env,lpObject,lpParaformatFc->dxOffset);
+ lpParaformat->wAlignment = (*env)->GetShortField(env,lpObject,lpParaformatFc->wAlignment);
+ lpParaformat->cTabCount = (*env)->GetShortField(env,lpObject,lpParaformatFc->cTabCount);
+ lpParaformat->rgxTabs[0] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs0);
+ lpParaformat->rgxTabs[1] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs1);
+ lpParaformat->rgxTabs[2] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs2);
+ lpParaformat->rgxTabs[3] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs3);
+ lpParaformat->rgxTabs[4] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs4);
+ lpParaformat->rgxTabs[5] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs5);
+ lpParaformat->rgxTabs[6] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs6);
+ lpParaformat->rgxTabs[7] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs7);
+ lpParaformat->rgxTabs[8] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs8);
+ lpParaformat->rgxTabs[9] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs9);
+ lpParaformat->rgxTabs[10] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs10);
+ lpParaformat->rgxTabs[11] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs11);
+ lpParaformat->rgxTabs[12] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs12);
+ lpParaformat->rgxTabs[13] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs13);
+ lpParaformat->rgxTabs[14] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs14);
+ lpParaformat->rgxTabs[15] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs15);
+ lpParaformat->rgxTabs[16] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs16);
+ lpParaformat->rgxTabs[17] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs17);
+ lpParaformat->rgxTabs[18] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs18);
+ lpParaformat->rgxTabs[19] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs19);
+ lpParaformat->rgxTabs[20] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs20);
+ lpParaformat->rgxTabs[21] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs21);
+ lpParaformat->rgxTabs[22] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs22);
+ lpParaformat->rgxTabs[23] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs23);
+ lpParaformat->rgxTabs[24] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs24);
+ lpParaformat->rgxTabs[25] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs25);
+ lpParaformat->rgxTabs[26] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs26);
+ lpParaformat->rgxTabs[27] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs27);
+ lpParaformat->rgxTabs[28] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs28);
+ lpParaformat->rgxTabs[29] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs29);
+ lpParaformat->rgxTabs[30] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs30);
+ lpParaformat->rgxTabs[31] = (*env)->GetIntField(env,lpObject,lpParaformatFc->rgxTabs31);
+}
+
+void setParaformatFields(JNIEnv *env, jobject lpObject, PARAFORMAT *lpParaformat, PARAFORMAT_FID_CACHE *lpParaformatFc)
+{
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->cbSize, lpParaformat->cbSize);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->dwMask, lpParaformat->dwMask);
+ (*env)->SetShortField(env,lpObject,lpParaformatFc->wNumbering, lpParaformat->wNumbering);
+ (*env)->SetShortField(env,lpObject,lpParaformatFc->wEffects, lpParaformat->wEffects);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->dxStartIndent, lpParaformat->dxStartIndent);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->dxRightIndent, lpParaformat->dxRightIndent);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->dxOffset, lpParaformat->dxOffset);
+ (*env)->SetShortField(env,lpObject,lpParaformatFc->wAlignment, lpParaformat->wAlignment);
+ (*env)->SetShortField(env,lpObject,lpParaformatFc->cTabCount, lpParaformat->cTabCount);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs0, lpParaformat->rgxTabs[0]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs1, lpParaformat->rgxTabs[1]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs2, lpParaformat->rgxTabs[2]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs3, lpParaformat->rgxTabs[3]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs4, lpParaformat->rgxTabs[4]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs5, lpParaformat->rgxTabs[5]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs6, lpParaformat->rgxTabs[6]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs7, lpParaformat->rgxTabs[7]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs8, lpParaformat->rgxTabs[8]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs9, lpParaformat->rgxTabs[9]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs10, lpParaformat->rgxTabs[10]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs11, lpParaformat->rgxTabs[11]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs12, lpParaformat->rgxTabs[12]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs13, lpParaformat->rgxTabs[13]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs14, lpParaformat->rgxTabs[14]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs15, lpParaformat->rgxTabs[15]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs16, lpParaformat->rgxTabs[16]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs17, lpParaformat->rgxTabs[17]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs18, lpParaformat->rgxTabs[18]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs19, lpParaformat->rgxTabs[19]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs20, lpParaformat->rgxTabs[20]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs21, lpParaformat->rgxTabs[21]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs22, lpParaformat->rgxTabs[22]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs23, lpParaformat->rgxTabs[23]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs24, lpParaformat->rgxTabs[24]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs25, lpParaformat->rgxTabs[25]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs26, lpParaformat->rgxTabs[26]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs27, lpParaformat->rgxTabs[27]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs28, lpParaformat->rgxTabs[28]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs29, lpParaformat->rgxTabs[29]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs30, lpParaformat->rgxTabs[30]);
+ (*env)->SetIntField(env,lpObject,lpParaformatFc->rgxTabs31, lpParaformat->rgxTabs[31]);
+}
+*/
+void getPointFields(JNIEnv *env, jobject lpObject, POINT *lpPoint, POINT_FID_CACHE *lpPointFc)
+{
+ lpPoint->x = (*env)->GetIntField(env,lpObject,lpPointFc->x);
+ lpPoint->y = (*env)->GetIntField(env,lpObject,lpPointFc->y);
+}
+
+void setPointFields(JNIEnv *env, jobject lpObject, POINT *lpPoint, POINT_FID_CACHE *lpPointFc)
+{
+ (*env)->SetIntField(env,lpObject,lpPointFc->x, lpPoint->x);
+ (*env)->SetIntField(env,lpObject,lpPointFc->y, lpPoint->y);
+}
+
+void getPrintdlgFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpPrintdlg, PRINTDLG_FID_CACHE *lpPrintdlgFc)
+{
+ lpPrintdlg->lStructSize = (*env)->GetIntField(env,lpObject,lpPrintdlgFc->lStructSize);
+ lpPrintdlg->hwndOwner = (HWND)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hwndOwner);
+ lpPrintdlg->hDevMode = (HANDLE)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hDevMode);
+ lpPrintdlg->hDevNames = (HANDLE)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hDevNames);
+ lpPrintdlg->hDC = (HDC)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hDC);
+ lpPrintdlg->Flags = (*env)->GetIntField(env,lpObject,lpPrintdlgFc->Flags);
+ lpPrintdlg->nFromPage = (*env)->GetShortField(env,lpObject,lpPrintdlgFc->nFromPage);
+ lpPrintdlg->nToPage = (*env)->GetShortField(env,lpObject,lpPrintdlgFc->nToPage);
+ lpPrintdlg->nMinPage = (*env)->GetShortField(env,lpObject,lpPrintdlgFc->nMinPage);
+ lpPrintdlg->nMaxPage = (*env)->GetShortField(env,lpObject,lpPrintdlgFc->nMaxPage);
+ lpPrintdlg->nCopies = (*env)->GetShortField(env,lpObject,lpPrintdlgFc->nCopies);
+ lpPrintdlg->hInstance = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hInstance);
+ lpPrintdlg->lCustData = (*env)->GetIntField(env,lpObject,lpPrintdlgFc->lCustData);
+ lpPrintdlg->lpfnPrintHook = (LPPRINTHOOKPROC)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->lpfnPrintHook);
+ lpPrintdlg->lpfnSetupHook = (LPSETUPHOOKPROC)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->lpfnSetupHook);
+ lpPrintdlg->lpPrintTemplateName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->lpPrintTemplateName);
+ lpPrintdlg->lpSetupTemplateName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->lpSetupTemplateName);
+ lpPrintdlg->hPrintTemplate = (HANDLE)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hPrintTemplate);
+ lpPrintdlg->hSetupTemplate = (HANDLE)(*env)->GetIntField(env,lpObject,lpPrintdlgFc->hSetupTemplate);
+}
+
+void setPrintdlgFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpPrintdlg, PRINTDLG_FID_CACHE *lpPrintdlgFc)
+{
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->lStructSize, lpPrintdlg->lStructSize);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hwndOwner, (jint)lpPrintdlg->hwndOwner);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hDevMode, (jint)lpPrintdlg->hDevMode);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hDevNames, (jint)lpPrintdlg->hDevNames);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hDC, (jint)lpPrintdlg->hDC);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->Flags, lpPrintdlg->Flags);
+ (*env)->SetShortField(env,lpObject,lpPrintdlgFc->nFromPage, lpPrintdlg->nFromPage);
+ (*env)->SetShortField(env,lpObject,lpPrintdlgFc->nToPage, lpPrintdlg->nToPage);
+ (*env)->SetShortField(env,lpObject,lpPrintdlgFc->nMinPage, lpPrintdlg->nMinPage);
+ (*env)->SetShortField(env,lpObject,lpPrintdlgFc->nMaxPage, lpPrintdlg->nMaxPage);
+ (*env)->SetShortField(env,lpObject,lpPrintdlgFc->nCopies, lpPrintdlg->nCopies);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hInstance, (jint)lpPrintdlg->hInstance);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->lCustData, lpPrintdlg->lCustData);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->lpfnPrintHook, (jint)lpPrintdlg->lpfnPrintHook);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->lpfnSetupHook, (jint)lpPrintdlg->lpfnSetupHook);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->lpPrintTemplateName, (jint)lpPrintdlg->lpPrintTemplateName);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->lpSetupTemplateName, (jint)lpPrintdlg->lpSetupTemplateName);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hPrintTemplate, (jint)lpPrintdlg->hPrintTemplate);
+ (*env)->SetIntField(env,lpObject,lpPrintdlgFc->hSetupTemplate, (jint)lpPrintdlg->hSetupTemplate);
+}
+
+void getRebarbandinfoFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpRebarbandinfo, REBARBANDINFO_FID_CACHE *lpRebarbandinfoFc)
+{
+ lpRebarbandinfo->cbSize = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cbSize);
+ lpRebarbandinfo->fMask = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->fMask);
+ lpRebarbandinfo->fStyle = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->fStyle);
+ lpRebarbandinfo->clrFore = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->clrFore);
+ lpRebarbandinfo->clrBack = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->clrBack);
+ lpRebarbandinfo->lpText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->lpText);
+ lpRebarbandinfo->cch = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cch);
+ lpRebarbandinfo->iImage = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->iImage);
+ lpRebarbandinfo->hwndChild = (HWND)(*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->hwndChild);
+ lpRebarbandinfo->cxMinChild = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cxMinChild);
+ lpRebarbandinfo->cyMinChild = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cyMinChild);
+ lpRebarbandinfo->cx = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cx);
+ lpRebarbandinfo->hbmBack = (HBITMAP)(*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->hbmBack);
+ lpRebarbandinfo->wID = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->wID);
+ lpRebarbandinfo->cyChild = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cyChild);
+ lpRebarbandinfo->cyMaxChild = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cyMaxChild);
+ lpRebarbandinfo->cyIntegral = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cyIntegral);
+ lpRebarbandinfo->cxIdeal = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cxIdeal);
+ lpRebarbandinfo->lParam = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->lParam);
+ lpRebarbandinfo->cxHeader = (*env)->GetIntField(env,lpObject,lpRebarbandinfoFc->cxHeader);
+}
+
+void setRebarbandinfoFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpRebarbandinfo, REBARBANDINFO_FID_CACHE *lpRebarbandinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cbSize, lpRebarbandinfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->fMask, lpRebarbandinfo->fMask);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->fStyle, lpRebarbandinfo->fStyle);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->clrFore, lpRebarbandinfo->clrFore);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->clrBack, lpRebarbandinfo->clrBack);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->lpText, (jint)lpRebarbandinfo->lpText);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cch, lpRebarbandinfo->cch);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->iImage, lpRebarbandinfo->iImage);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->hwndChild, (jint)lpRebarbandinfo->hwndChild);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cxMinChild, lpRebarbandinfo->cxMinChild);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cyMinChild, lpRebarbandinfo->cyMinChild);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cx, lpRebarbandinfo->cx);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->hbmBack, (jint)lpRebarbandinfo->hbmBack);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->wID, lpRebarbandinfo->wID);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cyChild, lpRebarbandinfo->cyChild);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cyMaxChild, lpRebarbandinfo->cyMaxChild);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cyIntegral, lpRebarbandinfo->cyIntegral);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cxIdeal, lpRebarbandinfo->cxIdeal);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->lParam, lpRebarbandinfo->lParam);
+ (*env)->SetIntField(env,lpObject,lpRebarbandinfoFc->cxHeader, lpRebarbandinfo->cxHeader);
+}
+
+void getRectFields(JNIEnv *env, jobject lpObject, RECT *lpRect, RECT_FID_CACHE *lpRectFc)
+{
+ lpRect->left = (*env)->GetIntField(env,lpObject,lpRectFc->left);
+ lpRect->top = (*env)->GetIntField(env,lpObject,lpRectFc->top);
+ lpRect->right = (*env)->GetIntField(env,lpObject,lpRectFc->right);
+ lpRect->bottom = (*env)->GetIntField(env,lpObject,lpRectFc->bottom);
+}
+
+void setRectFields(JNIEnv *env, jobject lpObject, RECT *lpRect, RECT_FID_CACHE *lpRectFc)
+{
+ (*env)->SetIntField(env,lpObject,lpRectFc->left,lpRect->left);
+ (*env)->SetIntField(env,lpObject,lpRectFc->top,lpRect->top);
+ (*env)->SetIntField(env,lpObject,lpRectFc->right,lpRect->right);
+ (*env)->SetIntField(env,lpObject,lpRectFc->bottom,lpRect->bottom);
+}
+
+void getScrollinfoFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpScrollinfo, SCROLLINFO_FID_CACHE *lpScrollinfoFc)
+{
+ lpScrollinfo->cbSize = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->cbSize);
+ lpScrollinfo->fMask = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->fMask);
+ lpScrollinfo->nMin = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->nMin);
+ lpScrollinfo->nMax = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->nMax);
+ lpScrollinfo->nPage = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->nPage);
+ lpScrollinfo->nPos = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->nPos);
+ lpScrollinfo->nTrackPos = (*env)->GetIntField(env,lpObject,lpScrollinfoFc->nTrackPos);
+}
+
+void setScrollinfoFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpScrollinfo, SCROLLINFO_FID_CACHE *lpScrollinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->cbSize, lpScrollinfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->fMask, lpScrollinfo->fMask);
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->nMin, lpScrollinfo->nMin);
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->nMax, lpScrollinfo->nMax);
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->nPage, lpScrollinfo->nPage);
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->nPos, lpScrollinfo->nPos);
+ (*env)->SetIntField(env,lpObject,lpScrollinfoFc->nTrackPos, lpScrollinfo->nTrackPos);
+}
+
+void getSizeFields(JNIEnv *env, jobject lpObject, SIZE *lpSize, SIZE_FID_CACHE *lpSizeFc)
+{
+ lpSize->cx = (*env)->GetIntField(env,lpObject,lpSizeFc->cx);
+ lpSize->cy = (*env)->GetIntField(env,lpObject,lpSizeFc->cy);
+}
+
+void setSizeFields(JNIEnv *env, jobject lpObject, SIZE *lpSize, SIZE_FID_CACHE *lpSizeFc)
+{
+ (*env)->SetIntField(env,lpObject,lpSizeFc->cx, lpSize->cx);
+ (*env)->SetIntField(env,lpObject,lpSizeFc->cy, lpSize->cy);
+}
+
+void getTbbuttonFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpTbbutton, TBBUTTON_FID_CACHE *lpTbbuttonFc)
+{
+ lpTbbutton->iBitmap = (*env)->GetIntField(env,lpObject,lpTbbuttonFc->iBitmap);
+ lpTbbutton->idCommand = (*env)->GetIntField(env,lpObject,lpTbbuttonFc->idCommand);
+ lpTbbutton->fsState = (*env)->GetByteField(env,lpObject,lpTbbuttonFc->fsState);
+ lpTbbutton->fsStyle = (*env)->GetByteField(env,lpObject,lpTbbuttonFc->fsStyle);
+ lpTbbutton->dwData = (*env)->GetIntField(env,lpObject,lpTbbuttonFc->dwData);
+ lpTbbutton->iString = (*env)->GetIntField(env,lpObject,lpTbbuttonFc->iString);
+}
+
+void setTbbuttonFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpTbbutton, TBBUTTON_FID_CACHE *lpTbbuttonFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTbbuttonFc->iBitmap, lpTbbutton->iBitmap);
+ (*env)->SetIntField(env,lpObject,lpTbbuttonFc->idCommand, lpTbbutton->idCommand);
+ (*env)->SetByteField(env,lpObject,lpTbbuttonFc->fsState, lpTbbutton->fsState);
+ (*env)->SetByteField(env,lpObject,lpTbbuttonFc->fsStyle, lpTbbutton->fsStyle);
+ (*env)->SetIntField(env,lpObject,lpTbbuttonFc->dwData, lpTbbutton->dwData);
+ (*env)->SetIntField(env,lpObject,lpTbbuttonFc->iString, lpTbbutton->iString);
+}
+
+void getTbbuttoninfoFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpTbbuttoninfo, TBBUTTONINFO_FID_CACHE *lpTbbuttoninfoFc)
+{
+ lpTbbuttoninfo->cbSize = (*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->cbSize);
+ lpTbbuttoninfo->dwMask = (*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->dwMask);
+ lpTbbuttoninfo->idCommand = (*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->idCommand);
+ lpTbbuttoninfo->iImage = (*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->iImage);
+ lpTbbuttoninfo->fsState = (*env)->GetByteField(env,lpObject,lpTbbuttoninfoFc->fsState);
+ lpTbbuttoninfo->fsStyle = (*env)->GetByteField(env,lpObject,lpTbbuttoninfoFc->fsStyle);
+ lpTbbuttoninfo->cx = (*env)->GetShortField(env,lpObject,lpTbbuttoninfoFc->cx);
+ lpTbbuttoninfo->lParam = (*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->lParam);
+ lpTbbuttoninfo->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->pszText);
+ lpTbbuttoninfo->cchText = (*env)->GetIntField(env,lpObject,lpTbbuttoninfoFc->cchText);
+}
+
+void setTbbuttoninfoFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpTbbuttoninfo, TBBUTTONINFO_FID_CACHE *lpTbbuttoninfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->cbSize, lpTbbuttoninfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->dwMask, lpTbbuttoninfo->dwMask);
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->idCommand, lpTbbuttoninfo->idCommand);
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->iImage, lpTbbuttoninfo->iImage);
+ (*env)->SetByteField(env,lpObject,lpTbbuttoninfoFc->fsState, lpTbbuttoninfo->fsState);
+ (*env)->SetByteField(env,lpObject,lpTbbuttoninfoFc->fsStyle, lpTbbuttoninfo->fsStyle);
+ (*env)->SetShortField(env,lpObject,lpTbbuttoninfoFc->cx, lpTbbuttoninfo->cx);
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->lParam, lpTbbuttoninfo->lParam);
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->pszText, (jint)lpTbbuttoninfo->pszText);
+ (*env)->SetIntField(env,lpObject,lpTbbuttoninfoFc->cchText, lpTbbuttoninfo->cchText);
+}
+
+void getTcitemFields(JNIEnv *env, jobject lpObject, TCITEM *lpTcitem, TCITEM_FID_CACHE *lpTcitemFc)
+{
+ lpTcitem->mask = (*env)->GetIntField(env,lpObject,lpTcitemFc->mask);
+ lpTcitem->dwState = (*env)->GetIntField(env,lpObject,lpTcitemFc->dwState);
+ lpTcitem->dwStateMask = (*env)->GetIntField(env,lpObject,lpTcitemFc->dwStateMask);
+ lpTcitem->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpTcitemFc->pszText);
+ lpTcitem->cchTextMax = (*env)->GetIntField(env,lpObject,lpTcitemFc->cchTextMax);
+ lpTcitem->iImage = (*env)->GetIntField(env,lpObject,lpTcitemFc->iImage);
+ lpTcitem->lParam = (*env)->GetIntField(env,lpObject,lpTcitemFc->lParam);
+}
+
+void setTcitemFields(JNIEnv *env, jobject lpObject, TCITEM *lpTcitem, TCITEM_FID_CACHE *lpTcitemFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->mask, lpTcitem->mask);
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->dwState, lpTcitem->dwState);
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->dwStateMask, lpTcitem->dwStateMask);
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->pszText, (jint)lpTcitem->pszText);
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->cchTextMax, lpTcitem->cchTextMax);
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->iImage, lpTcitem->iImage);
+ (*env)->SetIntField(env,lpObject,lpTcitemFc->lParam, lpTcitem->lParam);
+}
+
+void getTextmetricFields(JNIEnv *env, jobject lpObject, TEXTMETRIC *lpTextmetric, TEXTMETRIC_FID_CACHE *lpTextmetricFc)
+{
+ lpTextmetric->tmHeight = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmHeight);
+ lpTextmetric->tmAscent = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmAscent);
+ lpTextmetric->tmDescent = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmDescent);
+ lpTextmetric->tmInternalLeading = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmInternalLeading);
+ lpTextmetric->tmExternalLeading = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmExternalLeading);
+ lpTextmetric->tmAveCharWidth = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmAveCharWidth);
+ lpTextmetric->tmMaxCharWidth = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmMaxCharWidth);
+ lpTextmetric->tmWeight = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmWeight);
+ lpTextmetric->tmOverhang = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmOverhang);
+ lpTextmetric->tmDigitizedAspectX = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmDigitizedAspectX);
+ lpTextmetric->tmDigitizedAspectY = (*env)->GetIntField(env,lpObject,lpTextmetricFc->tmDigitizedAspectY);
+ lpTextmetric->tmFirstChar = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmFirstChar);
+ lpTextmetric->tmLastChar = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmLastChar);
+ lpTextmetric->tmDefaultChar = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmDefaultChar);
+ lpTextmetric->tmBreakChar = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmBreakChar);
+ lpTextmetric->tmItalic = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmItalic);
+ lpTextmetric->tmUnderlined = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmUnderlined);
+ lpTextmetric->tmStruckOut = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmStruckOut);
+ lpTextmetric->tmPitchAndFamily = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmPitchAndFamily);
+ lpTextmetric->tmCharSet = (*env)->GetByteField(env,lpObject,lpTextmetricFc->tmCharSet);
+}
+
+void setTextmetricFields(JNIEnv *env, jobject lpObject, TEXTMETRIC *lpTextmetric, TEXTMETRIC_FID_CACHE *lpTextmetricFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmHeight, lpTextmetric->tmHeight);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmAscent, lpTextmetric->tmAscent);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmDescent, lpTextmetric->tmDescent);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmInternalLeading, lpTextmetric->tmInternalLeading);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmExternalLeading, lpTextmetric->tmExternalLeading);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmAveCharWidth, lpTextmetric->tmAveCharWidth);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmMaxCharWidth, lpTextmetric->tmMaxCharWidth);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmWeight, lpTextmetric->tmWeight);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmOverhang, lpTextmetric->tmOverhang);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmDigitizedAspectX, lpTextmetric->tmDigitizedAspectX);
+ (*env)->SetIntField(env,lpObject,lpTextmetricFc->tmDigitizedAspectY, lpTextmetric->tmDigitizedAspectY);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmFirstChar, lpTextmetric->tmFirstChar);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmLastChar, lpTextmetric->tmLastChar);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmDefaultChar, lpTextmetric->tmDefaultChar);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmBreakChar, lpTextmetric->tmBreakChar);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmItalic, lpTextmetric->tmItalic);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmUnderlined, lpTextmetric->tmUnderlined);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmStruckOut, lpTextmetric->tmStruckOut);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmPitchAndFamily, lpTextmetric->tmPitchAndFamily);
+ (*env)->SetByteField(env,lpObject,lpTextmetricFc->tmCharSet, lpTextmetric->tmCharSet);
+}
+
+void getToolinfoFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpToolinfo, TOOLINFO_FID_CACHE *lpToolinfoFc)
+{
+ lpToolinfo->cbSize = (*env)->GetIntField(env,lpObject,lpToolinfoFc->cbSize);
+ lpToolinfo->uFlags = (*env)->GetIntField(env,lpObject,lpToolinfoFc->uFlags);
+ lpToolinfo->hwnd = (HWND)(*env)->GetIntField(env,lpObject,lpToolinfoFc->hwnd);
+ lpToolinfo->uId = (*env)->GetIntField(env,lpObject,lpToolinfoFc->uId);
+ lpToolinfo->rect.left = (*env)->GetIntField(env,lpObject,lpToolinfoFc->left);
+ lpToolinfo->rect.top = (*env)->GetIntField(env,lpObject,lpToolinfoFc->top);
+ lpToolinfo->rect.right = (*env)->GetIntField(env,lpObject,lpToolinfoFc->right);
+ lpToolinfo->rect.bottom = (*env)->GetIntField(env,lpObject,lpToolinfoFc->bottom);
+ lpToolinfo->hinst = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpToolinfoFc->hinst);
+ lpToolinfo->lpszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpToolinfoFc->lpszText);
+ lpToolinfo->lParam = (*env)->GetIntField(env,lpObject,lpToolinfoFc->lParam);
+}
+
+void setToolinfoFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpToolinfo, TOOLINFO_FID_CACHE *lpToolinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->cbSize, lpToolinfo->cbSize);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->uFlags, lpToolinfo->uFlags);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->hwnd, (jint)lpToolinfo->hwnd);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->uId, lpToolinfo->uId);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->left, lpToolinfo->rect.left);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->top, lpToolinfo->rect.top);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->right, lpToolinfo->rect.right);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->bottom, lpToolinfo->rect.bottom);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->hinst, (jint)lpToolinfo->hinst);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->lpszText, (jint)lpToolinfo->lpszText);
+ (*env)->SetIntField(env,lpObject,lpToolinfoFc->lParam, lpToolinfo->lParam);
+}
+
+void getTrackmouseeventFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpTrackmouseevent, TRACKMOUSEEVENT_FID_CACHE *lpTrackmouseeventFc)
+{
+ lpTrackmouseevent->cbSize = (*env)->GetIntField(env,lpObject,lpTrackmouseeventFc->cbSize);
+ lpTrackmouseevent->dwFlags = (*env)->GetIntField(env,lpObject,lpTrackmouseeventFc->dwFlags);
+ lpTrackmouseevent->hwndTrack = (HWND)(*env)->GetIntField(env,lpObject,lpTrackmouseeventFc->hwndTrack);
+ lpTrackmouseevent->dwHoverTime = (*env)->GetIntField(env,lpObject,lpTrackmouseeventFc->dwHoverTime);
+}
+
+void setTrackmouseeventFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpTrackmouseevent, TRACKMOUSEEVENT_FID_CACHE *lpTrackmouseeventFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTrackmouseeventFc->cbSize, lpTrackmouseevent->cbSize);
+ (*env)->SetIntField(env,lpObject,lpTrackmouseeventFc->dwFlags, lpTrackmouseevent->dwFlags);
+ (*env)->SetIntField(env,lpObject,lpTrackmouseeventFc->hwndTrack, (jint)lpTrackmouseevent->hwndTrack);
+ (*env)->SetIntField(env,lpObject,lpTrackmouseeventFc->dwHoverTime, lpTrackmouseevent->dwHoverTime);
+}
+
+void getTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc)
+{
+ lpTvhittestinfo->pt.x = (*env)->GetIntField(env,lpObject,lpTvhittestinfoFc->x);
+ lpTvhittestinfo->pt.y = (*env)->GetIntField(env,lpObject,lpTvhittestinfoFc->y);
+ lpTvhittestinfo->flags = (*env)->GetIntField(env,lpObject,lpTvhittestinfoFc->flags);
+ lpTvhittestinfo->hItem = (HTREEITEM)(*env)->GetIntField(env,lpObject,lpTvhittestinfoFc->hItem);
+}
+
+void setTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTvhittestinfoFc->x, lpTvhittestinfo->pt.x);
+ (*env)->SetIntField(env,lpObject,lpTvhittestinfoFc->y, lpTvhittestinfo->pt.y);
+ (*env)->SetIntField(env,lpObject,lpTvhittestinfoFc->flags, lpTvhittestinfo->flags);
+ (*env)->SetIntField(env,lpObject,lpTvhittestinfoFc->hItem, (jint)lpTvhittestinfo->hItem);
+}
+
+void getTvinsertstructFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpTvinsertstruct, TVINSERTSTRUCT_FID_CACHE *lpTvinsertstructFc)
+{
+ lpTvinsertstruct->hParent = (HTREEITEM)(*env)->GetIntField(env,lpObject,lpTvinsertstructFc->hParent);
+ lpTvinsertstruct->hInsertAfter = (HTREEITEM)(*env)->GetIntField(env,lpObject,lpTvinsertstructFc->hInsertAfter);
+
+ lpTvinsertstruct->item.mask = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->mask);
+ lpTvinsertstruct->item.hItem = (HTREEITEM)(*env)->GetIntField(env,lpObject,lpTvinsertstructFc->hItem);
+ lpTvinsertstruct->item.state = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->state);
+ lpTvinsertstruct->item.stateMask = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->stateMask);
+ lpTvinsertstruct->item.pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpTvinsertstructFc->pszText);
+ lpTvinsertstruct->item.cchTextMax = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->cchTextMax);
+ lpTvinsertstruct->item.iImage = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->iImage);
+ lpTvinsertstruct->item.iSelectedImage = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->iSelectedImage);
+ lpTvinsertstruct->item.cChildren = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->cChildren);
+ lpTvinsertstruct->item.lParam = (*env)->GetIntField(env,lpObject,lpTvinsertstructFc->lParam);
+}
+
+void setTvinsertstructFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpTvinsertstruct, TVINSERTSTRUCT_FID_CACHE *lpTvinsertstructFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->hParent, (jint)lpTvinsertstruct->hParent);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->hInsertAfter, (jint)lpTvinsertstruct->hInsertAfter);
+
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->mask, lpTvinsertstruct->item.mask);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->hItem, (jint)lpTvinsertstruct->item.hItem);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->state, lpTvinsertstruct->item.state);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->stateMask, lpTvinsertstruct->item.stateMask);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->pszText, (jint)lpTvinsertstruct->item.pszText);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->cchTextMax, lpTvinsertstruct->item.cchTextMax);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->iImage, lpTvinsertstruct->item.iImage);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->iSelectedImage, lpTvinsertstruct->item.iSelectedImage);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->cChildren, lpTvinsertstruct->item.cChildren);
+ (*env)->SetIntField(env,lpObject,lpTvinsertstructFc->lParam, lpTvinsertstruct->item.lParam);
+}
+
+void getTvitemFields(JNIEnv *env, jobject lpObject, TVITEM *lpTvitem, TVITEM_FID_CACHE *lpTvitemFc)
+{
+ lpTvitem->mask = (*env)->GetIntField(env,lpObject,lpTvitemFc->mask);
+ lpTvitem->hItem = (HTREEITEM)(*env)->GetIntField(env,lpObject,lpTvitemFc->hItem);
+ lpTvitem->state = (*env)->GetIntField(env,lpObject,lpTvitemFc->state);
+ lpTvitem->stateMask = (*env)->GetIntField(env,lpObject,lpTvitemFc->stateMask);
+ lpTvitem->pszText = (LPTSTR)(*env)->GetIntField(env,lpObject,lpTvitemFc->pszText);
+ lpTvitem->cchTextMax = (*env)->GetIntField(env,lpObject,lpTvitemFc->cchTextMax);
+ lpTvitem->iImage = (*env)->GetIntField(env,lpObject,lpTvitemFc->iImage);
+ lpTvitem->iSelectedImage = (*env)->GetIntField(env,lpObject,lpTvitemFc->iSelectedImage);
+ lpTvitem->cChildren = (*env)->GetIntField(env,lpObject,lpTvitemFc->cChildren);
+ lpTvitem->lParam = (*env)->GetIntField(env,lpObject,lpTvitemFc->lParam);
+}
+
+void setTvitemFields(JNIEnv *env, jobject lpObject, TVITEM *lpTvitem, TVITEM_FID_CACHE *lpTvitemFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->mask, lpTvitem->mask);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->hItem, (jint)lpTvitem->hItem);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->state, lpTvitem->state);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->stateMask, lpTvitem->stateMask);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->pszText, (jint)lpTvitem->pszText);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->cchTextMax, lpTvitem->cchTextMax);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->iImage, lpTvitem->iImage);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->iSelectedImage, lpTvitem->iSelectedImage);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->cChildren, lpTvitem->cChildren);
+ (*env)->SetIntField(env,lpObject,lpTvitemFc->lParam, lpTvitem->lParam);
+}
+
+void getWindowposFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpWindowpos, WINDOWPOS_FID_CACHE *lpWindowposFc)
+{
+ lpWindowpos->hwnd = (HWND)(*env)->GetIntField(env,lpObject,lpWindowposFc->hwnd);
+ lpWindowpos->hwndInsertAfter = (HWND)(*env)->GetIntField(env,lpObject,lpWindowposFc->hwndInsertAfter);
+ lpWindowpos->x = (*env)->GetIntField(env,lpObject,lpWindowposFc->x);
+ lpWindowpos->y = (*env)->GetIntField(env,lpObject,lpWindowposFc->y);
+ lpWindowpos->cx = (*env)->GetIntField(env,lpObject,lpWindowposFc->cx);
+ lpWindowpos->cy = (*env)->GetIntField(env,lpObject,lpWindowposFc->cy);
+ lpWindowpos->flags = (*env)->GetIntField(env,lpObject,lpWindowposFc->flags);
+}
+
+void setWindowposFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpWindowpos, WINDOWPOS_FID_CACHE *lpWindowposFc)
+{
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->hwnd, (jint)lpWindowpos->hwnd);
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->hwndInsertAfter, (jint)lpWindowpos->hwndInsertAfter);
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->x, lpWindowpos->x);
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->y, lpWindowpos->y);
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->cx, lpWindowpos->cx);
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->cy, lpWindowpos->cy);
+ (*env)->SetIntField(env,lpObject,lpWindowposFc->flags, lpWindowpos->flags);
+}
+
+void getWindowplacementFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpWindowplacement, WINDOWPLACEMENT_FID_CACHE *lpWindowplacementFc)
+{
+ lpWindowplacement->length = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->length);
+ lpWindowplacement->flags = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->flags);
+ lpWindowplacement->showCmd = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->showCmd);
+ lpWindowplacement->ptMinPosition.x = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->ptMinPosition_x);
+ lpWindowplacement->ptMinPosition.y = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->ptMinPosition_y);
+ lpWindowplacement->ptMaxPosition.x = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->ptMaxPosition_x);
+ lpWindowplacement->ptMaxPosition.y = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->ptMaxPosition_y);
+ lpWindowplacement->rcNormalPosition.left = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->left);
+ lpWindowplacement->rcNormalPosition.top = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->top);
+ lpWindowplacement->rcNormalPosition.right = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->right);
+ lpWindowplacement->rcNormalPosition.bottom = (*env)->GetIntField(env,lpObject,lpWindowplacementFc->bottom);
+}
+
+void setWindowplacementFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpWindowplacement, WINDOWPLACEMENT_FID_CACHE *lpWindowplacementFc)
+{
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->length, lpWindowplacement->length);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->flags, lpWindowplacement->flags);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->showCmd, lpWindowplacement->showCmd);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->ptMinPosition_x, lpWindowplacement->ptMinPosition.x);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->ptMinPosition_y, lpWindowplacement->ptMinPosition.y);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->ptMaxPosition_x, lpWindowplacement->ptMaxPosition.x);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->ptMaxPosition_y, lpWindowplacement->ptMaxPosition.y);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->left, lpWindowplacement->rcNormalPosition.left);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->top, lpWindowplacement->rcNormalPosition.top);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->right, lpWindowplacement->rcNormalPosition.right);
+ (*env)->SetIntField(env,lpObject,lpWindowplacementFc->bottom, lpWindowplacement->rcNormalPosition.bottom);
+}
+
+void getWndclassexFields(JNIEnv *env, jobject lpObject, WNDCLASSEX *lpWndclassex, WNDCLASSEX_FID_CACHE *lpWndclassexFc)
+{
+ lpWndclassex->cbSize = (*env)->GetIntField(env,lpObject,lpWndclassexFc->cbSize);
+ lpWndclassex->style = (*env)->GetIntField(env,lpObject,lpWndclassexFc->style);
+ lpWndclassex->lpfnWndProc = (WNDPROC)(*env)->GetIntField(env,lpObject,lpWndclassexFc->lpfnWndProc);
+ lpWndclassex->cbClsExtra = (*env)->GetIntField(env,lpObject,lpWndclassexFc->cbClsExtra);
+ lpWndclassex->cbWndExtra = (*env)->GetIntField(env,lpObject,lpWndclassexFc->cbWndExtra);
+ lpWndclassex->hInstance = (HINSTANCE)(*env)->GetIntField(env,lpObject,lpWndclassexFc->hInstance);
+ lpWndclassex->hIcon = (HICON)(*env)->GetIntField(env,lpObject,lpWndclassexFc->hIcon);
+ lpWndclassex->hCursor = (HICON)(*env)->GetIntField(env,lpObject,lpWndclassexFc->hCursor);
+ lpWndclassex->hbrBackground = (HBRUSH)(*env)->GetIntField(env,lpObject,lpWndclassexFc->hbrBackground);
+ lpWndclassex->lpszMenuName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpWndclassexFc->lpszMenuName);
+ lpWndclassex->lpszClassName = (LPCTSTR)(*env)->GetIntField(env,lpObject,lpWndclassexFc->lpszClassName);
+ lpWndclassex->hIconSm = (HICON)(*env)->GetIntField(env,lpObject,lpWndclassexFc->hIconSm);
+}
+
+void setWndclassexFields(JNIEnv *env, jobject lpObject, WNDCLASSEX *lpWndclassex, WNDCLASSEX_FID_CACHE *lpWndclassexFc)
+{
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->cbSize, lpWndclassex->cbSize);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->style, lpWndclassex->style);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->lpfnWndProc, (jint)lpWndclassex->lpfnWndProc);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->cbClsExtra, lpWndclassex->cbClsExtra);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->cbWndExtra, lpWndclassex->cbWndExtra);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->hInstance, (jint)lpWndclassex->hInstance);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->hIcon, (jint)lpWndclassex->hIcon);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->hCursor, (jint)lpWndclassex->hCursor);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->hbrBackground, (jint)lpWndclassex->hbrBackground);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->lpszMenuName, (jint)lpWndclassex->lpszMenuName);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->lpszClassName, (jint)lpWndclassex->lpszClassName);
+ (*env)->SetIntField(env,lpObject,lpWndclassexFc->hIconSm, (jint)lpWndclassex->hIconSm);
+}
+
+/*
+* NOTE: Untested - szDisplayName and szTypeName don't work
+*/
+/*
+void getShfileinfoFields(JNIEnv *env, jobject lpObject, SHFILEINFO *lpShfileinfo, SHFILEINFO_FID_CACHE *lpShfileinfoFc)
+{
+ lpShfileinfo->hIcon = (HICON) (*env)->GetIntField(env,lpObject,lpShfileinfoFc->hIcon);
+ lpShfileinfo->iIcon = (int) (*env)->GetIntField(env,lpObject,lpShfileinfoFc->iIcon);
+ lpShfileinfo->dwAttributes = (DWORD)(*env)->GetIntField(env,lpObject,lpShfileinfoFc->dwAttributes);
+ {
+ jbyteArray szDisplayName = (*env)->GetObjectField(env,lpObject,lpShfileinfoFc->szDisplayName);
+ if (szDisplayName) {
+ jbyte * szDisplayName1 = (*env)->GetByteArrayElements(env, szDisplayName,NULL);
+ memcpy (lpShfileinfo->szDisplayName, szDisplayName1, sizeof (lpShfileinfo->szDisplayName));
+ (*env)->ReleaseByteArrayElements(env,szDisplayName, szDisplayName1, NULL);
+ }
+ }
+ {
+ jbyteArray szTypeName = (*env)->GetObjectField(env,lpObject,lpShfileinfoFc->szTypeName);
+ if (szTypeName) {
+ jbyte * szTypeName1 = (*env)->GetByteArrayElements(env, szTypeName,NULL);
+ memcpy (lpShfileinfo->szTypeName, szTypeName1, sizeof (lpShfileinfo->szTypeName));
+ (*env)->ReleaseByteArrayElements(env, szTypeName, szTypeName1, NULL);
+ }
+ }
+}
+
+void setShfileinfoFields(JNIEnv *env, jobject lpObject, SHFILEINFO *lpShfileinfo, SHFILEINFO_FID_CACHE *lpShfileinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpShfileinfoFc->hIcon, lpShfileinfo->hIcon);
+ (*env)->SetIntField(env,lpObject,lpShfileinfoFc->iIcon, lpShfileinfo->iIcon);
+ (*env)->SetIntField(env,lpObject,lpShfileinfoFc->dwAttributes, lpShfileinfo->dwAttributes);
+ {
+ jbyteArray szDisplayName = (*env)->GetObjectField(env,lpObject,lpShfileinfoFc->szDisplayName);
+ if (szDisplayName) {
+ jbyte * szDisplayName1 = (*env)->GetByteArrayElements(env,szDisplayName,NULL);
+ memcpy (szDisplayName1, lpShfileinfo->szDisplayName, sizeof (lpShfileinfo->szDisplayName));
+ (*env)->ReleaseByteArrayElements(env,szDisplayName,szDisplayName1, NULL);
+ }
+ }
+ {
+ jbyteArray szTypeName = (*env)->GetObjectField(env,lpObject,lpShfileinfoFc->szTypeName);
+ if (szTypeName) {
+ jbyte * szTypeName1 = (*env)->GetByteArrayElements(env,szTypeName,NULL);
+ memcpy (szTypeName1, lpShfileinfo->szTypeName, sizeof (lpShfileinfo->szTypeName));
+ (*env)->ReleaseByteArrayElements(env,szTypeName,szTypeName1, NULL);
+ }
+ }
+}
+*/
+
+/* ----------- activex/ole getters and setters ----------- */
+
+void getCauuidFields(JNIEnv *env, jobject lpObject, CAUUID *lpCauuid, CAUUID_FID_CACHE *lpCauuidFc)
+{
+ lpCauuid->cElems = (*env)->GetIntField(env,lpObject,lpCauuidFc->cElems);
+ lpCauuid->pElems = (GUID FAR*)(*env)->GetIntField(env,lpObject,lpCauuidFc->pElems);
+}
+
+void setCauuidFields(JNIEnv *env, jobject lpObject, CAUUID *lpCauuid, CAUUID_FID_CACHE *lpCauuidFc)
+{
+ (*env)->SetIntField(env,lpObject,lpCauuidFc->cElems, lpCauuid->cElems);
+ (*env)->SetIntField(env,lpObject,lpCauuidFc->pElems, (jint)lpCauuid->pElems);
+}
+
+void getCoserverinfoFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpCoserverinfo, COSERVERINFO_FID_CACHE *lpCoserverinfoFc)
+{
+ lpCoserverinfo->dwReserved1 = (*env)->GetIntField(env,lpObject,lpCoserverinfoFc->dwReserved1);
+ lpCoserverinfo->pwszName = (LPWSTR)(*env)->GetIntField(env,lpObject,lpCoserverinfoFc->pwszName);
+ lpCoserverinfo->pAuthInfo = (COAUTHINFO *)(*env)->GetIntField(env,lpObject,lpCoserverinfoFc->pAuthInfo);
+ lpCoserverinfo->dwReserved2 = (*env)->GetIntField(env,lpObject,lpCoserverinfoFc->dwReserved2);
+}
+
+void setCoserverinfoFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpCoserverinfo, COSERVERINFO_FID_CACHE *lpCoserverinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpCoserverinfoFc->dwReserved1, lpCoserverinfo->dwReserved1);
+ (*env)->SetIntField(env,lpObject,lpCoserverinfoFc->pwszName, (jint)lpCoserverinfo->pwszName);
+ (*env)->SetIntField(env,lpObject,lpCoserverinfoFc->pAuthInfo, (jint)lpCoserverinfo->pAuthInfo);
+ (*env)->SetIntField(env,lpObject,lpCoserverinfoFc->dwReserved2, lpCoserverinfo->dwReserved2);
+}
+
+void getControlinfoFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpControlinfo, CONTROLINFO_FID_CACHE *lpControlinfoFc)
+{
+ lpControlinfo->cb = (*env)->GetIntField(env,lpObject,lpControlinfoFc->cb);
+ lpControlinfo->hAccel = (HACCEL)(*env)->GetIntField(env,lpObject,lpControlinfoFc->hAccel);
+ lpControlinfo->cAccel = (*env)->GetShortField(env,lpObject,lpControlinfoFc->cAccel);
+ lpControlinfo->dwFlags = (*env)->GetIntField(env,lpObject,lpControlinfoFc->dwFlags);
+}
+
+void setControlinfoFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpControlinfo, CONTROLINFO_FID_CACHE *lpControlinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpControlinfoFc->cb, lpControlinfo->cb);
+ (*env)->SetIntField(env,lpObject,lpControlinfoFc->hAccel, (jint)lpControlinfo->hAccel);
+ (*env)->SetShortField(env,lpObject,lpControlinfoFc->cAccel, lpControlinfo->cAccel);
+ (*env)->SetIntField(env,lpObject,lpControlinfoFc->dwFlags, lpControlinfo->dwFlags);
+}
+
+void getDvtargetdeviceFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpDvtargetdevice, DVTARGETDEVICE_FID_CACHE *lpDvtargetdeviceFc)
+{
+ lpDvtargetdevice->tdSize = (*env)->GetIntField(env,lpObject,lpDvtargetdeviceFc->tdSize);
+ lpDvtargetdevice->tdDriverNameOffset = (*env)->GetShortField(env,lpObject,lpDvtargetdeviceFc->tdDriverNameOffset);
+ lpDvtargetdevice->tdDeviceNameOffset = (*env)->GetShortField(env,lpObject,lpDvtargetdeviceFc->tdDeviceNameOffset);
+ lpDvtargetdevice->tdPortNameOffset = (*env)->GetShortField(env,lpObject,lpDvtargetdeviceFc->tdPortNameOffset);
+ lpDvtargetdevice->tdExtDevmodeOffset = (*env)->GetShortField(env,lpObject,lpDvtargetdeviceFc->tdExtDevmodeOffset);
+ *lpDvtargetdevice->tdData = (*env)->GetByteField(env,lpObject,lpDvtargetdeviceFc->tdData);
+}
+
+void setDvtargetdeviceFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpDvtargetdevice, DVTARGETDEVICE_FID_CACHE *lpDvtargetdeviceFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDvtargetdeviceFc->tdSize, lpDvtargetdevice->tdSize);
+ (*env)->SetShortField(env,lpObject,lpDvtargetdeviceFc->tdDriverNameOffset, lpDvtargetdevice->tdDriverNameOffset);
+ (*env)->SetShortField(env,lpObject,lpDvtargetdeviceFc->tdDeviceNameOffset, lpDvtargetdevice->tdDeviceNameOffset);
+ (*env)->SetShortField(env,lpObject,lpDvtargetdeviceFc->tdPortNameOffset, lpDvtargetdevice->tdPortNameOffset);
+ (*env)->SetShortField(env,lpObject,lpDvtargetdeviceFc->tdExtDevmodeOffset, lpDvtargetdevice->tdExtDevmodeOffset);
+ (*env)->SetByteField(env,lpObject,lpDvtargetdeviceFc->tdData, *lpDvtargetdevice->tdData);
+}
+
+void getFormatetcFields(JNIEnv *env, jobject lpObject, FORMATETC *lpFormatetc, FORMATETC_FID_CACHE *lpFormatetcFc)
+{
+ lpFormatetc->cfFormat = (CLIPFORMAT)(*env)->GetIntField(env,lpObject,lpFormatetcFc->cfFormat);
+ lpFormatetc->ptd = (DVTARGETDEVICE *)(*env)->GetIntField(env,lpObject,lpFormatetcFc->ptd);
+ lpFormatetc->dwAspect = (*env)->GetIntField(env,lpObject,lpFormatetcFc->dwAspect);
+ lpFormatetc->lindex = (*env)->GetIntField(env,lpObject,lpFormatetcFc->lindex);
+ lpFormatetc->tymed = (*env)->GetIntField(env,lpObject,lpFormatetcFc->tymed);
+}
+
+void setFormatetcFields(JNIEnv *env, jobject lpObject, FORMATETC *lpFormatetc, FORMATETC_FID_CACHE *lpFormatetcFc)
+{
+ (*env)->SetIntField(env,lpObject,lpFormatetcFc->cfFormat, (jint)lpFormatetc->cfFormat);
+ (*env)->SetIntField(env,lpObject,lpFormatetcFc->ptd, (jint)lpFormatetc->ptd);
+ (*env)->SetIntField(env,lpObject,lpFormatetcFc->dwAspect, lpFormatetc->dwAspect);
+ (*env)->SetIntField(env,lpObject,lpFormatetcFc->lindex, lpFormatetc->lindex);
+ (*env)->SetIntField(env,lpObject,lpFormatetcFc->tymed, lpFormatetc->tymed);
+}
+
+void getDispparamsFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpDispparams, DISPPARAMS_FID_CACHE *lpDispparamsFc)
+{
+ lpDispparams->rgvarg = (VARIANTARG FAR* )(*env)->GetIntField(env,lpObject,lpDispparamsFc->rgvarg);
+ lpDispparams->rgdispidNamedArgs = (DISPID FAR* )(*env)->GetIntField(env,lpObject,lpDispparamsFc->rgdispidNamedArgs);
+ lpDispparams->cArgs = (*env)->GetIntField(env,lpObject,lpDispparamsFc->cArgs);
+ lpDispparams->cNamedArgs = (*env)->GetIntField(env,lpObject,lpDispparamsFc->cNamedArgs);
+}
+
+void setDispparamsFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpDispparams, DISPPARAMS_FID_CACHE *lpDispparamsFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDispparamsFc->rgvarg, (jint)lpDispparams->rgvarg);
+ (*env)->SetIntField(env,lpObject,lpDispparamsFc->rgdispidNamedArgs, (jint)lpDispparams->rgdispidNamedArgs);
+ (*env)->SetIntField(env,lpObject,lpDispparamsFc->cArgs, lpDispparams->cArgs);
+ (*env)->SetIntField(env,lpObject,lpDispparamsFc->cNamedArgs, lpDispparams->cNamedArgs);
+}
+
+void getDropfilesFields(JNIEnv *env, jobject lpObject, DROPFILES *lpDropfiles, DROPFILES_FID_CACHE *lpDropfilesFc)
+{
+ lpDropfiles->pFiles = (*env)->GetIntField(env,lpObject,lpDropfilesFc->pFiles);
+ lpDropfiles->pt.x = (*env)->GetIntField(env,lpObject,lpDropfilesFc->pt_x);
+ lpDropfiles->pt.y = (*env)->GetIntField(env,lpObject,lpDropfilesFc->pt_y);
+ lpDropfiles->fNC = (*env)->GetIntField(env,lpObject,lpDropfilesFc->fNC);
+ lpDropfiles->fWide = (*env)->GetIntField(env,lpObject,lpDropfilesFc->fWide);
+}
+
+void setDropfilesFields(JNIEnv *env, jobject lpObject, DROPFILES *lpDropfiles, DROPFILES_FID_CACHE *lpDropfilesFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDropfilesFc->pFiles, (jint)lpDropfiles->pFiles);
+ (*env)->SetIntField(env,lpObject,lpDropfilesFc->pt_x, lpDropfiles->pt.x);
+ (*env)->SetIntField(env,lpObject,lpDropfilesFc->pt_y, lpDropfiles->pt.y);
+ (*env)->SetIntField(env,lpObject,lpDropfilesFc->fNC, lpDropfiles->fNC);
+ (*env)->SetIntField(env,lpObject,lpDropfilesFc->fWide, lpDropfiles->fWide);
+}
+
+void getDvaspectinfoFields(JNIEnv *env, jobject lpObject, DVASPECTINFO *lpDvaspectinfo, DVASPECTINFO_FID_CACHE *lpDvaspectinfoFc)
+{
+ lpDvaspectinfo->cb = (*env)->GetIntField(env,lpObject,lpDvaspectinfoFc->cb);
+ lpDvaspectinfo->dwFlags = (*env)->GetIntField(env,lpObject,lpDvaspectinfoFc->dwFlags);
+}
+
+void setDvaspectinfoFields(JNIEnv *env, jobject lpObject, DVASPECTINFO *lpDvaspectinfo, DVASPECTINFO_FID_CACHE *lpDvaspectinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpDvaspectinfoFc->cb, lpDvaspectinfo->cb);
+ (*env)->SetIntField(env,lpObject,lpDvaspectinfoFc->dwFlags, lpDvaspectinfo->dwFlags);
+}
+
+void getExcepinfoFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpExcepinfo, EXCEPINFO_FID_CACHE *lpExcepinfoFc)
+{
+ lpExcepinfo->wCode = (*env)->GetShortField(env,lpObject,lpExcepinfoFc->wCode);
+ lpExcepinfo->wReserved = (*env)->GetShortField(env,lpObject,lpExcepinfoFc->wReserved);
+ lpExcepinfo->bstrSource = (BSTR)(*env)->GetIntField(env,lpObject,lpExcepinfoFc->bstrSource);
+ lpExcepinfo->bstrDescription = (BSTR)(*env)->GetIntField(env,lpObject,lpExcepinfoFc->bstrDescription);
+ lpExcepinfo->bstrHelpFile = (BSTR)(*env)->GetIntField(env,lpObject,lpExcepinfoFc->bstrHelpFile);
+ lpExcepinfo->dwHelpContext = (*env)->GetIntField(env,lpObject,lpExcepinfoFc->dwHelpContext);
+ lpExcepinfo->pvReserved = (void FAR* )(*env)->GetIntField(env,lpObject,lpExcepinfoFc->pvReserved);
+ lpExcepinfo->pfnDeferredFillIn = (HRESULT (STDAPICALLTYPE FAR* )(struct tagEXCEPINFO FAR*))(*env)->GetIntField(env,lpObject,lpExcepinfoFc->pfnDeferredFillIn);
+ lpExcepinfo->scode = (*env)->GetIntField(env,lpObject,lpExcepinfoFc->scode);
+}
+
+void setExcepinfoFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpExcepinfo, EXCEPINFO_FID_CACHE *lpExcepinfoFc)
+{
+ (*env)->SetShortField(env,lpObject,lpExcepinfoFc->wCode, lpExcepinfo->wCode);
+ (*env)->SetShortField(env,lpObject,lpExcepinfoFc->wReserved, lpExcepinfo->wReserved);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->bstrSource, (jint)lpExcepinfo->bstrSource);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->bstrDescription, (jint)lpExcepinfo->bstrDescription);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->bstrHelpFile, (jint)lpExcepinfo->bstrHelpFile);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->dwHelpContext, lpExcepinfo->dwHelpContext);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->pvReserved, (jint)lpExcepinfo->pvReserved);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->pfnDeferredFillIn, (jint)lpExcepinfo->pfnDeferredFillIn);
+ (*env)->SetIntField(env,lpObject,lpExcepinfoFc->scode, lpExcepinfo->scode);
+}
+
+void getFiletimeFields(JNIEnv *env, jobject lpObject, FILETIME *lpFiletime, FILETIME_FID_CACHE *lpFiletimeFc)
+{
+ lpFiletime->dwLowDateTime = (*env)->GetIntField(env,lpObject,lpFiletimeFc->dwLowDateTime);
+ lpFiletime->dwHighDateTime = (*env)->GetIntField(env,lpObject,lpFiletimeFc->dwHighDateTime);
+}
+
+void setFiletimeFields(JNIEnv *env, jobject lpObject, FILETIME *lpFiletime, FILETIME_FID_CACHE *lpFiletimeFc)
+{
+ (*env)->SetIntField(env,lpObject,lpFiletimeFc->dwLowDateTime, lpFiletime->dwLowDateTime);
+ (*env)->SetIntField(env,lpObject,lpFiletimeFc->dwHighDateTime, lpFiletime->dwHighDateTime);
+}
+
+void getGuidFields(JNIEnv *env, jobject lpObject, GUID *lpGuid, GUID_FID_CACHE *lpGuidFc)
+{
+ lpGuid->Data1 = (*env)->GetIntField(env,lpObject,lpGuidFc->data1);
+ lpGuid->Data2 = (*env)->GetShortField(env,lpObject,lpGuidFc->data2);
+ lpGuid->Data3 = (*env)->GetShortField(env,lpObject,lpGuidFc->data3);
+ lpGuid->Data4[0] = (*env)->GetByteField(env,lpObject,lpGuidFc->b0);
+ lpGuid->Data4[1] = (*env)->GetByteField(env,lpObject,lpGuidFc->b1);
+ lpGuid->Data4[2] = (*env)->GetByteField(env,lpObject,lpGuidFc->b2);
+ lpGuid->Data4[3] = (*env)->GetByteField(env,lpObject,lpGuidFc->b3);
+ lpGuid->Data4[4] = (*env)->GetByteField(env,lpObject,lpGuidFc->b4);
+ lpGuid->Data4[5] = (*env)->GetByteField(env,lpObject,lpGuidFc->b5);
+ lpGuid->Data4[6] = (*env)->GetByteField(env,lpObject,lpGuidFc->b6);
+ lpGuid->Data4[7] = (*env)->GetByteField(env,lpObject,lpGuidFc->b7);
+}
+
+void setGuidFields(JNIEnv *env, jobject lpObject, GUID *lpGuid, GUID_FID_CACHE *lpGuidFc)
+{
+ (*env)->SetIntField(env,lpObject,lpGuidFc->data1, lpGuid->Data1);
+ (*env)->SetShortField(env,lpObject,lpGuidFc->data2, lpGuid->Data2);
+ (*env)->SetShortField(env,lpObject,lpGuidFc->data3, lpGuid->Data3);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b0, lpGuid->Data4[0]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b1, lpGuid->Data4[1]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b2, lpGuid->Data4[2]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b3, lpGuid->Data4[3]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b4, lpGuid->Data4[4]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b5, lpGuid->Data4[5]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b6, lpGuid->Data4[6]);
+ (*env)->SetByteField(env,lpObject,lpGuidFc->b7, lpGuid->Data4[7]);
+}
+
+void getIdldescFields(JNIEnv *env, jobject lpObject, IDLDESC *lpIdldesc, IDLDESC_FID_CACHE *lpIdldescFc)
+{
+ lpIdldesc->dwReserved = (*env)->GetIntField(env,lpObject,lpIdldescFc->dwReserved);
+ lpIdldesc->wIDLFlags = (*env)->GetShortField(env,lpObject,lpIdldescFc->wIDLFlags);
+}
+
+void setIdldescFields(JNIEnv *env, jobject lpObject, IDLDESC *lpIdldesc, IDLDESC_FID_CACHE *lpIdldescFc)
+{
+ (*env)->SetIntField(env,lpObject,lpIdldescFc->dwReserved, lpIdldesc->dwReserved);
+ (*env)->SetShortField(env,lpObject,lpIdldescFc->wIDLFlags, lpIdldesc->wIDLFlags);
+}
+
+void getLicinfoFields(JNIEnv *env, jobject lpObject, LICINFO *lpLicinfo, LICINFO_FID_CACHE *lpLicinfoFc)
+{
+ lpLicinfo->cbLicInfo = (*env)->GetIntField(env,lpObject,lpLicinfoFc->cbLicInfo);
+ lpLicinfo->fRuntimeKeyAvail = (*env)->GetIntField(env,lpObject,lpLicinfoFc->fRuntimeKeyAvail);
+ lpLicinfo->fLicVerified = (*env)->GetIntField(env,lpObject,lpLicinfoFc->fLicVerified);
+}
+
+void setLicinfoFields(JNIEnv *env, jobject lpObject, LICINFO *lpLicinfo, LICINFO_FID_CACHE *lpLicinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpLicinfoFc->cbLicInfo, lpLicinfo->cbLicInfo);
+ (*env)->SetIntField(env,lpObject,lpLicinfoFc->fRuntimeKeyAvail, lpLicinfo->fRuntimeKeyAvail);
+ (*env)->SetIntField(env,lpObject,lpLicinfoFc->fLicVerified, lpLicinfo->fLicVerified);
+}
+
+void getMulti_qiFields(JNIEnv *env, jobject lpObject, MULTI_QI *lpMulti_qi, MULTI_QI_FID_CACHE *lpMulti_qiFc)
+{
+ lpMulti_qi->pIID = (const IID*)(*env)->GetIntField(env,lpObject,lpMulti_qiFc->pIID);
+ lpMulti_qi->pItf = (IUnknown *)(*env)->GetIntField(env,lpObject,lpMulti_qiFc->pItf);
+ lpMulti_qi->hr = (HRESULT)(*env)->GetIntField(env,lpObject,lpMulti_qiFc->hr);
+}
+
+void setMulti_qiFields(JNIEnv *env, jobject lpObject, MULTI_QI *lpMulti_qi, MULTI_QI_FID_CACHE *lpMulti_qiFc)
+{
+ (*env)->SetIntField(env,lpObject,lpMulti_qiFc->pIID, (jint)lpMulti_qi->pIID);
+ (*env)->SetIntField(env,lpObject,lpMulti_qiFc->pItf, (jint)lpMulti_qi->pItf);
+ (*env)->SetIntField(env,lpObject,lpMulti_qiFc->hr, (jint)lpMulti_qi->hr);
+}
+
+void getOlecmdFields(JNIEnv *env, jobject lpObject, OLECMD *lpOlecmd, OLECMD_FID_CACHE *lpOlecmdFc)
+{
+ lpOlecmd->cmdID = (*env)->GetIntField(env,lpObject,lpOlecmdFc->cmdID);
+ lpOlecmd->cmdf = (*env)->GetIntField(env,lpObject,lpOlecmdFc->cmdf);
+}
+
+void setOlecmdFields(JNIEnv *env, jobject lpObject, OLECMD *lpOlecmd, OLECMD_FID_CACHE *lpOlecmdFc)
+{
+ (*env)->SetIntField(env,lpObject,lpOlecmdFc->cmdID, lpOlecmd->cmdID);
+ (*env)->SetIntField(env,lpObject,lpOlecmdFc->cmdf, lpOlecmd->cmdf);
+}
+
+void getOlecmdtextFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpOlecmdtext, OLECMDTEXT_FID_CACHE *lpOlecmdtextFc)
+{
+
+ lpOlecmdtext->cmdtextf = (*env)->GetIntField(env,lpObject,lpOlecmdtextFc->cmdtextf);
+ lpOlecmdtext->cwActual = (*env)->GetIntField(env,lpObject,lpOlecmdtextFc->cwActual);
+ lpOlecmdtext->cwBuf = (*env)->GetIntField(env,lpObject,lpOlecmdtextFc->cwBuf);
+ lpOlecmdtext->rgwz[0] = (*env)->GetShortField(env,lpObject,lpOlecmdtextFc->rgwz);;
+}
+
+void setOlecmdtextFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpOlecmdtext, OLECMDTEXT_FID_CACHE *lpOlecmdtextFc)
+{
+ (*env)->SetIntField(env,lpObject,lpOlecmdtextFc->cmdtextf, lpOlecmdtext->cmdtextf);
+ (*env)->SetIntField(env,lpObject,lpOlecmdtextFc->cwActual, lpOlecmdtext->cwActual);
+ (*env)->SetIntField(env,lpObject,lpOlecmdtextFc->cwBuf, lpOlecmdtext->cwBuf);
+ (*env)->SetShortField(env,lpObject,lpOlecmdtextFc->rgwz, lpOlecmdtext->rgwz[0]);
+}
+
+void getOleinplaceframeinfoFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpOleinplaceframeinfo, OLEINPLACEFRAMEINFO_FID_CACHE *lpOleinplaceframeinfoFc)
+{
+ lpOleinplaceframeinfo->cb = (*env)->GetIntField(env,lpObject,lpOleinplaceframeinfoFc->cb);
+ lpOleinplaceframeinfo->fMDIApp = (*env)->GetIntField(env,lpObject,lpOleinplaceframeinfoFc->fMDIApp);
+ lpOleinplaceframeinfo->hwndFrame = (HWND)(*env)->GetIntField(env,lpObject,lpOleinplaceframeinfoFc->hwndFrame);
+ lpOleinplaceframeinfo->haccel = (HACCEL)(*env)->GetIntField(env,lpObject,lpOleinplaceframeinfoFc->haccel);
+ lpOleinplaceframeinfo->cAccelEntries = (*env)->GetIntField(env,lpObject,lpOleinplaceframeinfoFc->cAccelEntries);
+}
+
+void setOleinplaceframeinfoFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpOleinplaceframeinfo, OLEINPLACEFRAMEINFO_FID_CACHE *lpOleinplaceframeinfoFc)
+{
+ (*env)->SetIntField(env,lpObject,lpOleinplaceframeinfoFc->cb, lpOleinplaceframeinfo->cb);
+ (*env)->SetIntField(env,lpObject,lpOleinplaceframeinfoFc->fMDIApp, lpOleinplaceframeinfo->fMDIApp);
+ (*env)->SetIntField(env,lpObject,lpOleinplaceframeinfoFc->hwndFrame, (jint)lpOleinplaceframeinfo->hwndFrame);
+ (*env)->SetIntField(env,lpObject,lpOleinplaceframeinfoFc->haccel, (jint)lpOleinplaceframeinfo->haccel);
+ (*env)->SetIntField(env,lpObject,lpOleinplaceframeinfoFc->cAccelEntries, lpOleinplaceframeinfo->cAccelEntries);
+}
+
+void getOleverbFields(JNIEnv *env, jobject lpObject, OLEVERB *lpOleverb, OLEVERB_FID_CACHE *lpOleverbFc)
+{
+ lpOleverb->lVerb = (*env)->GetIntField(env,lpObject,lpOleverbFc->lVerb);
+ lpOleverb->lpszVerbName = (LPWSTR)(*env)->GetIntField(env,lpObject,lpOleverbFc->lpszVerbName);
+ lpOleverb->fuFlags = (*env)->GetIntField(env,lpObject,lpOleverbFc->fuFlags);
+ lpOleverb->grfAttribs = (*env)->GetIntField(env,lpObject,lpOleverbFc->grfAttribs);
+}
+
+void setOleverbFields(JNIEnv *env, jobject lpObject, OLEVERB *lpOleverb, OLEVERB_FID_CACHE *lpOleverbFc)
+{
+ (*env)->SetIntField(env,lpObject,lpOleverbFc->lVerb, lpOleverb->lVerb);
+ (*env)->SetIntField(env,lpObject,lpOleverbFc->lpszVerbName, (jint)lpOleverb->lpszVerbName);
+ (*env)->SetIntField(env,lpObject,lpOleverbFc->fuFlags, lpOleverb->fuFlags);
+ (*env)->SetIntField(env,lpObject,lpOleverbFc->grfAttribs, lpOleverb->grfAttribs);
+}
+
+void getStgmediumFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStgmedium, STGMEDIUM_FID_CACHE *lpStgmediumFc)
+{
+ lpStgmedium->tymed = (*env)->GetIntField(env,lpObject,lpStgmediumFc->tymed);
+ lpStgmedium->hGlobal = (HGLOBAL)(*env)->GetIntField(env,lpObject,lpStgmediumFc->unionField);
+ lpStgmedium->pUnkForRelease = (IUnknown *)(*env)->GetIntField(env,lpObject,lpStgmediumFc->pUnkForRelease);
+}
+
+void setStgmediumFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStgmedium, STGMEDIUM_FID_CACHE *lpStgmediumFc)
+{
+ (*env)->SetIntField(env,lpObject,lpStgmediumFc->tymed, lpStgmedium->tymed);
+ (*env)->SetIntField(env,lpObject,lpStgmediumFc->unionField, (jint)lpStgmedium->hGlobal);
+ (*env)->SetIntField(env,lpObject,lpStgmediumFc->pUnkForRelease, (jint)lpStgmedium->pUnkForRelease);
+}
+
+void getStatstgFields(JNIEnv *env, jobject lpObject, STATSTG *lpStatstg, STATSTG_FID_CACHE *lpStatstgFc)
+{
+ lpStatstg->pwcsName = (LPWSTR)(*env)->GetIntField(env,lpObject,lpStatstgFc->pwcsName);
+ lpStatstg->type = (*env)->GetIntField(env,lpObject,lpStatstgFc->type);
+ lpStatstg->cbSize.QuadPart = (*env)->GetLongField(env,lpObject,lpStatstgFc->cbSize);
+ lpStatstg->mtime.dwLowDateTime = (*env)->GetIntField(env,lpObject,lpStatstgFc->mtime_dwLowDateTime);
+ lpStatstg->mtime.dwHighDateTime = (*env)->GetIntField(env,lpObject,lpStatstgFc->mtime_dwHighDateTime);
+ lpStatstg->ctime.dwLowDateTime = (*env)->GetIntField(env,lpObject,lpStatstgFc->ctime_dwLowDateTime);
+ lpStatstg->ctime.dwHighDateTime = (*env)->GetIntField(env,lpObject,lpStatstgFc->ctime_dwHighDateTime);
+ lpStatstg->atime.dwLowDateTime = (*env)->GetIntField(env,lpObject,lpStatstgFc->atime_dwLowDateTime);
+ lpStatstg->atime.dwHighDateTime = (*env)->GetIntField(env,lpObject,lpStatstgFc->atime_dwHighDateTime);
+ lpStatstg->grfMode = (*env)->GetIntField(env,lpObject,lpStatstgFc->grfMode);
+ lpStatstg->grfLocksSupported = (*env)->GetIntField(env,lpObject,lpStatstgFc->grfLocksSupported);
+ lpStatstg->clsid.Data1 = (*env)->GetIntField(env,lpObject,lpStatstgFc->clsid_data1);
+ lpStatstg->clsid.Data2 = (*env)->GetShortField(env,lpObject,lpStatstgFc->clsid_data2);
+ lpStatstg->clsid.Data3 = (*env)->GetShortField(env,lpObject,lpStatstgFc->clsid_data3);
+ lpStatstg->clsid.Data4[0] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b0);
+ lpStatstg->clsid.Data4[1] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b1);
+ lpStatstg->clsid.Data4[2] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b2);
+ lpStatstg->clsid.Data4[3] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b3);
+ lpStatstg->clsid.Data4[4] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b4);
+ lpStatstg->clsid.Data4[5] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b5);
+ lpStatstg->clsid.Data4[6] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b6);
+ lpStatstg->clsid.Data4[7] = (*env)->GetByteField(env,lpObject,lpStatstgFc->clsid_b7);
+ lpStatstg->grfStateBits = (*env)->GetIntField(env,lpObject,lpStatstgFc->grfStateBits);
+ lpStatstg->reserved = (*env)->GetIntField(env,lpObject,lpStatstgFc->reserved);
+}
+
+void setStatstgFields(JNIEnv *env, jobject lpObject, STATSTG *lpStatstg, STATSTG_FID_CACHE *lpStatstgFc)
+{
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->pwcsName, (jint)lpStatstg->pwcsName);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->type, lpStatstg->type);
+ (*env)->SetLongField(env,lpObject,lpStatstgFc->cbSize, lpStatstg->cbSize.QuadPart);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->mtime_dwLowDateTime, lpStatstg->mtime.dwLowDateTime);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->mtime_dwHighDateTime, lpStatstg->mtime.dwHighDateTime);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->ctime_dwLowDateTime, lpStatstg->ctime.dwLowDateTime);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->ctime_dwHighDateTime, lpStatstg->ctime.dwHighDateTime);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->atime_dwLowDateTime, lpStatstg->atime.dwLowDateTime);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->atime_dwHighDateTime, lpStatstg->atime.dwHighDateTime);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->grfMode, lpStatstg->grfMode);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->grfLocksSupported, lpStatstg->grfLocksSupported);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->clsid_data1, lpStatstg->clsid.Data1);
+ (*env)->SetShortField(env,lpObject,lpStatstgFc->clsid_data2, lpStatstg->clsid.Data2);
+ (*env)->SetShortField(env,lpObject,lpStatstgFc->clsid_data3, lpStatstg->clsid.Data3);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b0, lpStatstg->clsid.Data4[0]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b1, lpStatstg->clsid.Data4[1]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b2, lpStatstg->clsid.Data4[2]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b3, lpStatstg->clsid.Data4[3]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b4, lpStatstg->clsid.Data4[4]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b5, lpStatstg->clsid.Data4[5]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b6, lpStatstg->clsid.Data4[6]);
+ (*env)->SetByteField(env,lpObject,lpStatstgFc->clsid_b7, lpStatstg->clsid.Data4[7]);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->grfStateBits, lpStatstg->grfStateBits);
+ (*env)->SetIntField(env,lpObject,lpStatstgFc->reserved, lpStatstg->reserved);
+}
+
+void getTypeattrFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpTypeattr, TYPEATTR_FID_CACHE *lpTypeattrFc)
+{
+ lpTypeattr->guid.Data1 = (*env)->GetIntField(env,lpObject,lpTypeattrFc->guid_data1);
+ lpTypeattr->guid.Data2 = (*env)->GetShortField(env,lpObject,lpTypeattrFc->guid_data2);
+ lpTypeattr->guid.Data3 = (*env)->GetShortField(env,lpObject,lpTypeattrFc->guid_data3);
+ lpTypeattr->guid.Data4[0] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b0);
+ lpTypeattr->guid.Data4[1] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b1);
+ lpTypeattr->guid.Data4[2] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b2);
+ lpTypeattr->guid.Data4[3] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b3);
+ lpTypeattr->guid.Data4[4] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b4);
+ lpTypeattr->guid.Data4[5] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b5);
+ lpTypeattr->guid.Data4[6] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b6);
+ lpTypeattr->guid.Data4[7] = (*env)->GetByteField(env,lpObject,lpTypeattrFc->guid_b7);
+ lpTypeattr->lcid = (*env)->GetIntField(env,lpObject,lpTypeattrFc->lcid);
+ lpTypeattr->dwReserved = (*env)->GetIntField(env,lpObject,lpTypeattrFc->dwReserved);
+ lpTypeattr->memidConstructor = (*env)->GetIntField(env,lpObject,lpTypeattrFc->memidConstructor);
+ lpTypeattr->memidDestructor = (*env)->GetIntField(env,lpObject,lpTypeattrFc->memidDestructor);
+ lpTypeattr->lpstrSchema = (OLECHAR FAR* )(*env)->GetIntField(env,lpObject,lpTypeattrFc->lpstrSchema);
+ lpTypeattr->cbSizeInstance = (*env)->GetIntField(env,lpObject,lpTypeattrFc->cbSizeInstance);
+ lpTypeattr->typekind = (*env)->GetIntField(env,lpObject,lpTypeattrFc->typekind);
+ lpTypeattr->cFuncs = (*env)->GetShortField(env,lpObject,lpTypeattrFc->cFuncs);
+ lpTypeattr->cVars = (*env)->GetShortField(env,lpObject,lpTypeattrFc->cVars);
+ lpTypeattr->cImplTypes = (*env)->GetShortField(env,lpObject,lpTypeattrFc->cImplTypes);
+ lpTypeattr->cbSizeVft = (*env)->GetShortField(env,lpObject,lpTypeattrFc->cbSizeVft);
+ lpTypeattr->cbAlignment = (*env)->GetShortField(env,lpObject,lpTypeattrFc->cbAlignment);
+ lpTypeattr->wTypeFlags = (*env)->GetShortField(env,lpObject,lpTypeattrFc->wTypeFlags);
+ lpTypeattr->wMajorVerNum = (*env)->GetShortField(env,lpObject,lpTypeattrFc->wMajorVerNum);
+ lpTypeattr->wMinorVerNum = (*env)->GetShortField(env,lpObject,lpTypeattrFc->wMinorVerNum);
+ lpTypeattr->tdescAlias.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env,lpObject,lpTypeattrFc->tdescAlias_unionField);
+ lpTypeattr->tdescAlias.vt = (*env)->GetShortField(env,lpObject,lpTypeattrFc->tdescAlias_vt);
+ lpTypeattr->idldescType.dwReserved = (*env)->GetIntField(env,lpObject,lpTypeattrFc->idldescType_dwReserved);
+ lpTypeattr->idldescType.wIDLFlags = (*env)->GetShortField(env,lpObject,lpTypeattrFc->idldescType_wIDLFlags);
+}
+
+void setTypeattrFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpTypeattr, TYPEATTR_FID_CACHE *lpTypeattrFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->guid_data1, lpTypeattr->guid.Data1);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->guid_data2, lpTypeattr->guid.Data2);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->guid_data3, lpTypeattr->guid.Data3);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b0, lpTypeattr->guid.Data4[0]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b1, lpTypeattr->guid.Data4[1]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b2, lpTypeattr->guid.Data4[2]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b3, lpTypeattr->guid.Data4[3]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b4, lpTypeattr->guid.Data4[4]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b5, lpTypeattr->guid.Data4[5]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b6, lpTypeattr->guid.Data4[6]);
+ (*env)->SetByteField(env,lpObject,lpTypeattrFc->guid_b7, lpTypeattr->guid.Data4[7]);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->lcid, lpTypeattr->lcid);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->dwReserved, lpTypeattr->dwReserved);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->memidConstructor, lpTypeattr->memidConstructor);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->memidDestructor, lpTypeattr->memidDestructor);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->lpstrSchema, (jint)lpTypeattr->lpstrSchema);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->cbSizeInstance, lpTypeattr->cbSizeInstance);
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->typekind, lpTypeattr->typekind);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->cFuncs, lpTypeattr->cFuncs);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->cVars, lpTypeattr->cVars);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->cImplTypes, lpTypeattr->cImplTypes);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->cbSizeVft, lpTypeattr->cbSizeVft);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->cbAlignment, lpTypeattr->cbAlignment);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->wTypeFlags, lpTypeattr->wTypeFlags);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->wMajorVerNum, lpTypeattr->wMajorVerNum);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->wMinorVerNum, lpTypeattr->wMinorVerNum);
+
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->tdescAlias_unionField, (jint)lpTypeattr->tdescAlias.lptdesc);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->tdescAlias_vt, lpTypeattr->tdescAlias.vt);
+
+ (*env)->SetIntField(env,lpObject,lpTypeattrFc->idldescType_dwReserved, lpTypeattr->idldescType.dwReserved);
+ (*env)->SetShortField(env,lpObject,lpTypeattrFc->idldescType_wIDLFlags, lpTypeattr->idldescType.wIDLFlags);
+}
+
+void getTypedescFields(JNIEnv *env, jobject lpObject, TYPEDESC *lpTypedesc, TYPEDESC_FID_CACHE *lpTypedescFc)
+{
+ lpTypedesc->lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env,lpObject,lpTypedescFc->typedesc_union);
+ lpTypedesc->vt = (*env)->GetShortField(env,lpObject,lpTypedescFc->vt);
+}
+
+void setTypedescFields(JNIEnv *env, jobject lpObject, TYPEDESC *lpTypedesc, TYPEDESC_FID_CACHE *lpTypedescFc)
+{
+ (*env)->SetIntField(env,lpObject,lpTypedescFc->typedesc_union, (jint)lpTypedesc->lptdesc);
+ (*env)->SetShortField(env,lpObject,lpTypedescFc->vt, lpTypedesc->vt);
+}
+
+void getFuncdesc1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC1_FID_CACHE *lpFuncdescFc)
+{
+ lpFuncdesc->memid= (*env)->GetIntField(env,lpObject,lpFuncdescFc->memid);
+ lpFuncdesc->lprgscode = (SCODE FAR *)(*env)->GetIntField(env,lpObject,lpFuncdescFc->lprgscode);
+ lpFuncdesc->lprgelemdescParam = (ELEMDESC FAR *)(*env)->GetIntField(env,lpObject,lpFuncdescFc->lprgelemdescParam);
+ lpFuncdesc->funckind = (*env)->GetIntField(env,lpObject,lpFuncdescFc->funckind);
+ lpFuncdesc->invkind = (*env)->GetIntField(env,lpObject,lpFuncdescFc->invkind);
+ lpFuncdesc->callconv = (*env)->GetIntField(env,lpObject,lpFuncdescFc->callconv);
+ lpFuncdesc->cParams = (*env)->GetShortField(env,lpObject,lpFuncdescFc->cParams);
+ lpFuncdesc->cParamsOpt = (*env)->GetShortField(env,lpObject,lpFuncdescFc->cParamsOpt);
+ lpFuncdesc->oVft = (*env)->GetShortField(env,lpObject,lpFuncdescFc->oVft);
+ lpFuncdesc->cScodes = (*env)->GetShortField(env,lpObject,lpFuncdescFc->cScodes);
+ lpFuncdesc->elemdescFunc.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_union);
+ lpFuncdesc->elemdescFunc.tdesc.vt = (*env)->GetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_vt);
+ lpFuncdesc->elemdescFunc.paramdesc.pparamdescex = (LPPARAMDESCEX)(*env)->GetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_paramdesc_pparamdescex);
+ lpFuncdesc->elemdescFunc.paramdesc.wParamFlags = (*env)->GetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_paramdesc_wParamFlags);
+ lpFuncdesc->wFuncFlags = (*env)->GetShortField(env,lpObject,lpFuncdescFc->wFuncFlags);
+}
+
+void setFuncdesc1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC1_FID_CACHE *lpFuncdescFc)
+{
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->memid, (jint)lpFuncdesc->memid);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->lprgscode, (jint)lpFuncdesc->lprgscode);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->lprgelemdescParam, (jint)lpFuncdesc->lprgelemdescParam);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->funckind, (jint)lpFuncdesc->funckind);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->invkind, (jint)lpFuncdesc->invkind);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->callconv, (jint)lpFuncdesc->callconv);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->cParams, (jshort)lpFuncdesc->cParams);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->cParamsOpt, (jshort)lpFuncdesc->cParamsOpt);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->oVft, (jshort)lpFuncdesc->oVft);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->cScodes, (jshort)lpFuncdesc->cScodes);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_union, (jint)lpFuncdesc->elemdescFunc.tdesc.lptdesc);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_vt, (jshort)lpFuncdesc->elemdescFunc.tdesc.vt);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_paramdesc_pparamdescex, (jint)lpFuncdesc->elemdescFunc.paramdesc.pparamdescex);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_paramdesc_wParamFlags, (jshort)lpFuncdesc->elemdescFunc.paramdesc.wParamFlags);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->wFuncFlags, (jshort)lpFuncdesc->wFuncFlags);
+}
+void getFuncdesc2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC2_FID_CACHE *lpFuncdescFc)
+{
+ lpFuncdesc->memid= (*env)->GetIntField(env,lpObject,lpFuncdescFc->memid);
+ lpFuncdesc->lprgscode = (SCODE FAR *)(*env)->GetIntField(env,lpObject,lpFuncdescFc->lprgscode);
+ lpFuncdesc->lprgelemdescParam = (ELEMDESC FAR *)(*env)->GetIntField(env,lpObject,lpFuncdescFc->lprgelemdescParam);
+ lpFuncdesc->funckind = (*env)->GetIntField(env,lpObject,lpFuncdescFc->funckind);
+ lpFuncdesc->invkind = (*env)->GetIntField(env,lpObject,lpFuncdescFc->invkind);
+ lpFuncdesc->callconv = (*env)->GetIntField(env,lpObject,lpFuncdescFc->callconv);
+ lpFuncdesc->cParams = (*env)->GetShortField(env,lpObject,lpFuncdescFc->cParams);
+ lpFuncdesc->cParamsOpt = (*env)->GetShortField(env,lpObject,lpFuncdescFc->cParamsOpt);
+ lpFuncdesc->oVft = (*env)->GetShortField(env,lpObject,lpFuncdescFc->oVft);
+ lpFuncdesc->cScodes = (*env)->GetShortField(env,lpObject,lpFuncdescFc->cScodes);
+ lpFuncdesc->elemdescFunc.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_union);
+ lpFuncdesc->elemdescFunc.tdesc.vt = (*env)->GetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_vt);
+ lpFuncdesc->elemdescFunc.idldesc.dwReserved = (*env)->GetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_idldesc_dwReserved);
+ lpFuncdesc->elemdescFunc.idldesc.wIDLFlags = (*env)->GetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_idldesc_wIDLFlags);
+ lpFuncdesc->wFuncFlags = (*env)->GetShortField(env,lpObject,lpFuncdescFc->wFuncFlags);
+}
+
+void setFuncdesc2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC2_FID_CACHE *lpFuncdescFc)
+{
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->memid, (jint)lpFuncdesc->memid);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->lprgscode, (jint)lpFuncdesc->lprgscode);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->lprgelemdescParam, (jint)lpFuncdesc->lprgelemdescParam);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->funckind, (jint)lpFuncdesc->funckind);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->invkind, (jint)lpFuncdesc->invkind);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->callconv, (jint)lpFuncdesc->callconv);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->cParams, (jshort)lpFuncdesc->cParams);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->cParamsOpt, (jshort)lpFuncdesc->cParamsOpt);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->oVft, (jshort)lpFuncdesc->oVft);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->cScodes, (jshort)lpFuncdesc->cScodes);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_union, (jint)lpFuncdesc->elemdescFunc.tdesc.lptdesc);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_tdesc_vt, (jshort)lpFuncdesc->elemdescFunc.tdesc.vt);
+ (*env)->SetIntField(env,lpObject,lpFuncdescFc->elemdescFunc_idldesc_dwReserved, (jint)lpFuncdesc->elemdescFunc.idldesc.dwReserved);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->elemdescFunc_idldesc_wIDLFlags, (jshort)lpFuncdesc->elemdescFunc.idldesc.wIDLFlags);
+ (*env)->SetShortField(env,lpObject,lpFuncdescFc->wFuncFlags, (jshort)lpFuncdesc->wFuncFlags);
+}
+void getVardesc1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC1_FID_CACHE *lpVardescFc)
+{
+ lpVardesc->memid = (*env)->GetIntField(env,lpObject,lpVardescFc->memid);
+ lpVardesc->lpstrSchema = (OLECHAR FAR* )(*env)->GetIntField(env,lpObject,lpVardescFc->lpstrSchema);
+ lpVardesc->oInst = (*env)->GetIntField(env,lpObject,lpVardescFc->unionField);
+ lpVardesc->elemdescVar.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env,lpObject,lpVardescFc->elemdescVar_tdesc_union);
+ lpVardesc->elemdescVar.tdesc.vt = (*env)->GetShortField(env,lpObject,lpVardescFc->elemdescVar_tdesc_vt);
+ lpVardesc->elemdescVar.paramdesc.pparamdescex= (LPPARAMDESCEX)(*env)->GetIntField(env,lpObject,lpVardescFc->elemdescVar_paramdesc_pparamdescex);
+ lpVardesc->elemdescVar.paramdesc.wParamFlags = (*env)->GetShortField(env,lpObject,lpVardescFc->elemdescVar_paramdesc_wParamFlags);
+ lpVardesc->wVarFlags = (*env)->GetShortField(env,lpObject,lpVardescFc->wVarFlags);
+ lpVardesc->varkind = (*env)->GetIntField(env,lpObject,lpVardescFc->varkind);
+}
+
+void setVardesc1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC1_FID_CACHE *lpVardescFc)
+{
+ (*env)->SetIntField(env,lpObject,lpVardescFc->memid, lpVardesc->memid);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->lpstrSchema, (jint)lpVardesc->lpstrSchema);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->unionField, lpVardesc->oInst);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->elemdescVar_tdesc_union, (jint)lpVardesc->elemdescVar.tdesc.lptdesc);
+ (*env)->SetShortField(env,lpObject,lpVardescFc->elemdescVar_tdesc_vt, (jshort)lpVardesc->elemdescVar.tdesc.vt);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->elemdescVar_paramdesc_pparamdescex, (jint)lpVardesc->elemdescVar.paramdesc.pparamdescex);
+ (*env)->SetShortField(env,lpObject,lpVardescFc->elemdescVar_paramdesc_wParamFlags, (jshort)lpVardesc->elemdescVar.paramdesc.wParamFlags);
+ (*env)->SetShortField(env,lpObject,lpVardescFc->wVarFlags, (jshort)lpVardesc->wVarFlags);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->varkind, (jint)lpVardesc->varkind);
+}
+void getVardesc2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC2_FID_CACHE *lpVardescFc)
+{
+ lpVardesc->memid = (*env)->GetIntField(env,lpObject,lpVardescFc->memid);
+ lpVardesc->lpstrSchema = (OLECHAR FAR* )(*env)->GetIntField(env,lpObject,lpVardescFc->lpstrSchema);
+ lpVardesc->oInst = (*env)->GetIntField(env,lpObject,lpVardescFc->unionField);
+ lpVardesc->elemdescVar.tdesc.lptdesc = (struct FARSTRUCT tagTYPEDESC FAR* )(*env)->GetIntField(env,lpObject,lpVardescFc->elemdescVar_tdesc_union);
+ lpVardesc->elemdescVar.tdesc.vt = (*env)->GetShortField(env,lpObject,lpVardescFc->elemdescVar_tdesc_vt);
+ lpVardesc->elemdescVar.idldesc.dwReserved = (*env)->GetIntField(env,lpObject,lpVardescFc->elemdescVar_idldesc_dwReserved);
+ lpVardesc->elemdescVar.idldesc.wIDLFlags = (*env)->GetShortField(env,lpObject,lpVardescFc->elemdescVar_idldesc_wIDLFlags);
+ lpVardesc->wVarFlags = (*env)->GetShortField(env,lpObject,lpVardescFc->wVarFlags);
+ lpVardesc->varkind = (*env)->GetIntField(env,lpObject,lpVardescFc->varkind);
+}
+
+void setVardesc2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC2_FID_CACHE *lpVardescFc)
+{
+ (*env)->SetIntField(env,lpObject,lpVardescFc->memid, lpVardesc->memid);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->lpstrSchema, (jint)lpVardesc->lpstrSchema);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->unionField, (jint)lpVardesc->oInst);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->elemdescVar_tdesc_union, (jint)lpVardesc->elemdescVar.tdesc.lptdesc);
+ (*env)->SetShortField(env,lpObject,lpVardescFc->elemdescVar_tdesc_vt, (jshort)lpVardesc->elemdescVar.tdesc.vt);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->elemdescVar_idldesc_dwReserved, (jint)lpVardesc->elemdescVar.idldesc.dwReserved);
+ (*env)->SetShortField(env,lpObject,lpVardescFc->elemdescVar_idldesc_wIDLFlags, (jshort)lpVardesc->elemdescVar.idldesc.wIDLFlags);
+ (*env)->SetShortField(env,lpObject,lpVardescFc->wVarFlags, (jshort)lpVardesc->wVarFlags);
+ (*env)->SetIntField(env,lpObject,lpVardescFc->varkind, (jint)lpVardesc->varkind);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h
new file mode 100755
index 0000000000..11e62e8154
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/structs.h
@@ -0,0 +1,1514 @@
+/**
+ * JNI SWT object field getters and setters declarations for Windows structs.
+ */
+
+#ifndef INC_structs_H
+#define INC_structs_H
+
+#define USE_2000_CALLS
+//#undef USE_2000_CALLS
+
+#ifdef USE_2000_CALLS
+#define WINVER 0x0500
+#define _WIN32_IE 0x0500
+#endif
+
+#if _MSC_VER > 1000
+#pragma once
+#endif // _MSC_VER > 1000
+
+#define VC_EXTRALEAN
+
+#include <windows.h>
+#include <winuser.h>
+#include <commctrl.h>
+#include <oaidl.h>
+#include <shlobj.h>
+#include <ole2.h>
+#include <olectl.h>
+#include <objbase.h>
+#include <richedit.h>
+#include <shlwapi.h>
+
+/* All globals to be declared in globals.h */
+#define FID_CACHE_GLOBALS \
+ MULTI_QI_FID_CACHE MultiqiFc; \
+ OLEINPLACEFRAMEINFO_FID_CACHE OleinplaceframeinfoFc; \
+ CAUUID_FID_CACHE CauuidFc; \
+ HDLAYOUT_FID_CACHE HdlayoutFc; \
+ OLECMD_FID_CACHE OlecmdFc; \
+ TYPEATTR_FID_CACHE TypeattrFc; \
+ FORMATETC_FID_CACHE FormatetcFc; \
+ OLECMDTEXT_FID_CACHE OlecmdtextFc; \
+ GUID_FID_CACHE GuidFc; \
+ COSERVERINFO_FID_CACHE CoserverinfoFc; \
+ STGMEDIUM_FID_CACHE StgmediumFc; \
+ EXCEPINFO_FID_CACHE ExcepinfoFc; \
+ DVTARGETDEVICE_FID_CACHE DvtargetdeviceFc; \
+ DISPPARAMS_FID_CACHE DispparamsFc; \
+ CONTROLINFO_FID_CACHE ControlinfoFc; \
+ STATSTG_FID_CACHE StatstgFc; \
+ LICINFO_FID_CACHE LicinfoFc; \
+ DROPFILES_FID_CACHE DropfilesFc; \
+ TVHITTESTINFO_FID_CACHE TvhittestinfoFc; \
+ WINDOWPOS_FID_CACHE WindowposFc; \
+ ACCEL_FID_CACHE AccelFc; \
+ DRAWITEMSTRUCT_FID_CACHE DrawitemstructFc; \
+ NMLISTVIEW_FID_CACHE NmlistviewFc; \
+ TEXTMETRIC_FID_CACHE TextmetricFc; \
+ RECT_FID_CACHE RectFc; \
+ LOGBRUSH_FID_CACHE LogbrushFc; \
+ CHOOSECOLOR_FID_CACHE ChoosecolorFc; \
+ TOOLINFO_FID_CACHE ToolinfoFc; \
+ SCROLLINFO_FID_CACHE ScrollinfoFc; \
+ MEASUREITEMSTRUCT_FID_CACHE MeasureitemstructFc; \
+ CREATESTRUCT_FID_CACHE CreatestructFc; \
+ OPENFILENAME_FID_CACHE OpenfilenameFc; \
+ LVITEM_FID_CACHE LvitemFc; \
+ TVITEM_FID_CACHE TvitemFc; \
+ LVHITTESTINFO_FID_CACHE LvhittestinfoFc; \
+ NMTVCUSTOMDRAW_FID_CACHE NmtvcustomdrawFc; \
+ CHOOSEFONT_FID_CACHE ChoosefontFc; \
+ HDITEM_FID_CACHE HditemFc; \
+ NMTOOLBAR_FID_CACHE NmtoolbarFc; \
+ TBBUTTON_FID_CACHE TbbuttonFc; \
+ NMTTDISPINFO_FID_CACHE NmttdispinfoFc; \
+ WINDOWPLACEMENT_FID_CACHE WindowplacementFc; \
+ REBARBANDINFO_FID_CACHE RebarbandinfoFc; \
+ POINT_FID_CACHE PointFc; \
+ TBBUTTONINFO_FID_CACHE TbbuttoninfoFc; \
+ NMHDR_FID_CACHE NmhdrFc; \
+ SIZE_FID_CACHE SizeFc; \
+ INITCOMMONCONTROLSEX_FID_CACHE InitcommoncontrolsexFc; \
+ DLLVERSIONINFO_FID_CACHE DllversioninfoFc; \
+ MSGFILTER_FID_CACHE MsgfilterFc; \
+ BITMAP_FID_CACHE BitmapFc; \
+ PAINTSTRUCT_FID_CACHE PaintstructFc; \
+ MENUITEMINFO_FID_CACHE MenuiteminfoFc; \
+ ICONINFO_FID_CACHE IconinfoFc; \
+ WNDCLASSEX_FID_CACHE WndclassexFc; \
+ MENUINFO_FID_CACHE MenuinfoFc; \
+ LOGPEN_FID_CACHE LogpenFc; \
+ COMPOSITIONFORM_FID_CACHE CompositionformFc; \
+ LVCOLUMN_FID_CACHE LvcolumnFc; \
+ BROWSEINFO_FID_CACHE BrowseinfoFc; \
+ DOCINFO_FID_CACHE DocinfoFc; \
+ TVINSERTSTRUCT_FID_CACHE TvinsertstructFc; \
+ HELPINFO_FID_CACHE HelpinfoFc; \
+ LOGFONT_FID_CACHE LogfontFc; \
+ DIBSECTION_FID_CACHE DibsectionFc; \
+ NMHEADER_FID_CACHE NmheaderFc; \
+ TCITEM_FID_CACHE TcitemFc; \
+ PRINTDLG_FID_CACHE PrintdlgFc; \
+ MSG_FID_CACHE MsgFc; \
+ PAGESETUPDLG_FID_CACHE PagesetupdlgFc; \
+ TRACKMOUSEEVENT_FID_CACHE TrackmouseeventFc; \
+ FUNCDESC1_FID_CACHE Funcdesc1Fc; \
+ FUNCDESC2_FID_CACHE Funcdesc2Fc; \
+ VARDESC1_FID_CACHE Vardesc1Fc; \
+ VARDESC2_FID_CACHE Vardesc2Fc;
+
+/* PARAFORMAT_FID_CACHE ParaformatFc; \*/
+/* CHARFORMAT_FID_CACHE CharformatFc; \*/
+/* CHARFORMAT2_FID_CACHE Charformat2Fc; \*/
+/* SHFILEINFO_FID_CACHE ShfileinfoFc; \*/
+/* EXTLOGPEN_FID_CACHE ExtlogpenFc; \*/
+
+/* ----------- fid and class caches ----------- */
+/**
+ * Used for Java objects passed into JNI that are
+ * declared like:
+ *
+ * nativeFunction (Rectangle p1, Rectangle p2, Rectangle p3)
+ *
+ * and not like this
+ *
+ * nativeFunction (Object p1, Object p2, Object p3)
+ *
+ *
+ */
+
+/* ----------- fid cache structures ----------- */
+
+/* CALLBACK struct */
+typedef struct CALLBACK_FID_CACHE {
+
+ int cached;
+ jclass callbackClass;
+ jfieldID object, method, signature, isStatic;
+
+} CALLBACK_FID_CACHE;
+
+typedef CALLBACK_FID_CACHE *PCALLBACK_FID_CACHE;
+
+/* ACCEL struct */
+typedef struct ACCEL_FID_CACHE {
+
+ int cached;
+ jclass accelClass;
+ jfieldID fVirt, key, cmd;
+
+} ACCEL_FID_CACHE;
+
+typedef ACCEL_FID_CACHE *PACCEL_FID_CACHE;
+
+/* BITMAP struct */
+typedef struct BITMAP_FID_CACHE {
+
+ int cached;
+ jclass bitmapClass;
+ jfieldID bmType, bmWidth, bmHeight, bmWidthBytes, bmPlanes, \
+ bmBitsPixel, bmBits;
+
+} BITMAP_FID_CACHE;
+
+typedef BITMAP_FID_CACHE *PBITMAP_FID_CACHE;
+
+/* BROWSEINFO struct */
+typedef struct BROWSEINFO_FID_CACHE {
+
+ int cached;
+ jclass browseinfoClass;
+ jfieldID hwndOwner, pidlRoot, pszDisplayName, lpszTitle, ulFlags, \
+ lpfn, lParam, iImage;
+
+} BROWSEINFO_FID_CACHE;
+
+typedef BROWSEINFO_FID_CACHE *PBROWSEINFO_FID_CACHE;
+
+/* CHARFORMAT struct */
+/*
+typedef struct CHARFORMAT_FID_CACHE {
+
+ int cached;
+ jclass charformatClass;
+ jfieldID cbSize, dwMask, dwEffects, yHeight, yOffset, crTextColor, \
+ bCharSet, bPitchAndFamily, \
+ szFaceName0, szFaceName1, szFaceName2, szFaceName3, szFaceName4, \
+ szFaceName5, szFaceName6, szFaceName7, szFaceName8, szFaceName9, \
+ szFaceName10, szFaceName11, szFaceName12, szFaceName13, szFaceName14, \
+ szFaceName15, szFaceName16, szFaceName17, szFaceName18, szFaceName19, \
+ szFaceName20, szFaceName21, szFaceName22, szFaceName23, szFaceName24, \
+ szFaceName25, szFaceName26, szFaceName27, szFaceName28, szFaceName29, \
+ szFaceName30, szFaceName31;
+
+} CHARFORMAT_FID_CACHE;
+typedef CHARFORMAT_FID_CACHE *PCHARFORMAT_FID_CACHE;
+*/
+
+/* CHARFORMAT2 struct */
+/*
+typedef struct CHARFORMAT2_FID_CACHE {
+
+ int cached;
+ jclass charformat2Class;
+ jfieldID cbSize, dwMask, dwEffects, yHeight, yOffset, crTextColor, \
+ bCharSet, bPitchAndFamily, \
+ szFaceName0, szFaceName1, szFaceName2, szFaceName3, szFaceName4, \
+ szFaceName5, szFaceName6, szFaceName7, szFaceName8, szFaceName9, \
+ szFaceName10, szFaceName11, szFaceName12, szFaceName13, szFaceName14, \
+ szFaceName15, szFaceName16, szFaceName17, szFaceName18, szFaceName19, \
+ szFaceName20, szFaceName21, szFaceName22, szFaceName23, szFaceName24, \
+ szFaceName25, szFaceName26, szFaceName27, szFaceName28, szFaceName29, \
+ szFaceName30, szFaceName31, \
+ wWeight, sSpacing, crBackColor, lcid, dwReserved, sStyle, wKerning, \
+ bUnderlineType, bAnimation, bRevAuthor, bReserved1;
+} CHARFORMAT2_FID_CACHE;
+typedef CHARFORMAT2_FID_CACHE *PCHARFORMAT2_FID_CACHE;
+*/
+
+/* CHOOSECOLOR struct */
+typedef struct CHOOSECOLOR_FID_CACHE {
+
+ int cached;
+ jclass choosecolorClass;
+ jfieldID lStructSize, hwndOwner, hInstance, rgbResult, lpCustColors, \
+ Flags, lCustData, lpfnHook, lpTemplateName;
+
+} CHOOSECOLOR_FID_CACHE;
+
+typedef CHOOSECOLOR_FID_CACHE *PCHOOSECOLOR_FID_CACHE;
+
+/* CHOOSEFONT struct */
+typedef struct CHOOSEFONT_FID_CACHE {
+
+ int cached;
+ jclass choosefontClass;
+ jfieldID lStructSize, hwndOwner, hDC, lpLogFont, \
+ iPointSize, Flags, rgbColors, lCustData, lpfnHook, \
+ lpTemplateName, hInstance, lpszStyle, nFontType, \
+ ___MISSING_ALIGNMENT__, nSizeMin, nSizeMax;
+
+} CHOOSEFONT_FID_CACHE;
+
+typedef CHOOSEFONT_FID_CACHE *PCHOOSEFONT_FID_CACHE;
+
+/* COMPOSITIONFORM struct */
+typedef struct COMPOSITIONFORM_FID_CACHE {
+
+ int cached;
+ jclass compositionformClass;
+ jfieldID dwStyle, x, y, left, top, right, bottom;
+
+} COMPOSITIONFORM_FID_CACHE;
+
+typedef COMPOSITIONFORM_FID_CACHE *PCOMPOSITIONFORM_FID_CACHE;
+
+/* CREATESTRUCT struct */
+typedef struct CREATESTRUCT_FID_CACHE {
+
+ int cached;
+ jclass createstructClass;
+ jfieldID lpCreateParams, hInstance, hMenu, hwndParent, \
+ cx, cy, x, y, style, lpszName, lpszClass, \
+ dwExStyle;
+
+} CREATESTRUCT_FID_CACHE;
+
+typedef CREATESTRUCT_FID_CACHE *PCREATESTRUCT_FID_CACHE;
+
+/* DIBSECTION struct */
+typedef struct DIBSECTION_FID_CACHE {
+
+ int cached;
+ jclass dibsectionClass;
+ jfieldID bmType, bmWidth, bmHeight, bmWidthBytes, bmPlanes, \
+ bmBitsPixel, bmBits,\
+ biSize, biWidth, biHeight, biPlanes, biBitCount, \
+ biCompression, biSizeImage, biXPelsPerMeter, biYPelsPerMeter, \
+ biClrUsed, biClrImportant, dsBitfields0, dsBitfields1, \
+ dsBitfields2, dshSection, dsOffset;
+
+} DIBSECTION_FID_CACHE;
+
+typedef DIBSECTION_FID_CACHE *PDIBSECTION_FID_CACHE;
+
+/* DLLVERSIONINFO struct */
+typedef struct DLLVERSIONINFO_FID_CACHE {
+
+ int cached;
+ jclass dllversioninfoClass;
+ jfieldID cbSize, dwMajorVersion, dwMinorVersion, dwBuildNumber, dwPlatformID;
+
+} DLLVERSIONINFO_FID_CACHE;
+
+typedef DLLVERSIONINFO_FID_CACHE *PDLLVERSIONINFO_FID_CACHE;
+
+/* DOCINFO struct */
+typedef struct DOCINFO_FID_CACHE {
+
+ int cached;
+ jclass docinfoClass;
+ jfieldID cbSize, lpszDocName, lpszOutput, lpszDatatype, fwType;
+
+} DOCINFO_FID_CACHE;
+
+typedef DOCINFO_FID_CACHE *PDOCINFO_FID_CACHE;
+
+/* DRAWITEMSTRUCT struct */
+typedef struct DRAWITEMSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass drawitemstructClass;
+ jfieldID CtlType, CtlID, itemID, itemAction, \
+ itemState, hwndItem, hDC, left, top, \
+ right, bottom, itemData;
+
+} DRAWITEMSTRUCT_FID_CACHE;
+
+typedef DRAWITEMSTRUCT_FID_CACHE *PDRAWITEMSTRUCT_FID_CACHE;
+
+/* HDITEM struct */
+typedef struct HDITEM_FID_CACHE {
+
+ int cached;
+ jclass hditemClass;
+ jfieldID mask, cxy, pszText, hbm, cchTextMax, fmt, \
+ lParam, iImage, iOrder;
+
+} HDITEM_FID_CACHE;
+
+typedef HDITEM_FID_CACHE *PHDITEM_FID_CACHE;
+
+/* HDLAYOUT struct */
+typedef struct HDLAYOUT_FID_CACHE {
+
+ int cached;
+ jclass hdlayoutClass;
+ jfieldID prc, pwpos;
+
+} HDLAYOUT_FID_CACHE;
+
+typedef HDLAYOUT_FID_CACHE *PHDLAYOUT_FID_CACHE;
+
+/* HELPINFO struct */
+typedef struct HELPINFO_FID_CACHE {
+
+ int cached;
+ jclass helpinfoClass;
+ jfieldID cbSize, iContextType, iCtrlId, hItemHandle, dwContextId, x, y;
+
+} HELPINFO_FID_CACHE;
+
+typedef HELPINFO_FID_CACHE *PHELPINFO_FID_CACHE;
+
+/* ICONINFO struct */
+typedef struct ICONINFO_FID_CACHE {
+
+ int cached;
+ jclass iconinfoClass;
+ jfieldID fIcon, xHotspot, yHotspot, hbmMask, hbmColor;
+
+} ICONINFO_FID_CACHE;
+
+typedef ICONINFO_FID_CACHE *PICONINFO_FID_CACHE;
+
+/* INITCOMMONCONTROLSEX struct */
+typedef struct INITCOMMONCONTROLSEX_FID_CACHE {
+
+ int cached;
+ jclass initcommoncontrolsexClass;
+ jfieldID dwSize, dwICC;
+
+} INITCOMMONCONTROLSEX_FID_CACHE;
+
+typedef INITCOMMONCONTROLSEX_FID_CACHE *PINITCOMMONCONTROLSEX_FID_CACHE;
+
+/* LOGFONT struct */
+typedef struct LOGFONT_FID_CACHE {
+
+ int cached;
+ jclass logfontClass;
+ jfieldID lfHeight, lfWidth, lfEscapement, lfOrientation, \
+ lfWeight, lfItalic, lfUnderline, lfStrikeOut, \
+ lfCharSet, lfOutPrecision, lfClipPrecision, \
+ lfQuality, lfPitchAndFamily, \
+ lfFaceName0, lfFaceName1, lfFaceName2, lfFaceName3, \
+ lfFaceName4, lfFaceName5, lfFaceName6, lfFaceName7, \
+ lfFaceName8, lfFaceName9, lfFaceName10, lfFaceName11, \
+ lfFaceName12, lfFaceName13, lfFaceName14, lfFaceName15, \
+ lfFaceName16, lfFaceName17, lfFaceName18, lfFaceName19, \
+ lfFaceName20, lfFaceName21, lfFaceName22, lfFaceName23, \
+ lfFaceName24, lfFaceName25, lfFaceName26, lfFaceName27, \
+ lfFaceName28, lfFaceName29, lfFaceName30, lfFaceName31;
+
+} LOGFONT_FID_CACHE;
+
+typedef LOGFONT_FID_CACHE *PLOGFONT_FID_CACHE;
+
+
+/* LOGPEN struct */
+typedef struct LOGPEN_FID_CACHE {
+
+ int cached;
+ jclass logpenClass;
+ jfieldID lopnStyle, x, y, lopnColor;
+
+} LOGPEN_FID_CACHE;
+
+typedef LOGPEN_FID_CACHE *PLOGPEN_FID_CACHE;
+
+/* EXTLOGPEN struct */
+/*
+typedef struct EXTLOGPEN_FID_CACHE {
+
+ int cached;
+ jclass extlogpenClass;
+ jfieldID elpPenStyle, elpWidth, elpBrushStyle, elpColor, \
+ elpHatch, elpNumEntries;
+} EXTLOGPEN_FID_CACHE;
+
+typedef EXTLOGPEN_FID_CACHE *PEXTLOGPEN_FID_CACHE;
+*/
+
+/* LVCOLUMN struct */
+typedef struct LVCOLUMN_FID_CACHE {
+
+ int cached;
+ jclass lvcolumnClass;
+ jfieldID mask, fmt, cx, pszText, cchTextMax, iSubItem, \
+ iImage, iOrder;
+
+} LVCOLUMN_FID_CACHE;
+
+typedef LVCOLUMN_FID_CACHE *PLVCOLUMN_FID_CACHE;
+
+/* LVHITTESTINFO struct */
+typedef struct LVHITTESTINFO_FID_CACHE {
+
+ int cached;
+ jclass lvhittestinfoClass;
+ jfieldID x, y, flags, iItem, iSubItem;
+
+} LVHITTESTINFO_FID_CACHE;
+
+typedef LVHITTESTINFO_FID_CACHE *PLVHITTESTINFO_FID_CACHE;
+
+/* LVITEM struct */
+typedef struct LVITEM_FID_CACHE {
+
+ int cached;
+ jclass lvitemClass;
+ jfieldID mask, iItem, iSubItem, state, \
+ stateMask, pszText, cchTextMax, iImage, \
+ lParam, iIndent;
+
+} LVITEM_FID_CACHE;
+
+typedef LVITEM_FID_CACHE *PLVITEM_FID_CACHE;
+
+/* LOGBRUSH struct */
+typedef struct LOGBRUSH_FID_CACHE {
+
+ int cached;
+ jclass logbrushClass;
+ jfieldID lbStyle, lbColor, lbHatch;
+
+} LOGBRUSH_FID_CACHE;
+
+typedef LOGBRUSH_FID_CACHE *PLOGBRUSH_FID_CACHE;
+
+/* MEASUREITEMSTRUCT struct */
+typedef struct MEASUREITEMSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass measureitemstructClass;
+ jfieldID CtlType, CtlID, itemID, itemWidth, itemHeight, itemData;
+
+} MEASUREITEMSTRUCT_FID_CACHE;
+
+typedef MEASUREITEMSTRUCT_FID_CACHE *PMEASUREITEMSTRUCT_FID_CACHE;
+
+/* MENUINFO struct */
+typedef struct MENUINFO_FID_CACHE {
+
+ int cached;
+ jclass menuinfoClass;
+ jfieldID cbSize, fMask, dwStyle, cyMax, hbrBack, dwContextHelpID, dwMenuData;
+
+} MENUINFO_FID_CACHE;
+
+typedef MENUINFO_FID_CACHE *PMENUINFO_FID_CACHE;
+
+
+/* struct MENUITEMINFO*/
+typedef struct MENUITEMINFO_FID_CACHE {
+
+ int cached;
+ jclass menuiteminfoClass;
+ jfieldID cbSize, fMask, fType, fState, wID, hSubMenu, \
+ hbmpChecked, hbmpUnchecked, dwItemData, dwTypeData, \
+ cch
+#ifdef USE_2000_CALLS
+ ,hbmpItem
+#endif
+ ;
+
+} MENUITEMINFO_FID_CACHE ;
+
+typedef MENUITEMINFO_FID_CACHE *PMENUITEMINFO_FID_CACHE;
+
+/* MSG struct */
+typedef struct MSG_FID_CACHE {
+
+ int cached;
+ jclass msgClass;
+ jfieldID hwnd, message, wParam, lParam, time, x, y;
+
+} MSG_FID_CACHE;
+
+typedef MSG_FID_CACHE *PMSG_FID_CACHE;
+
+/* MSGFILTER struct */
+typedef struct MSGFILTER_FID_CACHE {
+
+ int cached;
+ jclass msgfilterClass;
+ jfieldID hwndFrom, idFrom, code, msg, wParam, lParam;
+
+} MSGFILTER_FID_CACHE;
+
+typedef MSGFILTER_FID_CACHE *PMSGFILTER_FID_CACHE;
+
+/* NMHDR struct */
+typedef struct NMHDR_FID_CACHE {
+
+ int cached;
+ jclass nmhdrClass;
+ jfieldID hwndFrom, idFrom, code;
+
+} NMHDR_FID_CACHE;
+
+typedef NMHDR_FID_CACHE *PNMHDR_FID_CACHE;
+
+/* NMHEADER struct */
+typedef struct NMHEADER_FID_CACHE {
+
+ int cached;
+ jclass nmheaderClass;
+ jfieldID hwndFrom, idFrom, code, iItem, iButton, pitem;
+
+} NMHEADER_FID_CACHE;
+
+typedef NMHEADER_FID_CACHE *PNMHEADER_FID_CACHE;
+
+/* NMLISTVIEW struct */
+typedef struct NMLISTVIEW_FID_CACHE {
+
+ int cached;
+ jclass nmlistviewClass;
+ jfieldID hwndFrom, idFrom, code, iItem, iSubItem, uNewState, \
+ uOldState, uChanged, x, y, lParam;
+
+} NMLISTVIEW_FID_CACHE;
+
+typedef NMLISTVIEW_FID_CACHE *PNMLISTVIEW_FID_CACHE;
+
+/* NMTOOLBAR struct */
+typedef struct NMTOOLBAR_FID_CACHE {
+
+ int cached;
+ jclass nmtoolbarClass;
+ jfieldID hwndFrom, idFrom, code, iItem, iBitmap, idCommand,
+ fsState, fsStyle, ___MISSING_ALIGNMENT__, dwData,
+ iString, cchText, pszText, left, top, right, bottom;
+
+} NMTOOLBAR_FID_CACHE;
+
+typedef NMTOOLBAR_FID_CACHE *PNMTOOLBAR_FID_CACHE;
+
+/* NMTTDISPINFO struct */
+typedef struct NMTTDISPINFO_FID_CACHE {
+
+ int cached;
+ jclass nmttdispinfoClass;
+ jfieldID hwndFrom, idFrom, code, lpszText, pad0, pad1, pad2, pad3, \
+ pad4, pad5, pad6, pad7, pad8, pad9, pad10, pad11, pad12, \
+ pad13, pad14, pad15, pad16, pad17, pad18, pad19, hinst, \
+ uFlags, lParam;
+
+} NMTTDISPINFO_FID_CACHE;
+
+typedef NMTTDISPINFO_FID_CACHE *PNMTTDISPINFO_FID_CACHE;
+
+/* NMTVCUSTOMDRAW struct */
+typedef struct NMTVCUSTOMDRAW_FID_CACHE {
+
+ int cached;
+ jclass nmtvcustomdrawClass;
+ jfieldID hwndFrom, idFrom, code, dwDrawStage, hdc, left, top, \
+ right, bottom, dwItemSpec, uItemState, lItemlParam, \
+ clrText, clrTextBk, iLevel;
+
+} NMTVCUSTOMDRAW_FID_CACHE;
+
+typedef NMTVCUSTOMDRAW_FID_CACHE *PNMTVCUSTOMDRAW_FID_CACHE;
+
+/* OPENFILENAME struct */
+typedef struct OPENFILENAME_FID_CACHE {
+
+ int cached;
+ jclass openfilenameClass;
+ jfieldID lStructSize, hwndOwner, hInstance, lpstrFilter, \
+ lpstrCustomFilter, nMaxCustFilter, nFilterIndex, lpstrFile, \
+ nMaxFile, lpstrFileTitle, nMaxFileTitle, lpstrInitialDir, \
+ lpstrTitle, Flags, nFileOffset, nFileExtension, lpstrDefExt, \
+ lCustData, lpfnHook, lpTemplateName;
+
+} OPENFILENAME_FID_CACHE;
+
+typedef OPENFILENAME_FID_CACHE *POPENFILENAME_FID_CACHE;
+
+/* PAINTSTRUCT struct */
+typedef struct PAINTSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass paintClass;
+ jfieldID hdc, fErase, left, top, right, bottom, \
+ fRestore, fIncUpdate;
+
+} PAINTSTRUCT_FID_CACHE;
+
+typedef PAINTSTRUCT_FID_CACHE *PPAINTSTRUCT_FID_CACHE;
+
+/* PAGESETUPDLG struct */
+typedef struct PAGESETUPDLG_FID_CACHE {
+
+ int cached;
+ jclass pagesetupdlgClass;
+ jfieldID lStructSize, hwndOwner, hDevMode, hDevNames, Flags, \
+ ptPaperSize_x, ptPaperSize_y, rtMinMargin_left, rtMinMargin_top, \
+ rtMinMargin_right, rtMinMargin_bottom, rtMargin_left, rtMargin_top, \
+ rtMargin_right, rtMargin_bottom, hInstance, lCustData, lpfnPageSetupHook, \
+ lpfnPagePaintHook, lpPageSetupTemplateName, hPageSetupTemplate;
+
+} PAGESETUPDLG_FID_CACHE;
+
+typedef PAGESETUPDLG_FID_CACHE *PPAGESETUPDLG_FID_CACHE;
+
+/* PARAFORMAT struct */
+/*
+typedef struct PARAFORMAT_FID_CACHE {
+ int cached;
+ jclass paraformatClass;
+ jfieldID cbSize, dwMask, wNumbering, wEffects, dxStartIndent, \
+ dxRightIndent, dxOffset, wAlignment, cTabCount, \
+ rgxTabs0, rgxTabs1, rgxTabs2, rgxTabs3, rgxTabs4, \
+ rgxTabs5, rgxTabs6, rgxTabs7, rgxTabs8, rgxTabs9, \
+ rgxTabs10, rgxTabs11, rgxTabs12, rgxTabs13, rgxTabs14, \
+ rgxTabs15, rgxTabs16, rgxTabs17, rgxTabs18, rgxTabs19, \
+ rgxTabs20, rgxTabs21, rgxTabs22, rgxTabs23, rgxTabs24, \
+ rgxTabs25, rgxTabs26, rgxTabs27, rgxTabs28, rgxTabs29, \
+ rgxTabs30, rgxTabs31;
+} PARAFORMAT_FID_CACHE;
+typedef PARAFORMAT_FID_CACHE *PPARAFORMAT_FID_CACHE;
+*/
+
+/* POINT struct */
+typedef struct POINT_FID_CACHE {
+
+ int cached;
+ jclass pointClass;
+ jfieldID x, y;
+
+} POINT_FID_CACHE;
+
+typedef POINT_FID_CACHE *PPOINT_FID_CACHE;
+
+/* PRINTDLG struct */
+typedef struct PRINTDLG_FID_CACHE {
+
+ int cached;
+ jclass printdlgClass;
+ jfieldID lStructSize, hwndOwner, hDevMode, hDevNames, hDC, Flags, \
+ nFromPage, nToPage, nMinPage, nMaxPage, nCopies, hInstance, \
+ lCustData, lpfnPrintHook, lpfnSetupHook, lpPrintTemplateName, \
+ lpSetupTemplateName, hPrintTemplate, hSetupTemplate;
+
+} PRINTDLG_FID_CACHE;
+
+typedef PRINTDLG_FID_CACHE *PPRINTDLG_FID_CACHE;
+
+/* REBARBANDINFO struct */
+typedef struct REBARBANDINFO_FID_CACHE {
+
+ int cached;
+ jclass rebarbandinfoClass;
+ jfieldID cbSize, fMask, fStyle, clrFore, clrBack, lpText, cch, \
+ iImage, hwndChild, cxMinChild, cyMinChild, cx, hbmBack, \
+ wID, cyChild, cyMaxChild, cyIntegral, cxIdeal, lParam, cxHeader;
+
+} REBARBANDINFO_FID_CACHE;
+
+typedef REBARBANDINFO_FID_CACHE *PREBARBANDINFO_FID_CACHE;
+
+/* RECT struct */
+typedef struct RECT_FID_CACHE {
+
+ int cached;
+ jclass rectClass;
+ jfieldID left, top, right, bottom;
+
+} RECT_FID_CACHE;
+
+typedef RECT_FID_CACHE *PRECT_FID_CACHE;
+
+/* SCROLLINFO struct */
+typedef struct SCROLLINFO_FID_CACHE {
+
+ int cached;
+ jclass scrollinfoClass;
+ jfieldID cbSize, fMask, nMin, nMax, nPage, nPos, nTrackPos;
+
+} SCROLLINFO_FID_CACHE;
+
+typedef SCROLLINFO_FID_CACHE *PSCROLLINFO_FID_CACHE;
+
+/* SIZE struct */
+typedef struct SIZE_FID_CACHE {
+
+ int cached;
+ jclass sizeClass;
+ jfieldID cx, cy;
+
+} SIZE_FID_CACHE;
+
+typedef SIZE_FID_CACHE *PSIZE_FID_CACHE;
+
+/* TBBUTTON struct */
+typedef struct TBBUTTON_FID_CACHE {
+
+ int cached;
+ jclass tbbuttonClass;
+ jfieldID iBitmap, idCommand, fsState, fsStyle, dwData, iString;
+
+} TBBUTTON_FID_CACHE;
+
+typedef TBBUTTON_FID_CACHE *PTBBUTTON_FID_CACHE;
+
+/* TBBUTTONINFO struct */
+typedef struct TBBUTTONINFO_FID_CACHE {
+
+ int cached;
+ jclass tbbuttoninfoClass;
+ jfieldID cbSize, dwMask, idCommand, iImage, fsState, fsStyle, cx, lParam, pszText, cchText;
+
+} TBBUTTONINFO_FID_CACHE;
+
+typedef TBBUTTONINFO_FID_CACHE *PTBBUTTONINFO_FID_CACHE;
+
+/* TCITEM struct */
+typedef struct TCITEM_FID_CACHE {
+
+ int cached;
+ jclass tcitemClass;
+ jfieldID mask, dwState, dwStateMask, pszText, cchTextMax, iImage, lParam;
+
+} TCITEM_FID_CACHE;
+
+typedef TCITEM_FID_CACHE *PTCITEM_FID_CACHE;
+
+/* TEXTMETRIC struct */
+typedef struct TEXTMETRIC_FID_CACHE {
+
+ int cached;
+ jclass textmetricClass;
+ jfieldID tmHeight, tmAscent, tmDescent, tmInternalLeading, tmExternalLeading, \
+ tmAveCharWidth, tmMaxCharWidth, tmWeight, tmOverhang, tmDigitizedAspectX, \
+ tmDigitizedAspectY, tmFirstChar, tmLastChar, tmDefaultChar, tmBreakChar, tmItalic, \
+ tmUnderlined, tmStruckOut, tmPitchAndFamily, tmCharSet;
+
+} TEXTMETRIC_FID_CACHE;
+
+typedef TEXTMETRIC_FID_CACHE *PTEXTMETRIC_FID_CACHE;
+
+/* TOOLINFO struct */
+typedef struct TOOLINFO_FID_CACHE {
+
+ int cached;
+ jclass toolinfoClass;
+ jfieldID cbSize, uFlags, hwnd, uId, left, top, right, bottom, \
+ hinst, lpszText, lParam;
+
+} TOOLINFO_FID_CACHE;
+
+typedef TOOLINFO_FID_CACHE *PTOOLINFO_FID_CACHE;
+
+/* TRACKMOUSEEVENT struct */
+typedef struct TRACKMOUSEEVENT_FID_CACHE {
+
+ int cached;
+ jclass trackmouseeventClass;
+ jfieldID cbSize, dwFlags, hwndTrack, dwHoverTime;
+
+} TRACKMOUSEEVENT_FID_CACHE;
+
+typedef TRACKMOUSEEVENT_FID_CACHE *PTRACKMOUSEEVENT_FID_CACHE;
+
+/* TVHITTESTINFO struct */
+typedef struct TVHITTESTINFO_FID_CACHE {
+
+ int cached;
+ jclass tvhittestinfoClass;
+ jfieldID x, y, flags, hItem;
+
+} TVHITTESTINFO_FID_CACHE;
+
+typedef TVHITTESTINFO_FID_CACHE *PTVHITTESTINFO_FID_CACHE;
+
+/* TVINSERTSTRUCT struct */
+typedef struct TVINSERTSTRUCT_FID_CACHE {
+
+ int cached;
+ jclass tvinsertstructClass;
+ jfieldID hParent, hInsertAfter, mask, hItem, state, stateMask, pszText, cchTextMax, \
+ iImage, iSelectedImage, cChildren, lParam;
+
+} TVINSERTSTRUCT_FID_CACHE;
+
+typedef TVINSERTSTRUCT_FID_CACHE *PTVINSERTSTRUCT_FID_CACHE;
+
+/* TVITEM struct */
+typedef struct TVITEM_FID_CACHE {
+
+ int cached;
+ jclass tvitemClass;
+ jfieldID mask, hItem, state, stateMask, pszText, cchTextMax, \
+ iImage, iSelectedImage, cChildren, lParam;
+
+} TVITEM_FID_CACHE;
+
+typedef TVITEM_FID_CACHE *PTVITEM_FID_CACHE;
+
+/* WINDOWPLACEMENT struct */
+typedef struct WINDOWPLACEMENT_FID_CACHE {
+
+ int cached;
+ jclass windowplacementClass;
+ jfieldID length, flags, showCmd, ptMinPosition_x, ptMinPosition_y, ptMaxPosition_x, ptMaxPosition_y,
+ left, top, right, bottom;
+
+} WINDOWPLACEMENT_FID_CACHE;
+
+typedef WINDOWPLACEMENT_FID_CACHE *PWINDOWPLACEMENT_FID_CACHE;
+
+/* WINDOWPOS struct */
+typedef struct WINDOWPOS_FID_CACHE {
+
+ int cached;
+ jclass windowposClass;
+ jfieldID hwnd, hwndInsertAfter, x, y, cx, cy, flags;
+
+} WINDOWPOS_FID_CACHE;
+
+typedef WINDOWPOS_FID_CACHE *PWINDOWPOS_FID_CACHE;
+
+/* WNDCLASSEX struct */
+typedef struct WNDCLASSEX_FID_CACHE {
+
+ int cached;
+ jclass wndclassexClass;
+ jfieldID cbSize, style, lpfnWndProc, cbClsExtra, \
+ cbWndExtra, hInstance, hIcon, hCursor, \
+ hbrBackground, lpszMenuName, lpszClassName, \
+ hIconSm;
+
+} WNDCLASSEX_FID_CACHE;
+
+typedef WNDCLASSEX_FID_CACHE *PWNDCLASSEX_FID_CACHE;
+
+/* SHFILEINFO struct */
+/*
+typedef struct SHFILEINFO_FID_CACHE {
+
+ int cached;
+ jclass shfileinfoClass;
+ jfieldID hIcon, iIcon, dwAttributes, szDisplayName, szTypeName;
+
+} SHFILEINFO_FID_CACHE;
+
+typedef SHFILEINFO_FID_CACHE *PSHFILEINFO_FID_CACHE;
+*/
+
+/* ----------- ole fid cache structures ----------- */
+
+/* CAUUID struct */
+typedef struct CAUUID_FID_CACHE {
+
+ int cached;
+ jclass cauuidClass;
+ jfieldID cElems, pElems;
+
+} CAUUID_FID_CACHE;
+
+typedef CAUUID_FID_CACHE *PCAUUID_FID_CACHE;
+
+/* COSERVERINFO struct */
+typedef struct COSERVERINFO_FID_CACHE {
+
+ int cached;
+ jclass coserverinfoClass;
+ jfieldID dwReserved1, pwszName, pAuthInfo, dwReserved2;
+
+} COSERVERINFO_FID_CACHE;
+
+typedef COSERVERINFO_FID_CACHE *PCOSERVERINFO_FID_CACHE;
+
+/* CONTROLINFO struct */
+typedef struct CONTROLINFO_FID_CACHE {
+
+ int cached;
+ jclass controlinfoClass;
+ jfieldID cb, hAccel, cAccel, filler, dwFlags;
+
+} CONTROLINFO_FID_CACHE;
+
+typedef CONTROLINFO_FID_CACHE *PCONTROLINFO_FID_CACHE;
+
+/* DISPPARAMS struct */
+typedef struct DISPPARAMS_FID_CACHE {
+
+ int cached;
+ jclass dispparamsClass;
+ jfieldID rgvarg, rgdispidNamedArgs, cArgs, cNamedArgs;
+
+} DISPPARAMS_FID_CACHE;
+
+typedef DISPPARAMS_FID_CACHE *PDISPPARAMS_FID_CACHE;
+
+/* DROPFILES struct */
+typedef struct DROPFILES_FID_CACHE {
+
+ int cached;
+ jclass dropfilesClass;
+ jfieldID pFiles, pt_x, pt_y, fNC, fWide;
+
+} DROPFILES_FID_CACHE;
+
+typedef DROPFILES_FID_CACHE *PDROPFILES_FID_CACHE;
+
+/* DVASPECTINFO struct */
+typedef struct DVASPECTINFO_FID_CACHE {
+
+ int cached;
+ jclass dvaspectinfoClass;
+ jfieldID cb, dwFlags;
+
+} DVASPECTINFO_FID_CACHE;
+
+typedef DVASPECTINFO_FID_CACHE *PDVASPECTINFO_FID_CACHE;
+
+/* DVTARGETDEVICE struct */
+typedef struct DVTARGETDEVICE_FID_CACHE {
+
+ int cached;
+ jclass dvtargetdeviceClass;
+ jfieldID tdSize, tdDriverNameOffset, tdDeviceNameOffset, \
+ tdPortNameOffset, tdExtDevmodeOffset, tdData;
+
+} DVTARGETDEVICE_FID_CACHE;
+
+typedef DVTARGETDEVICE_FID_CACHE *PDVTARGETDEVICE_FID_CACHE;
+
+/* EXCEPINFO struct */
+typedef struct EXCEPINFO_FID_CACHE {
+
+ int cached;
+ jclass excepinfoClass;
+ jfieldID wCode, wReserved, bstrSource, bstrDescription, bstrHelpFile, \
+ dwHelpContext, pvReserved, pfnDeferredFillIn, scode;
+
+} EXCEPINFO_FID_CACHE;
+
+typedef EXCEPINFO_FID_CACHE *PEXCEPINFO_FID_CACHE;
+
+/* FILETIME struct */
+typedef struct FILETIME_FID_CACHE {
+
+ int cached;
+ jclass filetimeClass;
+ jfieldID dwLowDateTime, dwHighDateTime;
+
+} FILETIME_FID_CACHE;
+
+typedef FILETIME_FID_CACHE *PFILETIME_FID_CACHE;
+
+/* FORMATETC struct */
+typedef struct FORMATEC_FID_CACHE {
+
+ int cached;
+ jclass formatetcClass;
+ jfieldID cfFormat, ptd, dwAspect, lindex, tymed;
+
+} FORMATETC_FID_CACHE;
+
+typedef FORMATETC_FID_CACHE *PFORMATETC_FID_CACHE;
+
+/* GUID struct */
+typedef struct GUID_FID_CACHE {
+
+ int cached;
+ jclass guidClass;
+ jfieldID data1, data2, data3, b0, b1, b2, b3, b4, b5, b6, b7;
+
+} GUID_FID_CACHE;
+
+typedef GUID_FID_CACHE *PGUID_FID_CACHE;
+
+/* IDLDESC struct */
+typedef struct IDLDESC_FID_CACHE {
+
+ int cached;
+ jclass idldescClass;
+ jfieldID dwReserved, wIDLFlags;
+
+} IDLDESC_FID_CACHE;
+
+typedef IDLDESC_FID_CACHE *PIDLDESC_FID_CACHE;
+
+/* LICINFO struct */
+typedef struct LICINFO_FID_CACHE {
+
+ int cached;
+ jclass licinfoClass;
+ jfieldID cbLicInfo, fRuntimeKeyAvail, fLicVerified;
+
+} LICINFO_FID_CACHE;
+
+typedef LICINFO_FID_CACHE *PLICINFO_FID_CACHE;
+
+/* MULTI_QI struct */
+typedef struct MULTI_QI_FID_CACHE {
+
+ int cached;
+ jclass multi_qiClass;
+ jfieldID pIID, pItf, hr;
+
+} MULTI_QI_FID_CACHE;
+
+typedef MULTI_QI_FID_CACHE *PMULTI_QI_FID_CACHE;
+
+/* OLECMD struct */
+typedef struct OLECMD_FID_CACHE {
+
+ int cached;
+ jclass olecmdClass;
+ jfieldID cmdID, cmdf;
+
+} OLECMD_FID_CACHE;
+
+typedef OLECMD_FID_CACHE *POLECMD_FID_CACHE;
+
+/* OLECMDTEXT struct */
+typedef struct OLECMDTEXT_FID_CACHE {
+
+ int cached;
+ jclass olecmdtextClass;
+ jfieldID cmdtextf, cwActual, cwBuf, rgwz;
+
+} OLECMDTEXT_FID_CACHE;
+
+typedef OLECMDTEXT_FID_CACHE *POLECMDTEXT_FID_CACHE;
+
+/* OLEINPLACEFRAMEINFO struct */
+typedef struct OLEINPLACEFRAMEINFO_FID_CACHE {
+
+ int cached;
+ jclass oleinplaceframeinfoClass;
+ jfieldID cb, fMDIApp, hwndFrame, haccel, cAccelEntries;
+
+} OLEINPLACEFRAMEINFO_FID_CACHE;
+
+typedef OLEINPLACEFRAMEINFO_FID_CACHE *POLEINPLACEFRAMEINFO_FID_CACHE;
+
+/* OLEVERB struct */
+typedef struct OLEVERB_FID_CACHE {
+
+ int cached;
+ jclass oleverbClass;
+ jfieldID lVerb, lpszVerbName, fuFlags, grfAttribs;
+
+} OLEVERB_FID_CACHE;
+
+typedef OLEVERB_FID_CACHE *POLEVERB_FID_CACHE;
+
+/* STATSTG struct */
+typedef struct STATSTG_FID_CACHE {
+
+ int cached;
+ jclass statstgClass;
+ jfieldID pwcsName, type, cbSize, mtime_dwLowDateTime, mtime_dwHighDateTime, \
+ ctime_dwLowDateTime, ctime_dwHighDateTime, atime_dwLowDateTime, \
+ atime_dwHighDateTime, grfMode, grfLocksSupported, clsid_data1, \
+ clsid_data2, clsid_data3, clsid_b0, clsid_b1, clsid_b2, clsid_b3, \
+ clsid_b4, clsid_b5, clsid_b6, clsid_b7, grfStateBits, reserved;
+
+} STATSTG_FID_CACHE;
+
+typedef STATSTG_FID_CACHE *PSTATSTG_FID_CACHE;
+
+/* STGMEDIUM struct */
+typedef struct STGMEDIUM_FID_CACHE {
+
+ int cached;
+ jclass stgmediumClass;
+ jfieldID tymed, unionField, pUnkForRelease;
+
+} STGMEDIUM_FID_CACHE;
+
+typedef STGMEDIUM_FID_CACHE *PSTGMEDIUM_FID_CACHE;
+
+/* TYPEATTR struct */
+typedef struct TYPEATTR_FID_CACHE {
+
+ int cached;
+ jclass typeattrClass;
+ jfieldID guid_data1, guid_data2, guid_data3, \
+ guid_b0, guid_b1, guid_b2, guid_b3, guid_b4, guid_b5, guid_b6, guid_b7, \
+ lcid, dwReserved, memidConstructor, memidDestructor, lpstrSchema, \
+ cbSizeInstance, typekind, cFuncs, cVars, cImplTypes, cbSizeVft, \
+ cbAlignment, wTypeFlags, wMajorVerNum, wMinorVerNum, \
+ tdescAlias_unionField, tdescAlias_vt, \
+ idldescType_dwReserved, idldescType_wIDLFlags;
+
+} TYPEATTR_FID_CACHE;
+
+typedef TYPEATTR_FID_CACHE *PTYPEATTR_FID_CACHE;
+
+/* TYPEDESC struct */
+typedef struct TYPEDESC_FID_CACHE {
+
+ int cached;
+ jclass typedescClass;
+ jfieldID typedesc_union, vt;
+
+} TYPEDESC_FID_CACHE;
+
+typedef TYPEDESC_FID_CACHE *PTYPEDESC_FID_CACHE;
+
+/* FUNCDESC1 struct */
+typedef struct FUNCDESC1_FID_CACHE {
+
+ int cached;
+ jclass funcdescClass;
+ jfieldID memid, lprgscode, lprgelemdescParam, funckind, invkind, \
+ callconv, cParams, cParamsOpt, oVft, cScodes, \
+ elemdescFunc_tdesc_union, elemdescFunc_tdesc_vt, elemdescFunc_tdesc_filler, \
+ elemdescFunc_paramdesc_pparamdescex, elemdescFunc_paramdesc_wParamFlags, elemdescFunc_paramdesc_filler, \
+ wFuncFlags;
+
+} FUNCDESC1_FID_CACHE;
+
+typedef FUNCDESC1_FID_CACHE *PFUNCDESC1_FID_CACHE;
+
+/* FUNCDESC2 struct */
+typedef struct FUNCDESC2_FID_CACHE {
+
+ int cached;
+ jclass funcdescClass;
+ jfieldID memid, lprgscode, lprgelemdescParam, funckind, invkind, \
+ callconv, cParams, cParamsOpt, oVft, cScodes, \
+ elemdescFunc_tdesc_union, elemdescFunc_tdesc_vt, elemdescFunc_tdesc_filler, \
+ elemdescFunc_idldesc_dwReserved, elemdescFunc_idldesc_wIDLFlags, elemdescFunc_idldesc_filler, \
+ wFuncFlags;
+
+} FUNCDESC2_FID_CACHE;
+
+typedef FUNCDESC2_FID_CACHE *PFUNCDESC2_FID_CACHE;
+
+
+/* VARDESC1 struct */
+typedef struct VARDESC1_FID_CACHE {
+
+ int cached;
+ jclass vardescClass;
+ jfieldID memid, lpstrSchema, unionField, \
+ elemdescVar_tdesc_union, elemdescVar_tdesc_vt, elemdescVar_tdesc_filler, \
+ elemdescVar_paramdesc_pparamdescex, elemdescVar_paramdesc_wParamFlags, elemdescVar_paramdesc_filler, \
+ wVarFlags, filler, varkind;
+
+} VARDESC1_FID_CACHE;
+
+typedef VARDESC1_FID_CACHE *PVARDESC1_FID_CACHE;
+
+/* VARDESC2 struct */
+typedef struct VARDESC2_FID_CACHE {
+
+ int cached;
+ jclass vardescClass;
+ jfieldID memid, lpstrSchema, unionField, \
+ elemdescVar_tdesc_union, elemdescVar_tdesc_vt, elemdescVar_tdesc_filler, \
+ elemdescVar_idldesc_dwReserved, elemdescVar_idldesc_wIDLFlags, elemdescVar_idldesc_filler, \
+ wVarFlags, filler, varkind;
+
+} VARDESC2_FID_CACHE;
+
+typedef VARDESC2_FID_CACHE *PVARDESC2_FID_CACHE;
+
+/* ----------- ole cache function prototypes ----------- */
+
+void cacheGuidFids(JNIEnv *env, jobject lpGuid, PGUID_FID_CACHE lpCache);
+void cacheOlecmdFids(JNIEnv *env, jobject lpOlecmd, POLECMD_FID_CACHE lpCache);
+void cacheDvtargetdeviceFids(JNIEnv *env, jobject lpDvtargetdevice, PDVTARGETDEVICE_FID_CACHE lpCache);
+void cacheOleinplaceframeinfoFids(JNIEnv *env, jobject lpOleinplaceframeinfo, POLEINPLACEFRAMEINFO_FID_CACHE lpCache);
+void cacheFormatetcFids(JNIEnv *env, jobject lpFormatetc, PFORMATETC_FID_CACHE lpCache);
+void cacheOleverbFids(JNIEnv *env, jobject lpOleverb, POLEVERB_FID_CACHE lpCache);
+void cacheTypedescFids(JNIEnv *env, jobject lpTypedesc, PTYPEDESC_FID_CACHE lpCache);
+void cacheIdldescFids(JNIEnv *env, jobject lpIdldesc, PIDLDESC_FID_CACHE lpCache);
+void cacheOlecmdtextFids(JNIEnv *env, jobject lpOlecmdtext, POLECMDTEXT_FID_CACHE lpCache);
+void cacheFiletimeFids(JNIEnv *env, jobject lpFiletime, PFILETIME_FID_CACHE lpCache);
+void cacheControlinfoFids(JNIEnv *env, jobject lpControlinfo, PCONTROLINFO_FID_CACHE lpCache);
+void cacheStgmediumFids(JNIEnv *env, jobject lpStgmedium, PSTGMEDIUM_FID_CACHE lpCache);
+void cacheDvaspectinfoFids(JNIEnv *env, jobject lpDvaspectinfo, PDVASPECTINFO_FID_CACHE lpCache);
+void cacheDispparamsFids(JNIEnv *env, jobject lpDispparams, PDISPPARAMS_FID_CACHE lpCache);
+void cacheLicinfoFids(JNIEnv *env, jobject lpLicinfo, PLICINFO_FID_CACHE lpCache);
+void cacheExcepinfoFids(JNIEnv *env, jobject lpExcepinfo, PEXCEPINFO_FID_CACHE lpCache);
+void cacheTypeattrFids(JNIEnv *env, jobject lpTypeattr, PTYPEATTR_FID_CACHE lpCache);
+void cacheFuncdesc1Fids(JNIEnv *env, jobject lpFuncdesc, PFUNCDESC1_FID_CACHE lpCache);
+void cacheFuncdesc2Fids(JNIEnv *env, jobject lpFuncdesc, PFUNCDESC2_FID_CACHE lpCache);
+void cacheVardesc1Fids(JNIEnv *env, jobject lpVardesc, PVARDESC1_FID_CACHE lpCache);
+void cacheVardesc2Fids(JNIEnv *env, jobject lpVardesc, PVARDESC2_FID_CACHE lpCache);
+
+/* ----------- cache function prototypes ----------- */
+
+void cacheAccelFids(JNIEnv *env, jobject lpAccel, PACCEL_FID_CACHE lpCache);
+void cacheBitmapFids(JNIEnv *env, jobject lpBitmap, PBITMAP_FID_CACHE lpCache);
+void cacheBrowseinfoFids(JNIEnv *env, jobject lpBrowseinfo, PBROWSEINFO_FID_CACHE lpCache);
+void cacheCauuidFids(JNIEnv *env, jobject lpCauuid, PCAUUID_FID_CACHE lpCache);
+/*
+void cacheCharformatFids(JNIEnv *env, jobject lpCharformat, PCHARFORMAT_FID_CACHE lpCache);
+void cacheCharformat2Fids(JNIEnv *env, jobject lpCharformat2, PCHARFORMAT2_FID_CACHE lpCache);
+*/
+void cacheChoosecolorFids(JNIEnv *env, jobject lpChoosecolor, PCHOOSECOLOR_FID_CACHE lpCache);
+void cacheChoosefontFids(JNIEnv *env, jobject lpChoosefont, PCHOOSEFONT_FID_CACHE lpCache);
+void cacheCompositionformFids(JNIEnv *env, jobject lpCompositionform, PCOMPOSITIONFORM_FID_CACHE lpCache);
+void cacheCoserverinfoFids(JNIEnv *env, jobject lpCoservinfo, PCOSERVERINFO_FID_CACHE lpCache);
+void cacheCreatestructFids(JNIEnv *env, jobject lpCreatestruct, PCREATESTRUCT_FID_CACHE lpCache);
+void cacheDibsectionFids(JNIEnv *env, jobject lpDibsection, PDIBSECTION_FID_CACHE lpCache);
+void cacheDllversioninfoFids(JNIEnv *env, jobject lpDllversioninfo, PDLLVERSIONINFO_FID_CACHE lpCache);
+void cacheDocinfoFids(JNIEnv *env, jobject lpDocinfo, PDOCINFO_FID_CACHE lpCache);
+void cacheDrawitemstructFids(JNIEnv *env, jobject lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpCache);
+void cacheDropfilesFids(JNIEnv *env, jobject lpDropfiles, PDROPFILES_FID_CACHE lpCache);
+void cacheHditemFids(JNIEnv *env, jobject lpHditem, PHDITEM_FID_CACHE lpCache);
+void cacheHdlayoutFids(JNIEnv *env, jobject lpHdlayout, PHDLAYOUT_FID_CACHE lpCache);
+void cacheHelpinfoFids(JNIEnv *env, jobject lpHelpinfo, PHELPINFO_FID_CACHE lpCache);
+void cacheIconinfoFids(JNIEnv *env, jobject lpIconinfo, PICONINFO_FID_CACHE lpCache);
+void cacheInitcommoncontrolsexFids(JNIEnv *env, jobject lpInitcommoncontrolsex, PINITCOMMONCONTROLSEX_FID_CACHE lpCache);
+void cacheLogbrushFids(JNIEnv *env, jobject lpLogbrush, PLOGBRUSH_FID_CACHE lpCache);
+void cacheLogfontFids(JNIEnv *env, jobject lpLogfont, PLOGFONT_FID_CACHE lpCache);
+void cacheLogpenFids(JNIEnv *env, jobject lpLogpen, PLOGPEN_FID_CACHE lpCache);
+/*
+void cacheExtlogpenFids(JNIEnv *env, jobject lpExtlogpen, PEXTLOGPEN_FID_CACHE lpCache);
+*/
+void cacheLvcolumnFids(JNIEnv *env, jobject lpLVColumn, PLVCOLUMN_FID_CACHE lpCache);
+void cacheLvhittestinfoFids(JNIEnv *env, jobject lpLvhittestinfo, PLVHITTESTINFO_FID_CACHE lpCache);
+void cacheLvitemFids(JNIEnv *env, jobject lpLVItem, PLVITEM_FID_CACHE lpCache);
+void cacheMenuinfoFids(JNIEnv *env, jobject lpMenuinfo, PMENUINFO_FID_CACHE lpCache);
+void cacheMeasureitemstructFids(JNIEnv *env, jobject lpMeasureitemstruct, PMEASUREITEMSTRUCT_FID_CACHE lpCache);
+void cacheMenuiteminfoFids(JNIEnv *env, jobject lpMenuiteminfo, PMENUITEMINFO_FID_CACHE lpCache);
+void cacheMsgFids(JNIEnv *env, jobject lpMsg, PMSG_FID_CACHE lpCache);
+void cacheMsgfilterFids(JNIEnv *env, jobject lpMsgfilter, PMSGFILTER_FID_CACHE lpCache);
+void cacheMulti_qiFids(JNIEnv *env, jobject lpMulti_qi, PMULTI_QI_FID_CACHE lpCache);
+void cacheNmhdrFids(JNIEnv *env, jobject lpNmhdr, PNMHDR_FID_CACHE lpCache);
+void cacheNmheaderFids(JNIEnv *env, jobject lpNmheader, PNMHEADER_FID_CACHE lpCache);
+void cacheNmlistviewFids(JNIEnv *env, jobject lpNmlistview, PNMLISTVIEW_FID_CACHE lpCache);
+void cacheNmtoolbarFids(JNIEnv *env, jobject lpNmtoolbar, PNMTOOLBAR_FID_CACHE lpCache);
+void cacheNmttdispinfoFids(JNIEnv *env, jobject lpNmttdispinfo, PNMTTDISPINFO_FID_CACHE lpCache);
+void cacheNmtvcustomdrawFids(JNIEnv *env, jobject lpNmtvcustomdraw, PNMTVCUSTOMDRAW_FID_CACHE lpCache);
+void cacheOpenfilenameFids(JNIEnv *env, jobject lpOpenfilename, POPENFILENAME_FID_CACHE lpCache);
+void cachePagesetupdlgFids(JNIEnv *env, jobject lpPagesetupdlg, PPAGESETUPDLG_FID_CACHE lpCache);
+void cachePaintstructFids(JNIEnv *env, jobject lpPaint, PPAINTSTRUCT_FID_CACHE lpCache);
+/*
+void cacheParaformatFids(JNIEnv *env, jobject lpParaformat, PPARAFORMAT_FID_CACHE lpCache);
+*/
+void cachePointFids(JNIEnv *env, jobject lpPoint, PPOINT_FID_CACHE lpCache);
+void cachePrintdlgFids(JNIEnv *env, jobject lpPrintdlg, PPRINTDLG_FID_CACHE lpCache);
+void cacheRebarbandinfoFids(JNIEnv *env, jobject lpRebarbandinfo, PREBARBANDINFO_FID_CACHE lpCache);
+void cacheRectFids(JNIEnv *env, jobject lpRect, PRECT_FID_CACHE lpCache);
+void cacheScrollinfoFids(JNIEnv *env, jobject lpScrollinfo, PSCROLLINFO_FID_CACHE lpCache);
+void cacheSizeFids(JNIEnv *env, jobject lpSize, PSIZE_FID_CACHE lpCache);
+void cacheStatstgFids(JNIEnv *env, jobject lpStatstg, PSTATSTG_FID_CACHE lpCache);
+void cacheTbbuttonFids(JNIEnv *env, jobject lpTbbutton, PTBBUTTON_FID_CACHE lpCache);
+void cacheTbbuttoninfoFids(JNIEnv *env, jobject lpTbbuttoninfo, PTBBUTTONINFO_FID_CACHE lpCache);
+void cacheTcitemFids(JNIEnv *env, jobject lpTcitem, PTCITEM_FID_CACHE lpCache);
+void cacheTextmetricFids(JNIEnv *env, jobject lpTextmetric, PTEXTMETRIC_FID_CACHE lpCache);
+void cacheToolinfoFids(JNIEnv *env, jobject lpToolinfo, PTOOLINFO_FID_CACHE lpCache);
+void cacheTrackmouseeventFids(JNIEnv *env, jobject lpTrackmouseevent, PTRACKMOUSEEVENT_FID_CACHE lpCache);
+void cacheTvhittestinfoFids(JNIEnv *env, jobject lpTvhittestinfo, PTVHITTESTINFO_FID_CACHE lpCache);
+void cacheTvinsertstructFids(JNIEnv *env, jobject lpTvinsertstruct, PTVINSERTSTRUCT_FID_CACHE lpCache);
+void cacheTvitemFids(JNIEnv *env, jobject lpTvitem, PTVITEM_FID_CACHE lpCache);
+void cacheWindowplacementFids(JNIEnv *env, jobject lpWindowplacement, PWINDOWPLACEMENT_FID_CACHE lpCache);
+void cacheWindowposFids(JNIEnv *env, jobject lpWindowpos, PWINDOWPOS_FID_CACHE lpCache);
+void cacheWndclassexFids(JNIEnv *env, jobject lpWndclassex, PWNDCLASSEX_FID_CACHE lpCache);
+/*
+*void cacheShfileinfoFids(JNIEnv *env, jobject lpShfileinfo, PSHFILEINFO_FID_CACHE lpCache);
+*/
+
+/* used to cast Vtabl entries */
+
+/* P_OLE_FN_x typedef for an OLE function returning int with x params*/
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_9)(jint, jint, jint, jint, jint, jint, jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_8)(jint, jint, jint, jint, jint, jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_7)(jint, jint, jint, jint, jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_6)(jint, jint, jint, jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_5)(jint, jint, jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_4)(jint, jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_3)(jint, jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_2)(jint, jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_1)(jint);
+typedef jint (STDMETHODCALLTYPE *P_OLE_FN_0)(void);
+
+/* ----------- swt getter and setter prototypes ----------- */
+/**
+ * These functions get or set object field ids assuming that the
+ * fids for these objects have already been cached.
+ *
+ * The header file just contains function prototypes
+ */
+void getAccelFields(JNIEnv *env, jobject lpObject, ACCEL *lpAccel, PACCEL_FID_CACHE lpAccelFc);
+void setAccelFields(JNIEnv *env, jobject lpObject, ACCEL *lpAccel, PACCEL_FID_CACHE lpAccelFc);
+void getBitmapFields(JNIEnv *env, jobject lpObject, BITMAP *lpBitmap, PBITMAP_FID_CACHE lpBitmapFc);
+void setBitmapFields(JNIEnv *env, jobject lpObject, BITMAP *lpBitmap, PBITMAP_FID_CACHE lpBitmapFc);
+void getBrowseinfoFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpBrowseinfo, PBROWSEINFO_FID_CACHE lpBrowseinfoFc);
+void setBrowseinfoFields(JNIEnv *env, jobject lpObject, BROWSEINFO *lpBrowseinfo, PBROWSEINFO_FID_CACHE lpBrowseinfoFc);
+void getCauuidFields(JNIEnv *env, jobject lpObject, CAUUID *lpCauuid, CAUUID_FID_CACHE *lpCauuidFc);
+void setCauuidFields(JNIEnv *env, jobject lpObject, CAUUID *lpCauuid, CAUUID_FID_CACHE *lpCauuidFc);
+/*
+void getCharformatFields(JNIEnv *env, jobject lpObject, CHARFORMAT *lpCharformat, CHARFORMAT_FID_CACHE *lpCharformatFc);
+void setCharformatFields(JNIEnv *env, jobject lpObject, CHARFORMAT *lpCharformat, CHARFORMAT_FID_CACHE *lpCharformatFc);
+void getCharformat2Fields(JNIEnv *env, jobject lpObject, CHARFORMAT2 *lpCharformat2, CHARFORMAT2_FID_CACHE *lpCharformat2Fc);
+void setCharformat2Fields(JNIEnv *env, jobject lpObject, CHARFORMAT2 *lpCharformat2, CHARFORMAT2_FID_CACHE *lpCharformat2Fc);
+*/
+void getChoosecolorFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpChoosecolor, CHOOSECOLOR_FID_CACHE *lpChoosecolorFc);
+void setChoosecolorFields(JNIEnv *env, jobject lpObject, CHOOSECOLOR *lpChoosecolor, CHOOSECOLOR_FID_CACHE *lpChoosecolorFc);
+void getChoosefontFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpChoosefont, CHOOSEFONT_FID_CACHE *lpChoosefontFc);
+void setChoosefontFields(JNIEnv *env, jobject lpObject, CHOOSEFONT *lpChoosefont, CHOOSEFONT_FID_CACHE *lpChoosefontFc);
+void getCompositionformFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpCompositionform, COMPOSITIONFORM_FID_CACHE *lpCompositionformFc);
+void setCompositionformFields(JNIEnv *env, jobject lpObject, COMPOSITIONFORM *lpCompositionform, COMPOSITIONFORM_FID_CACHE *lpCompositionformFc);
+void getCreatestructFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpCreatestruct, PCREATESTRUCT_FID_CACHE lpCreatestructFc);
+void setCreatestructFields(JNIEnv *env, jobject lpObject, CREATESTRUCT *lpCreatestruct, PCREATESTRUCT_FID_CACHE lpCreatestructFc);
+void getDibsectionFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpDibsection, DIBSECTION_FID_CACHE *lpDibsectionFc);
+void setDibsectionFields(JNIEnv *env, jobject lpObject, DIBSECTION *lpDibsection, DIBSECTION_FID_CACHE *lpDibsectionFc);
+void getDllversioninfoFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpDllversioninfo, DLLVERSIONINFO_FID_CACHE *lpDllversioninfoFc);
+void setDllversioninfoFields(JNIEnv *env, jobject lpObject, DLLVERSIONINFO *lpDllversioninfo, DLLVERSIONINFO_FID_CACHE *lpDllversioninfoFc);
+void getDocinfoFields(JNIEnv *env, jobject lpObject, DOCINFO *lpDocinfo, PDOCINFO_FID_CACHE lpDocinfoFc);
+void setDocinfoFields(JNIEnv *env, jobject lpObject, DOCINFO *lpDocinfo, PDOCINFO_FID_CACHE lpDocinfoFc);
+void getDrawitemstructFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpDrawitemstructFc);
+void setDrawitemstructFields(JNIEnv *env, jobject lpObject, DRAWITEMSTRUCT *lpDrawitemstruct, PDRAWITEMSTRUCT_FID_CACHE lpDrawitemstructFc);
+void getHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc);
+void setHditemFields(JNIEnv *env, jobject lpObject, HDITEM *lpHditem, HDITEM_FID_CACHE *lpHditemFc);
+void getHdlayoutFields(JNIEnv *env, jobject lpObject, HDLAYOUT *lpHdlayout, HDLAYOUT_FID_CACHE *lpHdlayoutFc);
+void setHdlayoutFields(JNIEnv *env, jobject lpObject, HDLAYOUT *lpHdlayout, HDLAYOUT_FID_CACHE *lpHdlayoutFc);
+void getHelpinfoFields(JNIEnv *env, jobject lpObject, HELPINFO *lpHelpinfo, HELPINFO_FID_CACHE *lpHelpinfoFc);
+void setHelpinfoFields(JNIEnv *env, jobject lpObject, HELPINFO *lpHelpinfo, HELPINFO_FID_CACHE *lpHelpinfoFc);
+void getIconinfoFields(JNIEnv *env, jobject lpObject, ICONINFO *lpIconinfo, PICONINFO_FID_CACHE lpIconinfoFc);
+void setIconinfoFields(JNIEnv *env, jobject lpObject, ICONINFO *lpIconinfo, PICONINFO_FID_CACHE lpIconinfoFc);
+void getInitcommoncontrolsexFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpInitcommoncontrolsex, INITCOMMONCONTROLSEX_FID_CACHE *lpInitcommoncontrolsexFc);
+void setInitcommoncontrolsexFields(JNIEnv *env, jobject lpObject, INITCOMMONCONTROLSEX *lpInitcommoncontrolsex, INITCOMMONCONTROLSEX_FID_CACHE *lpInitcommoncontrolsexFc);
+void getLogbrushFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpLogbrush, LOGBRUSH_FID_CACHE *lpLogbrushFc);
+void setLogbrushFields(JNIEnv *env, jobject lpObject, LOGBRUSH *lpLogbrush, LOGBRUSH_FID_CACHE *lpLogbrushFc);
+void getLogfontFields(JNIEnv *env, jobject lpObject, LOGFONT *lpLogfont, PLOGFONT_FID_CACHE lpLogfontFc);
+void setLogfontFields(JNIEnv *env, jobject lpObject, LOGFONT *lpLogfont, PLOGFONT_FID_CACHE lpLogfontFc);
+void getLogpenFields(JNIEnv *env, jobject lpObject, LOGPEN *lpLogpen, PLOGPEN_FID_CACHE lpLogpenFc);
+void setLogpenFields(JNIEnv *env, jobject lpObject, LOGPEN *lpLogpen, PLOGPEN_FID_CACHE lpLogpenFc);
+/*
+void getExtlogpenFields(JNIEnv *env, jobject lpObject, EXTLOGPEN *lpExtlogpen, PEXTLOGPEN_FID_CACHE lpExtlogpenFc);
+void setExtlogpenFields(JNIEnv *env, jobject lpObject, EXTLOGPEN *lpExtlogpen, PEXTLOGPEN_FID_CACHE lpExtlogpenFc);
+*/
+void getLvcolumnFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpLvcolumn, PLVCOLUMN_FID_CACHE lpLvcolumnFc);
+void setLvcolumnFields(JNIEnv *env, jobject lpObject, LVCOLUMN *lpLvcolumn, PLVCOLUMN_FID_CACHE lpLvcolumnFc);
+void getLvhittestinfoFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpLvhittestinfo, PLVHITTESTINFO_FID_CACHE lpLvhittestinfoFc);
+void setLvhittestinfoFields(JNIEnv *env, jobject lpObject, LVHITTESTINFO *lpLvhittestinfo, PLVHITTESTINFO_FID_CACHE lpLvhittestinfoFc);
+void getLvitemFields(JNIEnv *env, jobject lpObject, LVITEM *lpLvitem, LVITEM_FID_CACHE *lpLvitemFc);
+void setLvitemFields(JNIEnv *env, jobject lpObject, LVITEM *lpLvitem, LVITEM_FID_CACHE *lpLvitemFc);
+void getMeasureitemstructFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpMeasureitemstruct, MEASUREITEMSTRUCT_FID_CACHE *lpMeasureitemstructFc);
+void setMeasureitemstructFields(JNIEnv *env, jobject lpObject, MEASUREITEMSTRUCT *lpMeasureitemstruct, MEASUREITEMSTRUCT_FID_CACHE *lpMeasureitemstructFc);
+#ifdef USE_2000_CALLS
+void getMenuinfoFields(JNIEnv *env, jobject lpObject, MENUINFO *lpMenuinfo, MENUINFO_FID_CACHE *lpMenuinfoFc);
+void setMenuinfoFields(JNIEnv *env, jobject lpObject, MENUINFO *lpMenuinfo, MENUINFO_FID_CACHE *lpMenuinfoFc);
+#endif
+void getMenuiteminfoFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpMenuiteminfo, MENUITEMINFO_FID_CACHE *lpMenuiteminfoFc);
+void setMenuiteminfoFields(JNIEnv *env, jobject lpObject, MENUITEMINFO *lpMenuiteminfo, MENUITEMINFO_FID_CACHE *lpMenuiteminfoFc);
+void getMsgFields(JNIEnv *env, jobject lpObject, MSG *lpMsg, MSG_FID_CACHE *lpMsgFc);
+void setMsgFields(JNIEnv *env, jobject lpObject, MSG *lpMsg, MSG_FID_CACHE *lpMsgFc);
+void getMsgfilterFields(JNIEnv *env, jobject lpObject, MSGFILTER *lpMsgfilter, MSGFILTER_FID_CACHE *lpMsgfilterFc);
+void setMsgfilterFields(JNIEnv *env, jobject lpObject, MSGFILTER *lpMsgfilter, MSGFILTER_FID_CACHE *lpMsgfilterFc);
+void getNmhdrFields(JNIEnv *env, jobject lpObject, NMHDR *lpNmhdr, NMHDR_FID_CACHE *lpNmhdrFc);
+void setNmhdrFields(JNIEnv *env, jobject lpObject, NMHDR *lpNmhdr, NMHDR_FID_CACHE *lpNmhdrFc);
+void getNmheaderFields(JNIEnv *env, jobject lpObject, NMHEADER *lpNmheader, NMHEADER_FID_CACHE *lpNmheaderFc);
+void setNmheaderFields(JNIEnv *env, jobject lpObject, NMHEADER *lpNmheader, NMHEADER_FID_CACHE *lpNmheaderFc);
+void getNmlistviewFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpNmlistview, NMLISTVIEW_FID_CACHE *lpNmlistviewFc);
+void setNmlistviewFields(JNIEnv *env, jobject lpObject, NMLISTVIEW *lpNmlistview, NMLISTVIEW_FID_CACHE *lpNmlistviewFc);
+void getNmtoolbarFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpNmtoolbar, NMTOOLBAR_FID_CACHE *lpNmtoolbarFc);
+void setNmtoolbarFields(JNIEnv *env, jobject lpObject, NMTOOLBAR *lpNmtoolbar, NMTOOLBAR_FID_CACHE *lpNmtoolbarFc);
+void getNmttdispinfoFields(JNIEnv *env, jobject lpObject, NMTTDISPINFO *lpNmttdispinfo, NMTTDISPINFO_FID_CACHE *lpNmttdispinfoFc);
+void setNmttdispinfoFields(JNIEnv *env, jobject lpObject, NMTTDISPINFO *lpNmttdispinfo, NMTTDISPINFO_FID_CACHE *lpNmttdispinfoFc);
+void getNmtvcustomdrawFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpNmtvcustomdraw, NMTVCUSTOMDRAW_FID_CACHE *lpNmtvcustomdrawFc);
+void setNmtvcustomdrawFields(JNIEnv *env, jobject lpObject, NMTVCUSTOMDRAW *lpNmtvcustomdraw, NMTVCUSTOMDRAW_FID_CACHE *lpNmtvcustomdrawFc);
+void getOpenfilenameFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpOpenfilename, OPENFILENAME_FID_CACHE *lpOpenfilenameFc);
+void setOpenfilenameFields(JNIEnv *env, jobject lpObject, OPENFILENAME *lpOpenfilename, OPENFILENAME_FID_CACHE *lpOpenfilenameFc);
+void getPagesetupdlgFields(JNIEnv *env, jobject lpObject, PAGESETUPDLG *lpPagesetupdlg, PAGESETUPDLG_FID_CACHE *lpPagesetupdlgFc);
+void setPagesetupdlgFields(JNIEnv *env, jobject lpObject, PAGESETUPDLG *lpPagesetupdlg, PAGESETUPDLG_FID_CACHE *lpPagesetupdlgFc);
+void getPaintstructFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpPaint, PAINTSTRUCT_FID_CACHE *lpPaintFc);
+void setPaintstructFields(JNIEnv *env, jobject lpObject, PAINTSTRUCT *lpPaint, PAINTSTRUCT_FID_CACHE *lpPaintFc);
+/*
+void getParaformatFields(JNIEnv *env, jobject lpObject, PARAFORMAT *lpParaformat, PARAFORMAT_FID_CACHE *lpParaformatFc);
+void setParaformatFields(JNIEnv *env, jobject lpObject, PARAFORMAT *lpParaformat, PARAFORMAT_FID_CACHE *lpParaformatFc);
+*/
+void getPointFields(JNIEnv *env, jobject lpObject, POINT *lpPoint, PPOINT_FID_CACHE lpPointFc);
+void setPointFields(JNIEnv *env, jobject lpObject, POINT *lpPoint, PPOINT_FID_CACHE lpPointFc);
+void getPrintdlgFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpPrintdlg, PRINTDLG_FID_CACHE *lpPrintdlgFc);
+void setPrintdlgFields(JNIEnv *env, jobject lpObject, PRINTDLG *lpPrintdlg, PRINTDLG_FID_CACHE *lpPrintdlgFc);
+void getRebarbandinfoFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpRebarbandinfo, REBARBANDINFO_FID_CACHE *lpRebarbandinfoFc);
+void setRebarbandinfoFields(JNIEnv *env, jobject lpObject, REBARBANDINFO *lpRebarbandinfo, REBARBANDINFO_FID_CACHE *lpRebarbandinfoFc);
+void getRectFields(JNIEnv *env, jobject lpObject, RECT *lpRect, PRECT_FID_CACHE lpRectFc);
+void setRectFields(JNIEnv *env, jobject lpObject, RECT *lpRect, PRECT_FID_CACHE lpRectFc);
+void getScrollinfoFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpScrollinfo, SCROLLINFO_FID_CACHE *lpScrollinfoFc);
+void setScrollinfoFields(JNIEnv *env, jobject lpObject, SCROLLINFO *lpScrollinfo, SCROLLINFO_FID_CACHE *lpScrollinfoFc);
+void getSizeFields(JNIEnv *env, jobject lpObject, SIZE *lpSize, SIZE_FID_CACHE *lpSizeFc);
+void setSizeFields(JNIEnv *env, jobject lpObject, SIZE *lpSize, SIZE_FID_CACHE *lpSizeFc);
+void getTbbuttonFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpTbbutton, TBBUTTON_FID_CACHE *lpTbbuttonFc);
+void setTbbuttonFields(JNIEnv *env, jobject lpObject, TBBUTTON *lpTbbutton, TBBUTTON_FID_CACHE *lpTbbuttonFc);
+void getTbbuttoninfoFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpTbbuttoninfo, TBBUTTONINFO_FID_CACHE *lpTbbuttoninfoFc);
+void setTbbuttoninfoFields(JNIEnv *env, jobject lpObject, TBBUTTONINFO *lpTbbuttoninfo, TBBUTTONINFO_FID_CACHE *lpTbbuttoninfoFc);
+void getTcitemFields(JNIEnv *env, jobject lpObject, TCITEM *lpTcitem, TCITEM_FID_CACHE *lpTcitemFc);
+void setTcitemFields(JNIEnv *env, jobject lpObject, TCITEM *lpTcitem, TCITEM_FID_CACHE *lpTcitemFc);
+void getTextmetricFields(JNIEnv *env, jobject lpObject, TEXTMETRIC *lpTextmetric, TEXTMETRIC_FID_CACHE *lpTextmetricFc);
+void setTextmetricFields(JNIEnv *env, jobject lpObject, TEXTMETRIC *lpTextmetric, TEXTMETRIC_FID_CACHE *lpTextmetricFc);
+void getToolinfoFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpToolinfo, TOOLINFO_FID_CACHE *lpToolinfoFc);
+void setToolinfoFields(JNIEnv *env, jobject lpObject, TOOLINFO *lpToolinfo, TOOLINFO_FID_CACHE *lpToolinfoFc);
+void getTrackmouseeventFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpTrackmouseevent, TRACKMOUSEEVENT_FID_CACHE *lpTrackmouseeventFc);
+void setTrackmouseeventFields(JNIEnv *env, jobject lpObject, TRACKMOUSEEVENT *lpTrackmouseevent, TRACKMOUSEEVENT_FID_CACHE *lpTrackmouseeventFc);
+void getTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc);
+void setTvhittestinfoFields(JNIEnv *env, jobject lpObject, TVHITTESTINFO *lpTvhittestinfo, TVHITTESTINFO_FID_CACHE *lpTvhittestinfoFc);
+void getTvinsertstructFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpTvinsertstruct, TVINSERTSTRUCT_FID_CACHE *lpTvinsertstructFc);
+void setTvinsertstructFields(JNIEnv *env, jobject lpObject, TVINSERTSTRUCT *lpTvinsertstruct, TVINSERTSTRUCT_FID_CACHE *lpTvinsertstructFc);
+void getTvitemFields(JNIEnv *env, jobject lpObject, TVITEM *lpTvitem, TVITEM_FID_CACHE *lpTvitemFc);
+void setTvitemFields(JNIEnv *env, jobject lpObject, TVITEM *lpTvitem, TVITEM_FID_CACHE *lpTvitemFc);
+void getWindowplacementFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpWindowplacement, WINDOWPLACEMENT_FID_CACHE *lpWindowplacementFc);
+void setWindowplacementFields(JNIEnv *env, jobject lpObject, WINDOWPLACEMENT *lpWindowplacement, WINDOWPLACEMENT_FID_CACHE *lpWindowplacementFc);
+void getWindowposFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpWindowpos, WINDOWPOS_FID_CACHE *lpWindowposFc);
+void setWindowposFields(JNIEnv *env, jobject lpObject, WINDOWPOS *lpWindowpos, WINDOWPOS_FID_CACHE *lpWindowposFc);
+void getWndclassexFields(JNIEnv *env, jobject lpObject, WNDCLASSEX *lpWndclassex, WNDCLASSEX_FID_CACHE *lpWndclassexFc);
+void setWndclassexFields(JNIEnv *env, jobject lpObject, WNDCLASSEX *lpWndclassex, WNDCLASSEX_FID_CACHE *lpWndclassexFc);
+/*
+void getShfileinfoFields(JNIEnv *env, jobject lpObject, SHFILEINFO *lpShfileinfo, SHFILEINFO_FID_CACHE *lpShfileinfoFc);
+void setShfileinfoFields(JNIEnv *env, jobject lpObject, SHFILEINFO *lpShfileinfo, SHFILEINFO_FID_CACHE *lpShfileinfoFc);
+*/
+
+/* ----------- ole/activex getter and setter prototypes ----------- */
+void getCauuidFields(JNIEnv *env, jobject lpObject, CAUUID *lpCauuid, CAUUID_FID_CACHE *lpCauuidFc);
+void setCauuidFields(JNIEnv *env, jobject lpObject, CAUUID *lpCauuid, CAUUID_FID_CACHE *lpCauuidFc);
+void getControlinfoFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpControlinfo, CONTROLINFO_FID_CACHE *lpControlinfoFc);
+void setControlinfoFields(JNIEnv *env, jobject lpObject, CONTROLINFO *lpControlinfo, CONTROLINFO_FID_CACHE *lpControlinfoFc);
+void getCoserverinfoFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpCoserverinfo, COSERVERINFO_FID_CACHE *lpCoserverinfoFc);
+void setCoserverinfoFields(JNIEnv *env, jobject lpObject, COSERVERINFO *lpCoserverinfo, COSERVERINFO_FID_CACHE *lpCoserverinfoFc);
+void getDispparamsFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpDispparams, DISPPARAMS_FID_CACHE *lpDispparamsFc);
+void setDispparamsFields(JNIEnv *env, jobject lpObject, DISPPARAMS *lpDispparams, DISPPARAMS_FID_CACHE *lpDispparamsFc);
+void getDropfilesFields(JNIEnv *env, jobject lpObject, DROPFILES *lpDropfiles, DROPFILES_FID_CACHE *lpDropfilesFc);
+void setDropfilesFields(JNIEnv *env, jobject lpObject, DROPFILES *lpDropfiles, DROPFILES_FID_CACHE *lpDropfilesFc);
+void getDvaspectinfoFields(JNIEnv *env, jobject lpObject, DVASPECTINFO *lpDvaspectinfo, DVASPECTINFO_FID_CACHE *lpDvaspectinfoFc);
+void setDvaspectinfoFields(JNIEnv *env, jobject lpObject, DVASPECTINFO *lpDvaspectinfo, DVASPECTINFO_FID_CACHE *lpDvaspectinfoFc);
+void getDvtargetdeviceFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpDvtargetdevice, DVTARGETDEVICE_FID_CACHE *lpDvtargetdeviceFc);
+void setDvtargetdeviceFields(JNIEnv *env, jobject lpObject, DVTARGETDEVICE *lpDvtargetdevice, DVTARGETDEVICE_FID_CACHE *lpDvtargetdeviceFc);
+void getExcepinfoFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpExcepinfo, EXCEPINFO_FID_CACHE *lpExcepinfoFc);
+void setExcepinfoFields(JNIEnv *env, jobject lpObject, EXCEPINFO *lpExcepinfo, EXCEPINFO_FID_CACHE *lpExcepinfoFc);
+void getFiletimeFields(JNIEnv *env, jobject lpObject, FILETIME *lpFiletime, FILETIME_FID_CACHE *lpFiletimeFc);
+void setFiletimeFields(JNIEnv *env, jobject lpObject, FILETIME *lpFiletime, FILETIME_FID_CACHE *lpFiletimeFc);
+void getFormatetcFields(JNIEnv *env, jobject lpObject, FORMATETC *lpFormatetc, FORMATETC_FID_CACHE *lpFormatetcFc);
+void setFormatetcFields(JNIEnv *env, jobject lpObject, FORMATETC *lpFormatetc, FORMATETC_FID_CACHE *lpFormatetcFc);
+void getGuidFields(JNIEnv *env, jobject lpObject, GUID *lpGuid, GUID_FID_CACHE *lpGuidFc);
+void setGuidFields(JNIEnv *env, jobject lpObject, GUID *lpGuid, GUID_FID_CACHE *lpGuidFc);
+void getIdldescFields(JNIEnv *env, jobject lpObject, IDLDESC *lpIdldesc, IDLDESC_FID_CACHE *lpIdldescFc);
+void setIdldescFields(JNIEnv *env, jobject lpObject, IDLDESC *lpIdldesc, IDLDESC_FID_CACHE *lpIdldescFc);
+void getLicinfoFields(JNIEnv *env, jobject lpObject, LICINFO *lpLicinfo, LICINFO_FID_CACHE *lpLicinfoFc);
+void setLicinfoFields(JNIEnv *env, jobject lpObject, LICINFO *lpLicinfo, LICINFO_FID_CACHE *lpLicinfoFc);
+void getMulti_qiFields(JNIEnv *env, jobject lpObject, MULTI_QI *lpMulti_qi, MULTI_QI_FID_CACHE *lpMulti_qiFc);
+void setMulti_qiFields(JNIEnv *env, jobject lpObject, MULTI_QI *lpMulti_qi, MULTI_QI_FID_CACHE *lpMulti_qiFc);
+void getOlecmdFields(JNIEnv *env, jobject lpObject, OLECMD *lpOlecmd, OLECMD_FID_CACHE *lpOlecmdFc);
+void setOlecmdFields(JNIEnv *env, jobject lpObject, OLECMD *lpOlecmd, OLECMD_FID_CACHE *lpOlecmdFc);
+void getOlecmdtextFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpOlecmdtext, OLECMDTEXT_FID_CACHE *lpOlecmdtextFc);
+void setOlecmdtextFields(JNIEnv *env, jobject lpObject, OLECMDTEXT *lpOlecmdtext, OLECMDTEXT_FID_CACHE *lpOlecmdtextFc);
+void getOleinplaceframeinfoFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpOleinplaceframeinfo, OLEINPLACEFRAMEINFO_FID_CACHE *lpOleinplaceframeinfoFc);
+void setOleinplaceframeinfoFields(JNIEnv *env, jobject lpObject, OLEINPLACEFRAMEINFO *lpOleinplaceframeinfo, OLEINPLACEFRAMEINFO_FID_CACHE *lpOleinplaceframeinfoFc);
+void getOleverbFields(JNIEnv *env, jobject lpObject, OLEVERB *lpOleverb, OLEVERB_FID_CACHE *lpOleverbFc);
+void setOleverbFields(JNIEnv *env, jobject lpObject, OLEVERB *lpOleverb, OLEVERB_FID_CACHE *lpOleverbFc);
+void getStgmediumFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStgmedium, STGMEDIUM_FID_CACHE *lpStgmediumFc);
+void setStgmediumFields(JNIEnv *env, jobject lpObject, STGMEDIUM *lpStgmedium, STGMEDIUM_FID_CACHE *lpStgmediumFc);
+void getStatstgFields(JNIEnv *env, jobject lpObject, STATSTG *lpStatstg, STATSTG_FID_CACHE *lpStatstgFc);
+void setStatstgFields(JNIEnv *env, jobject lpObject, STATSTG *lpStatstg, STATSTG_FID_CACHE *lpStatstgFc);
+void getTypeattrFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpTypeattr, TYPEATTR_FID_CACHE *lpTypeattrFc);
+void setTypeattrFields(JNIEnv *env, jobject lpObject, TYPEATTR *lpTypeattr, TYPEATTR_FID_CACHE *lpTypeattrFc);
+void getTypedescFields(JNIEnv *env, jobject lpObject, TYPEDESC *lpTypedesc, TYPEDESC_FID_CACHE *lpTypedescFc);
+void setTypedescFields(JNIEnv *env, jobject lpObject, TYPEDESC *lpTypedesc, TYPEDESC_FID_CACHE *lpTypedescFc);
+void getFuncdesc1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC1_FID_CACHE *lpFuncdescFc);
+void setFuncdesc1Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC1_FID_CACHE *lpFuncdescFc);
+void getFuncdesc2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC2_FID_CACHE *lpFuncdescFc);
+void setFuncdesc2Fields(JNIEnv *env, jobject lpObject, FUNCDESC *lpFuncdesc, FUNCDESC2_FID_CACHE *lpFuncdescFc);
+void getVardesc1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC1_FID_CACHE *lpVardescFc);
+void setVardesc1Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC1_FID_CACHE *lpVardescFc);
+void getVardesc2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC2_FID_CACHE *lpVardescFc);
+void setVardesc2Fields(JNIEnv *env, jobject lpObject, VARDESC *lpVardesc, VARDESC2_FID_CACHE *lpVardescFc);
+
+
+#endif // INC_structs_H \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c
new file mode 100755
index 0000000000..1eb55ee847
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.c
@@ -0,0 +1,7893 @@
+/**
+ * SWT OS natives implementation.
+ */
+
+#include "globals.h"
+#include "structs.h"
+
+/* export the dll version info call */
+
+__declspec(dllexport) HRESULT DllGetVersion(DLLVERSIONINFO *dvi);
+
+HRESULT DllGetVersion(DLLVERSIONINFO *dvi)
+{
+ dvi->dwMajorVersion = SWT_LIBRARY_MAJOR_VERSION;
+ dvi->dwMinorVersion = SWT_LIBRARY_MINOR_VERSION;
+ dvi->dwBuildNumber = SWT_LIBRARY_BUILD_NUM;
+ dvi->dwPlatformID = DLLVER_PLATFORM_WINDOWS;
+ return 1;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Call
+ * Signature: (ILorg/eclipse/swt/internal/win32/DLLVERSIONINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_Call
+ (JNIEnv *env, jclass that, jint address, jobject arg0)
+{
+ DECL_GLOB(pGlob)
+ DLLVERSIONINFO dllversioninfo, *arg01=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Call\n");
+#endif
+
+ if (arg0) {
+ arg01 = &dllversioninfo;
+ cacheDllversioninfoFids(env, arg0, &PGLOB(DllversioninfoFc));
+ getDllversioninfoFields(env, arg0, arg01, &PGLOB(DllversioninfoFc));
+ }
+ rc = ((DLLGETVERSIONPROC)address)(arg01);
+
+ if (arg0) {
+ setDllversioninfoFields(env, arg0, arg01, &PGLOB(DllversioninfoFc));
+ }
+ return rc;
+}
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_win32_OS_getSharedLibraryMajorVersionNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryMajorVersionNumber\n");
+#endif
+ return SWT_LIBRARY_MAJOR_VERSION;
+}
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_win32_OS_getSharedLibraryMinorVersionNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryMinorVersionNumber\n");
+#endif
+ return SWT_LIBRARY_MINOR_VERSION;
+}
+
+JNIEXPORT int JNICALL Java_org_eclipse_swt_internal_win32_OS_getSharedLibraryBuildNumber
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "getSharedLibraryBuildNumber\n");
+#endif
+ return SWT_LIBRARY_BUILD_NUM;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: AbortDoc
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_AbortDoc
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "AbortDoc\n");
+#endif
+ return (jint) AbortDoc((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: AdjustWindowRectEx
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;IZI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_AdjustWindowRectEx
+ (JNIEnv *env, jclass that, jobject lpRect, jint dwStyle, jboolean bMenu, jint dwExStyle)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "AdjustWindowRectEx\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) AdjustWindowRectEx(lpRect1, dwStyle, bMenu, dwExStyle);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Arc
+ * Signature: (IIIIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_Arc
+ (JNIEnv *env, jclass that, jint hdc, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect, jint nXStartArc,jint nYStartArc, jint nXEndArc, jint nYEndArc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Arc\n");
+#endif
+
+ return (jboolean) Arc((HDC)hdc, nLeftRect, nTopRect, nRightRect, nBottomRect, nXStartArc, nYStartArc, nXEndArc, nYEndArc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: BitBlt
+ * Signature: (IIIIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_BitBlt
+ (JNIEnv *env, jclass that, jint hdcDest, jint nXDest, jint nYDest, jint nWidth, jint nHeight, jint hdcSrc, jint nXSrc, jint nYSrc, jint dwRop)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "BitBlt\n");
+#endif
+
+ return (jboolean) BitBlt((HDC)hdcDest, nXDest, nYDest, nWidth, nHeight, (HDC)hdcSrc, nXSrc, nYSrc, dwRop);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: BeginDeferWindowPos
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_BeginDeferWindowPos
+ (JNIEnv *env, jclass that, jint numWindows)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "BeginDeferWindowPos\n");
+#endif
+
+ return (jint) BeginDeferWindowPos(numWindows);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: BeginPaint
+ * Signature: (ILorg/eclipse/swt/internal/win32/PAINTSTRUCT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_BeginPaint
+ (JNIEnv *env, jclass that, jint hwnd, jobject lpPaint)
+{
+ DECL_GLOB(pGlob)
+ PAINTSTRUCT paint, *lpPaint1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "BeginPaint\n");
+#endif
+
+ lpPaint1 = &paint;
+ rc = (jint) BeginPaint((HWND)hwnd, lpPaint1);
+
+ if (lpPaint) {
+ cachePaintstructFids(env, lpPaint, &PGLOB(PaintstructFc));
+ setPaintstructFields(env, lpPaint, lpPaint1, &PGLOB(PaintstructFc));
+ /* we do not touch rgbReserved byte array of the PAINTSTRUCT */
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: BringWindowToTop
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_BringWindowToTop
+ (JNIEnv *env, jclass that, jint hwnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "BringWindowToTop\n");
+#endif
+
+ return (jboolean) BringWindowToTop((HWND)hwnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CallWindowProc
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CallWindowProc
+ (JNIEnv *env, jclass that,jint lpPrevWndFunc, jint hWnd, jint Msg, jint wParam, jint lParam)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CallWindowProc\n");
+#endif
+
+ return (jint) CallWindowProc((WNDPROC)lpPrevWndFunc,(HWND)hWnd, Msg, wParam, lParam);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CharLower
+ * Signature: (S)S
+ */
+JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_win32_OS_CharLower
+ (JNIEnv *env, jclass that, jshort lpsz)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CharLower\n");
+#endif
+
+ return (jshort) CharLower((LPSTR) lpsz);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CharUpper
+ * Signature: (S)S
+ */
+JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_win32_OS_CharUpper
+ (JNIEnv *env, jclass that, jshort lpsz)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CharUpper\n");
+#endif
+
+ return (jshort) CharUpper((LPSTR) lpsz);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ChooseColor
+ * Signature: (Lorg/eclipse/swt/internal/win32/CHOOSECOLOR;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ChooseColor
+ (JNIEnv *env, jclass that, jobject lpcc)
+{
+ DECL_GLOB(pGlob)
+ CHOOSECOLOR choosecolor, *lpcc1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ChooseColor\n");
+#endif
+
+ if (lpcc) {
+ lpcc1 = &choosecolor;
+ cacheChoosecolorFids(env, lpcc, &PGLOB(ChoosecolorFc));
+ getChoosecolorFields(env, lpcc, lpcc1, &PGLOB(ChoosecolorFc));
+ }
+ rc = (jboolean) ChooseColor((LPCHOOSECOLOR) lpcc1);
+ if (lpcc) {
+ setChoosecolorFields(env, lpcc, lpcc1, &PGLOB(ChoosecolorFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ChooseFont
+ * Signature: (Lorg/eclipse/swt/internal/win32/CHOOSEFONT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ChooseFont
+ (JNIEnv *env, jclass that, jobject chooseFont)
+{
+ DECL_GLOB(pGlob)
+ CHOOSEFONT choosefont, *chooseFont1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ChooseFont\n");
+#endif
+
+ if (chooseFont) {
+ chooseFont1 = &choosefont;
+ cacheChoosefontFids(env, chooseFont, &PGLOB(ChoosefontFc));
+ getChoosefontFields(env, chooseFont, chooseFont1, &PGLOB(ChoosefontFc));
+ }
+ rc = (jboolean) ChooseFont((LPCHOOSEFONT) chooseFont1);
+ if (chooseFont) {
+ setChoosefontFields(env, chooseFont, chooseFont1, &PGLOB(ChoosefontFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ClientToScreen
+ * Signature: (ILorg/eclipse/swt/internal/win32/POINT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ClientToScreen
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpPoint)
+{
+ DECL_GLOB(pGlob)
+ POINT point, *lpPoint1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ClientToScreen\n");
+#endif
+
+ if (lpPoint) {
+ lpPoint1 = &point;
+ cachePointFids(env, lpPoint, &PGLOB(PointFc));
+ getPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ rc = (jboolean) ClientToScreen((HWND)hWnd, lpPoint1);
+ if (lpPoint) {
+ setPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CloseClipboard
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_CloseClipboard
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CloseClipboard\n");
+#endif
+ return (jboolean) CloseClipboard();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CombineRgn
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CombineRgn
+ (JNIEnv *env, jclass that, jint hrgnDest, jint hrgnSrc1, jint hrgnSrc2, jint fnCombineMode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CombineRgn\n");
+#endif
+
+ return (jint) CombineRgn( (HRGN)hrgnDest, (HRGN)hrgnSrc1, (HRGN)hrgnSrc2, fnCombineMode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CommDlgExtendedError
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CommDlgExtendedError
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CommDlgExtendedError\n");
+#endif
+
+ return (jint) CommDlgExtendedError();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CopyImage
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CopyImage
+ (JNIEnv *env, jclass that, jint hImage, jint uType, jint cxDesired, jint cyDesired, jint fuFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CopyImage\n");
+#endif
+
+ return (jint)CopyImage((HANDLE)hImage, uType, cxDesired, cyDesired, fuFlags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateAcceleratorTable
+ * Signature: ([BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateAcceleratorTable
+ (JNIEnv *env, jclass that, jbyteArray lpAccel, jint cEntries)
+{
+ LPACCEL lpAccel1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateAcceleratorTable\n");
+#endif
+
+ if (lpAccel)
+ lpAccel1 = (LPACCEL)(*env)->GetByteArrayElements(env, lpAccel, NULL);
+
+ rc = (jint)CreateAcceleratorTable(lpAccel1, cEntries);
+
+ if (lpAccel)
+ (*env)->ReleaseByteArrayElements(env, lpAccel, (jbyte *)lpAccel1, 0);
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateBitmap
+ * Signature: (IIII[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateBitmap
+ (JNIEnv *env, jclass that, jint nWidth, jint nHeight, jint cPlanes, jint cBitsPerPel, jbyteArray lpvBits)
+{
+ LPVOID lpvBits1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateBitmap\n");
+#endif
+
+ if (lpvBits)
+ lpvBits1 = (LPVOID)(*env)->GetByteArrayElements(env, lpvBits, NULL);
+
+ rc = (jint)CreateBitmap(nWidth, nHeight, cPlanes, cBitsPerPel, (CONST VOID *)lpvBits1);
+
+ if (lpvBits)
+ (*env)->ReleaseByteArrayElements(env, lpvBits, (jbyte *)lpvBits1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateCompatibleBitmap
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateCompatibleBitmap
+ (JNIEnv *env, jclass that, jint hdc, jint nWidth, jint nHeight)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateCompatibleBitmap\n");
+#endif
+
+ return (jint) CreateCompatibleBitmap((HDC)hdc, nWidth, nHeight);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateCaret
+ * Signature: (IIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateCaret
+ (JNIEnv *env, jclass that, jint hWnd, jint hBitMap, jint nWidth, jint nHeight)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateCaret\n");
+#endif
+
+ return (jboolean) CreateCaret( (HWND) hWnd, (HBITMAP)hBitMap, nWidth, nHeight);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateCompatibleDC
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateCompatibleDC
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateCompatibleDC\n");
+#endif
+
+ return (jint) CreateCompatibleDC((HDC) hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateCursor
+ * Signature: (IIIII[B[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateCursor
+ (JNIEnv *env, jclass that, jint hInst, jint xHotSpot, jint yHotSpot, jint nWidth, jint nHeight, jbyteArray pvANDPlane, jbyteArray pvXORPlane)
+{
+ CONST VOID *pvANDPlane1=NULL;
+ CONST VOID *pvXORPlane1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateCursor\n");
+#endif
+
+ if (pvANDPlane)
+ pvANDPlane1 = (CONST VOID *)(*env)->GetByteArrayElements(env,pvANDPlane, NULL);
+
+ if (pvXORPlane)
+ pvXORPlane1 = (CONST VOID *)(*env)->GetByteArrayElements(env,pvXORPlane, NULL);
+
+ rc = (jint)CreateCursor((HINSTANCE) hInst, xHotSpot, yHotSpot, nWidth, nHeight, pvANDPlane1, pvXORPlane1);
+
+ if (pvANDPlane)
+ (*env)->ReleaseByteArrayElements(env, pvANDPlane, (jbyte *)pvANDPlane1, 0);
+
+ if (pvXORPlane)
+ (*env)->ReleaseByteArrayElements(env, pvXORPlane, (jbyte *)pvXORPlane1, 0);
+
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateDC
+ * Signature: ([B[BII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateDC
+ (JNIEnv *env, jclass that, jbyteArray lpszDriver, jbyteArray lpszDevice, jint lpszOutput, jint lpInitData)
+{
+ LPCTSTR lpszDriver1=NULL;
+ LPCTSTR lpszDevice1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateDC\n");
+#endif
+
+ if (lpszDriver)
+ lpszDriver1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpszDriver, NULL);
+
+ if (lpszDevice)
+ lpszDevice1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpszDevice, NULL);
+
+ rc = (jint)CreateDC(lpszDriver1, lpszDevice1, (LPCTSTR)lpszOutput, (CONST DEVMODE *)lpInitData);
+
+ if (lpszDriver)
+ (*env)->ReleaseByteArrayElements(env, lpszDriver, (jbyte *)lpszDriver1, 0);
+
+ if (lpszDevice)
+ (*env)->ReleaseByteArrayElements(env, lpszDevice, (jbyte *)lpszDevice1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateDIBSection
+ * Signature: (I[BI[III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateDIBSection
+ (JNIEnv *env, jclass that, jint hdc, jbyteArray pbmi, jint iUsage, jintArray ppvBits, jint hSection, jint dwOffset)
+{
+ BITMAPINFO *pbmi1=NULL;
+ PVOID *ppvBits1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateDIBSection\n");
+#endif
+
+ if (pbmi)
+ pbmi1 = (BITMAPINFO *)(*env)->GetByteArrayElements(env,pbmi, NULL);
+
+ if (ppvBits)
+ ppvBits1 = (PVOID *)(*env)->GetIntArrayElements(env, ppvBits, NULL);
+
+
+ rc = (jint)CreateDIBSection((HDC)hdc, pbmi1, iUsage, ppvBits1, (HANDLE)hSection, dwOffset);
+
+ if (pbmi)
+ (*env)->ReleaseByteArrayElements(env, pbmi, (jbyte *)pbmi1, 0);
+
+ if (ppvBits)
+ (*env)->ReleaseIntArrayElements(env, ppvBits, (jint *)ppvBits1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateFontIndirect
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateFontIndirect__I
+ (JNIEnv *env, jclass that, jint lplf)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateFontIndirect__I\n");
+#endif
+ return (jint) CreateFontIndirect((LOGFONT *)lplf);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateFontIndirect
+ * Signature: (Lorg/eclipse/swt/internal/win32/LOGFONT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateFontIndirect__Lorg_eclipse_swt_internal_win32_LOGFONT_2
+ (JNIEnv *env, jclass that, jobject lpLogFont)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *lpLogFont1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateFontIndirect__Lorg_eclipse_swt_internal_win32_LOGFONT_2\n");
+#endif
+
+ if (lpLogFont) {
+ lpLogFont1 = &logfont;
+ cacheLogfontFids(env, lpLogFont, &PGLOB(LogfontFc));
+ getLogfontFields(env, lpLogFont, lpLogFont1, &PGLOB(LogfontFc));
+ }
+ return (jint) CreateFontIndirect(lpLogFont1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateIconIndirect
+ * Signature: (Lorg/eclipse/swt/internal/win32/ICONINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateIconIndirect
+ (JNIEnv *env, jclass that, jobject lplf)
+{
+ DECL_GLOB(pGlob)
+ ICONINFO iconinfo, *lplf1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateIconIndirect\n");
+#endif
+
+ if (lplf) {
+ lplf1 = &iconinfo;
+ cacheIconinfoFids(env, lplf, &PGLOB(IconinfoFc));
+ getIconinfoFields(env, lplf, lplf1, &PGLOB(IconinfoFc));
+ }
+ rc = (jint) CreateIconIndirect(lplf1);
+ if (lplf) {
+ setIconinfoFields(env, lplf, lplf1, &PGLOB(IconinfoFc));
+ }
+ return rc;
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateBitmapIndirect
+ * Signature: (Lorg/eclipse/swt/internal/win32/BITMAP;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateBitmapIndirect
+ (JNIEnv *env, jclass that, jobject lpbm)
+{
+ DECL_GLOB(pGlob)
+ BITMAP bm, *lpbm1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateBitmapIndirect\n");
+#endif
+
+ if (lpbm) {
+ lpbm1= &bm;
+ cacheBitmapFids(env, lpbm, &PGLOB(BitmapFc));
+ getBitmapFields(env, lpbm, lpbm1, &PGLOB(BitmapFc));
+ }
+ rc = (jint) CreateBitmapIndirect(lpbm1);
+ if (lpbm) {
+ setBitmapFields(env, lpbm, lpbm1, &PGLOB(BitmapFc));
+ }
+ return rc;
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateMenu
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateMenu
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateMenu\n");
+#endif
+
+ return (jint) CreateMenu();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreatePalette
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreatePalette
+ (JNIEnv *env, jclass that, jbyteArray logPalette)
+{
+ jbyte *logPalette1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreatePalette\n");
+#endif
+
+ if (logPalette)
+ logPalette1 = (*env)->GetByteArrayElements(env, logPalette, NULL);
+
+ rc = (jint) CreatePalette( (LOGPALETTE *) logPalette1);
+
+ if (logPalette)
+ (*env)->ReleaseByteArrayElements(env, logPalette, (jbyte *)logPalette1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreatePatternBrush
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreatePatternBrush
+ (JNIEnv *env, jclass that, jint colorRef)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreatePatternBrush\n");
+#endif
+
+ return (jint) CreatePatternBrush((HBITMAP)colorRef);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreatePen
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreatePen
+ (JNIEnv *env, jclass that, jint fnPenStyle, jint nWidth, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreatePen\n");
+#endif
+
+ return (jint) CreatePen(fnPenStyle, nWidth, (COLORREF)crColor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ExtCreatePen
+ * Signature: (IILorg/eclipse/swt/internal/win32/LOGBRUSH;II)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ExtCreatePen
+ (JNIEnv *env, jclass that, jint dwPenStyle, jint dwWidth, jobject lplb, int dwStyleCount, int lpStyle)
+{
+ DECL_GLOB(pGlob)
+ LOGBRUSH logbrush, *lplb1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ExtCreatePen\n");
+#endif
+
+ if (lplb) {
+ lplb1 = &logbrush;
+ cacheLogbrushFids(env, lplb, &PGLOB(LogbrushFc));
+ getLogbrushFields(env, lplb, lplb1, &PGLOB(LogbrushFc));
+ }
+ rc = (jint) ExtCreatePen(dwPenStyle, dwWidth, (CONST LOGBRUSH *)lplb1, dwStyleCount, (CONST DWORD *)lpStyle);
+
+ if (lplb) {
+ setLogbrushFields(env, lplb, lplb1, &PGLOB(LogbrushFc));
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreatePopupMenu
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreatePopupMenu
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreatePopupMenu\n");
+#endif
+
+ return (jint) CreatePopupMenu();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method:
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateRectRgn
+ (JNIEnv *env, jclass that, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateRectRgn\n");
+#endif
+
+ return (jint) CreateRectRgn(nLeftRect, nTopRect, nRightRect, nBottomRect);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateSolidBrush
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateSolidBrush
+ (JNIEnv *env, jclass that, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "\n");
+#endif
+
+ return (jint) CreateSolidBrush((COLORREF)crColor) ;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CreateWindowEx
+ * Signature: (I[B[BIIIIIIIILorg/eclipse/swt/internal/win32/CREATESTRUCT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CreateWindowEx
+ (JNIEnv *env, jclass that, jint dwExStyle, jbyteArray buff1, jbyteArray buff2,
+ jint dwStyle, jint X, jint Y, jint nWidth, jint nHeight,
+ jint hWndParent, jint hMenu, jint hInstance, jobject lpParam)
+{
+ DECL_GLOB(pGlob)
+ LPCTSTR lpClassName=NULL, lpWindowName=NULL;
+ CREATESTRUCT param, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CreateWindowEx\n");
+#endif
+
+ if (lpParam) {
+ lpParam1 = &param;
+ cacheCreatestructFids(env, lpParam, &PGLOB(CreatestructFc));
+ getCreatestructFields(env, lpParam, lpParam1, &PGLOB(CreatestructFc));
+ }
+ if (buff1)
+ lpClassName = (*env)->GetByteArrayElements(env, buff1, NULL);
+ if (buff2)
+ lpWindowName = (*env)->GetByteArrayElements(env, buff2, NULL);
+
+ rc = (jint) CreateWindowEx (dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight,
+ (HWND)hWndParent, (HMENU)hMenu, (HINSTANCE) hInstance, lpParam1);
+
+ if (buff1)
+ (*env)->ReleaseByteArrayElements(env, buff1, (jbyte *)lpClassName, 0);
+ if (buff2)
+ (*env)->ReleaseByteArrayElements(env, buff2, (jbyte *)lpWindowName, 0);
+
+ if (lpParam) {
+ setCreatestructFields(env, lpParam, lpParam1, &PGLOB(CreatestructFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DeferWindowPos
+ * Signature: (IIIIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_DeferWindowPos
+ (JNIEnv *env, jclass that, jint hWinPosInfo, jint hWnd, jint hWndInsertAfter, jint x, jint y, jint cx, jint cy, jint uFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DeferWindowPos\n");
+#endif
+
+ return (jint) DeferWindowPos((HDWP)hWinPosInfo, (HWND)hWnd, (HWND)hWndInsertAfter, x, y, cx, cy, uFlags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DefWindowProc
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_DefWindowProc
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jint lParam)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DefWindowProc\n");
+#endif
+
+ return (jint) DefWindowProc((HWND)hWnd, Msg, (WPARAM)wParam, (LPARAM)lParam);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DeleteDC
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DeleteDC
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DeleteDC\n");
+#endif
+
+ return (jboolean) DeleteDC((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DeleteMenu
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DeleteMenu
+ (JNIEnv *env, jclass that, jint hMenu, jint uPosition, jint uFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DeleteMenu\n");
+#endif
+
+ return (jboolean) DeleteMenu((HMENU)hMenu, uPosition, uFlags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DeleteObject
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DeleteObject
+ (JNIEnv *env, jclass that, jint hObject)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DeleteObject\n");
+#endif
+
+ return (jboolean) DeleteObject((HGDIOBJ)hObject);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DestroyAcceleratorTable
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DestroyAcceleratorTable
+ (JNIEnv *env, jclass that, jint hAccel)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DestroyAcceleratorTable\n");
+#endif
+
+ return (jboolean) DestroyAcceleratorTable((HACCEL) hAccel);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DestroyCaret
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DestroyCaret
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DestroyCaret\n");
+#endif
+
+ return (jboolean) DestroyCaret();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DestroyCursor
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DestroyCursor
+ (JNIEnv *env, jclass that, jint hCursor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DestroyCursor\n");
+#endif
+
+ return (jboolean) DestroyCursor((HCURSOR)hCursor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DestroyIcon
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DestroyIcon
+ (JNIEnv *env, jclass that, jint hIcon)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DestroyIcon\n");
+#endif
+
+ return (jboolean) DestroyIcon((HICON)hIcon);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DestroyMenu
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DestroyMenu
+ (JNIEnv *env, jclass that, jint hMenu)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DestroyMenu\n");
+#endif
+
+ return (jboolean) DestroyMenu((HMENU) hMenu);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DestroyWindow
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DestroyWindow
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DestroyWindow\n");
+#endif
+
+ return (jboolean) DestroyWindow((HWND) hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DispatchMessage
+ * Signature: (Lorg/eclipse/swt/internal/win32/MSG;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_DispatchMessage
+ (JNIEnv *env, jclass that, jobject lpMsg)
+{
+ DECL_GLOB(pGlob)
+ MSG callBack, *lpMsg1 = NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DispatchMessage\n");
+#endif
+
+ if (lpMsg) {
+ lpMsg1 = &callBack;
+ cacheMsgFids(env, lpMsg, &PGLOB(MsgFc));
+ getMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ return (jint) DispatchMessage(lpMsg1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DragDetect
+ * Signature: (ILorg/eclipse/swt/internal/win32/POINT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DragDetect
+ (JNIEnv *env, jclass that, jint hwnd, jobject pt)
+{
+ DECL_GLOB(pGlob)
+ POINT point, *pt1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DragDetect\n");
+#endif
+
+ if (pt) {
+ pt1 = &point;
+ cachePointFids(env, pt, &PGLOB(PointFc));
+ getPointFields(env, pt, pt1, &PGLOB(PointFc));
+ }
+ return (jboolean) DragDetect((HWND)hwnd, *pt1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawEdge
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawEdge
+ (JNIEnv *env, jclass that, jint hdc, jobject lpRect, jint edge, jint grfFlags)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawEdge\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) DrawEdge((HDC)hdc, lpRect1, edge, grfFlags);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc)); }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawFocusRect
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawFocusRect
+ (JNIEnv *env, jclass that, jint hdc, jobject lpRect)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawFocusRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) DrawFocusRect((HDC)hdc, lpRect1);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc)); }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawFrameControl
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawFrameControl
+ (JNIEnv *env, jclass that, jint hdc, jobject lprc, jint uType, jint uState)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lprc1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawFrameControl\n");
+#endif
+
+ if (lprc) {
+ lprc1 = &rect;
+ cacheRectFids(env, lprc, &PGLOB(RectFc));
+ getRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) DrawFrameControl((HDC)hdc, lprc1, uType, uState);
+ if (lprc) {
+ setRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawIconEx
+ * Signature: (IIIIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawIconEx
+ (JNIEnv *env, jclass that, jint hdc, jint xLeft, jint yTop, jint hIcom,
+ jint cxWidth, jint cyWidth, jint istepIfAniCur,
+ jint hbrFlickerFreeDraw, jint diFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawIconEx\n");
+#endif
+
+ return (jboolean) DrawIconEx((HDC)hdc, xLeft, yTop, (HICON)hIcom, cxWidth,
+ cyWidth, istepIfAniCur, (HBRUSH)hbrFlickerFreeDraw,
+ diFlags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawMenuBar
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawMenuBar
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawMenuBar\n");
+#endif
+
+ return (jboolean) DrawMenuBar((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawText
+ * Signature: (I[BILorg/eclipse/swt/internal/win32/RECT;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawText
+ (JNIEnv *env, jclass that, jint hDC, jbyteArray lpString, jint nCount, jobject lpRect, jint uFormat)
+{
+ DECL_GLOB(pGlob)
+ LPCTSTR lpString1=NULL;
+ RECT rect, *lpRect1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawText\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+
+ if (lpString)
+ lpString1 = (*env)->GetByteArrayElements(env, lpString, NULL);
+
+ rc = (jint) DrawText((HDC)hDC, lpString1, nCount, lpRect1, uFormat);
+
+ if (lpString)
+ (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
+
+ if (lpRect)
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Ellipse
+ * Signature: (IIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_Ellipse
+ (JNIEnv *env, jclass that, jint hdc, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Ellipse\n");
+#endif
+
+ return (jboolean) Ellipse((HDC)hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EnableMenuItem
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EnableMenuItem
+ (JNIEnv *env, jclass that, jint hMenu, jint uIDEnableItem, jint uEnable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EnableMenuItem\n");
+#endif
+
+ return (jboolean) EnableMenuItem((HMENU)hMenu, uIDEnableItem, uEnable);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EnableScrollBar
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EnableScrollBar
+ (JNIEnv *env, jclass that, jint hWnd, jint wSBflags, jint wArrows)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EnableScrollBar\n");
+#endif
+
+ return (jboolean) EnableScrollBar((HWND)hWnd, wSBflags, wArrows);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EnableWindow
+ * Signature: (IZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EnableWindow
+ (JNIEnv *env, jclass that, jint hWnd, jboolean bEnable)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EnableWindow\n");
+#endif
+
+ return (jboolean) EnableWindow((HWND)hWnd, bEnable);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EndDeferWindowPos
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EndDeferWindowPos
+ (JNIEnv *env, jclass that, jint hWinPosInfo)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EndDeferWindowPos\n");
+#endif
+
+ return (jboolean) EndDeferWindowPos((HDWP)hWinPosInfo);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EndDoc
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_EndDoc
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EndDoc\n");
+#endif
+ return (jint) EndDoc((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EndPage
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_EndPage
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EndPage\n");
+#endif
+ return (jint) EndPage((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EndPaint
+ * Signature: (ILorg/eclipse/swt/internal/win32/;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_EndPaint
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpPaint)
+{
+ PAINTSTRUCT paint, *lpPaint1=NULL;
+ jclass paintClass;
+ jfieldID fid;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EndPaint\n");
+#endif
+
+ if (lpPaint) {
+ paintClass = (*env)->GetObjectClass(env,lpPaint);
+ lpPaint1=&paint;
+
+ fid = (*env)->GetFieldID(env,paintClass,"hdc","I");
+ lpPaint1->hdc = (void *) (*env)->GetIntField(env,lpPaint,fid);
+ }
+ rc = (jint)EndPaint((HWND)hWnd, lpPaint1);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EnumFontFamilies
+ * Signature: (I[BII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_EnumFontFamilies
+ (JNIEnv *env, jclass that, jint hdc, jbyteArray lpszFamily, jint lpEnumFontFamProc, jint lParam)
+{
+ LPCTSTR lpszFamily1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EnumFontFamilies\n");
+#endif
+
+ if (lpszFamily)
+ lpszFamily1 = (*env)->GetByteArrayElements(env, lpszFamily, NULL);
+
+ rc = (jint) EnumFontFamilies((HDC)hdc, lpszFamily1, (FONTENUMPROC)lpEnumFontFamProc, (LPARAM)lParam);
+
+ if (lpszFamily)
+ (*env)->ReleaseByteArrayElements(env, lpszFamily, (jbyte *)lpszFamily1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EnumFontFamiliesEx
+ * Signature: (ILorg/eclipse/swt/internal/win32/LOGFONT;III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_EnumFontFamiliesEx
+ (JNIEnv *env, jclass that, jint hdc, jobject lpLogfont, jint lpEnumFontFamExProc, jint lParam, jint dwFlags)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *lpLogfont1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EnumFontFamiliesEx\n");
+#endif
+ if (lpLogfont) {
+ lpLogfont1 = &logfont;
+ cacheLogfontFids(env, lpLogfont, &PGLOB(LogfontFc));
+ getLogfontFields(env, lpLogfont, lpLogfont1, &PGLOB(LogfontFc));
+ }
+ rc = (jint) EnumFontFamiliesEx((HDC)hdc, lpLogfont1, (FONTENUMPROC)lpEnumFontFamExProc, lParam, dwFlags);
+ if (lpLogfont) {
+ setLogfontFields(env, lpLogfont, lpLogfont1, &PGLOB(LogfontFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EqualRgn
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EqualRgn
+ (JNIEnv *env, jclass that, jint hSrcRgn1, jint hSrcRgn2)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EqualRgn\n");
+#endif
+
+ return (jboolean) EqualRgn((HRGN)hSrcRgn1, (HRGN)hSrcRgn2);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ExpandEnvironmentStrings
+ * Signature: ([B[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ExpandEnvironmentStrings
+ (JNIEnv *env, jclass that, jbyteArray lpSrc, jbyteArray lpDest, jint nSize)
+{
+ LPCTSTR lpSrc1=NULL;
+ LPTSTR lpDest1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ExpandEnvironmentStrings\n");
+#endif
+
+ if (lpSrc)
+ lpSrc1 = (*env)->GetByteArrayElements(env, lpSrc, NULL);
+ if (lpDest)
+ lpDest1 = (*env)->GetByteArrayElements(env, lpDest, NULL);
+
+ rc = (jint) ExpandEnvironmentStrings(lpSrc1, lpDest1, nSize);
+
+ if (lpSrc)
+ (*env)->ReleaseByteArrayElements(env, lpSrc, (jbyte *)lpSrc1, 0);
+ if (lpDest)
+ (*env)->ReleaseByteArrayElements(env, lpDest, (jbyte *)lpDest1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ExtractIconEx
+ * Signature: ([BI[I[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ExtractIconEx
+ (JNIEnv *env, jclass that, jbyteArray lpszFile, jint nIconIndex, jintArray phiconLarge, jintArray phiconSmall, jint nIcons)
+{
+ LPCTSTR lpszFile1=NULL;
+ HICON FAR *phiconLarge1=NULL, *phiconSmall1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ExtractIconEx\n");
+#endif
+
+ if (lpszFile)
+ lpszFile1 = (*env)->GetByteArrayElements(env, lpszFile, NULL);
+ if (phiconLarge)
+ phiconLarge1 = (HICON FAR *)(*env)->GetIntArrayElements(env, phiconLarge, NULL);
+ if (phiconSmall)
+ phiconSmall1 = (HICON FAR *)(*env)->GetIntArrayElements(env, phiconSmall, NULL);
+
+ rc = (jint) ExtractIconEx( lpszFile1, nIconIndex, phiconLarge1, phiconSmall1, nIcons);
+
+ if (lpszFile)
+ (*env)->ReleaseByteArrayElements(env, lpszFile, (jbyte *)lpszFile1, 0);
+ if (phiconLarge)
+ (*env)->ReleaseIntArrayElements(env, phiconLarge, (jint *)phiconLarge1, 0);
+ if (phiconSmall)
+ (*env)->ReleaseIntArrayElements(env, phiconSmall, (jint *)phiconSmall1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: FillRect
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_FillRect
+ (JNIEnv *env, jclass that, jint hDC, jobject lpRect, jint hbr)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "FillRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jint) FillRect((HDC)hDC, lpRect1, (HBRUSH) hbr);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: FreeLibrary
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_FreeLibrary
+ (JNIEnv *env, jclass that, jint hLibModule)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "FreeLibrary\n");
+#endif
+
+ return (jboolean) FreeLibrary((HMODULE) hLibModule);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetACP
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetACP
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetACP\n");
+#endif
+
+ return (jint)GetACP();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetActiveWindow
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetActiveWindow
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetActiveWindow\n");
+#endif
+
+ return (jint)GetActiveWindow();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetBkColor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetBkColor
+ (JNIEnv *env, jclass that, jint hDC)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetBkColor\n");
+#endif
+
+ return (jint) GetBkColor((HDC)hDC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCapture
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCapture
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCapture\n");
+#endif
+
+ return (jint)GetCapture();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCaretPos
+ * Signature: (Lorg/eclipse/swt/internal/win32/POINT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCaretPos
+ (JNIEnv *env, jclass that, jobject lpPoint)
+{
+ DECL_GLOB(pGlob)
+ POINT point, *lpPoint1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCaretPos\n");
+#endif
+
+ if (lpPoint) {
+ lpPoint1 = &point;
+ cachePointFids(env, lpPoint, &PGLOB(PointFc));
+ getPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ rc = (jboolean) GetCaretPos(lpPoint1);
+ if (lpPoint) {
+ setPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCharABCWidths
+ * Signature: (III[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCharABCWidths
+ (JNIEnv *env, jclass that, jint hdc, jint iFirstChar, jint iLastChar, jintArray lpabc)
+{
+ LPABC lpabc1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCharABCWidths\n");
+#endif
+
+ if (lpabc)
+ lpabc1 = (LPABC)(*env)->GetIntArrayElements(env, lpabc, NULL);
+
+ rc = (jboolean) GetCharABCWidths((HDC)hdc, iFirstChar, iLastChar, lpabc1);
+
+ if (lpabc)
+ (*env)->ReleaseIntArrayElements(env, lpabc, (jint *)lpabc1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCharWidth
+ * Signature: (III[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCharWidth
+ (JNIEnv *env, jclass that, jint hdc, jint iFirstCharacter, jint iLastCharacter, jintArray lpBuffer)
+{
+ LPINT lpBuffer1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCharWidth\n");
+#endif
+
+ if (lpBuffer)
+ lpBuffer1 = (LPINT)(*env)->GetIntArrayElements(env, lpBuffer, NULL);
+
+ rc = (jboolean) GetCharWidth((HDC)hdc, iFirstCharacter, iLastCharacter, lpBuffer1);
+
+ if (lpBuffer)
+ (*env)->ReleaseIntArrayElements(env, lpBuffer, (jint *)lpBuffer1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetClassInfoEx
+ * Signature: (I[BLorg/eclipse/swt/internal/win32/WNDCLASSEX;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetClassInfoEx
+ (JNIEnv *env, jclass that, jint hinst, jbyteArray lpszClass, jobject lpwcx)
+{
+ DECL_GLOB(pGlob)
+ LPCTSTR lpszClass1=NULL;
+ WNDCLASSEX wcx, *lpwcx1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClassInfoEx\n");
+#endif
+
+ if (lpszClass)
+ lpszClass1 = (*env)->GetByteArrayElements(env, lpszClass, NULL);
+
+ if (lpwcx) {
+ lpwcx1 = &wcx;
+ cacheWndclassexFids(env, lpwcx, &PGLOB(WndclassexFc));
+ getWndclassexFields(env, lpwcx, lpwcx1, &PGLOB(WndclassexFc));
+ }
+ rc = (jboolean) GetClassInfoEx((HINSTANCE)hinst, lpszClass1, &wcx);
+
+ if (lpwcx) {
+ setWndclassexFields(env, lpwcx, lpwcx1, &PGLOB(WndclassexFc));
+ }
+ if (lpszClass)
+ (*env)->ReleaseByteArrayElements(env, lpszClass, (jbyte *)lpszClass1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetClientRect
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetClientRect
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpRect)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClientRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) GetClientRect((HWND)hWnd, lpRect1);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetClipboardData
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetClipboardData
+ (JNIEnv *env, jclass that, jint uFormat)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClipboardData\n");
+#endif
+ return (jint) GetClipboardData(uFormat);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetClipBox
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetClipBox
+ (JNIEnv *env, jclass that, jint hdc, jobject lprc)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lprc1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClipBox\n");
+#endif
+
+ if (lprc) {
+ lprc1 = &rect;
+ cacheRectFids(env, lprc, &PGLOB(RectFc));
+ getRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ rc = (jint) GetClipBox((HDC)hdc, lprc1);
+ if (lprc) {
+ setRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCursor
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCursor
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCursor\n");
+#endif
+
+ return (jint) GetCursor();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetClipRgn
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetClipRgn
+ (JNIEnv *env, jclass that, jint hdc, jint hrgn)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClipRgn\n");
+#endif
+ return (jint) GetClipRgn((HDC)hdc, (HRGN)hrgn);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCurrentObject
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCurrentObject
+ (JNIEnv *env, jclass that, jint hdc, jint uObjectType)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCurrentObject\n");
+#endif
+
+ return (jint)GetCurrentObject((HDC)hdc, uObjectType);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCurrentProcessId
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCurrentProcessId
+ (JNIEnv * env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCurrentProcessId\n");
+#endif
+
+ return (jint) GetCurrentProcessId();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCurrentThreadId
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCurrentThreadId
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCurrentThreadId\n");
+#endif
+
+ return (jint)GetCurrentThreadId();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCursorPos
+ * Signature: (Lorg/eclipse/swt/internal/win32/POINT;)I
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCursorPos
+ (JNIEnv *env, jclass that, jobject lpPoint)
+{
+ DECL_GLOB(pGlob)
+ POINT point, *lpPoint1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCursorPos\n");
+#endif
+
+ if (lpPoint) {
+ lpPoint1 = &point;
+ cachePointFids(env, lpPoint, &PGLOB(PointFc));
+ getPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ rc = (jboolean) GetCursorPos(lpPoint1);
+ if (lpPoint)
+ setPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDC
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDC
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDC\n");
+#endif
+
+ return (jint)GetDC((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDCEx
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDCEx
+ (JNIEnv *env, jclass that, jint hWnd, jint hrgnClip, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDCEx\n");
+#endif
+
+ return (jint)GetDCEx((HWND)hWnd, (HRGN)hrgnClip, (DWORD)flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDesktopWindow
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDesktopWindow
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDesktopWindow\n");
+#endif
+
+ return (jint) GetDesktopWindow();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDeviceCaps
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDeviceCaps
+ (JNIEnv *env, jclass that, jint hdc, jint nIndex)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDeviceCaps\n");
+#endif
+
+ return (jint) GetDeviceCaps((HDC) hdc, nIndex);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDialogBaseUnits
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDialogBaseUnits
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDialogBaseUnits\n");
+#endif
+
+ return (jint)GetDialogBaseUnits();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDIBColorTable
+ * Signature: (III[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDIBColorTable
+ (JNIEnv *env, jclass that, jint hdc, jint uStartIndex, jint cEntries, jbyteArray pColors)
+{
+ RGBQUAD *pColors1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDIBColorTable\n");
+#endif
+
+ if (pColors)
+ pColors1 = (RGBQUAD *)(*env)->GetByteArrayElements(env,pColors, NULL);
+
+ rc = (jint)GetDIBColorTable((HDC)hdc, uStartIndex, cEntries, pColors1);
+
+ if (pColors)
+ (*env)->ReleaseByteArrayElements(env, pColors, (jbyte *)pColors1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDIBits
+ * Signature: (IIIII[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDIBits
+ (JNIEnv *env, jclass that, jint hdc, jint hbmp, jint uStartScan, jint cScanLines, jint lpvBits, jbyteArray lpbi, jint uUsage)
+{
+ LPBITMAPINFO lpbi1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDIBits\n");
+#endif
+
+ if (lpbi)
+ lpbi1 = (LPBITMAPINFO)(*env)->GetByteArrayElements(env,lpbi, NULL);
+
+ rc = (jint)GetDIBits((HDC)hdc, (HBITMAP)hbmp, uStartScan, cScanLines, (LPBITMAPINFO)lpvBits, lpbi1, uUsage);
+
+ if (lpbi)
+ (*env)->ReleaseByteArrayElements(env, lpbi, (jbyte *)lpbi1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDlgItem
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDlgItem
+ (JNIEnv *env, jclass that, jint hDlg, jint nIDDlgItem)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDlgItem\n");
+#endif
+
+ return (jint)GetDlgItem((HWND)hDlg, nIDDlgItem);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDoubleClickTime
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDoubleClickTime
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDoubleClickTime\n");
+#endif
+
+ return (jint)GetDoubleClickTime();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetFileTitle
+ * Signature: ([B[BS)S
+ */
+JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_win32_OS_GetFileTitle
+ (JNIEnv *env, jclass that, jbyteArray lpszFile, jbyteArray lpszTitle, jshort cbBuf)
+{
+ LPCTSTR lpszFile1=NULL;
+ LPTSTR lpszTitle1=NULL;
+ jshort rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetFileTitle\n");
+#endif
+
+ if (lpszFile)
+ lpszFile1 = (*env)->GetByteArrayElements(env, lpszFile, NULL);
+ if (lpszTitle)
+ lpszTitle1 = (*env)->GetByteArrayElements(env, lpszTitle, NULL);
+
+ rc = (jshort)GetFileTitle(lpszFile1, lpszTitle1, (WORD)cbBuf);
+
+ if (lpszFile)
+ (*env)->ReleaseByteArrayElements(env, lpszFile, (jbyte *)lpszFile1, 0);
+ if (lpszTitle)
+ (*env)->ReleaseByteArrayElements(env, lpszTitle, (jbyte *)lpszTitle1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetFocus
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetFocus
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetFocus\n");
+#endif
+
+ return (jint) GetFocus();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetIconInfo
+ * Signature: (ILorg/eclipse/swt/internal/win32/ICONINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetIconInfo
+ (JNIEnv *env, jclass that, jint hIcon, jobject lpIconinfo)
+{
+ DECL_GLOB(pGlob)
+ ICONINFO iconinfo, *lpIconinfo1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetIconInfo\n");
+#endif
+
+ if (lpIconinfo) {
+ lpIconinfo1 = &iconinfo;
+ cacheIconinfoFids(env, lpIconinfo, &PGLOB(IconinfoFc));
+ getIconinfoFields(env, lpIconinfo, lpIconinfo1, &PGLOB(IconinfoFc));
+ }
+ rc = (jboolean) GetIconInfo((HICON)hIcon, lpIconinfo1);
+ if (lpIconinfo) {
+ setIconinfoFields(env, lpIconinfo, lpIconinfo1, &PGLOB(IconinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetKeyboardState
+ * Signature: ([B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetKeyboardState
+ (JNIEnv *env, jclass that, jbyteArray lpKeyState)
+{
+ PBYTE lpKeyState1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetKeyboardState\n");
+#endif
+
+ if (lpKeyState)
+ lpKeyState1 = (*env)->GetByteArrayElements(env, lpKeyState, NULL);
+
+ rc = (jboolean) GetKeyboardState(lpKeyState1);
+
+ if (lpKeyState)
+ (*env)->ReleaseByteArrayElements(env, lpKeyState, (jbyte *)lpKeyState1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetKeyState
+ * Signature: (I)S
+ */
+JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_win32_OS_GetKeyState
+ (JNIEnv *env, jclass that, jint nVirtKey)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetKeyState\n");
+#endif
+
+ return (jshort) GetKeyState(nVirtKey);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetLastActivePopup
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetLastActivePopup
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetLastActivePopup\n");
+#endif
+
+ return (jint) GetLastActivePopup((HWND) hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetLastError
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetLastError
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetLastError\n");
+#endif
+ return (jint) GetLastError();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMenu
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMenu
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMenu\n");
+#endif
+
+ return (jint) GetMenu((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMenuDefaultItem
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMenuDefaultItem
+ (JNIEnv *env, jclass that, jint hMenu, jint fByPos, jint gmdiFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMenuDefaultItem\n");
+#endif
+
+ return (jint) GetMenuDefaultItem((HMENU)hMenu, fByPos, gmdiFlags);
+}
+
+#ifdef USE_2000_CALLS
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMenuInfo
+ * Signature: (ILorg/eclipse/swt/internal/win32/MENUINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMenuInfo
+ (JNIEnv *env, jclass that, jint hmenu, jobject lpcmi)
+{
+ DECL_GLOB(pGlob)
+ HMODULE hm;
+ FARPROC fp;
+ MENUINFO menuinfo, *lpcmi1=NULL;
+ jboolean rc=FALSE;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMenuInfo\n");
+#endif
+
+ /*
+ ** GetMenuInfo is a Win2000 and Win98 specific call
+ ** If you link it into swt.dll a system modal entry point not found dialog will
+ ** appear as soon as swt.dll is loaded. Here we check for the entry point and
+ ** only do the call if it exists.
+ */
+ if ((hm=GetModuleHandle("user32.dll")) && (fp=GetProcAddress(hm, "GetMenuInfo"))) {
+ if (lpcmi) {
+ lpcmi1 = &menuinfo;
+ cacheMenuinfoFids(env, lpcmi, &PGLOB(MenuinfoFc));
+ getMenuinfoFields(env, lpcmi, lpcmi1, &PGLOB(MenuinfoFc));
+ }
+ rc = (jboolean) (fp)((HMENU)hmenu, lpcmi1);
+// rc = (jboolean) GetMenuInfo((HMENU)hmenu, lpcmi1);
+ if (lpcmi) {
+ setMenuinfoFields(env, lpcmi, lpcmi1, &PGLOB(MenuinfoFc));
+ }
+ }
+ return rc;
+}
+#endif
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMenuItemCount
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMenuItemCount
+ (JNIEnv *env, jclass that, jint hMenu)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMenuItemCount\n");
+#endif
+
+ return (jint) GetMenuItemCount((HMENU)hMenu);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMenuItemInfo
+ * Signature: (IIZLorg/eclipse/swt/internal/win32/MENUITEMINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMenuItemInfo
+ (JNIEnv *env, jclass that, jint hMenu, jint uItem, jboolean fByPosition, jobject lpmii)
+{
+ DECL_GLOB(pGlob)
+ MENUITEMINFO mii1, *lpmii1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMenuItemInfo\n");
+#endif
+
+ if (lpmii) {
+ lpmii1 = &mii1;
+ cacheMenuiteminfoFids(env, lpmii, &PGLOB(MenuiteminfoFc));
+ getMenuiteminfoFields(env, lpmii, lpmii1, &PGLOB(MenuiteminfoFc));
+ }
+
+ rc = (jboolean) GetMenuItemInfo((HMENU)hMenu, uItem, fByPosition, lpmii1);
+ if (lpmii) {
+ setMenuiteminfoFields(env, lpmii, lpmii1, &PGLOB(MenuiteminfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMessage
+ * Signature: (Lorg/eclipse/swt/internal/win32/MSG;III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMessage
+ (JNIEnv *env, jclass that, jobject lpMsg, jint hWnd, jint wMsgFilterMin, jint wMsgFilterMax)
+{
+ DECL_GLOB(pGlob)
+ MSG callBack, *lpMsg1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMessage\n");
+#endif
+
+ if (lpMsg) {
+ lpMsg1 = &callBack;
+ cacheMsgFids(env, lpMsg, &PGLOB(MsgFc));
+ getMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ rc = (jboolean) GetMessage(&callBack,(HWND)hWnd,wMsgFilterMin,wMsgFilterMax);
+ if (lpMsg) {
+ setMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMessagePos
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMessagePos
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMessagePos\n");
+#endif
+
+ return (jint) GetMessagePos();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetMessageTime
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetMessageTime
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetMessageTime\n");
+#endif
+
+ return (jint) GetMessageTime();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetModuleHandle
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetModuleHandle
+ (JNIEnv *env, jclass that, jbyteArray lpModuleName)
+{
+ jbyte *lpModuleName1 = NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetModuleHandle\n");
+#endif
+
+ if (lpModuleName)
+ lpModuleName1 = (*env)->GetByteArrayElements(env, lpModuleName, NULL);
+
+ rc = (jint) GetModuleHandle(lpModuleName1);
+
+ if (lpModuleName)
+ (*env)->ReleaseByteArrayElements(env, lpModuleName, lpModuleName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetNearestPaletteIndex
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetNearestPaletteIndex
+ (JNIEnv *env, jclass that, jint hPal, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetNearestPaletteIndex\n");
+#endif
+
+ return (jint)GetNearestPaletteIndex((HPALETTE)hPal, (COLORREF) crColor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetObject
+ * Signature: (IILorg/eclipse/swt/internal/win32/BITMAP;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetObject__IILorg_eclipse_swt_internal_win32_BITMAP_2
+ (JNIEnv *env, jclass that, jint hgdiobj, jint cbBuffer, jobject lpvObject)
+{
+ DECL_GLOB(pGlob)
+ BITMAP bitmap, *lpvObject1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetObject__IILorg_eclipse_swt_internal_win32_BITMAP_2\n");
+#endif
+
+ if (lpvObject) {
+ lpvObject1 = &bitmap;
+ cacheBitmapFids(env, lpvObject, &PGLOB(BitmapFc));
+ getBitmapFields(env, lpvObject, lpvObject1, &PGLOB(BitmapFc));
+ }
+ rc = (jint) GetObject((HGDIOBJ)hgdiobj, cbBuffer, (LPVOID)lpvObject1);
+ if (lpvObject) {
+ setBitmapFields(env, lpvObject, lpvObject1, &PGLOB(BitmapFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetObject
+ * Signature: (IILorg/eclipse/swt/internal/win32/DIBSECTION;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetObject__IILorg_eclipse_swt_internal_win32_DIBSECTION_2
+ (JNIEnv *env, jclass that, jint hgdiobj, jint cbBuffer, jobject lpvObject)
+{
+ DECL_GLOB(pGlob)
+ DIBSECTION dibsection, *lpvObject1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetObject__IILorg_eclipse_swt_internal_win32_DIBSECTION_2\n");
+#endif
+
+ if (lpvObject) {
+ lpvObject1 = &dibsection;
+ cacheDibsectionFids(env, lpvObject, &PGLOB(DibsectionFc));
+ getDibsectionFields(env, lpvObject, lpvObject1, &PGLOB(DibsectionFc));
+ }
+ rc = (jint) GetObject((HGDIOBJ)hgdiobj, cbBuffer, (LPVOID)lpvObject1);
+ if (lpvObject) {
+ setDibsectionFields(env, lpvObject, lpvObject1, &PGLOB(DibsectionFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetObject
+ * Signature: (IILorg/eclipse/swt/internal/win32/LOGBRUSH;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetObject__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2
+ (JNIEnv *env, jclass that, jint hgdiobj, jint cbBuffer, jobject lpvObject)
+{
+ DECL_GLOB(pGlob)
+ LOGBRUSH logbrush, *lpvObject1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetObject__IILorg_eclipse_swt_internal_win32_LOGBRUSH_2\n");
+#endif
+
+ if (lpvObject) {
+ lpvObject1 = &logbrush;
+ cacheLogbrushFids(env, lpvObject, &PGLOB(LogbrushFc));
+ getLogbrushFields(env, lpvObject, lpvObject1, &PGLOB(LogbrushFc));
+ }
+ rc = (jint) GetObject((HGDIOBJ)hgdiobj, cbBuffer, (LPVOID)lpvObject1);
+ if (lpvObject) {
+ setLogbrushFields(env, lpvObject, lpvObject1, &PGLOB(LogbrushFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetObject
+ * Signature: (IILorg/eclipse/swt/internal/win32/LOGFONT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetObject__IILorg_eclipse_swt_internal_win32_LOGFONT_2
+ (JNIEnv *env, jclass that, jint hgdiobj, jint cbBuffer, jobject lpvObject)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *lpvObject1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetObject__IILorg_eclipse_swt_internal_win32_LOGFONT_2\n");
+#endif
+ if (lpvObject) {
+ lpvObject1 = &logfont;
+ cacheLogfontFids(env, lpvObject, &PGLOB(LogfontFc));
+ getLogfontFields(env, lpvObject, lpvObject1, &PGLOB(LogfontFc));
+ }
+
+ rc = (jint) GetObject((HGDIOBJ)hgdiobj, cbBuffer, lpvObject1);
+
+ if (lpvObject1) {
+ setLogfontFields(env, lpvObject, lpvObject1, &PGLOB(LogfontFc));
+ }
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetObject
+ * Signature: (IILorg/eclipse/swt/internal/win32/LOGPEN;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetObject__IILorg_eclipse_swt_internal_win32_LOGPEN_2
+ (JNIEnv *env, jclass that, jint hgdiobj, jint cbBuffer, jobject lpvObject)
+{
+ DECL_GLOB(pGlob)
+ LOGPEN logpen, *lpvObject1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetObject__IILorg_eclipse_swt_internal_win32_LOGPEN_2\n");
+#endif
+ if (lpvObject) {
+ lpvObject1 = &logpen;
+ cacheLogpenFids(env, lpvObject, &PGLOB(LogpenFc));
+ getLogpenFields(env, lpvObject, lpvObject1, &PGLOB(LogpenFc));
+ }
+
+ rc = (jint) GetObject((HGDIOBJ)hgdiobj, cbBuffer, lpvObject1);
+
+ if (lpvObject1) {
+ setLogpenFields(env, lpvObject, lpvObject1, &PGLOB(LogpenFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetObject
+ * Signature: (IILorg/eclipse/swt/internal/win32/EXTLOGPEN;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetObject__IILorg_eclipse_swt_internal_win32_EXTLOGPEN_2
+ (JNIEnv *env, jclass that, jint hgdiobj, jint cbBuffer, jobject lpvObject)
+{
+ DECL_GLOB(pGlob)
+ EXTLOGPEN extlogpen, *lpvObject1=NULL;
+ jint rc;
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetObject__IILorg_eclipse_swt_internal_win32_EXTLOGPEN_2\n");
+#endif
+ if (lpvObject) {
+ lpvObject1 = &extlogpen;
+ cacheExtlogpenFids(env, lpvObject, &PGLOB(ExtlogpenFc));
+ getExtlogpenFields(env, lpvObject, lpvObject1, &PGLOB(ExtlogpenFc));
+ }
+ rc = (jint) GetObject((HGDIOBJ)hgdiobj, cbBuffer, lpvObject1);
+ if (lpvObject1) {
+ setExtlogpenFields(env, lpvObject, lpvObject1, &PGLOB(ExtlogpenFc));
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetOpenFileName
+ * Signature: (Lorg/eclipse/swt/internal/win32/OPENFILENAME;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetOpenFileName
+ (JNIEnv *env, jclass that, jobject lpofn)
+{
+ DECL_GLOB(pGlob)
+ OPENFILENAME ofn1, *lpofn1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetOpenFileName\n");
+#endif
+
+ if (lpofn) {
+ lpofn1 = &ofn1;
+ cacheOpenfilenameFids(env, lpofn, &PGLOB(OpenfilenameFc));
+ getOpenfilenameFields(env, lpofn, lpofn1, &PGLOB(OpenfilenameFc));
+ }
+ rc = (jboolean) GetOpenFileName((LPOPENFILENAME)lpofn1);
+ if (lpofn) {
+ setOpenfilenameFields(env, lpofn, lpofn1, &PGLOB(OpenfilenameFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetPaletteEntries
+ * Signature: (III[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetPaletteEntries
+ (JNIEnv *env, jclass that, jint hPalette, jint iStartIndex, jint nEntries, jbyteArray logPalette)
+{
+ LPTSTR logPalette1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetPaletteEntries\n");
+#endif
+
+ if (logPalette)
+ logPalette1 = (*env)->GetByteArrayElements(env, logPalette, NULL);
+
+ rc = (jint) GetPaletteEntries((HPALETTE) hPalette, iStartIndex, nEntries, (LPPALETTEENTRY)logPalette1);
+
+ if (logPalette)
+ (*env)->ReleaseByteArrayElements(env, logPalette, (jbyte *)logPalette1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetParent
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetParent
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetParent\n");
+#endif
+
+ return (jint) GetParent((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetProcAddress
+ * Signature: (I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetProcAddress
+ (JNIEnv *env, jclass that, jint hModule, jbyteArray lpProcName)
+{
+ LPCSTR lpProcName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetProcAddress\n");
+#endif
+
+ if (lpProcName)
+ lpProcName1 = (LPCSTR)(*env)->GetByteArrayElements(env,lpProcName, NULL);
+
+ rc = (jint)GetProcAddress((HMODULE)hModule, lpProcName1);
+
+ if (lpProcName)
+ (*env)->ReleaseByteArrayElements(env, lpProcName, (jbyte *)lpProcName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetProcessHeap
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetProcessHeap
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetProcessHeap\n");
+#endif
+
+ return (jint) GetProcessHeap();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetProfileString
+ * Signature: ([B[B[B[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetProfileString
+ (JNIEnv *env, jclass that, jbyteArray lpAppName, jbyteArray lpKeyName, jbyteArray lpDefault, jbyteArray lpReturnedString, jint nSize)
+{
+ LPCTSTR lpAppName1=NULL;
+ LPCTSTR lpKeyName1=NULL;
+ LPCTSTR lpDefault1=NULL;
+ LPTSTR lpReturnedString1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetProfileString\n");
+#endif
+ if (lpAppName)
+ lpAppName1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpAppName, NULL);
+
+ if (lpKeyName)
+ lpKeyName1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpKeyName, NULL);
+
+ if (lpDefault)
+ lpDefault1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpDefault, NULL);
+
+ if (lpReturnedString)
+ lpReturnedString1 = (LPTSTR)(*env)->GetByteArrayElements(env,lpReturnedString, NULL);
+
+ rc = (jint)GetProfileString(lpAppName1, lpKeyName1, lpDefault1, lpReturnedString1, nSize);
+
+ if (lpAppName)
+ (*env)->ReleaseByteArrayElements(env, lpAppName, (jbyte *)lpAppName1, 0);
+
+ if (lpKeyName)
+ (*env)->ReleaseByteArrayElements(env, lpKeyName, (jbyte *)lpKeyName1, 0);
+
+ if (lpDefault)
+ (*env)->ReleaseByteArrayElements(env, lpDefault, (jbyte *)lpDefault1, 0);
+
+ if (lpReturnedString)
+ (*env)->ReleaseByteArrayElements(env, lpReturnedString, (jbyte *)lpReturnedString1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetRegionData
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetRegionData
+ (JNIEnv *env, jclass that, jint hRgn, jint dwCount, jintArray lpRgnData)
+{
+ RGNDATA *lpRgnData1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetRegionData\n");
+#endif
+
+ if (lpRgnData)
+ lpRgnData1 = (RGNDATA *)(*env)->GetIntArrayElements(env, lpRgnData, NULL);
+
+ rc = (jint) GetRegionData((HRGN)hRgn, dwCount, lpRgnData1);
+
+ if (lpRgnData)
+ (*env)->ReleaseIntArrayElements(env, lpRgnData, (jint *)lpRgnData1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetRgnBox
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetRgnBox
+ (JNIEnv *env, jclass that, jint hrgn, jobject lpRect)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetRgnBox\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jint) GetRgnBox((HRGN)hrgn, lpRect1);
+
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetROP2
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetROP2
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetROP2\n");
+#endif
+
+ return (jint) GetROP2((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetSaveFileName
+ * Signature: (Lorg/eclipse/swt/internal/win32/OPENFILENAME;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetSaveFileName
+ (JNIEnv *env, jclass that, jobject lpofn)
+{
+ DECL_GLOB(pGlob)
+ OPENFILENAME ofn1, *lpofn1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetSaveFileName\n");
+#endif
+
+ if (lpofn) {
+ lpofn1 = &ofn1;
+ cacheOpenfilenameFids(env, lpofn, &PGLOB(OpenfilenameFc));
+ getOpenfilenameFields(env, lpofn, lpofn1, &PGLOB(OpenfilenameFc));
+ }
+ rc = (jboolean) GetSaveFileName((LPOPENFILENAME)lpofn1);
+ if (lpofn) {
+ setOpenfilenameFields(env, lpofn, lpofn1, &PGLOB(OpenfilenameFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetScrollInfo
+ * Signature: (IILorg/eclipse/swt/internal/win32/SCROLLINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetScrollInfo
+ (JNIEnv *env, jclass that, jint hWnd, jint fnBar, jobject lpsi)
+{
+ DECL_GLOB(pGlob)
+ SCROLLINFO si1, *lpsi1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetScrollInfo\n");
+#endif
+
+ if (lpsi) {
+ lpsi1 = &si1;
+ cacheScrollinfoFids(env, lpsi, &PGLOB(ScrollinfoFc));
+ getScrollinfoFields(env, lpsi, lpsi1, &PGLOB(ScrollinfoFc));
+ }
+ rc = (jboolean) GetScrollInfo((HWND)hWnd, fnBar, lpsi1);
+ if (lpsi) {
+ setScrollinfoFields(env, lpsi, lpsi1, &PGLOB(ScrollinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetStockObject
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetStockObject
+ (JNIEnv *env, jclass that, jint fnObject)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetStockObject\n");
+#endif
+
+ return (jint) GetStockObject(fnObject);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetSysColor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetSysColor
+ (JNIEnv *env, jclass that, jint nIndex)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetSysColor\n");
+#endif
+
+ return (jint) GetSysColor(nIndex);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetSysColorBrush
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetSysColorBrush
+ (JNIEnv *env, jclass that, jint nIndex)
+{
+ return (jint) GetSysColorBrush(nIndex);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetSystemMenu
+ * Signature: (IZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetSystemMenu
+ (JNIEnv *env, jclass that, jint hWnd, jboolean bRevert)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetSystemMenu\n");
+#endif
+
+ return (jint) GetSystemMenu((HWND)hWnd, bRevert);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetSystemMetrics
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetSystemMetrics
+ (JNIEnv *env, jclass that, jint nIndex)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetSystemMetrics\n");
+#endif
+
+ return (jint) GetSystemMetrics(nIndex);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetTextColor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetTextColor
+ (JNIEnv *env, jclass that, jint hDC)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetTextColor\n");
+#endif
+
+ return (jint) GetTextColor((HDC)hDC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetTextMetrics
+ * Signature: (ILorg/eclipse/swt/internal/win32/TEXTMETRIC;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetTextMetrics
+ (JNIEnv *env, jclass that, jint hdc, jobject lptm)
+{
+ DECL_GLOB(pGlob)
+ TEXTMETRIC tm, *lptm1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetTextMetrics\n");
+#endif
+
+ rc = GetTextMetrics((HDC)hdc, &tm);
+
+ if (lptm) {
+ lptm1 = &tm;
+ cacheTextmetricFids(env, lptm, &PGLOB(TextmetricFc));
+ setTextmetricFields(env, lptm, lptm1, &PGLOB(TextmetricFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetUpdateRgn
+ * Signature: (IIZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetUpdateRgn
+ (JNIEnv *env, jclass that, jint hWnd, jint hRgn, jboolean hErase)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetUpdateRgn\n");
+#endif
+
+ return (jint) GetUpdateRgn((HWND)hWnd, (HRGN)hRgn, hErase);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetVersion
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetVersion
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetVersion\n");
+#endif
+
+ return (jint) GetVersion();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindow
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindow
+ (JNIEnv *env, jclass that, jint hWnd, jint uCmd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindow\n");
+#endif
+
+ return (jint) GetWindow((HWND)hWnd, uCmd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindowLong
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindowLong
+ (JNIEnv *env, jclass that, jint hWnd, jint nIndex)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindowLong\n");
+#endif
+
+ return (jint) GetWindowLong((HWND)hWnd, nIndex);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindowPlacement
+ * Signature: (ILorg/eclipse/swt/internal/win32/WINDOWPLACEMENT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindowPlacement
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpwndpl)
+{
+ DECL_GLOB(pGlob)
+ WINDOWPLACEMENT wndpl, *lpwndpl1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindowPlacement\n");
+#endif
+
+ if (lpwndpl) {
+ lpwndpl1 = &wndpl;
+ cacheWindowplacementFids(env, lpwndpl, &PGLOB(WindowplacementFc));
+ getWindowplacementFields(env, lpwndpl, lpwndpl1, &PGLOB(WindowplacementFc));
+ }
+ rc = (jboolean) GetWindowPlacement((HWND)hWnd, lpwndpl1);
+ if (lpwndpl) {
+ setWindowplacementFields(env, lpwndpl, lpwndpl1, &PGLOB(WindowplacementFc)); }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindowRect
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindowRect
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpRect)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindowRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) GetWindowRect((HWND)hWnd, lpRect1);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc)); }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindowText
+ * Signature: (I[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindowText
+ (JNIEnv *env, jclass that, jint hWnd, jbyteArray lpString, jint nMaxCount)
+{
+ LPTSTR lpString1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindowText\n");
+#endif
+
+ if (lpString)
+ lpString1 = (*env)->GetByteArrayElements(env, lpString, NULL);
+
+ rc = (jint) GetWindowText((HWND)hWnd, lpString1, nMaxCount);
+
+ if (lpString)
+ (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindowTextLength
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindowTextLength
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindowTextLength\n");
+#endif
+
+ return (jint) GetWindowTextLength((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetWindowThreadProcessId
+ * Signature: (I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetWindowThreadProcessId
+ (JNIEnv *env, jclass that, jint hWnd, jintArray lpdwProcessId)
+{
+ LPDWORD lpdwProcessId1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetWindowThreadProcessId\n");
+#endif
+
+ if (lpdwProcessId)
+ lpdwProcessId1 = (*env)->GetIntArrayElements(env, lpdwProcessId, NULL);
+
+ rc = (jint) GetWindowThreadProcessId((HWND)hWnd, lpdwProcessId1);
+
+ if (lpdwProcessId)
+ (*env)->ReleaseIntArrayElements(env, lpdwProcessId, (jint *)lpdwProcessId1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GlobalAlloc
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GlobalAlloc
+ (JNIEnv *env, jclass that, jint uFlags, jint dwBytes)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GlobalAlloc\n");
+#endif
+ return (jint) GlobalAlloc(uFlags, dwBytes);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GlobalFree
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GlobalFree
+ (JNIEnv *env, jclass that, jint hMem)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GlobalFree: handle = %d\n", hMem);
+#endif
+ return (jint) GlobalFree((HANDLE)hMem);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GlobalLock
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GlobalLock
+ (JNIEnv *env, jclass that, jint hMem)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GlobalLock\n");
+#endif
+ return (jint) GlobalLock((HANDLE)hMem);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GlobalSize
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GlobalSize
+ (JNIEnv *env, jclass that, jint hMem)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GlobalSize\n");
+#endif
+ return (jint) GlobalSize((HANDLE)hMem);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GlobalUnlock
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GlobalUnlock
+ (JNIEnv *env, jclass that, jint hMem)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GlobalUnlock\n");
+#endif
+ return (jboolean) GlobalUnlock((HANDLE)hMem);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: HeapAlloc
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_HeapAlloc
+ (JNIEnv *env, jclass that, jint hHeap, jint dwFlags, jint dwBytes)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "HeapAlloc\n");
+#endif
+
+ return (jint) HeapAlloc((HANDLE)hHeap, (DWORD)dwFlags, (DWORD)dwBytes);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: HeapFree
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_HeapFree
+ (JNIEnv *env, jclass that, jint hHeap, jint dwFlags, jint lpMenu)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "HeapFree\n");
+#endif
+
+ return (jboolean) HeapFree((HANDLE)hHeap, (DWORD)dwFlags, (LPVOID)lpMenu);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: HideCaret
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_HideCaret
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "HideCaret\n");
+#endif
+
+ return (jboolean) HideCaret((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_AddMasked
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1AddMasked
+ (JNIEnv *env, jclass that, jint himl, jint hbmImage, jint crMask)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_AddMasked\n");
+#endif
+
+ return (jint)ImageList_AddMasked((HIMAGELIST)himl, (HBITMAP)hbmImage, (COLORREF)crMask);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_Create
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1Create
+ (JNIEnv *env, jclass that, jint cx, jint cy, jint flags, jint cInitial, jint cGrow)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_Create\n");
+#endif
+
+ return (jint)ImageList_Create(cx, cy, flags, cInitial, cGrow);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_Destroy
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1Destroy
+ (JNIEnv *env, jclass that, jint himl)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_Destroy\n");
+#endif
+
+ return (jboolean)ImageList_Destroy((HIMAGELIST)himl);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_GetIcon
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1GetIcon
+ (JNIEnv *env, jclass that, jint himl, jint i, jint flags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_GetIcon\n");
+#endif
+
+ return (jint)ImageList_GetIcon((HIMAGELIST)himl, i, flags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_GetIconSize
+ * Signature: (I[I[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1GetIconSize
+ (JNIEnv *env, jclass that, jint himl, jintArray cx, jintArray cy)
+{
+ int FAR *lpcx1=NULL,*lpcy1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_GetIconSize\n");
+#endif
+
+ if (cx)
+ lpcx1 = (int FAR *)(*env)->GetIntArrayElements(env, cx, NULL);
+ if (cy)
+ lpcy1 = (int FAR *)(*env)->GetIntArrayElements(env, cy, NULL);
+
+ rc = (jboolean) ImageList_GetIconSize((HIMAGELIST)himl, lpcx1, lpcy1);
+
+ if (cx)
+ (*env)->ReleaseIntArrayElements(env, cx, (jint *)lpcx1, 0);
+ if (cy)
+ (*env)->ReleaseIntArrayElements(env, cy, (jint *)lpcy1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_GetImageCount
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1GetImageCount
+ (JNIEnv *env, jclass that, jint himl)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_GetImageCount\n");
+#endif
+
+ return (jint)ImageList_GetImageCount((HIMAGELIST)himl);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_Remove
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1Remove
+ (JNIEnv *env, jclass that, jint himl, jint i)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_Remove\n");
+#endif
+
+ return (jboolean)ImageList_Remove((HIMAGELIST)himl, i);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_Replace
+ * Signature: (IIII)Z
+ */
+JNIEXPORT boolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1Replace
+ (JNIEnv *env, jclass that, jint himl, jint i, jint hbmImage, jint hbmMask)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_Replace\n");
+#endif
+
+ return (boolean)ImageList_Replace((HIMAGELIST)himl, i, (HBITMAP)hbmImage, (HBITMAP)hbmMask);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_ReplaceIcon
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1ReplaceIcon
+ (JNIEnv *env, jclass that, jint himl, jint i, jint hicon)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_ReplaceIcon\n");
+#endif
+
+ return (jint)ImageList_ReplaceIcon((HIMAGELIST)himl, i, (HICON)hicon);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImageList_SetIconSize
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImageList_1SetIconSize
+ (JNIEnv *env, jclass that, jint himl, jint cx, jint cy)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImageList_SetIconSize\n");
+#endif
+
+ return (jboolean)ImageList_SetIconSize((HIMAGELIST)himl, cx, cy);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmAssociateContext
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmAssociateContext
+ (JNIEnv *env, jclass that, jint hWnd, jint hIMC)
+{
+ return (jint) ImmAssociateContext((HWND)hWnd, (HIMC)hIMC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmCreateContext
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmCreateContext
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImmCreateContext\n");
+#endif
+ return (jint) ImmCreateContext();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmDestroyContext
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmDestroyContext
+ (JNIEnv *env, jclass that, jint hIMC)
+{
+ return (jboolean) ImmDestroyContext((HIMC)hIMC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmGetCompositionFont
+ * Signature: (ILorg/eclipse/swt/internal/win32/LOGFONT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmGetCompositionFont
+ (JNIEnv *env, jclass that, jint hIMC, jobject lplf)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *lplf1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImmGetCompositionFont\n");
+#endif
+ if (lplf) {
+ lplf1 = &logfont;
+ cacheLogfontFids(env, lplf, &PGLOB(LogfontFc));
+ getLogfontFields(env, lplf, lplf1, &PGLOB(LogfontFc));
+ }
+ rc = (jboolean) ImmGetCompositionFont((HIMC)hIMC, lplf1);
+ if (lplf) {
+ setLogfontFields(env, lplf, lplf1, &PGLOB(LogfontFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmGetCompositionString
+ * Signature: (II[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmGetCompositionString
+ (JNIEnv *env, jclass that, jint hIMC, jint dwIndex, jbyteArray lpBuf, jint dwBufLen)
+{
+ LPVOID lpBuf1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImmGetCompositionString\n");
+#endif
+
+ if (lpBuf)
+ lpBuf1 = (LPVOID)(*env)->GetByteArrayElements(env, lpBuf, NULL);
+
+ rc = (jint) ImmGetCompositionString((HIMC)hIMC, dwIndex, lpBuf1, dwBufLen);
+
+ if (lpBuf)
+ (*env)->ReleaseByteArrayElements(env, lpBuf, (jbyte *)lpBuf1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmGetContext
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmGetContext
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+ return (jint) ImmGetContext((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmGetConversionStatus
+ * Signature: (I[I[I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmGetConversionStatus
+ (JNIEnv *env, jclass that, jint hIMC, jintArray lpfdwConversion, jintArray lpfdwSentence)
+{
+ LPDWORD lpfdwConversion1=NULL, lpfdwSentence1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImmGetConversionStatus\n");
+#endif
+
+ if (lpfdwConversion)
+ lpfdwConversion1 = (LPDWORD)(*env)->GetIntArrayElements(env, lpfdwConversion, NULL);
+
+ if (lpfdwSentence)
+ lpfdwSentence1 = (LPDWORD)(*env)->GetIntArrayElements(env, lpfdwSentence, NULL);
+
+ rc = (jboolean) ImmGetConversionStatus((HIMC)hIMC, lpfdwConversion1, lpfdwSentence1);
+
+ if (lpfdwConversion)
+ (*env)->ReleaseIntArrayElements(env, lpfdwConversion, (jint *)lpfdwConversion1, 0);
+
+ if (lpfdwSentence)
+ (*env)->ReleaseIntArrayElements(env, lpfdwSentence, (jint *)lpfdwSentence1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmGetDefaultIMEWnd
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmGetDefaultIMEWnd
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+ return (jint) ImmGetDefaultIMEWnd((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmGetOpenStatus
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmGetOpenStatus
+ (JNIEnv *env, jclass that, jint hIMC)
+{
+ return (jboolean) ImmGetOpenStatus((HIMC) hIMC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmReleaseContext
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmReleaseContext
+ (JNIEnv *env, jclass that, jint hWnd, jint hIMC)
+{
+ return (jboolean) ImmReleaseContext((HWND)hWnd, (HIMC)hIMC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmSetCompositionFont
+ * Signature: (ILorg/eclipse/swt/internal/win32/LOGFONT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmSetCompositionFont
+ (JNIEnv *env, jclass that, jint hIMC, jobject lplf)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *lplf1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImmSetCompositionFont\n");
+#endif
+ if (lplf) {
+ lplf1 = &logfont;
+ cacheLogfontFids(env, lplf, &PGLOB(LogfontFc));
+ getLogfontFields(env, lplf, lplf1, &PGLOB(LogfontFc));
+ }
+ return (jboolean) ImmSetCompositionFont((HIMC)hIMC, lplf1);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmSetCompositionWindow
+ * Signature: (ILorg/eclipse/swt/internal/win32/COMPOSITIONFORM;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmSetCompositionWindow
+ (JNIEnv *env, jclass that, jint hIMC, jobject lpCompForm)
+{
+ DECL_GLOB(pGlob)
+
+ COMPOSITIONFORM compositionform, *lpCompForm1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ImmSetCompositionWindow\n");
+#endif
+ if (lpCompForm) {
+ lpCompForm1 = &compositionform;
+ cacheCompositionformFids(env, lpCompForm, &PGLOB(CompositionformFc));
+ getCompositionformFields(env, lpCompForm, lpCompForm1, &PGLOB(CompositionformFc));
+ }
+ rc = (jboolean) ImmSetCompositionWindow((HIMC)hIMC, lpCompForm1);
+ if (lpCompForm) {
+ setCompositionformFields(env, lpCompForm, lpCompForm1, &PGLOB(CompositionformFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmSetConversionStatus
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmSetConversionStatus
+ (JNIEnv *env, jclass that, jint hIMC, jint fdwConversion, jint dwSentence)
+{
+ return (jboolean) ImmSetConversionStatus((HIMC)hIMC, fdwConversion, dwSentence);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ImmSetOpenStatus
+ * Signature: (IZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ImmSetOpenStatus
+ (JNIEnv *env, jclass that, jint hIMC, jboolean fOpen)
+{
+ return (jboolean) ImmSetOpenStatus((HIMC) hIMC, fOpen);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: InitCommonControls
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_InitCommonControls
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "InitCommonControls\n");
+#endif
+
+ InitCommonControls();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: InitCommonControlsEx
+ * Signature: (Lorg/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_InitCommonControlsEx
+ (JNIEnv *env, jclass that, jobject lpInitCtrls)
+{
+ DECL_GLOB(pGlob)
+ INITCOMMONCONTROLSEX initCtrl, *lpInitCtrls1=NULL;
+ jboolean rc;
+
+ if (lpInitCtrls) {
+ lpInitCtrls1 = &initCtrl;
+ cacheInitcommoncontrolsexFids(env, lpInitCtrls, &PGLOB(InitcommoncontrolsexFc));
+ getInitcommoncontrolsexFields(env, lpInitCtrls, lpInitCtrls1, &PGLOB(InitcommoncontrolsexFc));
+ }
+ rc = (jboolean) InitCommonControlsEx(lpInitCtrls1);
+ if (lpInitCtrls) {
+ setInitcommoncontrolsexFields(env, lpInitCtrls, lpInitCtrls1, &PGLOB(InitcommoncontrolsexFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: InsertMenuItem
+ * Signature: (IIZLorg/eclipse/swt/internal/win32/MENUITEMINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_InsertMenuItem
+ (JNIEnv *env, jclass that, jint hMenu, jint uItem, jboolean fByPosition, jobject lpmii)
+{
+ DECL_GLOB(pGlob)
+ MENUITEMINFO mii1, *lpmii1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "InsertMenuItem\n");
+#endif
+
+ if (lpmii) {
+ lpmii1 = &mii1;
+ cacheMenuiteminfoFids(env, lpmii, &PGLOB(MenuiteminfoFc));
+ getMenuiteminfoFields(env, lpmii, lpmii1, &PGLOB(MenuiteminfoFc));
+ }
+ rc = (jboolean) InsertMenuItem((HMENU)hMenu, uItem, fByPosition, lpmii1);
+ if (lpmii) {
+ setMenuiteminfoFields(env, lpmii, lpmii1, &PGLOB(MenuiteminfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: InvalidateRect
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;Z)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_InvalidateRect
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpRect, jboolean hErase)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "InvalidateRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) InvalidateRect((HWND)hWnd, lpRect1, hErase);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: InvalidateRgn
+ * Signature: (IIZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_InvalidateRgn
+ (JNIEnv *env, jclass that, jint hWnd, jint hRgn, jboolean hErase)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "InvalidateRgn\n");
+#endif
+
+ return (jboolean) InvalidateRgn((HWND)hWnd, (HRGN)hRgn, hErase);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsDBCSLeadByte
+ * Signature: (B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsDBCSLeadByte
+ (JNIEnv *env, jclass that, jbyte TestChar)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsDBCSLeadByte\n");
+#endif
+ return (jboolean) IsDBCSLeadByte(TestChar);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsIconic
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsIconic
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsIconic\n");
+#endif
+
+ return (jboolean) IsIconic((HWND)hWnd);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsMenu
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsMenu
+ (JNIEnv *env, jclass that, jint hMenu)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsMenu\n");
+#endif
+
+ return (jboolean) IsMenu((HMENU)hMenu);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsWindow
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsWindow
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsWindow\n");
+#endif
+
+ return (jboolean) IsWindow((HWND)hWnd);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsWindowEnabled
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsWindowEnabled
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsWindowEnabled\n");
+#endif
+
+ return (jboolean) IsWindowEnabled((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsWindowVisible
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsWindowVisible
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsWindowVisible\n");
+#endif
+
+ return (jboolean) IsWindowVisible((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsZoomed
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsZoomed
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsZoomed\n");
+#endif
+
+ return (jboolean) IsZoomed((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LineTo
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_LineTo
+ (JNIEnv *env, jclass that, jint hdc, jint nXEnd, jint nYEnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LineTo\n");
+#endif
+
+ return (jboolean) LineTo((HDC)hdc, nXEnd, nYEnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadBitmap
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadBitmap__II
+ (JNIEnv *env, jclass that, jint hInstance, jint lpBitmapName)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadBitmap__II\n");
+#endif
+
+ return (jint) LoadBitmap((HINSTANCE)hInstance, (LPCTSTR)lpBitmapName);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadCursor
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadCursor
+ (JNIEnv *env, jclass that, jint hInstance, jint lpCursorName)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadCursor\n");
+#endif
+
+ return (jint) LoadCursor((HINSTANCE)hInstance, (LPCTSTR)lpCursorName);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadIcon
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadIcon
+ (JNIEnv *env, jclass that, jint hInstance, jint lpIconName)
+{
+ LPCTSTR lpin;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadIcon\n");
+#endif
+
+ lpin = MAKEINTRESOURCE( lpIconName );
+ return (jint) LoadIcon((HINSTANCE)hInstance, lpin);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadLibrary
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadLibrary
+ (JNIEnv *env, jclass that, jbyteArray lpLibFileName)
+{
+ LPCTSTR lpLibFileName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadLibrary\n");
+#endif
+
+ if (lpLibFileName)
+ lpLibFileName1 = (*env)->GetByteArrayElements(env, lpLibFileName, NULL);
+
+ rc = (jint) LoadLibrary(lpLibFileName1);
+
+ if (lpLibFileName)
+ (*env)->ReleaseByteArrayElements(env, lpLibFileName, (jbyte *)lpLibFileName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MapVirtualKey
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_MapVirtualKey
+ (JNIEnv *env, jclass that, jint uCode, jint uMapType)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MapVirtualKey\n");
+#endif
+
+ return (jint) MapVirtualKey(uCode, uMapType);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MapWindowPoints
+ * Signature: (IILorg/eclipse/swt/internal/win32/POINT;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I
+ (JNIEnv *env, jclass that, jint hWndFrom, jint hWndTo, jobject lpPoints, jint cPoints)
+{
+ DECL_GLOB(pGlob)
+ POINT point, *lpPoints1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MapWindowPoints__IILorg_eclipse_swt_internal_win32_POINT_2I\n");
+#endif
+
+ if (lpPoints) {
+ lpPoints1 = &point;
+ cachePointFids(env, lpPoints, &PGLOB(PointFc));
+ getPointFields(env, lpPoints, lpPoints1, &PGLOB(PointFc));
+ }
+ rc = (jint) MapWindowPoints((HWND)hWndFrom, (HWND)hWndTo, (LPPOINT)lpPoints1, cPoints);
+
+ if (lpPoints) {
+ setPointFields(env, lpPoints, lpPoints1, &PGLOB(PointFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MapWindowPoints
+ * Signature: (IILorg/eclipse/swt/internal/win32/RECT;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I
+ (JNIEnv *env, jclass that, jint hWndFrom, jint hWndTo, jobject lpPoints, jint cPoints)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpPoints1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MapWindowPoints__IILorg_eclipse_swt_internal_win32_RECT_2I\n");
+#endif
+
+ if (lpPoints) {
+ lpPoints1 = &rect;
+ cacheRectFids(env, lpPoints, &PGLOB(RectFc));
+ getRectFields(env, lpPoints, lpPoints1, &PGLOB(RectFc));
+ }
+ rc = (jint) MapWindowPoints((HWND)hWndFrom, (HWND)hWndTo, (LPPOINT)lpPoints1, cPoints);
+
+ if (lpPoints) {
+ setRectFields(env, lpPoints, lpPoints1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MessageBeep
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_MessageBeep
+ (JNIEnv *env, jclass that, jint uType)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MessageBeep\n");
+#endif
+
+ return (jboolean) MessageBeep(uType);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MessageBox
+ * Signature: (I[B[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_MessageBox
+ (JNIEnv *env, jclass that, jint hWnd, jbyteArray lpText, jbyteArray lpCaption, jint uType)
+{
+ LPCTSTR lpText1=NULL, lpCaption1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MessageBox\n");
+#endif
+
+ if (lpText)
+ lpText1 = (*env)->GetByteArrayElements(env, lpText, NULL);
+ if (lpCaption)
+ lpCaption1 = (*env)->GetByteArrayElements(env, lpCaption, NULL);
+
+ rc = (jint) MessageBox((HWND)hWnd, lpText1, lpCaption1, uType);
+
+ if (lpText)
+ (*env)->ReleaseByteArrayElements(env, lpText, (jbyte *)lpText1, 0);
+ if (lpCaption)
+ (*env)->ReleaseByteArrayElements(env, lpCaption, (jbyte *)lpCaption1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: ([BII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory___3BII
+ (JNIEnv *env, jclass that, jbyteArray Destination, jint Source, jint Length)
+{
+ PVOID Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OS_MoveMemory___3BII\n");
+#endif
+
+ if (Destination)
+ Destination1 = (PVOID)(*env)->GetByteArrayElements(env, Destination, NULL);
+
+ MoveMemory(Destination1, (CONST VOID *)Source, Length);
+
+ if (Destination)
+ (*env)->ReleaseByteArrayElements(env, Destination, (jbyte *)Destination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: ([BLorg/eclipse/swt/internal/win32/ACCEL;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I
+ (JNIEnv *env, jclass that, jbyteArray Destination, jobject lpSource, jint Length)
+{
+ DECL_GLOB(pGlob)
+ PVOID Destination1=NULL;
+ ACCEL source, *lpSource1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory___3BLorg_eclipse_swt_internal_win32_ACCEL_2I\n");
+#endif
+
+ if (lpSource) {
+ lpSource1 = &source;
+ cacheAccelFids(env, lpSource, &PGLOB(AccelFc));
+ getAccelFields(env, lpSource, lpSource1, &PGLOB(AccelFc));
+ }
+
+ if (Destination)
+ Destination1 = (PVOID)(*env)->GetByteArrayElements(env, Destination, NULL);
+
+ MoveMemory(Destination1, (CONST VOID *)lpSource1, Length);
+
+ if (Destination)
+ (*env)->ReleaseByteArrayElements(env, Destination, (jbyte *)Destination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: ([III)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory___3III
+ (JNIEnv *env, jclass that, jintArray lpDestination, jint Source, jint Length)
+{
+ jint *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory___3III\n");
+#endif
+
+ if (lpDestination)
+ lpDestination1 = (*env)->GetIntArrayElements(env, lpDestination, NULL);
+
+ MoveMemory((PVOID)lpDestination1, (PVOID)Source, Length);
+
+ if (lpDestination)
+ (*env)->ReleaseIntArrayElements(env, lpDestination, lpDestination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/HDITEM;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ HDITEM hditem, *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_HDITEM_2II\n");
+#endif
+
+ MoveMemory((PVOID)&hditem, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ Destination1 = &hditem;
+ cacheHditemFids(env, Destination, &PGLOB(HditemFc));
+ setHditemFields(env, Destination, Destination1, &PGLOB(HditemFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/HELPINFO;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ HELPINFO helpinfo, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_HELPINFO_2II\n");
+#endif
+
+ MoveMemory((PVOID)&helpinfo, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &helpinfo;
+ cacheHelpinfoFids(env, Destination, &PGLOB(HelpinfoFc));
+ setHelpinfoFields(env, Destination, lpDestination1, &PGLOB(HelpinfoFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/LOGFONT;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_LOGFONT_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_LOGFONT_2II\n");
+#endif
+
+ MoveMemory((PVOID)&logfont, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &logfont;
+ cacheLogfontFids(env, Destination, &PGLOB(LogfontFc));
+ setLogfontFields(env, Destination, lpDestination1, &PGLOB(LogfontFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMHEADER;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ NMHEADER nmheader, *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmheader, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ Destination1 = &nmheader;
+ cacheNmheaderFids(env, Destination, &PGLOB(NmheaderFc));
+ setNmheaderFields(env, Destination, Destination1, &PGLOB(NmheaderFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMLISTVIEW;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ NMLISTVIEW nmlistview, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMLISTVIEW_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmlistview, (CONST VOID *)Source, Length);
+ if (Destination) {
+ lpDestination1=&nmlistview;
+ cacheNmlistviewFids(env, Destination, &PGLOB(NmlistviewFc));
+ setNmlistviewFields(env, Destination, lpDestination1, &PGLOB(NmlistviewFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (I[BI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__I_3BI
+ (JNIEnv *env, jclass that, jint Destination, jbyteArray Source, jint Length)
+{
+ CONST VOID *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__I_3BI\n");
+#endif
+
+ if (Source)
+ Source1 = (PVOID)(*env)->GetByteArrayElements(env, Source, NULL);
+
+ MoveMemory((PVOID)Destination, Source1, Length);
+
+ if (Source)
+ (*env)->ReleaseByteArrayElements(env, Source, (jbyte *)Source1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (I[CI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__I_3CI
+ (JNIEnv * env, jclass that, jint Destination, jcharArray Source, jint Length)
+{
+ CONST VOID *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__I_3CI\n");
+#endif
+
+ if (Source)
+ Source1 = (PVOID)(*env)->GetCharArrayElements(env, Source, NULL);
+
+ MoveMemory((PVOID)Destination, Source1, Length);
+
+ if (Source)
+ (*env)->ReleaseCharArrayElements(env, Source, (jchar *)Source1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__I_3II
+ (JNIEnv *env, jclass that, jint Destination, jintArray Source, jint Length)
+{
+ CONST VOID *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__I_3II\n");
+#endif
+
+ if (Source)
+ Source1 = (CONST VOID *)(*env)->GetIntArrayElements(env, Source, NULL);
+
+ MoveMemory((PVOID)Destination, Source1, Length);
+
+ if (Source)
+ (*env)->ReleaseIntArrayElements(env, Source, (jint *)Source1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/win32/LOGFONT;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_LOGFONT_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ LOGFONT logfont, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_LOGFONT_2I\n");
+#endif
+ if (Source) {
+ Source1 = &logfont;
+ cacheLogfontFids(env, Source, &PGLOB(LogfontFc));
+ getLogfontFields(env, Source, Source1, &PGLOB(LogfontFc));
+ }
+ MoveMemory((PVOID)Destination, (CONST VOID *)Source1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/MEASUREITEMSTRUCT;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ MEASUREITEMSTRUCT measureitemstruct, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2II\n");
+#endif
+
+ MoveMemory((PVOID)&measureitemstruct, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &measureitemstruct;
+ cacheMeasureitemstructFids(env, Destination, &PGLOB(MeasureitemstructFc));
+ setMeasureitemstructFields(env, Destination, lpDestination1, &PGLOB(MeasureitemstructFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/win32/MEASUREITEMSTRUCT;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ MEASUREITEMSTRUCT measureitemstruct, *lpSource1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_MEASUREITEMSTRUCT_2I\n");
+#endif
+
+ if (Source) {
+ lpSource1 = &measureitemstruct;
+ cacheMeasureitemstructFids(env, Source, &PGLOB(MeasureitemstructFc));
+ getMeasureitemstructFields(env, Source, lpSource1, &PGLOB(MeasureitemstructFc));
+ }
+ MoveMemory((PVOID)Destination, lpSource1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/win32/NMTTDISPINFO;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I
+ (JNIEnv * env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ NMTTDISPINFO nmttdispinfo, *lpSource1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_NMTTDISPINFO_2I\n");
+#endif
+
+ if (Source) {
+ lpSource1 = &nmttdispinfo;
+ cacheNmttdispinfoFids(env, Source, &PGLOB(NmttdispinfoFc));
+ getNmttdispinfoFields(env, Source, lpSource1, &PGLOB(NmttdispinfoFc));
+ }
+ MoveMemory((PVOID)Destination, lpSource1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpSource1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_RECT_2I\n");
+#endif
+
+ if (Source) {
+ lpSource1 = &rect;
+ cacheRectFids(env, Source, &PGLOB(RectFc));
+ getRectFields(env, Source, lpSource1, &PGLOB(RectFc));
+ }
+ MoveMemory((PVOID)Destination, lpSource1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/DRAWITEMSTRUCT;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ DRAWITEMSTRUCT drawItem, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_DRAWITEMSTRUCT_2II\n");
+#endif
+
+ if (Source) {
+ lpDestination1=&drawItem;
+ }
+
+ MoveMemory((PVOID)lpDestination1, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ cacheDrawitemstructFids(env, Destination, &PGLOB(DrawitemstructFc));
+ setDrawitemstructFields(env, Destination, lpDestination1, &PGLOB(DrawitemstructFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMHDR;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ NMHDR nmhdr, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMHDR_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmhdr, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &nmhdr;
+ cacheNmhdrFids(env, Destination, &PGLOB(NmhdrFc));
+ setNmhdrFields(env, Destination, lpDestination1, &PGLOB(NmhdrFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMTOOLBAR;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ NMTOOLBAR nmtoolbar, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMTOOLBAR_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmtoolbar, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &nmtoolbar;
+ cacheNmtoolbarFids(env, Destination, &PGLOB(NmtoolbarFc));
+ setNmtoolbarFields(env, Destination, lpDestination1, &PGLOB(NmtoolbarFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMTTDISPINFO;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II
+ (JNIEnv * env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ NMTTDISPINFO nmttdispinfo, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMTTDISPINFO_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmttdispinfo, (CONST VOID *)Source, Length);
+ if (Destination) {
+ lpDestination1 = &nmttdispinfo;
+ cacheNmttdispinfoFids(env, Destination, &PGLOB(NmttdispinfoFc));
+ setNmttdispinfoFields(env, Destination, lpDestination1, &PGLOB(NmttdispinfoFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/TVITEM;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ TVITEM tvitem, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_TVITEM_2II\n");
+#endif
+
+ MoveMemory((PVOID)&tvitem, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &tvitem;
+ cacheTvitemFids(env, Destination, &PGLOB(TvitemFc));
+ setTvitemFields(env, Destination, lpDestination1, &PGLOB(TvitemFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/WINDOWPOS;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ WINDOWPOS windowpos, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_WINDOWPOS_2II\n");
+#endif
+
+ MoveMemory((PVOID)&windowpos, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &windowpos;
+ cacheWindowposFids(env, Destination, &PGLOB(WindowposFc));
+ setWindowposFields(env, Destination, lpDestination1, &PGLOB(WindowposFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveToEx
+ * Signature: (IIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveToEx
+ (JNIEnv *env, jclass that, jint hdc, jint X, jint Y, jint lpPoint)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveToEx\n");
+#endif
+
+ return (jboolean) MoveToEx((HDC)hdc, X, Y, (LPPOINT)lpPoint);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MultiByteToWideChar
+ * Signature: (II[BI[CI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_MultiByteToWideChar__II_3BI_3CI
+ (JNIEnv *env, jclass that, jint CodePage, jint dwFlags, jbyteArray lpMultiByteStr, jint cchMultiByte, jcharArray lpWideCharStr, jint cchWideChar)
+{
+ LPCSTR lpMultiByteStr1=NULL;
+ LPWSTR lpWideCharStr1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MultiByteToWideChar__II_3BI_3CI\n");
+#endif
+
+ if (lpMultiByteStr)
+ lpMultiByteStr1 = (LPCSTR) (*env)->GetByteArrayElements(env, lpMultiByteStr, NULL);
+ if (lpWideCharStr)
+ lpWideCharStr1 = (LPWSTR) (*env)->GetCharArrayElements(env, lpWideCharStr, NULL);
+
+ rc = (jint) MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr1, cchMultiByte, lpWideCharStr1, cchWideChar);
+
+ if (lpMultiByteStr)
+ (*env)->ReleaseByteArrayElements(env, lpMultiByteStr, (jbyte *)lpMultiByteStr1, 0);
+ if (lpWideCharStr)
+ (*env)->ReleaseCharArrayElements(env, lpWideCharStr, (jchar *)lpWideCharStr1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MultiByteToWideChar
+ * Signature: (IIII[CI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_MultiByteToWideChar__IIII_3CI
+ (JNIEnv *env, jclass that, jint CodePage, jint dwFlags, jint lpMultiByteStr, jint cchMultiByte, jcharArray lpWideCharStr, jint cchWideChar)
+{
+ LPWSTR lpWideCharStr1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MultiByteToWideChar__IIII_3CI\n");
+#endif
+
+ if (lpWideCharStr)
+ lpWideCharStr1 = (LPWSTR) (*env)->GetCharArrayElements(env, lpWideCharStr, NULL);
+
+ rc = (jint) MultiByteToWideChar(CodePage, dwFlags, (LPCSTR)lpMultiByteStr, cchMultiByte, lpWideCharStr1, cchWideChar);
+
+ if (lpWideCharStr)
+ (*env)->ReleaseCharArrayElements(env, lpWideCharStr, (jchar *)lpWideCharStr1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: OpenClipboard
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_OpenClipboard
+ (JNIEnv *env, jclass that, jint hWndNewOwner)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OpenClipboard\n");
+#endif
+ return (jboolean) OpenClipboard((HWND) hWndNewOwner);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PatBlt
+ * Signature: (IIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PatBlt
+ (JNIEnv *env, jclass that, jint hdc, jint nXLeft, jint nYLeft, jint nWidth, jint nHeight, jint dwRop)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PatBlt\n");
+#endif
+
+ return (jboolean) PatBlt((HDC)hdc, nXLeft, nYLeft, nWidth, nHeight, dwRop);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PeekMessage
+ * Signature: (Lorg/eclipse/swt/internal/win32/MSG;IIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PeekMessage
+ (JNIEnv *env, jclass that, jobject lpMsg, jint hWnd, jint wMsgFilterMin, jint wMsgFilterMax, jint wRemoveMsg)
+{
+ DECL_GLOB(pGlob)
+ MSG callBack, *lpMsg1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PeekMessage\n");
+#endif
+
+ if (lpMsg) {
+ lpMsg1 = &callBack;
+ cacheMsgFids(env, lpMsg, &PGLOB(MsgFc));
+ getMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ rc = (jboolean) PeekMessage(lpMsg1,(HWND)hWnd,wMsgFilterMin,wMsgFilterMax, wRemoveMsg);
+ if (lpMsg) {
+ setMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Pie
+ * Signature: (IIIIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_Pie
+ (JNIEnv *env, jclass that, jint hdc, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect, jint nXStartArc, jint nYStartArc, jint nXEndArc, jint nYEndArc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Pie\n");
+#endif
+
+ return (jboolean) Pie((HDC)hdc, nLeftRect, nTopRect, nRightRect, nBottomRect, nXStartArc, nYStartArc, nXEndArc, nYEndArc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Polygon
+ * Signature: (I[II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_Polygon
+ (JNIEnv *env, jclass that, jint hdc, jintArray points, jint nPoints)
+{
+ jint *points1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Polygon\n");
+#endif
+
+ if (points)
+ points1 = (*env)->GetIntArrayElements(env, points, NULL);
+
+ rc = (jboolean) Polygon((HDC)hdc, (POINT *)points1, nPoints);
+
+ if (points)
+ (*env)->ReleaseIntArrayElements(env, points, (jint *)points1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Polyline
+ * Signature: (I[II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_Polyline
+ (JNIEnv *env, jclass that, jint hdc, jintArray points, jint nPoints)
+{
+ POINT *points1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Polyline\n");
+#endif
+
+ if (points)
+ points1 = (POINT *)(*env)->GetIntArrayElements(env, points, NULL);
+
+ rc = (jboolean) Polyline((HDC)hdc, points1, nPoints);
+
+ if (points)
+ (*env)->ReleaseIntArrayElements(env, points, (jint *)points1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PostMessage
+ * Signature: (IIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PostMessage
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jint lParam)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PostMessage\n");
+#endif
+
+ return (jboolean) PostMessage((HWND)hWnd, Msg, (WPARAM)wParam, (LPARAM)lParam);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PostThreadMessage
+ * Signature: (IIII)I
+ */
+JNIEXPORT boolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PostThreadMessage
+ (JNIEnv *env, jclass that, jint idThread, jint Msg, jint wParam, jint lParam)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PostThreadMessage\n");
+#endif
+
+ return (jboolean) PostThreadMessage(idThread, Msg, (WPARAM)wParam, (LPARAM)lParam);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PtInRect
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;Lorg/eclipse/swt/internal/win32/POINT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PtInRect
+ (JNIEnv *env, jclass that, jobject lpRect, jobject lpPoint)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ POINT point, *lpPoint1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtInRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ if (lpPoint) {
+ lpPoint1 = &point;
+ cachePointFids(env, lpPoint, &PGLOB(PointFc));
+ getPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ rc = (jboolean) PtInRect(lpRect1, point);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ if (lpPoint) {
+ setPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PtInRegion
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PtInRegion
+ (JNIEnv *env, jclass that, jint hrgn, jint X, jint Y)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PtInRegion\n");
+#endif
+
+ return (jboolean) PtInRegion((HRGN)hrgn, X, Y);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RealizePalette
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RealizePalette
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RealizePalette\n");
+#endif
+
+ return (jint) RealizePalette((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: Rectangle
+ * Signature: (IIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_Rectangle
+ (JNIEnv *env, jclass that, jint hdc, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "Rectangle\n");
+#endif
+ return (jboolean) Rectangle((HDC)hdc, nLeftRect, nTopRect, nRightRect, nBottomRect);
+}
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RectInRegion
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_RectInRegion
+ (JNIEnv *env, jclass that, jint hrgn, jobject lprc)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lprc1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RectInRegion\n");
+#endif
+
+ if (lprc) {
+ lprc1 = &rect;
+ cacheRectFids(env, lprc, &PGLOB(RectFc));
+ getRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) RectInRegion((HRGN)hrgn, lprc1);
+
+ if (lprc) {
+ setRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RedrawWindow
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_RedrawWindow
+ (JNIEnv *env, jclass that, jint hWnd, jobject lprcUpdate, jint hrgnUpdate, jint flags)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lprcUpdate1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RedrawWindow\n");
+#endif
+
+ if (lprcUpdate) {
+ lprcUpdate1 = &rect;
+ cacheRectFids(env, lprcUpdate, &PGLOB(RectFc));
+ getRectFields(env, lprcUpdate, lprcUpdate1, &PGLOB(RectFc));
+ }
+
+ rc = (jboolean) RedrawWindow((HWND)hWnd, lprcUpdate1, (HRGN)hrgnUpdate, flags);
+
+ if (lprcUpdate) {
+ setRectFields(env, lprcUpdate, lprcUpdate1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RegCloseKey
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RegCloseKey
+ (JNIEnv *env, jclass that, jint hKey)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegCloseKey\n");
+#endif
+
+ return (jint) RegCloseKey((HKEY)hKey);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RegEnumKey
+ * Signature: (II[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RegEnumKey
+ (JNIEnv *env, jclass that, jint hKey, jint dwIndex, jbyteArray lpName, jint cbName)
+{
+ jbyte *lpName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegEnumKey\n");
+#endif
+ if (lpName)
+ lpName1 = (*env)->GetByteArrayElements(env, lpName, NULL);
+
+ rc = (jint) RegEnumKey((HKEY)hKey, dwIndex, (LPTSTR)lpName1, cbName);
+
+ if (lpName)
+ (*env)->ReleaseByteArrayElements(env, lpName, lpName1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RegisterClassEx
+ * Signature: (Lorg/eclipse/swt/internal/win32/WNDCLASSEX;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RegisterClassEx
+ (JNIEnv *env, jclass that, jobject lpwcx)
+{
+ DECL_GLOB(pGlob)
+ WNDCLASSEX wcx, *lpwcx1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegisterClassEx\n");
+#endif
+
+ if (lpwcx) {
+ lpwcx1 = &wcx;
+ cacheWndclassexFids(env, lpwcx, &PGLOB(WndclassexFc));
+ getWndclassexFields(env, lpwcx, lpwcx1, &PGLOB(WndclassexFc));
+ }
+ rc = (jint) RegisterClassEx(lpwcx1);
+
+ if (lpwcx) {
+ setWndclassexFields(env, lpwcx, lpwcx1, &PGLOB(WndclassexFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RegOpenKeyEx
+ * Signature: (I[BII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RegOpenKeyEx
+ (JNIEnv *env, jclass that, jint hKey, jbyteArray lpSubKey, jint ulOptions, jint samDesired, jintArray jhkResult)
+{
+ jint *jhkResult1=NULL;
+ jbyte *lpSubKey1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegOpenKeyEx\n");
+#endif
+
+
+ if (jhkResult)
+ jhkResult1 = (*env)->GetIntArrayElements(env, jhkResult, NULL);
+ if (lpSubKey)
+ lpSubKey1 = (*env)->GetByteArrayElements(env, lpSubKey, NULL);
+
+ rc = (jint) RegOpenKeyEx((HKEY)hKey, (LPTSTR)lpSubKey1, ulOptions, samDesired, (PHKEY)jhkResult1);
+
+ if (jhkResult)
+ (*env)->ReleaseIntArrayElements(env, jhkResult, jhkResult1, 0);
+ if (lpSubKey)
+ (*env)->ReleaseByteArrayElements(env, lpSubKey, lpSubKey1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RegQueryInfoKey
+ * Signature: (II[II[I[I[I[I[I[I[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RegQueryInfoKey
+ (JNIEnv *env, jclass that, jint hKey, jint lpClass, jintArray lpcbClass, jint lpReserved, jintArray lpSubKeys, jintArray lpcbMaxSubKeyLen, jintArray lpcbMaxClassLen, jintArray lpcValues, jintArray lpcbMaxValueNameLen, jintArray lpcbMaxValueLen, jintArray lpcbSecurityDescriptor, jint lpftLastWriteTime)
+{
+ jint *lpcbClass1=NULL;
+ jint *lpSubKeys1=NULL;
+ jint *lpcbMaxSubKeyLen1=NULL;
+ jint *lpcbMaxClassLen1=NULL;
+ jint *lpcValues1=NULL;
+ jint *lpcbMaxValueNameLen1=NULL;
+ jint *lpcbMaxValueLen1=NULL;
+ jint *lpcbSecurityDescriptor1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegQueryInfoKey\n");
+#endif
+
+ if (lpcbClass)
+ lpcbClass1 = (*env)->GetIntArrayElements(env, lpcbClass, NULL);
+ if (lpSubKeys)
+ lpSubKeys1 = (*env)->GetIntArrayElements(env, lpSubKeys, NULL);
+ if (lpcbMaxSubKeyLen)
+ lpcbMaxSubKeyLen1 = (*env)->GetIntArrayElements(env, lpcbMaxSubKeyLen, NULL);
+ if (lpcbMaxClassLen)
+ lpcbMaxClassLen1 = (*env)->GetIntArrayElements(env, lpcbMaxClassLen, NULL);
+ if (lpcValues)
+ lpcValues1 = (*env)->GetIntArrayElements(env, lpcValues, NULL);
+ if (lpcbMaxValueNameLen)
+ lpcbMaxValueNameLen1 = (*env)->GetIntArrayElements(env, lpcbMaxValueNameLen, NULL);
+ if (lpcbMaxValueLen)
+ lpcbMaxValueLen1 = (*env)->GetIntArrayElements(env, lpcbMaxValueLen, NULL);
+ if (lpcbSecurityDescriptor)
+ lpcbSecurityDescriptor1 = (*env)->GetIntArrayElements(env, lpcbSecurityDescriptor, NULL);
+
+ rc = (jint) RegQueryInfoKey((HKEY)hKey, (LPTSTR)lpClass, lpcbClass1, (LPDWORD)lpReserved, lpSubKeys1, lpcbMaxSubKeyLen1, lpcbMaxClassLen1, lpcValues1, lpcbMaxValueNameLen1, lpcbMaxValueLen1, lpcbSecurityDescriptor1, (PFILETIME)lpftLastWriteTime);
+
+ if (lpcbClass)
+ (*env)->ReleaseIntArrayElements(env, lpcbClass, lpcbClass1, 0);
+ if (lpSubKeys)
+ (*env)->ReleaseIntArrayElements(env, lpSubKeys, lpSubKeys1, 0);
+ if (lpcbMaxSubKeyLen)
+ (*env)->ReleaseIntArrayElements(env, lpcbMaxSubKeyLen, lpcbMaxSubKeyLen1, 0);
+ if (lpcbMaxClassLen)
+ (*env)->ReleaseIntArrayElements(env, lpcbMaxClassLen, lpcbMaxClassLen1, 0);
+ if (lpcValues)
+ (*env)->ReleaseIntArrayElements(env, lpcValues, lpcValues1, 0);
+ if (lpcbMaxValueNameLen)
+ (*env)->ReleaseIntArrayElements(env, lpcbMaxValueNameLen, lpcbMaxValueNameLen1, 0);
+ if (lpcbMaxValueLen)
+ (*env)->ReleaseIntArrayElements(env, lpcbMaxValueLen, lpcbMaxValueLen1, 0);
+ if (lpcbSecurityDescriptor)
+ (*env)->ReleaseIntArrayElements(env, lpcbSecurityDescriptor, lpcbSecurityDescriptor1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RegQueryValueEx
+ * Signature: (I[BI[I[B[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_RegQueryValueEx
+ (JNIEnv *env, jclass that, jint hKey, jbyteArray lpValueName, jint lpReserved, jintArray lpType, jbyteArray lpData, jintArray lpcbData)
+{
+ jbyte *lpValueName1=NULL;
+ jbyte *lpData1=NULL;
+ jint *lpType1=NULL;
+ jint *lpcbData1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegQueryValueEx\n");
+#endif
+
+ if (lpValueName)
+ lpValueName1 = (*env)->GetByteArrayElements(env, lpValueName, NULL);
+ if (lpData)
+ lpData1 = (*env)->GetByteArrayElements(env, lpData, NULL);
+ if (lpType)
+ lpType1 = (*env)->GetIntArrayElements(env, lpType, NULL);
+ if (lpcbData)
+ lpcbData1 = (*env)->GetIntArrayElements(env, lpcbData, NULL);
+
+ rc = (jint) RegQueryValueEx((HKEY)hKey, (LPCTSTR)lpValueName1, (LPDWORD)lpReserved, lpType1, (LPBYTE)lpData1, lpcbData1);
+
+ if (lpValueName)
+ (*env)->ReleaseByteArrayElements(env, lpValueName, lpValueName1, 0);
+ if (lpData)
+ (*env)->ReleaseByteArrayElements(env, lpData, lpData1, 0);
+ if (lpType)
+ (*env)->ReleaseIntArrayElements(env, lpType, lpType1, 0);
+ if (lpcbData)
+ (*env)->ReleaseIntArrayElements(env, lpcbData, lpcbData1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ReleaseCapture
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ReleaseCapture
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ReleaseCapture\n");
+#endif
+
+ return (jboolean) ReleaseCapture();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ReleaseDC
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ReleaseDC
+ (JNIEnv *env, jclass that, jint hWnd, jint hDC)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ReleaseDC\n");
+#endif
+
+ return (jint) ReleaseDC((HWND)hWnd, (HDC)hDC);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RemoveMenu
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_RemoveMenu
+ (JNIEnv *env, jclass that, jint hMenu, jint uPosition, jint uFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RemoveMenu\n");
+#endif
+
+ return (jboolean) RemoveMenu((HMENU)hMenu, uPosition, uFlags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: RoundRect
+ * Signature: (IIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_RoundRect
+ (JNIEnv *env, jclass that, jint hdc, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect, jint nWidth, jint nHeight)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RoundRect\n");
+#endif
+
+ return (jboolean) RoundRect((HDC)hdc, nLeftRect, nTopRect, nRightRect, nBottomRect, nWidth, nHeight);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ScreenToClient
+ * Signature: (ILorg/eclipse/swt/internal/win32/POINT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ScreenToClient
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpPoint)
+{
+ DECL_GLOB(pGlob)
+ POINT point1, *lpPoint1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ScreenToClient\n");
+#endif
+
+ if (lpPoint) {
+ lpPoint1 = &point1;
+ cachePointFids(env, lpPoint, &PGLOB(PointFc));
+ getPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ rc = (jboolean) ScreenToClient((HWND)hWnd, lpPoint1);
+ if (lpPoint) {
+ setPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ScrollWindowEx
+ * Signature: (IIILorg/eclipse/swt/internal/win32/RECT;Lorg/eclipse/swt/internal/win32/RECT;ILorg/eclipse/swt/internal/win32/RECT;I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ScrollWindowEx
+ (JNIEnv *env, jclass that, jint hWnd, jint dx, jint dy, jobject prcScroll, jobject prcClip, jint hrgnUpdate, jobject prcUpdate, jint flags)
+{
+ DECL_GLOB(pGlob)
+ RECT rect1, rect2, rect3;
+ RECT *prcScroll1=NULL, *prcClip1=NULL, *prcUpdate1=NULL;
+ jobject lpRect;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ScrollWindowEx\n");
+#endif
+
+ if (prcScroll || prcClip || prcUpdate) {
+ if (prcScroll) {
+ lpRect = prcScroll;
+ }
+ else if (prcClip) {
+ lpRect = prcClip;
+ }
+ else if (prcUpdate) {
+ lpRect = prcUpdate;
+ }
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ }
+
+ if (prcScroll) {
+ prcScroll1 = &rect1;
+ getRectFields(env, prcScroll, prcScroll1, &PGLOB(RectFc));
+ }
+ if (prcClip) {
+ prcClip1 = &rect2;
+ getRectFields(env, prcClip, prcClip1, &PGLOB(RectFc));
+ }
+ if (prcUpdate) {
+ prcUpdate1 = &rect3;
+ getRectFields(env, prcUpdate, prcUpdate1, &PGLOB(RectFc));
+ }
+ rc = (jint) ScrollWindowEx((HWND)hWnd, dx, dy, prcScroll1, prcClip1, (HRGN)hrgnUpdate, prcUpdate1, flags);
+ if (prcScroll) {
+ setRectFields(env, prcScroll, prcScroll1, &PGLOB(RectFc));
+ }
+ if (prcClip) {
+ setRectFields(env, prcClip, prcClip1, &PGLOB(RectFc));
+ }
+ if (prcUpdate) {
+ setRectFields(env, prcUpdate, prcUpdate1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SelectClipRgn
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SelectClipRgn
+ (JNIEnv *env, jclass that, jint hdc, jint hrgn)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SelectClipRgn\n");
+#endif
+
+ return (jint) SelectClipRgn((HDC)hdc, (HRGN)hrgn);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SelectObject
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SelectObject
+ (JNIEnv *env, jclass that, jint hdc, jint hgdiobj)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SelectObject\n");
+#endif
+
+ return (jint) SelectObject((HDC)hdc, (HGDIOBJ)hgdiobj);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SelectPalette
+ * Signature: (IIZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SelectPalette
+ (JNIEnv *env, jclass that, jint hdc, jint hpal, jboolean bForceBackground)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SelectPalette\n");
+#endif
+
+ return (jint) SelectPalette((HDC)hdc, (HPALETTE)hpal, bForceBackground);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (II[I[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__II_3I_3B
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jintArray wParam, jbyteArray lParam)
+{
+ jint *wParam1=NULL;
+ jbyte *lParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__II_3I_3B\n");
+#endif
+
+ if (wParam)
+ wParam1 = (*env)->GetIntArrayElements(env, wParam, NULL);
+ if (lParam)
+ lParam1 = (*env)->GetByteArrayElements(env, lParam, NULL);
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, (WPARAM)wParam1, (LPARAM)lParam1);
+
+ if (wParam)
+ (*env)->ReleaseIntArrayElements(env, wParam, wParam1, 0);
+ if (lParam)
+ (*env)->ReleaseByteArrayElements(env, lParam, lParam1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (II[II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__II_3II
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jintArray wParam, jint lParam)
+{
+ jint *wParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__II_3II\n");
+#endif
+
+ if (wParam)
+ wParam1 = (*env)->GetIntArrayElements(env, wParam, NULL);
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, (WPARAM)wParam1, (LPARAM)lParam);
+
+ if (wParam)
+ (*env)->ReleaseIntArrayElements(env, wParam, wParam1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (II[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__II_3I_3I
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jintArray wParam, jintArray lParam)
+{
+ WPARAM wParam1=0;
+ LPARAM lParam1=0;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__II_3I_3I\n");
+#endif
+
+ if (wParam)
+ wParam1 = (WPARAM)(*env)->GetIntArrayElements(env, wParam, NULL);
+ if (lParam)
+ lParam1 = (LPARAM)(*env)->GetIntArrayElements(env, lParam, NULL);
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam1, lParam1);
+
+ if (wParam)
+ (*env)->ReleaseIntArrayElements(env, wParam, (jint *)wParam1, 0);
+ if (lParam)
+ (*env)->ReleaseIntArrayElements(env, lParam, (jint *)lParam1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (III[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__III_3B
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jbyteArray lParam)
+{
+ LPARAM lParam1=0;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__III_3B\n");
+#endif
+
+ if (lParam)
+ lParam1 = (LPARAM)(*env)->GetByteArrayElements(env, lParam, NULL);
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, lParam1);
+
+ if (lParam)
+ (*env)->ReleaseByteArrayElements(env, lParam, (jbyte *)lParam1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (III[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__III_3I
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jintArray lParam)
+{
+ LPARAM lParam1=0;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__III_3I\n");
+#endif
+
+ if (lParam)
+ lParam1 = (LPARAM)(*env)->GetIntArrayElements(env, lParam, NULL);
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, lParam1);
+
+ if (lParam)
+ (*env)->ReleaseIntArrayElements(env, lParam, (jint *)lParam1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (III[S)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__III_3S
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jshortArray lParam)
+{
+ LPARAM lParam1=0;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__III_3S\n");
+#endif
+
+ if (lParam)
+ lParam1 = (LPARAM)(*env)->GetShortArrayElements(env, lParam, NULL);
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, lParam1);
+
+ if (lParam)
+ (*env)->ReleaseShortArrayElements(env, lParam, (jshort *)lParam1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIII
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jint lParam)
+{
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIII\n");
+#endif
+
+ return (jint) SendMessage((HWND)hWnd, Msg, wParam, lParam);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/CHARFORMAT2;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_CHARFORMAT2_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ CHARFORMAT2 charformat2, *lParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_CHARFORMAT2_2\n");
+#endif
+
+ if (lParam) {
+ lParam1 = &charformat2;
+ cacheCharformat2Fids(env, lParam, &PGLOB(Charformat2Fc));
+ getCharformat2Fields(env, lParam, lParam1, &PGLOB(Charformat2Fc));
+ }
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lParam1);
+ if (lParam) {
+ setCharformat2Fields(env, lParam, lParam1, &PGLOB(Charformat2Fc));
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/LVCOLUMN;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ LVCOLUMN lvcolumn, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_LVCOLUMN_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &lvcolumn;
+ cacheLvcolumnFids(env, lParam, &PGLOB(LvcolumnFc));
+ getLvcolumnFields(env, lParam, lpParam1, &PGLOB(LvcolumnFc));
+ }
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+
+ if (lParam) {
+ setLvcolumnFields(env, lParam, lpParam1, &PGLOB(LvcolumnFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/LVHITTESTINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ LVHITTESTINFO lvhittestinfo, *lParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_LVHITTESTINFO_2\n");
+#endif
+
+ if (lParam) {
+ lParam1 = &lvhittestinfo;
+ cacheLvhittestinfoFids(env, lParam, &PGLOB(LvhittestinfoFc));
+ getLvhittestinfoFields(env, lParam, lParam1, &PGLOB(LvhittestinfoFc));
+ }
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lParam1);
+
+ if (lParam) {
+ setLvhittestinfoFields(env, lParam, lParam1, &PGLOB(LvhittestinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/LVITEM;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_LVITEM_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ LVITEM lvitem, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_LVITEM_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &lvitem;
+ cacheLvitemFids(env, lParam, &PGLOB(LvitemFc));
+ getLvitemFields(env, lParam, lpParam1, &PGLOB(LvitemFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setLvitemFields(env, lParam, lpParam1, &PGLOB(LvitemFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/PARAFORMAT;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_PARAFORMAT_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ PARAFORMAT paraformat, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_PARAFORMAT_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &paraformat;
+ cacheParaformatFids(env, lParam, &PGLOB(ParaformatFc));
+ getParaformatFields(env, lParam, lpParam1, &PGLOB(ParaformatFc));
+ }
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+
+ if (lParam) {
+ setParaformatFields(env, lParam, lpParam1, &PGLOB(ParaformatFc));
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/REBARBANDINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ REBARBANDINFO rebarbandinfo, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_REBARBANDINFO_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &rebarbandinfo;
+ cacheRebarbandinfoFids(env, lParam, &PGLOB(RebarbandinfoFc));
+ getRebarbandinfoFields(env, lParam, lpParam1, &PGLOB(RebarbandinfoFc));
+ }
+
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+
+ if (lParam) {
+ setRebarbandinfoFields(env, lParam, lpParam1, &PGLOB(RebarbandinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/RECT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_RECT_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_RECT_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &rect;
+ cacheRectFids(env, lParam, &PGLOB(RectFc));
+ getRectFields(env, lParam, lpParam1, &PGLOB(RectFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setRectFields(env, lParam, lpParam1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TBBUTTON;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TBBUTTON tbbutton, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TBBUTTON_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &tbbutton;
+ cacheTbbuttonFids(env, lParam, &PGLOB(TbbuttonFc));
+ getTbbuttonFields(env, lParam, lpParam1, &PGLOB(TbbuttonFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setTbbuttonFields(env, lParam, lpParam1, &PGLOB(TbbuttonFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TBBUTTONINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TBBUTTONINFO tbbuttoninfo, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TBBUTTONINFO_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &tbbuttoninfo;
+ cacheTbbuttoninfoFids(env, lParam, &PGLOB(TbbuttoninfoFc));
+ getTbbuttoninfoFields(env, lParam, lpParam1, &PGLOB(TbbuttoninfoFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+
+ if (lParam) {
+ setTbbuttoninfoFields(env, lParam, lpParam1, &PGLOB(TbbuttoninfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TCITEM;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TCITEM_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TCITEM tcitem, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TCITEM_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &tcitem;
+ cacheTcitemFids(env, lParam, &PGLOB(TcitemFc));
+ getTcitemFields(env, lParam, lpParam1, &PGLOB(TcitemFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setTcitemFields(env, lParam, lpParam1, &PGLOB(TcitemFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TOOLINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2
+ (JNIEnv * env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TOOLINFO toolinfo, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TOOLINFO_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &toolinfo;
+ cacheToolinfoFids(env, lParam, &PGLOB(ToolinfoFc));
+ getToolinfoFields(env, lParam, lpParam1, &PGLOB(ToolinfoFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setToolinfoFields(env, lParam, lpParam1, &PGLOB(ToolinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TVHITTESTINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TVHITTESTINFO tvhittestinfo, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TVHITTESTINFO_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &tvhittestinfo;
+ cacheTvhittestinfoFids(env, lParam, &PGLOB(TvhittestinfoFc));
+ getTvhittestinfoFields(env, lParam, lpParam1, &PGLOB(TvhittestinfoFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setTvhittestinfoFields(env, lParam, lpParam1, &PGLOB(TvhittestinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TVINSERTSTRUCT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TVINSERTSTRUCT tvinsertstruct, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TVINSERTSTRUCT_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &tvinsertstruct;
+ cacheTvinsertstructFids(env, lParam, &PGLOB(TvinsertstructFc));
+ getTvinsertstructFields(env, lParam, lpParam1, &PGLOB(TvinsertstructFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setTvinsertstructFields(env, lParam, lpParam1, &PGLOB(TvinsertstructFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/TVITEM;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_TVITEM_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ DECL_GLOB(pGlob)
+ TVITEM tvitem, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_TVITEM_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &tvitem;
+ cacheTvitemFids(env, lParam, &PGLOB(TvitemFc));
+ getTvitemFields(env, lParam, lpParam1, &PGLOB(TvitemFc));
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setTvitemFields(env, lParam, lpParam1, &PGLOB(TvitemFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetActiveWindow
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetActiveWindow
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetActiveWindow\n");
+#endif
+
+ return (jint) SetActiveWindow((HWND) hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetBkColor
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetBkColor
+ (JNIEnv *env, jclass that, jint hdc, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetBkColor\n");
+#endif
+
+ return (jint) SetBkColor((HDC)hdc, (COLORREF)crColor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetBkMode
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetBkMode
+ (JNIEnv *env, jclass that, jint hdc, jint iBkMode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetBkMode\n");
+#endif
+ return (jint) SetBkMode((HDC)hdc, iBkMode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetCapture
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetCapture
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetCapture\n");
+#endif
+
+ return (jint) SetCapture((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetCaretPos
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetCaretPos
+ (JNIEnv *env, jclass that, jint X, jint Y)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetCaretPos\n");
+#endif
+
+ return (jboolean) SetCaretPos(X, Y);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetClipboardData
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetClipboardData
+ (JNIEnv *env, jclass that, jint uFormat, jint hMem)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetClipboardData\n");
+#endif
+ return (jint) SetClipboardData(uFormat, (HANDLE)hMem);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetCursor
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetCursor
+ (JNIEnv *env, jclass that, jint hCursor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetCursor\n");
+#endif
+
+ return (jint) SetCursor((HCURSOR)hCursor);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetDIBColorTable
+ * Signature: (III[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetDIBColorTable
+ (JNIEnv *env, jclass that, jint hdc, jint uStartIndex, jint cEntries, jbyteArray pColors)
+{
+ RGBQUAD *pColors1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetDIBColorTable\n");
+#endif
+
+ if (pColors)
+ pColors1 = (RGBQUAD *)(*env)->GetByteArrayElements(env,pColors, NULL);
+
+ rc = (jint)SetDIBColorTable((HDC)hdc, uStartIndex, cEntries, pColors1);
+
+ if (pColors)
+ (*env)->ReleaseByteArrayElements(env, pColors, (jbyte *)pColors1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetFocus
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetFocus
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetFocus\n");
+#endif
+
+ return (jint) SetFocus((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetMapMode
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetMapMode
+ (JNIEnv *env, jclass that, jint hdc, jint fnMapMode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetMapMode\n");
+#endif
+ return (jint) SetMapMode((HDC)hdc, fnMapMode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetMenu
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetMenu
+ (JNIEnv *env, jclass that, jint hWnd, jint hMenu)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetMenu\n");
+#endif
+
+ return (jboolean) SetMenu((HWND)hWnd, (HMENU)hMenu);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ShowOwnedPopups:with:
+ * Signature: (IZ)Z
+ */
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ShowOwnedPopups
+ (JNIEnv *env, jclass that, jint hWnd, jboolean fShow)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetShowOwnedPopups\n");
+#endif
+
+ return (jboolean) ShowOwnedPopups((HWND)hWnd, fShow);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetMenuDefaultItem
+ * Signature: (III)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetMenuDefaultItem
+ (JNIEnv *env, jclass that, jint hMenu, jint uItem, jint fByPos)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetMenuDefaultItem\n");
+#endif
+
+ return (jboolean) SetMenuDefaultItem((HMENU)hMenu, uItem, fByPos);
+}
+
+#ifdef USE_2000_CALLS
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetMenuInfo
+ * Signature: (ILorg/eclipse/swt/internal/win32/MENUINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetMenuInfo
+ (JNIEnv *env, jclass that, jint hmenu, jobject lpcmi)
+{
+ DECL_GLOB(pGlob)
+ HMODULE hm;
+ FARPROC fp;
+ MENUINFO menuinfo, *lpcmi1=NULL;
+ jboolean rc=FALSE;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetMenuInfo\n");
+#endif
+
+ /*
+ ** SetMenuInfo is a Win2000 and Win98 specific call
+ ** If you link it into swt.dll a system modal entry point not found dialog will
+ ** appear as soon as swt.dll is loaded. Here we check for the entry point and
+ ** only do the call if it exists.
+ */
+ if ((hm=GetModuleHandle("user32.dll")) && (fp=GetProcAddress(hm, "SetMenuInfo"))) {
+
+ if (lpcmi) {
+ lpcmi1 = &menuinfo;
+ cacheMenuinfoFids(env, lpcmi, &PGLOB(MenuinfoFc));
+ getMenuinfoFields(env, lpcmi, lpcmi1, &PGLOB(MenuinfoFc));
+ }
+ rc = (jboolean) (fp)((HMENU)hmenu, lpcmi1);
+// rc = (jboolean) SetMenuInfo((HMENU)hmenu, lpcmi1);
+ if (lpcmi) {
+ setMenuinfoFields(env, lpcmi, lpcmi1, &PGLOB(MenuinfoFc));
+ }
+ }
+ return rc;
+}
+#endif
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetMenuItemInfo
+ * Signature: (IIZLorg/eclipse/swt/internal/win32/MENUITEMINFO;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetMenuItemInfo
+ (JNIEnv *env, jclass that, jint hMenu, jint uItem, jboolean fByPosition, jobject lpmii)
+{
+ DECL_GLOB(pGlob)
+ MENUITEMINFO mii1, *lpmii1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetMenuItemInfo\n");
+#endif
+
+ if (lpmii) {
+ lpmii1 = &mii1;
+ cacheMenuiteminfoFids(env, lpmii, &PGLOB(MenuiteminfoFc));
+ getMenuiteminfoFields(env, lpmii, lpmii1, &PGLOB(MenuiteminfoFc));
+ }
+ rc = (jboolean) SetMenuItemInfo((HMENU)hMenu, uItem, fByPosition, lpmii1);
+ if (lpmii) {
+ setMenuiteminfoFields(env, lpmii, lpmii1, &PGLOB(MenuiteminfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetPaletteEntries
+ * Signature: (III[B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetPaletteEntries
+ (JNIEnv *env, jclass that, jint hPal, jint iStart, jint cEntries, jbyteArray lppe)
+{
+ PALETTEENTRY *lppe1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetPaletteEntries\n");
+#endif
+
+ if (lppe)
+ lppe1 = (PALETTEENTRY *)(*env)->GetByteArrayElements(env, lppe, NULL);
+
+ rc = (jint) SetPaletteEntries((HPALETTE)hPal, iStart, cEntries, lppe1);
+
+ if (lppe)
+ (*env)->ReleaseByteArrayElements(env, lppe, (jbyte *)lppe1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetParent
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetParent
+ (JNIEnv *env, jclass that, jint hWndChild, jint hWndNewParent)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetParent\n");
+#endif
+
+ return (jint) SetParent((HWND)hWndChild, (HWND)hWndNewParent);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetPixel
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetPixel
+ (JNIEnv *env, jclass that, jint hDC, jint X, jint Y, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetPixel\n");
+#endif
+
+ return (jint) SetPixel((HDC) hDC, X, Y, crColor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetRect
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;IIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetRect
+ (JNIEnv *env, jclass that, jobject lprc, jint xLeft, jint yTop, jint xRight, jint yBottom)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lprc1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetRect\n");
+#endif
+
+ if (lprc) {
+ lprc1 = &rect;
+ cacheRectFids(env, lprc, &PGLOB(RectFc));
+ getRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) SetRect(lprc1, xLeft, yTop, xRight, yBottom);
+
+ if (lprc) {
+ setRectFields(env, lprc, lprc1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetRectRgn
+ * Signature: (IIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetRectRgn
+ (JNIEnv *env, jclass that, jint hrgn, jint nLeftRect, jint nTopRect, jint nRightRect, jint nBottomRect)
+{
+ return (jboolean) SetRectRgn((HRGN)hrgn, nLeftRect, nTopRect, nRightRect, nBottomRect);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetROP2
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetROP2
+ (JNIEnv *env, jclass that, jint hdc, jint fnDrawMode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetROP2\n");
+#endif
+ return (jint) SetROP2((HDC)hdc, fnDrawMode);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetScrollInfo
+ * Signature: (IILorg/eclipse/swt/internal/win32/SCROLLINFO;Z)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetScrollInfo
+ (JNIEnv *env, jclass that, jint hWnd, jint fnBar, jobject lpsi, jboolean fRedraw)
+{
+ DECL_GLOB(pGlob)
+ SCROLLINFO si1, *lpsi1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetScrollInfo\n");
+#endif
+
+ if (lpsi) {
+ lpsi1 = &si1;
+ cacheScrollinfoFids(env, lpsi, &PGLOB(ScrollinfoFc));
+ getScrollinfoFields(env, lpsi, lpsi1, &PGLOB(ScrollinfoFc));
+ }
+ rc = (jboolean) SetScrollInfo((HWND)hWnd, fnBar, lpsi1, fRedraw);
+ if (lpsi) {
+ setScrollinfoFields(env, lpsi, lpsi1, &PGLOB(ScrollinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetTextColor
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetTextColor
+ (JNIEnv *env, jclass that, jint hdc, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetTextColor\n");
+#endif
+
+ return (jint) SetTextColor((HDC)hdc, (COLORREF)crColor);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetWindowLong
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetWindowLong
+ (JNIEnv *env, jclass that, jint hWnd, jint nIndex, jint dwNewLong)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetWindowLong\n");
+#endif
+
+ return (jint) SetWindowLong((HWND)hWnd, nIndex,dwNewLong);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetWindowPlacement
+ * Signature: (ILorg/eclipse/swt/internal/win32/WINDOWPLACEMENT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetWindowPlacement
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpwndpl)
+{
+ DECL_GLOB(pGlob)
+ WINDOWPLACEMENT wndpl, *lpwndpl1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetWindowPlacement\n");
+#endif
+
+ if (lpwndpl) {
+ lpwndpl1 = &wndpl;
+ cacheWindowplacementFids(env, lpwndpl, &PGLOB(WindowplacementFc));
+ getWindowplacementFields(env, lpwndpl, lpwndpl1, &PGLOB(WindowplacementFc));
+ }
+ rc = (jboolean) SetWindowPlacement((HWND)hWnd, lpwndpl1);
+ if (lpwndpl) {
+ setWindowplacementFields(env, lpwndpl, lpwndpl1, &PGLOB(WindowplacementFc)); }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetWindowPos
+ * Signature: (IIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetWindowPos
+ (JNIEnv *env, jclass that, jint hWnd, jint hWndInsertAfter, jint X, jint Y, jint cx, jint cy, jint uFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetWindowPos\n");
+#endif
+
+ return (jboolean) SetWindowPos((HWND)hWnd, (HWND)hWndInsertAfter, X, Y, cx, cy, uFlags);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetWindowText
+ * Signature: (I[B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetWindowText
+ (JNIEnv *env, jclass that, jint hWnd, jbyteArray lpString)
+{
+ LPCTSTR lpString1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetWindowText\n");
+#endif
+
+ if (lpString)
+ lpString1 = (*env)->GetByteArrayElements(env, lpString, NULL);
+
+ rc = (jboolean) SetWindowText((HWND)hWnd, lpString1);
+
+ if (lpString)
+ (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SHBrowseForFolder
+ * Signature: (Lorg/eclipse/swt/internal/win32/BROWSEINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SHBrowseForFolder
+ (JNIEnv *env, jclass that, jobject lpbi)
+{
+ DECL_GLOB(pGlob)
+ BROWSEINFO bi, *lpbi1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SHBrowseForFolder\n");
+#endif
+
+ if (lpbi) {
+ lpbi1 = &bi;
+ cacheBrowseinfoFids(env, lpbi, &PGLOB(BrowseinfoFc));
+ getBrowseinfoFields(env, lpbi, lpbi1, &PGLOB(BrowseinfoFc));
+ }
+ rc = (jint) SHBrowseForFolder(lpbi1);
+ if (lpbi) {
+ setBrowseinfoFields(env, lpbi, lpbi1, &PGLOB(BrowseinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ShellExecute
+ * Signature: (I[B[B[B[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ShellExecute
+ (JNIEnv *env, jclass that, jint hwnd, jbyteArray lpOperation, jbyteArray lpFile,
+ jbyteArray lpParameters, jbyteArray lpDirectory, jint nShowCmd)
+{
+ LPCTSTR lpOperation1=NULL, lpFile1=NULL, lpParameters1=NULL, lpDirectory1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ShellExecute\n");
+#endif
+
+ if (lpOperation)
+ lpOperation1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpOperation, NULL);
+
+ if (lpFile)
+ lpFile1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpFile, NULL);
+
+ if (lpParameters)
+ lpParameters1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpParameters, NULL);
+
+ if (lpDirectory)
+ lpDirectory1 = (LPCTSTR)(*env)->GetByteArrayElements(env,lpDirectory, NULL);
+
+ rc = (jint)ShellExecute((HWND) hwnd, lpOperation1, lpFile1, lpParameters1, lpDirectory1, nShowCmd);
+
+ if (lpOperation)
+ (*env)->ReleaseByteArrayElements(env, lpOperation, (jbyte *)lpOperation1, 0);
+ if (lpFile)
+ (*env)->ReleaseByteArrayElements(env, lpFile, (jbyte *)lpFile1, 0);
+ if (lpParameters)
+ (*env)->ReleaseByteArrayElements(env, lpParameters, (jbyte *)lpParameters1, 0);
+ if (lpDirectory)
+ (*env)->ReleaseByteArrayElements(env, lpDirectory, (jbyte *)lpDirectory1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SHGetMalloc
+ * Signature: ([I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SHGetMalloc
+ (JNIEnv *env, jclass that, jintArray ppMalloc)
+{
+ LPMALLOC *ppMalloc1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SHGetMalloc\n");
+#endif
+
+ if (ppMalloc)
+ ppMalloc1 = (LPMALLOC *)(*env)->GetIntArrayElements(env, ppMalloc, NULL);
+
+ rc = (jint) SHGetMalloc(ppMalloc1);
+
+ if (ppMalloc)
+ (*env)->ReleaseIntArrayElements(env, ppMalloc, (jint *)ppMalloc1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SHGetPathFromIDList
+ * Signature: (I[B)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SHGetPathFromIDList
+ (JNIEnv *env, jclass that, jint pidl, jbyteArray pszPath)
+{
+ LPSTR pszPath1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SHGetPathFromIDList\n");
+#endif
+
+ if (pszPath)
+ pszPath1 = (*env)->GetByteArrayElements(env,pszPath, NULL);
+
+ rc = (jboolean)SHGetPathFromIDList((LPCITEMIDLIST)pidl, pszPath1);
+
+ if (pszPath)
+ (*env)->ReleaseByteArrayElements(env, pszPath, (jbyte *)pszPath1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ShowCaret
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ShowCaret
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ShowCaret\n");
+#endif
+
+ return (jboolean) ShowCaret((HWND)hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ShowScrollBar
+ * Signature: (IIZ)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ShowScrollBar
+ (JNIEnv *env, jclass that, jint hWnd, jint wBar, jboolean bShow)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ShowScrollBar\n");
+#endif
+
+ return (jboolean) ShowScrollBar((HWND)hWnd, wBar, bShow);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ShowWindow
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ShowWindow
+ (JNIEnv *env, jclass that, jint hWnd, jint nCmdShow)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ShowWindow\n");
+#endif
+
+ return (jboolean) ShowWindow((HWND)hWnd, nCmdShow);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: StartDoc
+ * Signature: (ILorg/eclipse/swt/internal/win32/DOCINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_StartDoc
+ (JNIEnv *env, jclass that, jint hdc, jobject lpdi)
+{
+ DECL_GLOB(pGlob)
+ DOCINFO di, *lpdi1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "StartDoc\n");
+#endif
+
+ if (lpdi) {
+ lpdi1 = &di;
+ cacheDocinfoFids(env, lpdi, &PGLOB(DocinfoFc));
+ getDocinfoFields(env, lpdi, lpdi1, &PGLOB(DocinfoFc));
+ }
+ rc = (jint) StartDoc((HDC)hdc, lpdi1);
+ if (lpdi) {
+ setDocinfoFields(env, lpdi, lpdi1, &PGLOB(DocinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: StartPage
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_StartPage
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "StartPage\n");
+#endif
+ return (jint) StartPage((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: StretchBlt
+ * Signature: (IIIIIIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_StretchBlt
+ (JNIEnv *env, jclass that, jint hdcDest, jint nxOriginDest, jint nyOriginDest, jint nWidthDest, jint nHeightDest,
+ jint hdcSrc, jint nXOriginSrc, jint nYOriginSrc, jint nWidthSrc, jint nHeightSrc, jint dwRop)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "StretchBlt\n");
+#endif
+
+ return (jboolean) StretchBlt((HDC)hdcDest, nxOriginDest, nyOriginDest, nWidthDest, nHeightDest,
+ (HDC)hdcSrc, nXOriginSrc, nYOriginSrc, nWidthSrc, nHeightSrc, dwRop);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: TextOut
+ * Signature: (III[BI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_TextOut
+ (JNIEnv *env, jclass that, jint hdc, jint nXStart, jint nYStart, jbyteArray lpString, jint cbString)
+{
+ LPCTSTR lpString1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "TextOut\n");
+#endif
+
+ if (lpString)
+ lpString1 = (*env)->GetByteArrayElements(env, lpString, NULL);
+
+ rc = (jboolean) TextOut((HDC)hdc, nXStart, nYStart, lpString1, cbString);
+
+ if (lpString)
+ (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ToAscii
+ * Signature: (II[B[SI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ToAscii
+ (JNIEnv *env, jclass that, jint uVirtKey, jint uScanMode, jbyteArray lpKeyState, jshortArray lpChar, jint uFlags)
+{
+ PBYTE lpKeyState1=NULL;
+ LPWORD lpChar1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ToAscii\n");
+#endif
+
+ if (lpKeyState)
+ lpKeyState1 = (*env)->GetByteArrayElements(env, lpKeyState, NULL);
+ if (lpChar)
+ lpChar1 = (*env)->GetShortArrayElements(env, lpChar, NULL);
+
+ rc = (jint) ToAscii(uVirtKey, uScanMode, lpKeyState1, lpChar1, uFlags);
+
+ if (lpKeyState)
+ (*env)->ReleaseByteArrayElements(env, lpKeyState, (jbyte *)lpKeyState1, 0);
+ if (lpChar)
+ (*env)->ReleaseShortArrayElements(env, lpChar, (jshort *)lpChar1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: TrackMouseEvent
+ * Signature: (Lorg/eclipse/swt/internal/win32/TRACKMOUSEEVENT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_TrackMouseEvent
+ (JNIEnv *env, jclass that, jobject lpEventTrack)
+{
+ DECL_GLOB(pGlob)
+ TRACKMOUSEEVENT eventTrack, *lpEventTrack1=NULL;
+ jboolean rc;
+
+#ifdef DEEBUG_CALL_PRINTS
+ fprintf(stderr, "TrackMouseEvent\n");
+#endif
+
+ if (lpEventTrack) {
+ lpEventTrack1 = &eventTrack;
+ cacheTrackmouseeventFids(env, lpEventTrack, &PGLOB(TrackmouseeventFc));
+ getTrackmouseeventFields(env, lpEventTrack, lpEventTrack1, &PGLOB(TrackmouseeventFc));
+ }
+ rc = (jboolean) _TrackMouseEvent(lpEventTrack1);
+ if (lpEventTrack) {
+ setTrackmouseeventFields(env, lpEventTrack, lpEventTrack1, &PGLOB(TrackmouseeventFc));
+ }
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: TrackPopupMenu
+ * Signature: (IIIIIILorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_TrackPopupMenu
+ (JNIEnv *env, jclass that, jint hMenu, jint uFlags, jint x, jint y, jint nReserved, jint hWnd, jobject lpRect)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "TrackPopupMenu\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) TrackPopupMenu((HMENU)hMenu, uFlags, x, y, nReserved, (HWND)hWnd, lpRect1);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: TranslateAccelerator
+ * Signature: (IILorg/eclipse/swt/internal/win32/MSG;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_TranslateAccelerator
+ (JNIEnv *env, jclass that, jint hWnd, jint hAccTable, jobject lpMsg)
+{
+ DECL_GLOB(pGlob)
+ MSG callBack, *lpMsg1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "TranslateAccelerator\n");
+#endif
+
+ if (lpMsg) {
+ lpMsg1 = &callBack;
+ cacheMsgFids(env, lpMsg, &PGLOB(MsgFc));
+ getMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ rc = (jint)TranslateAccelerator((HWND)hWnd, (HACCEL)hAccTable, lpMsg1);
+ if (lpMsg) {
+ setMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: TranslateMessage
+ * Signature: (Lorg/eclipse/swt/internal/win32/MSG;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_TranslateMessage
+ (JNIEnv *env, jclass that, jobject lpMsg)
+{
+ DECL_GLOB(pGlob)
+ MSG callBack, *lpMsg1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "TranslateMessage\n");
+#endif
+
+ if (lpMsg) {
+ lpMsg1 = &callBack;
+ cacheMsgFids(env, lpMsg, &PGLOB(MsgFc));
+ getMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ rc = (jboolean)TranslateMessage(lpMsg1);
+ if (lpMsg) {
+ setMsgFields(env, lpMsg, lpMsg1, &PGLOB(MsgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: UnregisterClass
+ * Signature: ([BI)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_UnregisterClass
+ (JNIEnv *env, jclass that, jbyteArray lpClassName, jint hInstance)
+{
+ LPCTSTR lpClassName1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "UnregisterClass\n");
+#endif
+
+ if (lpClassName)
+ lpClassName1 = (*env)->GetByteArrayElements(env,lpClassName, NULL);
+
+ rc = (jboolean)UnregisterClass(lpClassName1, (HINSTANCE)hInstance);
+
+ if (lpClassName)
+ (*env)->ReleaseByteArrayElements(env, lpClassName, (jbyte *)lpClassName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: UpdateWindow
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_UpdateWindow
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "UpdateWindow\n");
+#endif
+
+ return (jboolean) UpdateWindow((HWND) hWnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ValidateRect
+ * Signature: (ILorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_ValidateRect
+ (JNIEnv *env, jclass that, jint hWnd, jobject lpRect)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpRect1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ValidateRect\n");
+#endif
+
+ if (lpRect) {
+ lpRect1 = &rect;
+ cacheRectFids(env, lpRect, &PGLOB(RectFc));
+ getRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ rc = (jboolean) ValidateRect((HWND)hWnd, lpRect1);
+ if (lpRect) {
+ setRectFields(env, lpRect, lpRect1, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: VkKeyScan
+ * Signature: (S)S
+ */
+JNIEXPORT jshort JNICALL Java_org_eclipse_swt_internal_win32_OS_VkKeyScan
+ (JNIEnv *env, jclass that, jshort ch)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VkKeyScan\n");
+#endif
+
+ return (jshort) VkKeyScan((TCHAR)ch);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: WaitMessage
+ * Signature: ()Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_WaitMessage
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "WaitMessage\n");
+#endif
+
+ return (jboolean) WaitMessage();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: WideCharToMultiByte
+ * Signature: (II[CI[BI[B[Z)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_WideCharToMultiByte
+ (JNIEnv *env, jclass that,
+ jint CodePage, jint dwFlags, jcharArray lpWideCharStr, jint cchWideChar,
+ jbyteArray lpMultiByteCharStr, jint cchMultiByte, jbyteArray lpDefaultChar,
+ jbooleanArray lpUsedDefaultChar)
+{
+ LPCWSTR lpWideCharStr1=NULL;
+ LPSTR lpMultiByteCharStr1=NULL;
+ LPCSTR lpDefaultChar1=NULL;
+ LPBOOL lpUsedDefaultChar1=NULL;
+
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "WideCharToMultiByte\n");
+#endif
+
+ if (lpWideCharStr)
+ lpWideCharStr1 = (LPWSTR)(*env)->GetCharArrayElements(env, lpWideCharStr, NULL);
+ if (lpMultiByteCharStr)
+ lpMultiByteCharStr1 = (LPSTR)(*env)->GetByteArrayElements(env, lpMultiByteCharStr, NULL);
+ if (lpDefaultChar)
+ lpDefaultChar1 = (*env)->GetByteArrayElements(env, lpDefaultChar, NULL);
+ if (lpUsedDefaultChar)
+ lpUsedDefaultChar1 = (LPBOOL)(*env)->GetBooleanArrayElements(env,lpUsedDefaultChar, NULL);
+
+ rc = (jint) WideCharToMultiByte(CodePage, (DWORD)dwFlags, lpWideCharStr1, cchWideChar, lpMultiByteCharStr1,
+ cchMultiByte, lpDefaultChar1, lpUsedDefaultChar1);
+ if (lpWideCharStr)
+ (*env)->ReleaseCharArrayElements(env, lpWideCharStr, (jchar *)lpWideCharStr1, 0);
+ if (lpMultiByteCharStr)
+ (*env)->ReleaseByteArrayElements(env, lpMultiByteCharStr, (jbyte *)lpMultiByteCharStr1, 0);
+ if (lpDefaultChar)
+ (*env)->ReleaseByteArrayElements(env, lpDefaultChar, (jbyte *)lpDefaultChar1, 0);
+ if (lpUsedDefaultChar)
+ (*env)->ReleaseBooleanArrayElements(env, lpUsedDefaultChar, (jboolean *)lpUsedDefaultChar1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: WindowFromDC
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_WindowFromDC
+ (JNIEnv *env, jclass that, jint hdc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "WindowFromDC\n");
+#endif
+
+ return (jint) WindowFromDC((HDC)hdc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: WindowFromPoint
+ * Signature: (Lorg/eclipse/swt/internal/win32/POINT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_WindowFromPoint
+ (JNIEnv *env, jclass that, jobject lpPoint)
+{
+ DECL_GLOB(pGlob)
+ POINT point, *lpPoint1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "WindowFromPoint\n");
+#endif
+
+ if (lpPoint) {
+ lpPoint1 = &point;
+ cachePointFids(env, lpPoint, &PGLOB(PointFc));
+ getPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ rc = (jint) WindowFromPoint(point);
+ if (lpPoint) {
+ setPointFields(env, lpPoint, lpPoint1, &PGLOB(PointFc));
+ }
+ return rc;
+}
+
+/* ****************************************************************
+
+UNUSED OS calls - kept here in case we decide to use them again
+
+******************************************************************* */
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ChildWindowFromPoint
+ * Signature: (ILorg/eclipse/swt/internal/win32/POINT;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ChildWindowFromPoint
+ (JNIEnv *env, jclass that, jint hWndParent, jobject lpPoint)
+{
+ POINT point, *lpPoint1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ChildWindowFromPoint\n");
+#endif
+
+ if (lpPoint) {
+ lpPoint1 = &point;
+ cachePointFids(env, lpPoint, &PointFc);
+ getPointFields(env, lpPoint, lpPoint1, &PointFc);
+ }
+ rc = (jint) ChildWindowFromPoint((HWND)hWndParent, point);
+ if (lpPoint) {
+ setPointFields(env, lpPoint, lpPoint1, &PointFc);
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetClassLong
+ * Signature: (II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetClassLong
+ (JNIEnv *env, jclass that, jint hWnd, jint nIndex)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClassLong\n");
+#endif
+
+ return (jint)GetClassLong((HWND)hWnd, nIndex);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetCaretBlinkTime
+ * Signature: ()I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetCaretBlinkTime
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetCaretBlinkTime\n");
+#endif
+
+ return (jint)GetCaretBlinkTime();
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: CopyAcceleratorTable
+ * Signature: (I[BI)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_CopyAcceleratorTable
+ (JNIEnv *env, jclass that, jint hAccelSrc, jbyteArray lpAccelDst, jint cAccelEntries)
+{
+ LPACCEL lpAccelDst1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CopyAcceleratorTable\n");
+#endif
+
+ if (lpAccelDst)
+ lpAccelDst1 = (LPACCEL)(*env)->GetByteArrayElements(env,lpAccelDst, NULL);
+
+ rc = (jint)CopyAcceleratorTable((HACCEL)hAccelSrc, (LPACCEL)lpAccelDst1, cAccelEntries);
+
+ if (lpAccelDst)
+ (*env)->ReleaseByteArrayElements(env, lpAccelDst, (jbyte *)lpAccelDst1, 0);
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: EqualRect
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;Lorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_EqualRect
+ (JNIEnv *env, jclass that, jobject lprc1, jobject lprc2)
+{
+ RECT rect1, rect2, *lprc11=NULL, *lprc21=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "EqualRect\n");
+#endif
+
+ if (lprc1 || lprc2) {
+ if (lprc1) {
+ cacheRectFids(env, lprc1, &RectFc);
+ }
+ else if (lprc2) {
+ cacheRectFids(env, lprc2, &RectFc);
+ }
+ }
+
+ if (lprc1) {
+ lprc11 = &rect1;
+ getRectFields(env, lprc1, lprc11, &RectFc);
+ }
+ if (lprc2) {
+ lprc21 = &rect2;
+ getRectFields(env, lprc2, lprc21, &RectFc);
+ }
+ rc = (jboolean) EqualRect(lprc11, lprc21);
+ if (lprc1) {
+ setRectFields(env, lprc1, lprc11, &RectFc);
+ }
+ if (lprc2) {
+ setRectFields(env, lprc2, lprc21, &RectFc);
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetDlgCtrlID
+ * Signature: (I)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetDlgCtrlID
+ (JNIEnv *env, jclass that, jint hwndCtl)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetDlgCtrlID\n");
+#endif
+
+ return (jint)GetDlgCtrlID((HWND)hwndCtl);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetTextExtentPoint32
+ * Signature: (I[BILorg/eclipse/swt/internal/win32/SIZE;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_GetTextExtentPoint32
+ (JNIEnv *env, jclass that, jint hdc, jbyteArray lpString, jint cbString, jobject lpSize)
+{
+ DECL_GLOB(pGlob)
+ PBYTE lpString1=NULL;
+ SIZE size, *lpSize1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetTextExtentPoint32\n");
+#endif
+
+ if (lpString)
+ lpString1 = (*env)->GetByteArrayElements(env, lpString, NULL);
+
+ if (lpSize) {
+ lpSize1=&size;
+ cacheSizeFids(env, lpSize, &PGLOB(SizeFc));
+ getSizeFields(env, lpSize, lpSize1, &PGLOB(SizeFc));
+ }
+ rc = (jboolean) GetTextExtentPoint32((HDC)hdc, lpString1, cbString, lpSize1);
+
+ if (lpSize) {
+ setSizeFields(env, lpSize, lpSize1, &PGLOB(SizeFc));
+ }
+
+ if (lpString)
+ (*env)->ReleaseByteArrayElements(env, lpString, (jbyte *)lpString1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IntersectRect
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;Lorg/eclipse/swt/internal/win32/RECT;Lorg/eclipse/swt/internal/win32/RECT;)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IntersectRect
+ (JNIEnv *env, jclass that, jobject lprcDst, jobject lprcSrc1, jobject lprcSrc2)
+{
+ RECT rect1, rect2, rect3;
+ RECT *lprcDst1=NULL, *lprcSrc11=NULL, *lprcSrc21=NULL;
+ jobject lpRect;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IntersectRect\n");
+#endif
+
+ if (lprcDst || lprcSrc1 || lprcSrc2) {
+ if (lprcDst) {
+ lpRect = lprcDst;
+ }
+ else if (lprcSrc1) {
+ lpRect = lprcSrc1;
+ }
+ else if (lprcSrc2) {
+ lpRect = lprcSrc2;
+ }
+ cacheRectFids(env, lpRect, &RectFc);
+ }
+
+ if (lprcDst) {
+ lprcDst1 = &rect1;
+
+ lprcDst1->left = (*env)->GetIntField(env,lprcDst,RectFc.left);
+ lprcDst1->top = (*env)->GetIntField(env,lprcDst,RectFc.top);
+ lprcDst1->right = (*env)->GetIntField(env,lprcDst,RectFc.right);
+ lprcDst1->bottom = (*env)->GetIntField(env,lprcDst,RectFc.bottom);
+ }
+ if (lprcSrc1) {
+ lprcSrc11 = &rect2;
+
+ lprcSrc11->left = (*env)->GetIntField(env,lprcSrc1,RectFc.left);
+ lprcSrc11->top = (*env)->GetIntField(env,lprcSrc1,RectFc.top);
+ lprcSrc11->right = (*env)->GetIntField(env,lprcSrc1,RectFc.right);
+ lprcSrc11->bottom = (*env)->GetIntField(env,lprcSrc1,RectFc.bottom);
+ }
+ if (lprcSrc2) {
+ lprcSrc21 = &rect3;
+
+ lprcSrc21->left = (*env)->GetIntField(env,lprcSrc2,RectFc.left);
+ lprcSrc21->top = (*env)->GetIntField(env,lprcSrc2,RectFc.top);
+ lprcSrc21->right = (*env)->GetIntField(env,lprcSrc2,RectFc.right);
+ lprcSrc21->bottom = (*env)->GetIntField(env,lprcSrc2,RectFc.bottom);
+ }
+ rc = (jboolean) IntersectRect(lprcDst1, lprcSrc11, lprcSrc21);
+ if (lprcDst) {
+ (*env)->SetIntField(env,lprcDst,RectFc.left,lprcDst1->left);
+ (*env)->SetIntField(env,lprcDst,RectFc.top,lprcDst1->top);
+ (*env)->SetIntField(env,lprcDst,RectFc.right, lprcDst1->right);
+ (*env)->SetIntField(env,lprcDst,RectFc.bottom, lprcDst1->bottom);
+ }
+ if (lprcSrc1) {
+ (*env)->SetIntField(env,lprcSrc1,RectFc.left,lprcSrc11->left);
+ (*env)->SetIntField(env,lprcSrc1,RectFc.top,lprcSrc11->top);
+ (*env)->SetIntField(env,lprcSrc1,RectFc.right, lprcSrc11->right);
+ (*env)->SetIntField(env,lprcSrc1,RectFc.bottom, lprcSrc11->bottom);
+ }
+ if (lprcSrc2) {
+ (*env)->SetIntField(env,lprcSrc2,RectFc.left,lprcSrc21->left);
+ (*env)->SetIntField(env,lprcSrc2,RectFc.top,lprcSrc21->top);
+ (*env)->SetIntField(env,lprcSrc2,RectFc.right, lprcSrc21->right);
+ (*env)->SetIntField(env,lprcSrc2,RectFc.bottom, lprcSrc21->bottom);
+ }
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsMenu
+ * Signature: (I)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsMenu
+ (JNIEnv *env, jclass that, jint hMenu)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsMenu\n");
+#endif
+
+ return (jboolean) IsMenu((HMENU)hMenu);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: IsWindow
+ * Signature: (I)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_IsWindow
+ (JNIEnv *env, jclass that, jint hWnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsWindow\n");
+#endif
+
+ return (jboolean) IsWindow((HWND)hWnd);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: KillTimer
+ * Signature: (II)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_KillTimer
+ (JNIEnv *env, jclass that, jint hWnd, jint uIDEvent)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "KillTimern\n");
+#endif
+
+ return (jboolean) KillTimer((HWND)hWnd, uIDEvent);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadBitmap
+ * Signature: (I[B)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadBitmap__I_3B
+ (JNIEnv *env, jclass that, jint hInstance, jbyteArray lpBitmapName)
+{
+ LPCTSTR lpBitmapName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadBitmap__I_3B\n");
+#endif
+
+ if (lpBitmapName)
+ lpBitmapName1 = (*env)->GetByteArrayElements(env, lpBitmapName, NULL);
+
+ rc = (jint) LoadBitmap((HINSTANCE)hInstance, lpBitmapName1);
+
+ if (lpBitmapName)
+ (*env)->ReleaseByteArrayElements(env, lpBitmapName, (jbyte *)lpBitmapName1, 0);
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadCursor
+ * Signature: (I[B)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadCursor__I_3B
+ (JNIEnv *env, jclass that, jint hInstance, jbyteArray lpCursorName)
+{
+ LPCTSTR lpCursorName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadCursor__I_3B\n");
+#endif
+
+ if (lpCursorName)
+ lpCursorName1 = (*env)->GetByteArrayElements(env, lpCursorName, NULL);
+
+ rc = (jint) LoadCursor((HINSTANCE)hInstance, lpCursorName1);
+
+ if (lpCursorName)
+ (*env)->ReleaseByteArrayElements(env, lpCursorName, (jbyte *)lpCursorName1, 0);
+
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadIcon
+ * Signature: (I[B)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadIcon__I_3B
+ (JNIEnv *env, jclass that, jint hInstance, jbyteArray lpIconName)
+{
+ LPCTSTR lpIconName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadIcon__I_3B\n");
+#endif
+
+ if (lpIconName)
+ lpIconName1 = (*env)->GetByteArrayElements(env, lpIconName, NULL);
+
+ rc = (jint) LoadIcon((HINSTANCE)hInstance, lpIconName1);
+
+ if (lpIconName)
+ (*env)->ReleaseByteArrayElements(env, lpIconName, (jbyte *)lpIconName1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadImage
+ * Signature: (I[BIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadImage__I_3BIIII
+ (JNIEnv *env, jclass that, jint hinst, jbyteArray lpszName, jint uType, jint cxDesired, jint cyDesired, jint fuLoad)
+{
+ LPCTSTR lpszName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadImage__I_3BIIII\n");
+#endif
+
+ if (lpszName)
+ lpszName1 = (*env)->GetByteArrayElements(env, lpszName, NULL);
+
+ rc = (jint) LoadImage((HINSTANCE)hinst, lpszName1, uType, cxDesired, cyDesired, fuLoad);
+
+ if (lpszName)
+ (*env)->ReleaseByteArrayElements(env, lpszName, (jbyte *)lpszName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: LoadImage
+ * Signature: (IIIIII)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_LoadImage__IIIIII
+ (JNIEnv *env, jclass that, jint hinst, jint lpszName, jint uType, jint cxDesired, jint cyDesired, jint fuLoad)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "LoadImage__IIIIII\n");
+#endif
+
+ return (jint) LoadImage((HINSTANCE)hinst, (LPCTSTR)lpszName, uType, cxDesired, cyDesired, fuLoad);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/ACCEL;[BI)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_ACCEL_2_3BI
+ (JNIEnv *env, jclass that, jobject lpDestination, jbyteArray lpSource, jint Length)
+{
+ PVOID lpSource1=NULL;
+ ACCEL destination, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_ACCEL_2_3BI\n");
+#endif
+
+ if (lpSource)
+ lpSource1 = (PVOID)(*env)->GetByteArrayElements(env, lpSource, NULL);
+
+ if (lpDestination) {
+ cacheAccelFids(env, lpDestination, &AccelFc);
+ lpDestination1 = &destination;
+ }
+
+ if (lpSource && lpDestination)
+ MoveMemory(lpDestination1, (CONST VOID *)lpSource1, Length);
+
+ if (lpSource)
+ (*env)->ReleaseByteArrayElements(env, lpSource, (jbyte *)lpSource1, 0);
+
+ if (lpDestination) {
+ setAccelFields(env, lpDestination, lpDestination1, &AccelFc);
+ }
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMTVCUSTOMDRAW;II)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ NMTVCUSTOMDRAW nmtvcustomdraw, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMTVCUSTOMDRAW_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmtvcustomdraw, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &nmtvcustomdraw;
+ cacheNmtvcustomdrawFids(env, Destination, &NmtvcustomdrawFc);
+ setNmtvcustomdrawFields(env, Destination, lpDestination1, &NmtvcustomdrawFc);
+ }
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;II)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_RECT_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ RECT rect, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_RECT_2II\n");
+#endif
+
+ MoveMemory((PVOID)&rect, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &rect;
+ cacheRectFids(env, Destination, &RectFc);
+ setRectFields(env, Destination, lpDestination1, &RectFc);
+ }
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PostQuitMessage
+ * Signature: (I)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_PostQuitMessage
+ (JNIEnv *env, jclass that, jint nExitCode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PostQuitMessage\n");
+#endif
+
+ PostQuitMessage(nExitCode);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/MSG;)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_MSG_2
+ (JNIEnv * env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ MSG msg, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_MSG_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &msg;
+ cacheMsgFids(env, lParam, &MsgFc);
+ getMsgFields(env, lParam, lpParam1, &MsgFc);
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setMsgFields(env, lParam, lpParam1, &MsgFc);
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetCaretBlinkTime
+ * Signature: (I)Z
+ */
+/* JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_SetCaretBlinkTime
+ (JNIEnv *env, jclass that, jint uMSeconds)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetCaretBlinkTime\n");
+#endif
+
+ return (jboolean) SetCaretBlinkTime(uMSeconds);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetTimer
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetTimer
+ (JNIEnv *env, jclass that, jint hWnd, jint nIDEvent, jint uElapse, jint lpTimerFunc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetTimer\n");
+#endif
+
+ return (jint) SetTimer((HWND)hWnd, nIDEvent, uElapse, (TIMERPROC)lpTimerFunc);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: ExtractIcon
+ * Signature: (I[BI)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_ExtractIcon
+ (JNIEnv *env, jclass that, jint hinst, jbyteArray lpszFile, jint nIconIndex)
+{
+ LPCTSTR lpszFile1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "ExtractIcon\n");
+#endif
+
+ if (lpszFile)
+ lpszFile1 = (*env)->GetByteArrayElements(env, lpszFile, NULL);
+
+ rc = (jint) ExtractIcon( (HINSTANCE)hinst, lpszFile1, nIconIndex);
+
+ if (lpszFile)
+ (*env)->ReleaseByteArrayElements(env, lpszFile, (jbyte *)lpszFile1, 0);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/win32/MSGFILTER;I)V
+ */
+/*
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__ILorg_eclipse_swt_internal_win32_MSGFILTER_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ MSGFILTER msgfilter, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_win32_MSGFILTER_2I\n");
+#endif
+ if (Source) {
+ Source1 = &msgfilter;
+ cacheMsgfilterFids(env, Source, &MsgfilterFc);
+ getMsgfilterFields(env, Source, Source1, &MsgfilterFc);
+ }
+ MoveMemory((PVOID)Destination, (CONST VOID *)Source1, Length);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/MSGFILTER;II)V
+ */
+/*JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_MSGFILTER_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ MSGFILTER msgfilter, *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_MSGFILTER_2II\n");
+#endif
+ MoveMemory((PVOID)Destination1, (CONST VOID *)Source, Length);
+ if (Destination) {
+ Destination1 = &msgfilter;
+ cacheMsgfilterFids(env, Destination, &MsgfilterFc);
+ setMsgfilterFields(env, Destination, Destination1, &MsgfilterFc);
+ }
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: GetNearestColor
+ * Signature: (II)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_GetNearestColor
+ (JNIEnv *env, jclass that, jint hdc, jint crColor)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetNearestColor\n");
+#endif
+
+ return (jint) GetNearestColor((HDC)hdc, (COLORREF)crColor);
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/CHARFORMAT;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_CHARFORMAT_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ CHARFORMAT charformat, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_CHARFORMAT_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &charformat;
+ cacheCharformatFids(env, lParam, &CharformatFc);
+ getCharformatFields(env, lParam, lpParam1, &CharformatFc);
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setCharformatFields(env, lParam, lpParam1, &CharformatFc);
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PrintDlg
+ * Signature: (Lorg/eclipse/swt/internal/win32/PRINTDLG;)Z
+ */
+
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PrintDlg
+ (JNIEnv *env, jclass that, jobject lppd)
+{
+ DECL_GLOB(pGlob)
+ PRINTDLG printdlg, *lppd1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PrintDlg\n");
+#endif
+
+ if (lppd) {
+ lppd1 = &printdlg;
+ cachePrintdlgFids(env, lppd, &PGLOB(PrintdlgFc));
+ getPrintdlgFields(env, lppd, lppd1, &PGLOB(PrintdlgFc));
+ }
+ rc = (jboolean) PrintDlg(lppd1);
+ if (lppd) {
+ setPrintdlgFields(env, lppd, lppd1, &PGLOB(PrintdlgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: PageSetupDlg
+ * Signature: (Lorg/eclipse/swt/internal/win32/PAGESETUPDLG;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_PageSetupDlg
+ (JNIEnv *env, jclass that, jobject lppsd)
+{
+ DECL_GLOB(pGlob)
+ PAGESETUPDLG pagesetupdlg, *lppsd1=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "PageSetupDlg\n");
+#endif
+
+ if (lppsd) {
+ lppsd1 = &pagesetupdlg;
+ cachePagesetupdlgFids(env, lppsd, &PGLOB(PagesetupdlgFc));
+ getPagesetupdlgFields(env, lppsd, lppsd1, &PGLOB(PagesetupdlgFc));
+ }
+ rc = (jboolean) PageSetupDlg(lppsd1);
+ if (lppsd) {
+ setPagesetupdlgFields(env, lppsd, lppsd1, &PGLOB(PagesetupdlgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: OleInitialize
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_OleInitialize
+ (JNIEnv *env, jclass that, jint pvReserved)
+{
+ return (jint) OleInitialize ((LPVOID)pvReserved);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: OleUninitialize
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_OleUninitialize
+ (JNIEnv *env, jclass that)
+{
+ OleUninitialize ();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: VtblCall
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_VtblCall
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0)
+{
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OS_VtblCall\n");
+#endif
+
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+
+ rc = fn(ppVtbl, arg0); /* cast it to an OLE function returning int */
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: DrawState
+ * Signature: (IIIIIIIIII)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_win32_OS_DrawState
+ (JNIEnv *env, jclass that, jint hdc, jint hbr, jint lpOutputFunc, jint lData, jint wData, jint x, jint y, jint cx, jint cy, jint fuFlags)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DrawState");
+#endif
+ return (jboolean) DrawState ((HDC)hdc, (HBRUSH)hbr, (DRAWSTATEPROC) lpOutputFunc, (LPARAM)lData, (WPARAM) wData, x, y, cx, cy, fuFlags);
+
+}
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SHGetFileInfo
+ * Signature: ([BILorg/eclipse/swt/internal/win32/SHFILEINFO;II)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SHGetFileInfo
+ (JNIEnv * env, jclass that, jbyteArray pszPath, jint dwFileAttributes, jobject psfi, jint cbFileInfo, jint uFlags)
+{
+ DECL_GLOB(pGlob)
+ LPCTSTR pszPath1=NULL;
+ SHFILEINFO shellinfo, *psfi1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SHGetFileInfo\n");
+#endif
+
+ if (pszPath)
+ pszPath1 = (*env)->GetByteArrayElements(env, pszPath, NULL);
+ if (psfi) {
+ psfi1 = &shellinfo;
+ cacheShfileinfoFids(env, psfi, &PGLOB(ShfileinfoFc));
+ getShfileinfoFields(env, psfi, psfi1, &PGLOB(ShfileinfoFc));
+ }
+
+ rc = (jint) SHGetFileInfo (pszPath1, dwFileAttributes, psfi1, cbFileInfo, uFlags);
+
+ if (pszPath)
+ (*env)->ReleaseByteArrayElements(env, pszPath, (jbyte *)pszPath1, 0);
+ if (psfi) {
+ setShfileinfoFields(env, psfi, psfi1, &PGLOB(ShfileinfoFc));
+ }
+
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SetStretchBltMode
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SetStretchBltMode
+ (JNIEnv *env, jclass that, jint hdc, jint iStretchMode)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SetStretchBltMode\n");
+#endif
+
+ return (jint) SetStretchBltMode((HDC)hdc, iStretchMode);
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc
new file mode 100755
index 0000000000..506d7f0d8f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swt.rc
@@ -0,0 +1,108 @@
+//Microsoft Developer Studio generated resource script.
+//
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION 0,1,0,5
+ 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", "IBM Corporation\0"
+ VALUE "FileDescription", "Standard Widget Toolkit\0"
+ VALUE "FileVersion", "win32 0.105\0"
+ VALUE "InternalName", "SWT\0"
+ VALUE "LegalCopyright", "Copyright © 1999-2000\0"
+ VALUE "OriginalFilename", "swt0105.dll\0"
+ VALUE "ProductName", "\0"
+ VALUE "ProductVersion", "0, 0, 0, 0\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
+
+#endif // !_MAC
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "#include ""windows.h""\r\n"
+ "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+ "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+ "\r\n"
+ "\0"
+END
+
+#endif // APSTUDIO_INVOKED
+
+#endif // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif // not APSTUDIO_INVOKED
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swtole.c b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swtole.c
new file mode 100755
index 0000000000..2fc92cf686
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/library/swtole.c
@@ -0,0 +1,3418 @@
+#include "globals.h"
+#include "structs.h"
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CLSIDFromProgID
+ * Signature: ([CLorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CLSIDFromProgID
+ (JNIEnv *env, jclass that, jcharArray lpszProgID, jobject pclsid)
+{
+ DECL_GLOB(pGlob)
+ LPCOLESTR lpszProgID1=NULL;
+ GUID guid, *pclsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CLSIDFromProgID\n");
+#endif
+
+ if (pclsid) {
+ pclsid1=&guid;
+ cacheGuidFids(env, pclsid, &PGLOB(GuidFc));
+ getGuidFields(env, pclsid, pclsid1, &PGLOB(GuidFc));
+ }
+
+ if (lpszProgID)
+ lpszProgID1 = (LPCOLESTR)(*env)->GetCharArrayElements(env, lpszProgID, NULL);
+
+ rc = (jint) CLSIDFromProgID(lpszProgID1, pclsid1);
+
+ if (lpszProgID)
+ (*env)->ReleaseCharArrayElements(env, lpszProgID, (jchar *)lpszProgID1, 0);
+
+ if (pclsid) {
+ setGuidFields(env, pclsid, pclsid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CLSIDFromString
+ * Signature: ([CLorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CLSIDFromString
+ (JNIEnv *env, jclass that, jcharArray lpsz, jobject pclsid)
+{
+ DECL_GLOB(pGlob)
+ LPOLESTR lpsz1=NULL;
+ GUID guid, *pclsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CLSIDFromString\n");
+#endif
+ if (pclsid) {
+ pclsid1=&guid;
+ cacheGuidFids(env, pclsid, &PGLOB(GuidFc));
+ getGuidFields(env, pclsid, pclsid1, &PGLOB(GuidFc));
+ }
+
+ if (lpsz)
+ lpsz1 = (LPOLESTR)(*env)->GetCharArrayElements(env, lpsz, NULL);
+
+ rc = CLSIDFromString(lpsz1, pclsid1);
+
+ if (lpsz)
+ (*env)->ReleaseCharArrayElements(env, lpsz, lpsz1, 0);
+
+ if (pclsid) {
+ setGuidFields(env, pclsid, pclsid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoCreateInstance
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;IILorg/eclipse/swt/internal/ole/win32/GUID;[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoCreateInstance
+ (JNIEnv *env, jclass that, jobject rclsid, jint pUnkOuter, jint dwClsContext, jobject riid, jintArray ppv)
+{
+ DECL_GLOB(pGlob)
+ LPVOID *ppv1=NULL;
+ GUID guid1, guid2, *riid1=NULL, *rclsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CoCreateInstance\n");
+#endif
+
+ if (rclsid) {
+ rclsid1=&guid2;
+ cacheGuidFids(env, rclsid, &PGLOB(GuidFc));
+ getGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ if (riid) {
+ riid1=&guid1;
+ cacheGuidFids(env, riid, &PGLOB(GuidFc));
+ getGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+
+ if (ppv)
+ ppv1 = (LPVOID *)(*env)->GetIntArrayElements(env, ppv, NULL);
+
+ rc = (jint) CoCreateInstance(rclsid1, (LPUNKNOWN)pUnkOuter, dwClsContext, riid1, ppv1);
+
+ if (ppv)
+ (*env)->ReleaseIntArrayElements(env, ppv, (jint *)ppv1, 0);
+
+ if (rclsid) {
+ setGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ if (riid) {
+ setGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoFreeUnusedLibraries
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoFreeUnusedLibraries
+ (JNIEnv *env, jclass that)
+{
+ CoFreeUnusedLibraries();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoGetClassObject
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;IILorg/eclipse/swt/internal/ole/win32/GUID;[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoGetClassObject
+ (JNIEnv *env, jclass that, jobject rclsid, jint dwClsContext, jint pServerInfo,
+ jobject riid, jintArray ppv)
+{
+ DECL_GLOB(pGlob)
+ LPVOID *ppv1=NULL;
+ GUID guid1, *rclsid1=NULL;
+ GUID guid2, *riid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CoGetClassObject\n");
+#endif
+
+ if (rclsid) {
+ rclsid1=&guid1;
+ cacheGuidFids(env, rclsid, &PGLOB(GuidFc));
+ getGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ if (riid) {
+ riid1=&guid2;
+ cacheGuidFids(env, riid, &PGLOB(GuidFc));
+ getGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+ if (ppv)
+ ppv1 = (LPVOID *)(*env)->GetIntArrayElements(env, ppv, NULL);
+
+ rc = (jint) CoGetClassObject(rclsid1, dwClsContext, (COSERVERINFO *)pServerInfo, riid1, ppv1);
+ if (ppv)
+ (*env)->ReleaseIntArrayElements(env, ppv, (jint *)ppv1, 0);
+
+ if (rclsid) {
+ setGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ if (riid) {
+ setGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoLockObjectExternal
+ * Signature: (IZZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoLockObjectExternal
+ (JNIEnv *env, jclass that, jint pUnk, jboolean fLock, jboolean fLastUnlockReleases)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CoLockObjectExternal\n");
+#endif
+ return (jint) CoLockObjectExternal((IUnknown *)pUnk, (BOOL)fLock, (BOOL)fLastUnlockReleases);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoTaskMemAlloc
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoTaskMemAlloc
+ (JNIEnv *env, jclass that, jint cb)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CoTaskMemAlloc\n");
+#endif
+ return (jint) CoTaskMemAlloc((ULONG)cb);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoTaskMemFree
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoTaskMemFree
+ (JNIEnv *env, jclass that, jint pv)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CoTaskMemFree\n");
+#endif
+ CoTaskMemFree((LPVOID)pv);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: DoDragDrop
+ * Signature: (III[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_DoDragDrop
+ (JNIEnv *env, jclass that, jint pDataObject, jint pDropSource, jint dwOKEffect, jintArray pdwEffect)
+{
+ jint *pdwEffect1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DoDragDrop\n");
+#endif
+
+ if (pdwEffect)
+ pdwEffect1 = (*env)->GetIntArrayElements(env, pdwEffect, NULL);
+
+ rc = DoDragDrop((IDataObject *)pDataObject, (IDropSource *)pDropSource, dwOKEffect, pdwEffect1);
+
+ if (pdwEffect)
+ (*env)->ReleaseIntArrayElements(env, pdwEffect, pdwEffect1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: DragFinish
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_DragFinish
+ (JNIEnv *env, jclass that, jint hDrop)
+{
+ DragFinish((HDROP)hDrop);
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: DragQueryFile
+ * Signature: (II[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_DragQueryFile
+ (JNIEnv *env, jclass that, jint hDrop, jint iFile, jbyteArray lpszFile, jint cch)
+{
+ LPTSTR lpszFile1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DragQueryFile\n");
+#endif
+
+ if (lpszFile)
+ lpszFile1 = (*env)->GetByteArrayElements(env, lpszFile, NULL);
+
+ rc = (jint) DragQueryFile((HDROP)hDrop, iFile, lpszFile1, cch);
+
+ if (lpszFile)
+ (*env)->ReleaseByteArrayElements(env, lpszFile, (jbyte *)lpszFile1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: GetClassFile
+ * Signature: ([CLorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_GetClassFile
+ (JNIEnv *env, jclass that, jcharArray szFileName, jobject clsid)
+{
+ DECL_GLOB(pGlob)
+ LPCWSTR szFileName1=NULL;
+ GUID guid, *clsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClassFile\n");
+#endif
+ if (clsid) {
+ clsid1=&guid;
+ cacheGuidFids(env, clsid, &PGLOB(GuidFc));
+ getGuidFields(env, clsid, clsid1, &PGLOB(GuidFc));
+ }
+
+ if (szFileName)
+ szFileName1 = (LPCWSTR)(*env)->GetCharArrayElements(env, szFileName, NULL);
+
+ rc = GetClassFile(szFileName1, clsid1);
+
+ if (szFileName)
+ (*env)->ReleaseCharArrayElements(env, szFileName, (jchar *)szFileName1, 0);
+
+ if (clsid) {
+ setGuidFields(env, clsid, clsid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: GetClipboardFormatName
+ * Signature: (I[BI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_GetClipboardFormatName
+ (JNIEnv *env, jclass that, jint format, jbyteArray lpszFormatName, jint cchMaxCount)
+{
+ LPTSTR lpszFormatName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "GetClipboardFormatName\n");
+#endif
+
+ if (lpszFormatName)
+ lpszFormatName1 = (*env)->GetByteArrayElements(env, lpszFormatName, NULL);
+
+ rc = (jint) GetClipboardFormatName(format, lpszFormatName1, cchMaxCount);
+
+ if (lpszFormatName)
+ (*env)->ReleaseByteArrayElements(env, lpszFormatName, (jbyte *)lpszFormatName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: IIDFromString
+ * Signature: ([CLorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_IIDFromString
+ (JNIEnv *env, jclass that, jcharArray lpsz, jobject lpiid)
+{
+ DECL_GLOB(pGlob)
+ LPOLESTR lpsz1=NULL;
+ GUID guid, *lpiid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IIDFromString\n");
+#endif
+
+ if (lpsz)
+ lpsz1 = (LPOLESTR)(*env)->GetCharArrayElements(env, lpsz, NULL);
+
+ if (lpiid) {
+ lpiid1=&guid;
+ cacheGuidFids(env, lpiid, &PGLOB(GuidFc));
+ getGuidFields(env, lpiid, lpiid1, &PGLOB(GuidFc));
+ }
+
+ rc = (jint) IIDFromString(lpsz1, lpiid1);
+
+ if (lpiid) {
+ setGuidFields(env, lpiid, lpiid1, &PGLOB(GuidFc));
+ }
+
+ if (lpsz)
+ (*env)->ReleaseCharArrayElements(env, lpsz, (jchar *)lpsz1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: IsEqualGUID
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;Lorg/eclipse/swt/internal/ole/win32/GUID;)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_IsEqualGUID
+ (JNIEnv *env, jclass that, jobject rguid1, jobject rguid2)
+{
+ DECL_GLOB(pGlob)
+ GUID guid1, *rguid11=NULL;
+ GUID guid2, *rguid21=NULL;
+ jboolean rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "IsEqualGUID\n");
+#endif
+
+ if (rguid1) {
+ rguid11=&guid1;
+ cacheGuidFids(env, rguid1, &PGLOB(GuidFc));
+ getGuidFields(env, rguid1, rguid11, &PGLOB(GuidFc));
+ }
+
+ if (rguid2) {
+ rguid21=&guid2;
+ cacheGuidFids(env, rguid2, &PGLOB(GuidFc));
+ getGuidFields(env, rguid2, rguid21, &PGLOB(GuidFc));
+ }
+
+ rc = (jboolean) IsEqualGUID(rguid11, rguid21);
+
+ if (rguid1) {
+ setGuidFields(env, rguid1, rguid11, &PGLOB(GuidFc));
+ }
+ if (rguid2) {
+ setGuidFields(env, rguid2, rguid21, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: ([CII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory___3CII
+ (JNIEnv *env, jclass that, jcharArray DestinationPtr, jint Source, jint Length)
+{
+ jchar *DestinationPtr1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___3CII\n");
+#endif
+
+ if (DestinationPtr)
+ DestinationPtr1 = (*env)->GetCharArrayElements(env, DestinationPtr, NULL);
+
+ MoveMemory(DestinationPtr1, (CONST VOID *)Source, Length);
+
+ if (DestinationPtr)
+ (*env)->ReleaseCharArrayElements(env, DestinationPtr, DestinationPtr1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: ([DII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory___3DII
+ (JNIEnv *env, jclass that, jdoubleArray Destination, jint SourcePtr, jint Length)
+{
+ jdouble *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___3DII\n");
+#endif
+
+ if (Destination)
+ Destination1 = (*env)->GetDoubleArrayElements(env, Destination, NULL);
+
+ MoveMemory(Destination1, (CONST VOID *)SourcePtr, Length);
+
+ if (Destination)
+ (*env)->ReleaseDoubleArrayElements(env, Destination, Destination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: ([FII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory___3FII
+ (JNIEnv *env, jclass that, jfloatArray Destination, jint SourcePtr, jint Length)
+{
+ jfloat *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___3FII\n");
+#endif
+
+ if (Destination)
+ Destination1 = (*env)->GetFloatArrayElements(env, Destination, NULL);
+
+ MoveMemory(Destination1, (CONST VOID *)SourcePtr, Length);
+
+ if (Destination)
+ (*env)->ReleaseFloatArrayElements(env, Destination, Destination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: ([SII)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory___3SII
+ (JNIEnv *env, jclass that, jshortArray Destination, jint SourcePtr, jint Length)
+{
+ jshort *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___3SII\n");
+#endif
+
+ if (Destination)
+ Destination1 = (*env)->GetShortArrayElements(env, Destination, NULL);
+
+ MoveMemory(Destination1, (CONST VOID *)SourcePtr, Length);
+
+ if (Destination)
+ (*env)->ReleaseShortArrayElements(env, Destination, Destination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (I[FI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__I_3FI
+ (JNIEnv *env, jclass that, jint Destination, jfloatArray SourcePtr, jint Length)
+{
+ jfloat *SourcePtr1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___I_3FI\n");
+#endif
+
+ if (SourcePtr)
+ SourcePtr1 = (*env)->GetFloatArrayElements(env, SourcePtr, NULL);
+
+ MoveMemory((LPVOID)Destination, (CONST VOID *)SourcePtr1, Length);
+
+ if (SourcePtr)
+ (*env)->ReleaseFloatArrayElements(env, SourcePtr, SourcePtr1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (I[DI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__I_3DI
+ (JNIEnv *env, jclass that, jint DestinationPtr, jdoubleArray Source, jint Length)
+{
+ jdouble *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__I_3DI\n");
+#endif
+
+ if (Source)
+ Source1 = (jdouble *)(*env)->GetDoubleArrayElements(env, Source, NULL);
+
+ MoveMemory((PVOID)DestinationPtr, (CONST VOID *)Source1, Length);
+
+ if (Source)
+ (*env)->ReleaseDoubleArrayElements(env, Source, Source1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (I[II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__I_3II
+ (JNIEnv *env, jclass that, jint DestinationPtr, jintArray Source, jint Length)
+{
+ jint *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___I_3II\n");
+#endif
+
+ if (Source)
+ Source1 = (*env)->GetIntArrayElements(env, Source, NULL);
+
+ MoveMemory((PVOID)DestinationPtr, Source1, Length);
+
+ if (Source)
+ (*env)->ReleaseIntArrayElements(env, Source, Source1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (I[SI)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__I_3SI
+ (JNIEnv *env, jclass that, jint DestinationPtr, jshortArray Source, jint Length)
+{
+ short *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___I_3SI\n");
+#endif
+
+ if (Source)
+ Source1 = (*env)->GetShortArrayElements(env, Source, NULL);
+
+ MoveMemory((PVOID)DestinationPtr, Source1, Length);
+
+ if (Source)
+ (*env)->ReleaseShortArrayElements(env, Source, Source1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: ([BLorg/eclipse/swt/internal/ole/win32/DROPFILES;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory___3BLorg_eclipse_swt_internal_ole_win32_DROPFILES_2I
+ (JNIEnv *env, jclass that, jbyteArray Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ DROPFILES dropfiles, *Source1=NULL;
+ VOID *Destination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory___3BLorg_eclipse_swt_internal_ole_win32_DROPFILES_2I\n");
+#endif
+
+ if (Source) {
+ Source1=&dropfiles;
+ cacheDropfilesFids(env, Source, &PGLOB(DropfilesFc));
+ getDropfilesFields(env, Source, Source1, &PGLOB(DropfilesFc));
+ }
+
+ if (Destination)
+ Destination1 = (*env)->GetByteArrayElements(env, Destination, NULL);
+
+ MoveMemory((PVOID)Destination1, Source1, Length);
+
+ if (Destination)
+ (*env)->ReleaseByteArrayElements(env, Destination, (jbyte *)Destination1, 0);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/DROPFILES;I)V
+ */
+/*
+/*JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_DROPFILES_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DROPFILES dropfiles, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_DROPFILES_2I\n");
+#endif
+
+ if (Source) {
+ Source1=&dropfiles;
+ cacheDropfilesFids(env, Source, &DropfilesFc);
+ getDropfilesFields(env, Source, Source1, &DropfilesFc);
+ }
+ MoveMemory((PVOID)Destination, Source1, Length);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/FORMATETC;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_FORMATETC_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ FORMATETC formatetc, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_FORMATETC_2I\n");
+#endif
+
+ if (Source) {
+ Source1=&formatetc;
+ cacheFormatetcFids(env, Source, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, Source, Source1, &PGLOB(FormatetcFc));
+ }
+ MoveMemory((PVOID)Destination, Source1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/GUID;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_GUID_2I
+ (JNIEnv *env, jclass that, jint DestinationPtr, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__ILorg_eclipse_swt_internal_ole_win32_GUID_2I\n");
+#endif
+
+ if (Source) {
+ Source1=&guid;
+ cacheGuidFids(env, Source, &PGLOB(GuidFc));
+ getGuidFields(env, Source, Source1, &PGLOB(GuidFc));
+ }
+ MoveMemory((PVOID)DestinationPtr, Source1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/OLEINPLACEFRAMEINFO;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_OLEINPLACEFRAMEINFO_2I
+ (JNIEnv *env, jclass that, jint DestinationPtr, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ OLEINPLACEFRAMEINFO oleinplaceframeinfo, *Source1=&oleinplaceframeinfo;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_OLEINPLACEFRAMEINFO_2I\n");
+#endif
+
+ if (Source) {
+ cacheOleinplaceframeinfoFids(env, Source, &PGLOB(OleinplaceframeinfoFc));
+ getOleinplaceframeinfoFields(env, Source, Source1, &PGLOB(OleinplaceframeinfoFc));
+ }
+
+ MoveMemory((PVOID)DestinationPtr, Source1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/STATSTG;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_STATSTG_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ STATSTG statstg, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_STATSTG_2I\n");
+#endif
+
+ if (Source) {
+ Source1=&statstg;
+ cacheStatstgFids(env, Source, &PGLOB(StatstgFc));
+ getStatstgFields(env, Source, Source1, &PGLOB(StatstgFc));
+ }
+ MoveMemory((PVOID)Destination, Source1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/STGMEDIUM;I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_STGMEDIUM_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ STGMEDIUM stgmedium, *Source1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_STGMEDIUM_2I\n");
+#endif
+
+ if (Source) {
+ Source1=&stgmedium;
+ cacheStgmediumFids(env, Source, &PGLOB(StgmediumFc));
+ getStgmediumFields(env, Source, Source1, &PGLOB(StgmediumFc));
+ }
+ MoveMemory((PVOID)Destination, Source1, Length);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/DISPPARAMS;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_DISPPARAMS_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint SourcePtr, jint Length)
+{
+ DECL_GLOB(pGlob)
+ DISPPARAMS dispparams, *Destination1=&dispparams;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_DISPPARAMS_2II\n");
+#endif
+
+ MoveMemory((PVOID)Destination1, (CONST VOID *)SourcePtr, Length);
+
+ if (Destination) {
+ cacheDispparamsFids(env, Destination, &PGLOB(DispparamsFc));
+ setDispparamsFields(env, Destination, Destination1, &PGLOB(DispparamsFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/FORMATETC;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_FORMATETC_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ FORMATETC formatetc, *Destination1=&formatetc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_FORMATETC_2II\n");
+#endif
+
+ MoveMemory((PVOID)Destination1, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ cacheFormatetcFids(env, Destination, &PGLOB(FormatetcFc));
+ setFormatetcFields(env, Destination, Destination1, &PGLOB(FormatetcFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_GUID_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint SourcePtr, jint Length)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *Destination1=&guid;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_GUID_2II\n");
+#endif
+
+ MoveMemory((PVOID)Destination1, (CONST VOID *)SourcePtr, Length);
+
+ if (Destination) {
+ cacheGuidFids(env, Destination, &PGLOB(GuidFc));
+ setGuidFields(env, Destination, Destination1, &PGLOB(GuidFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/STATSTG;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_STATSTG_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ STATSTG statstg, *Destination1=&statstg;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_STATSTG_2II\n");
+#endif
+
+ MoveMemory((PVOID)Destination1, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ cacheStatstgFids(env, Destination, &PGLOB(StatstgFc));
+ setStatstgFields(env, Destination, Destination1, &PGLOB(StatstgFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/TYPEATTR;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_TYPEATTR_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint SourcePtr, jint Length)
+{
+ DECL_GLOB(pGlob)
+ TYPEATTR typeattr, *Destination1=&typeattr;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_TYPEATTR_2II\n");
+#endif
+ MoveMemory((PVOID)Destination1, (CONST VOID *)SourcePtr, Length);
+ if (Destination) {
+ cacheTypeattrFids(env, Destination, &PGLOB(TypeattrFc));
+ setTypeattrFields(env, Destination, Destination1, &PGLOB(TypeattrFc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/RECT;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_win32_RECT_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_win32_RECT_2II\n");
+#endif
+
+ MoveMemory((PVOID)&rect, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &rect;
+ cacheRectFids(env, Destination, &PGLOB(RectFc));
+ setRectFields(env, Destination, lpDestination1, &PGLOB(RectFc));
+ }
+}
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/FUNCDESC1;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_FUNCDESC1_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ FUNCDESC funcdesc, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_FUNCDESC1_2II\n");
+#endif
+
+ MoveMemory((PVOID)&funcdesc, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &funcdesc;
+ cacheFuncdesc1Fids(env, Destination, &PGLOB(Funcdesc1Fc));
+ setFuncdesc1Fields(env, Destination, lpDestination1, &PGLOB(Funcdesc1Fc));
+ }
+}
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/FUNCDESC2;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_FUNCDESC2_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ FUNCDESC funcdesc, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_FUNCDESC2_2II\n");
+#endif
+
+ MoveMemory((PVOID)&funcdesc, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &funcdesc;
+ cacheFuncdesc2Fids(env, Destination, &PGLOB(Funcdesc2Fc));
+ setFuncdesc2Fields(env, Destination, lpDestination1, &PGLOB(Funcdesc2Fc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/VARDESC1;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_VARDESC1_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ VARDESC vardesc, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_VARDESC1_2II\n");
+#endif
+
+ MoveMemory((PVOID)&vardesc, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &vardesc;
+ cacheVardesc1Fids(env, Destination, &PGLOB(Vardesc1Fc));
+ setVardesc1Fields(env, Destination, lpDestination1, &PGLOB(Vardesc1Fc));
+ }
+}
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/VARDESC2;II)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_VARDESC2_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ DECL_GLOB(pGlob)
+ VARDESC vardesc, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__Lorg_eclipse_swt_internal_ole_win32_VARDESC2_2II\n");
+#endif
+
+ MoveMemory((PVOID)&vardesc, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &vardesc;
+ cacheVardesc2Fids(env, Destination, &PGLOB(Vardesc2Fc));
+ setVardesc2Fields(env, Destination, lpDestination1, &PGLOB(Vardesc2Fc));
+ }
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleCreate
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;Lorg/eclipse/swt/internal/ole/win32/GUID;ILorg/eclipse/swt/internal/ole/win32/FORMATETC;II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleCreate
+ (JNIEnv *env, jclass that, jobject rclsid, jobject riid, jint renderopt,
+ jobject pFormatEtc, jint pClientSite, jint pStg, jintArray ppvObject)
+{
+ DECL_GLOB(pGlob)
+ LPVOID *ppvObject1=NULL;
+ GUID guid1, *rclsid1=NULL;
+ GUID guid2, *riid1=NULL;
+ FORMATETC formatec, *pFormatEtc1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleCreate\n");
+#endif
+
+ if (rclsid) {
+ rclsid1=&guid1;
+ cacheGuidFids(env, rclsid, &PGLOB(GuidFc));
+ getGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ if (riid) {
+ riid1=&guid2;
+ cacheGuidFids(env, riid, &PGLOB(GuidFc));
+ getGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+ if (pFormatEtc) {
+ pFormatEtc1 = &formatec;
+ cacheFormatetcFids(env, pFormatEtc, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, pFormatEtc, pFormatEtc1, &PGLOB(FormatetcFc));
+ }
+
+ if (ppvObject)
+ ppvObject1 = (LPVOID *)(*env)->GetIntArrayElements(env, ppvObject, NULL);
+
+ rc = (jint) OleCreate(rclsid1, riid1, renderopt, pFormatEtc1, (IOleClientSite * )pClientSite, (IStorage * )pStg, ppvObject1);
+
+ if (ppvObject)
+ (*env)->ReleaseIntArrayElements(env, ppvObject, (jint *)ppvObject1, 0);
+
+/* all of these objects are inputs so we don't not need to set the
+ fields back
+*/
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleCreateFromFile
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;[CLorg/eclipse/swt/internal/ole/win32/GUID;ILorg/eclipse/swt/internal/ole/win32/FORMATETC;II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleCreateFromFile
+ (JNIEnv *env, jclass that, jobject rclsid, jcharArray lpszFileName, jobject riid, jint renderopt,
+ jobject pFormatEtc, jint pClientSite, jint pStg, jintArray ppvObj)
+{
+ DECL_GLOB(pGlob)
+ LPVOID *ppvObj1=NULL;
+ LPCOLESTR lpszFileName1=NULL;
+ GUID guid1, *rclsid1=NULL;
+ GUID guid2, *riid1=NULL;
+ FORMATETC formatec, *pFormatEtc1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleCreateFromFile\n");
+#endif
+
+ if (rclsid) {
+ rclsid1=&guid1;
+ cacheGuidFids(env, rclsid, &PGLOB(GuidFc));
+ getGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+
+ if (riid) {
+ riid1=&guid2;
+ cacheGuidFids(env, riid, &PGLOB(GuidFc));
+ getGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+ if (pFormatEtc) {
+ pFormatEtc1 = &formatec;
+ cacheFormatetcFids(env, pFormatEtc, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, pFormatEtc, pFormatEtc1, &PGLOB(FormatetcFc));
+ }
+
+ if (lpszFileName)
+ lpszFileName1 = (LPCOLESTR)(*env)->GetCharArrayElements(env, lpszFileName, NULL);
+
+ if (ppvObj)
+ ppvObj1 = (LPVOID *)(*env)->GetIntArrayElements(env, ppvObj, NULL);
+
+ rc = (jint) OleCreateFromFile(rclsid1, lpszFileName1, riid1, renderopt, pFormatEtc1, (LPOLECLIENTSITE)pClientSite, (LPSTORAGE)pStg, ppvObj1);
+
+ if (ppvObj)
+ (*env)->ReleaseIntArrayElements(env, ppvObj, (jint *)ppvObj1, 0);
+
+ if (lpszFileName)
+ (*env)->ReleaseCharArrayElements(env, lpszFileName, (jchar *)lpszFileName1, 0);
+
+/* all of these objects are inputs so we don't not need to set the
+ fields back
+*/
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleCreatePropertyFrame
+ * Signature: (III[CI[IIIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleCreatePropertyFrame
+ (JNIEnv *env, jclass that, jint hwndOwner, jint x, jint y, jcharArray lpszCaption, jint cObjects, jintArray lplpUnk, jint cPages, jint lpPageClsID, jint lcid, jint dwReserved, jint lpvReserved)
+{
+ LPCOLESTR lpszCaption1=NULL;
+ jint *lplpUnk1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleCreatePropertyFrame\n");
+#endif
+
+ if (lpszCaption)
+ lpszCaption1 = (LPCOLESTR)(*env)->GetCharArrayElements(env, lpszCaption, NULL);
+
+ if (lplpUnk)
+ lplpUnk1 = (*env)->GetIntArrayElements(env, lplpUnk, NULL);
+
+ rc = (jint) OleCreatePropertyFrame((HWND)hwndOwner, x, y, lpszCaption1, cObjects, (LPUNKNOWN FAR*)lplpUnk1, cPages, (LPCLSID)lpPageClsID, (LCID)lcid, dwReserved, (LPVOID)lpvReserved);
+
+ if (lplpUnk)
+ (*env)->ReleaseIntArrayElements(env, lplpUnk, (jint *)lplpUnk1, 0);
+
+ if (lpszCaption)
+ (*env)->ReleaseCharArrayElements(env, lpszCaption, (jchar *)lpszCaption1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleIsRunning
+ * Signature: (I)Z
+ */
+JNIEXPORT jboolean JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleIsRunning
+ (JNIEnv *env, jclass that, jint pObject)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleIsRunning\n");
+#endif
+ return (jboolean) OleIsRunning((LPOLEOBJECT)pObject);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleLoad
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/GUID;I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleLoad
+ (JNIEnv *env, jclass that, jint pStg, jobject riid, jint pClientSite, jintArray ppvObj)
+{
+ DECL_GLOB(pGlob)
+ LPVOID *ppvObj1=NULL;
+ GUID guid, *riid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleLoad\n");
+#endif
+ if (riid) {
+ riid1=&guid;
+ cacheGuidFids(env, riid, &PGLOB(GuidFc));
+ getGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+
+ if (ppvObj)
+ ppvObj1 = (LPVOID *)(*env)->GetIntArrayElements(env, ppvObj, NULL);
+
+ rc = (jint) OleLoad((IStorage *)pStg, riid1, (IOleClientSite *)pClientSite, ppvObj1); /* cast it to an OLE function returning int */
+
+ if (ppvObj)
+ (*env)->ReleaseIntArrayElements(env, ppvObj, (jint *)ppvObj1, 0);
+
+ if (riid) {
+ setGuidFields(env, riid, riid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleRun
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleRun
+ (JNIEnv *env, jclass that, jint pUnknown)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleRun\n");
+#endif
+ return (jint) OleRun((LPUNKNOWN)pUnknown);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleSave
+ * Signature: (IIZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleSave
+ (JNIEnv *env, jclass that, jint pPS, jint pStg, jboolean fSameAsLoad)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleSave\n");
+#endif
+ return (jint) OleSave((IPersistStorage *)pPS, (IStorage *)pStg, fSameAsLoad);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleSetContainedObject
+ * Signature: (IZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleSetContainedObject
+ (JNIEnv *env, jclass that, jint pUnk, jboolean fContained)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleSetContainedObject\n");
+#endif
+ return (jint) OleSetContainedObject((LPUNKNOWN)pUnk, fContained);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleSetMenuDescriptor
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleSetMenuDescriptor
+ (JNIEnv *env, jclass that, jint holemenu, jint hwndFrame, jint hwndActiveObject, jint lpFrame, jint lpActiveObj)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleSetMenuDescriptor\n");
+#endif
+ return (jint) OleSetMenuDescriptor((HOLEMENU)holemenu, (HWND)hwndFrame, (HWND)hwndActiveObject, (LPOLEINPLACEFRAME)lpFrame, (LPOLEINPLACEACTIVEOBJECT)lpActiveObj);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleTranslateColor
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleTranslateColor
+ (JNIEnv *env, jclass that, jint clr, jint hpal, jintArray pcolorref)
+{
+ jint *pcolorref1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleTranslateColor\n");
+#endif
+
+ if (pcolorref)
+ pcolorref1 = (*env)->GetIntArrayElements(env, pcolorref, NULL);
+
+ rc = (jint) OleTranslateColor((OLE_COLOR)clr, (HPALETTE)hpal, (COLORREF *)pcolorref1);
+
+ if (pcolorref)
+ (*env)->ReleaseIntArrayElements(env, pcolorref, pcolorref1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: RegisterClipboardFormat
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_RegisterClipboardFormat
+ (JNIEnv *env, jclass that, jbyteArray lpszFormat)
+{
+ LPCTSTR lpszFormat1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegisterClipboardFormat\n");
+#endif
+
+ if (lpszFormat)
+ lpszFormat1 = (*env)->GetByteArrayElements(env, lpszFormat, NULL);
+
+ rc = (jint) RegisterClipboardFormat(lpszFormat1);
+
+ if (lpszFormat)
+ (*env)->ReleaseByteArrayElements(env, lpszFormat, (jbyte *)lpszFormat1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: RegisterDragDrop
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_RegisterDragDrop
+ (JNIEnv *env, jclass that, jint hwnd, jint pDropTarget)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RegisterDragDrop\n");
+#endif
+ return (jint) RegisterDragDrop((HWND)hwnd, (IDropTarget *)pDropTarget);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: RevokeDragDrop
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_RevokeDragDrop
+ (JNIEnv *env, jclass that, jint hwnd)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "RevokeDragDrop\n");
+#endif
+ return (jint) RevokeDragDrop((HWND)hwnd);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: StgCreateDocfile
+ * Signature: ([CII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_StgCreateDocfile
+ (JNIEnv *env, jclass that, jcharArray pwcsName, jint grfMode, jint reserved, jintArray ppstgOpen)
+{
+ jchar *pwcsName1=NULL;
+ IStorage **ppstgOpen1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "StgCreateDocfile\n");
+#endif
+
+ if (pwcsName)
+ pwcsName1 = (*env)->GetCharArrayElements(env, pwcsName, NULL);
+
+ if (ppstgOpen)
+ ppstgOpen1 = (IStorage **)(*env)->GetIntArrayElements(env, ppstgOpen, NULL);
+
+ rc = (jint) StgCreateDocfile(pwcsName1, grfMode, reserved, ppstgOpen1);
+
+ if (ppstgOpen)
+ (*env)->ReleaseIntArrayElements(env, ppstgOpen, (jint *)ppstgOpen1, 0);
+
+ if (pwcsName)
+ (*env)->ReleaseCharArrayElements(env, pwcsName, pwcsName1, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: StgIsStorageFile
+ * Signature: ([C)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_StgIsStorageFile
+ (JNIEnv *env, jclass that, jcharArray pwcsName)
+{
+ const WCHAR *pwcsName1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "StgIsStorageFile\n");
+#endif
+
+ if (pwcsName)
+ pwcsName1 = (const WCHAR *)(*env)->GetCharArrayElements(env, pwcsName, NULL);
+
+ rc = (jint)StgIsStorageFile(pwcsName1);
+
+ if (pwcsName)
+ (*env)->ReleaseCharArrayElements(env, pwcsName, (jchar *)pwcsName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: StgOpenStorage
+ * Signature: ([CIIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_StgOpenStorage
+ (JNIEnv *env, jclass that, jcharArray pwcsName, jint pstgPriority, jint grfMode, jint snbExclude, jint reserved, jintArray ppstgOpen)
+{
+ const WCHAR *pwcsName1=NULL;
+ IStorage **ppstgOpen1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "StgOpenStorage\n");
+#endif
+
+ if (pwcsName)
+ pwcsName1 = (const WCHAR *)(*env)->GetCharArrayElements(env, pwcsName, NULL);
+
+ if (ppstgOpen)
+ ppstgOpen1 = (IStorage **)(*env)->GetIntArrayElements(env, ppstgOpen, NULL);
+
+ rc = (jint) StgOpenStorage(pwcsName1, (IStorage *)pstgPriority, grfMode, (SNB)snbExclude, reserved, ppstgOpen1);
+
+ if (ppstgOpen)
+ (*env)->ReleaseIntArrayElements(env, ppstgOpen, (jint *)ppstgOpen1, 0);
+
+ if (pwcsName)
+ (*env)->ReleaseCharArrayElements(env, pwcsName, (jchar *)pwcsName1, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: SysAllocString
+ * Signature: ([C)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_SysAllocString
+ (JNIEnv *env, jclass that, jcharArray sz0)
+{
+ jchar *sz01=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SysAllocString\n");
+#endif
+ if (sz0)
+ sz01 = (*env)->GetCharArrayElements(env, sz0, NULL);
+ rc = (jint) SysAllocString( (OLECHAR *) sz01);
+ if (sz0)
+ (*env)->ReleaseCharArrayElements(env, sz0, sz01, 0);
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: SysFreeString
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_SysFreeString
+ (JNIEnv *env, jclass that, jint bstr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SysFreeString\n");
+#endif
+ SysFreeString((BSTR)bstr);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: SysStringByteLen
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_SysStringByteLen
+ (JNIEnv *env, jclass that, jint bstr)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SysStringByteLen\n");
+#endif
+ return (jint) SysStringByteLen((BSTR)bstr);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VariantChangeType
+ * Signature: (IISS)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VariantChangeType
+ (JNIEnv *env, jclass that, jint pvargDest, jint pvarSrc, jshort wFlags, jshort vt)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VariantChangeType\n");
+#endif
+ return (jint) VariantChangeType((VARIANTARG FAR* )pvargDest, (VARIANTARG FAR* )pvarSrc, wFlags, (VARTYPE) vt);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VariantClear
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VariantClear
+ (JNIEnv *env, jclass that, jint pvarg)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VariantClear\n");
+#endif
+ return (jint) VariantClear((VARIANTARG FAR* ) pvarg);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VariantInit
+ * Signature: (I)V
+ */
+JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VariantInit
+ (JNIEnv *env, jclass that, jint pvarg)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VariantInit\n");
+#endif
+ VariantInit((VARIANTARG FAR*)pvarg);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl)
+{
+ P_OLE_FN_1 fn; /* this is a function that returns int */
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II\n");
+#endif
+ fn = (P_OLE_FN_1)(*(int **)ppVtbl)[fnNumber];
+ return fn(ppVtbl); /* cast it to an OLE function returning int */
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[C)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3C
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jcharArray arg0)
+{
+ P_OLE_FN_2 fn;
+ jchar *arg01=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3C\n");
+#endif
+
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetCharArrayElements(env, arg0, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01);
+
+ if (arg0)
+ (*env)->ReleaseCharArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[C[C)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3C_3C
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jcharArray arg0, jcharArray arg1)
+{
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jchar *arg01=NULL, *arg11=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3C_3C\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetCharArrayElements(env, arg0, NULL);
+
+ if (arg1)
+ arg11 = (*env)->GetCharArrayElements(env, arg1, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, (jint)arg11); /* cast it to an OLE function returning int */
+
+ if (arg1)
+ (*env)->ReleaseCharArrayElements(env, arg1, arg11, 0);
+
+ if (arg0)
+ (*env)->ReleaseCharArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[CI)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3CI
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jcharArray arg0, jint arg1)
+{
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jchar *arg01=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3CI\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetCharArrayElements(env, arg0, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, arg1);
+
+ if (arg0)
+ (*env)->ReleaseCharArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[CIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3CIII_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jcharArray arg0, jint arg1, jint arg2, jint arg3, jintArray arg4)
+{
+ P_OLE_FN_6 fn; /* this is a function that returns int */
+ jchar *arg01=NULL;
+ jint *arg41=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3CIII_3I\n");
+#endif
+
+ fn = (P_OLE_FN_6)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg4)
+ arg41 = (*env)->GetIntArrayElements(env, arg4, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, arg2, arg3, (jint)arg41); /* cast it to an OLE function returning int */
+
+ if (arg4)
+ (*env)->ReleaseIntArrayElements(env, arg4, arg41, 0);
+ if (arg0)
+ (*env)->ReleaseCharArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[CIIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3CIIII_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jcharArray arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5)
+{
+ P_OLE_FN_7 fn; /* this is a function that returns int */ jchar *arg01=NULL;
+ jint *arg51=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3CIIII_3I\n");
+#endif
+
+ fn = (P_OLE_FN_7)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetCharArrayElements(env, arg0, NULL);
+ if (arg5)
+ arg51 = (*env)->GetIntArrayElements(env, arg5, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, arg2, arg3, arg4, (jint)arg51); /* cast it to an OLE function returning int */
+
+ if (arg5)
+ (*env)->ReleaseIntArrayElements(env, arg5, arg51, 0);
+ if (arg0)
+ (*env)->ReleaseCharArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jintArray arg0)
+{
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ jint *arg01=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3I\n");
+#endif
+
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetIntArrayElements(env, arg0, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01); /* cast it to an OLE function returning int */
+
+ if (arg0)
+ (*env)->ReleaseIntArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (III)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__III
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0)
+{
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__III\n");
+#endif
+
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+
+ rc = fn(ppVtbl, arg0); /* cast it to an OLE function returning int */
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIII
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1)
+{
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIII\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+
+ rc = fn(ppVtbl, arg0, arg1); /* cast it to an OLE function returning int */
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (III[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__III_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jintArray arg1)
+{
+ P_OLE_FN_3 fn;
+
+ jint *arg11=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__III_3I\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*((jint **)ppVtbl))[fnNumber];
+
+ if (arg1)
+ arg11 = (*env)->GetIntArrayElements(env, arg1, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11);
+
+ if (arg1)
+ (*env)->ReleaseIntArrayElements(env, arg1, arg11, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIII_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jintArray arg2)
+{
+ P_OLE_FN_4 fn; /* this is a function that returns int */
+ jint *arg21=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIII_3I\n");
+#endif
+
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg2)
+ arg21 = (*env)->GetIntArrayElements(env, arg2, NULL);
+
+ rc = fn(ppVtbl, arg0, arg1, (jint)arg21); /* cast it to an OLE function returning int */
+
+ if (arg2)
+ (*env)->ReleaseIntArrayElements(env, arg2, arg21, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIII
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jint arg2)
+{
+ P_OLE_FN_4 fn; /* this is a function that returns int */
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIIII\n");
+#endif
+
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+ return fn(ppVtbl, arg0, arg1, arg2);;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIII_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jint arg2, jintArray arg3)
+{
+ P_OLE_FN_5 fn; /* this is a function that returns int */
+ jint *arg31=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VtblCall__IIIII_3I\n");
+#endif
+
+ fn = (P_OLE_FN_5)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg3)
+ arg31 = (*env)->GetIntArrayElements(env, arg3, NULL);
+
+ rc = fn(ppVtbl, arg0, arg1, arg2, (jint)arg31);
+
+ if (arg3)
+ (*env)->ReleaseIntArrayElements(env, arg3, arg31, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIIII_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jint arg2, jint arg3, jintArray arg4)
+{
+ P_OLE_FN_6 fn;
+ jint *arg41=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3CIIII_3I\n");
+#endif
+
+ fn = (P_OLE_FN_6)(*(int **)ppVtbl)[fnNumber];
+ if (arg4)
+ arg41 = (*env)->GetIntArrayElements(env, arg4, NULL);
+
+ rc = fn(ppVtbl, arg0, arg1, arg2, arg3, (jint)arg41);
+
+ if (arg4)
+ (*env)->ReleaseIntArrayElements(env, arg4, arg41, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIIIII[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIIIII_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jint arg2, jint arg3, jint arg4, jintArray arg5)
+{
+ P_OLE_FN_7 fn;
+
+ jint *arg51=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIIIIII_3I\n");
+#endif
+
+ fn = (P_OLE_FN_7)(*((jint **)ppVtbl))[fnNumber];
+
+ if (arg5)
+ arg51 = (*env)->GetIntArrayElements(env, arg5, NULL);
+
+ rc = fn(ppVtbl, arg0, arg1, arg2, arg3, arg4, (jint)arg51);
+
+ if (arg5)
+ (*env)->ReleaseIntArrayElements(env, arg5, arg51, 0);
+
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIILorg/eclipse/swt/internal/ole/win32/DVTARGETDEVICE;Lorg/eclipse/swt/internal/win32/SIZE;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIILorg_eclipse_swt_internal_ole_win32_DVTARGETDEVICE_2Lorg_eclipse_swt_internal_win32_SIZE_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jobject arg2, jobject arg3)
+{
+ DECL_GLOB(pGlob)
+ DVTARGETDEVICE dvtargetdevice, *arg21=NULL;
+ SIZE size, *arg31=NULL;
+ P_OLE_FN_5 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIIILorg_eclipse_swt_internal_ole_win32_DVTARGETDEVICE_2Lorg_eclipse_swt_internal_win32_SIZE_2\n");
+#endif
+
+ fn = (P_OLE_FN_5)(*(int **)ppVtbl)[fnNumber];
+ if (arg2) {
+ arg21=&dvtargetdevice;
+ cacheDvtargetdeviceFids(env, arg2, &PGLOB(DvtargetdeviceFc));
+ getDvtargetdeviceFields(env, arg2, arg21, &PGLOB(DvtargetdeviceFc));
+ }
+ if (arg3) {
+ arg31=&size;
+ cacheSizeFids(env, arg3, &PGLOB(SizeFc));
+ getSizeFields(env, arg3, arg31, &PGLOB(SizeFc));
+ }
+
+ rc = fn(ppVtbl, arg0, arg1, (jint)arg21, (jint)arg31); /* cast it to an OLE function returning int */
+
+ if (arg2) {
+ setDvtargetdeviceFields(env, arg2, arg21, &PGLOB(DvtargetdeviceFc));
+ }
+ if (arg3) {
+ setSizeFields(env, arg3, arg31, &PGLOB(SizeFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIILorg/eclipse/swt/internal/ole/win32/GUID;I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIILorg_eclipse_swt_internal_ole_win32_GUID_2I_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1, jobject arg2, jint arg3, jintArray arg4)
+{
+ DECL_GLOB(pGlob)
+ jint *arg41=NULL;
+ GUID guid, *arg21=NULL;
+ P_OLE_FN_6 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIIILorg_eclipse_swt_internal_ole_win32_GUID_2I_3I\n");
+#endif
+ fn = (P_OLE_FN_6)(*(int **)ppVtbl)[fnNumber];
+ if (arg2) {
+ arg21=&guid;
+ cacheGuidFids(env, arg2, &PGLOB(GuidFc));
+ getGuidFields(env, arg2, arg21, &PGLOB(GuidFc));
+ }
+
+ if (arg4)
+ arg41 = (*env)->GetIntArrayElements(env, arg4, NULL);
+
+ rc = fn(ppVtbl, arg0, arg1, (jint)arg21, arg3, (jint)arg41); /* cast it to an OLE function returning int */
+
+ if (arg4)
+ (*env)->ReleaseIntArrayElements(env, arg4, arg41, 0);
+
+ if (arg2) {
+ setGuidFields(env, arg2, arg21, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/ole/win32/FORMATETC;[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_FORMATETC_2_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1, jintArray arg2)
+{
+ DECL_GLOB(pGlob)
+ P_OLE_FN_4 fn;
+ FORMATETC formatetc, *arg11=NULL;
+ jint *arg21=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_FORMATETC_2_3I\n");
+#endif
+
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg1) {
+ arg11 = &formatetc;
+ cacheFormatetcFids(env, arg1, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, arg1, arg11, &PGLOB(FormatetcFc));
+ }
+ if (arg2)
+ arg21 = (*env)->GetIntArrayElements(env, arg2, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, (jint)arg21);
+
+ if (arg2)
+ (*env)->ReleaseIntArrayElements(env, arg2, arg21, 0);
+
+ if (arg1) {
+ setFormatetcFields(env, arg1, arg11, &PGLOB(FormatetcFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *arg11=NULL;
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIIILorg_eclipse_swt_internal_ole_win32_GUID_2n");
+#endif
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&guid;
+ cacheGuidFids(env, arg1, &PGLOB(GuidFc));
+ getGuidFields(env, arg1, arg11, &PGLOB(GuidFc));
+ }
+
+ rc = fn(ppVtbl, arg0, (jint)arg11); /* cast it to an COM function returning int */
+
+ if (arg1) {
+ setGuidFields(env, arg1, arg11, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/ole/win32/GUID;II)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2II
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1, jint arg2, jint arg3)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *arg11=NULL;
+ P_OLE_FN_5 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2II\n");
+#endif
+ fn = (P_OLE_FN_5)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&guid;
+ cacheGuidFids(env, arg1, &PGLOB(GuidFc));
+ getGuidFields(env, arg1, arg11, &PGLOB(GuidFc));
+ }
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, arg2, arg3); /* cast it to an OLE function returning int */
+
+ if (arg1) {
+ setGuidFields(env, arg1, arg11, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/ole/win32/GUID;IILorg/eclipse/swt/internal/ole/win32/DISPPARAMS;ILorg/eclipse/swt/internal/ole/win32/EXCEPINFO;[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2IILorg_eclipse_swt_internal_ole_win32_DISPPARAMS_2ILorg_eclipse_swt_internal_ole_win32_EXCEPINFO_2_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1, jint arg2, jint arg3, jobject arg4, jint arg5, jobject arg6, jintArray arg7)
+{
+ DECL_GLOB(pGlob)
+ jint *arg71=NULL;
+ GUID guid, *arg11=NULL;
+ EXCEPINFO excepinfo, *arg61=NULL;
+ DISPPARAMS dispparams, *arg41=NULL;
+ P_OLE_FN_9 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2IILorg_eclipse_swt_internal_ole_win32_DISPPARAMS_2ILorg_eclipse_swt_internal_ole_win32_EXCEPINFO_2_3I\n");
+#endif
+
+ fn = (P_OLE_FN_9)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&guid;
+ cacheGuidFids(env, arg1, &PGLOB(GuidFc));
+ getGuidFields(env, arg1, arg11, &PGLOB(GuidFc));
+ }
+ if (arg4) {
+ arg41=&dispparams;
+ cacheDispparamsFids(env, arg4, &PGLOB(DispparamsFc));
+ getDispparamsFields(env, arg4, arg41, &PGLOB(DispparamsFc));
+ }
+
+ if (arg6) {
+ arg61=&excepinfo;
+ cacheExcepinfoFids(env, arg6, &PGLOB(ExcepinfoFc));
+ getExcepinfoFields(env, arg6, arg61, &PGLOB(ExcepinfoFc));
+ }
+
+ if (arg7)
+ arg71 = (*env)->GetIntArrayElements(env, arg7, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, arg2, arg3, (jint)arg41, arg5, (jint)arg61, (jint)arg71); /* cast it to an OLE function returning int */
+
+ if (arg7)
+ (*env)->ReleaseIntArrayElements(env, arg7, arg71, 0);
+
+ if (arg6) {
+ setExcepinfoFields(env, arg6, arg61, &PGLOB(ExcepinfoFc));
+ }
+
+ if (arg4) {
+ setDispparamsFields(env, arg4, arg41, &PGLOB(DispparamsFc));
+ }
+
+ if (arg1) {
+ setGuidFields(env, arg1, arg11, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/ole/win32/STATSTG;[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_STATSTG_2_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1, jintArray arg2)
+{
+ DECL_GLOB(pGlob)
+ jint *arg21=NULL;
+ STATSTG statstg, *arg11=NULL;
+ P_OLE_FN_4 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VtblCall__IIILorg_eclipse_swt_internal_ole_win32_STATSTG_2_3I\n");
+#endif
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&statstg;
+ cacheStatstgFids(env, arg1, &PGLOB(StatstgFc));
+ getStatstgFields(env, arg1, arg11, &PGLOB(StatstgFc));
+ }
+
+ if (arg2)
+ arg21 = (*env)->GetIntArrayElements(env, arg2, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, (jint)arg21); /* cast it to an OLE function returning int */
+
+ if (arg2)
+ (*env)->ReleaseIntArrayElements(env, arg2, arg21, 0);
+
+ if (arg1) {
+ setStatstgFields(env, arg1, arg11, &PGLOB(StatstgFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/win32/MSG;IIILorg/eclipse/swt/internal/win32/RECT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_win32_MSG_2IIILorg_eclipse_swt_internal_win32_RECT_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1, jint arg2, jint arg3, jint arg4, jobject arg5)
+{
+ DECL_GLOB(pGlob)
+ MSG msg, *arg11=NULL;
+ RECT rect, *arg51=NULL;
+ P_OLE_FN_7 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIILorg_eclipse_swt_internal_win32_MSG_2IIILorg_eclipse_swt_internal_win32_RECT_2\n");
+#endif
+
+ fn = (P_OLE_FN_7)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&msg;
+ cacheMsgFids(env, arg1, &PGLOB(MsgFc));
+ getMsgFields(env, arg1, arg11, &PGLOB(MsgFc));
+ }
+ if (arg5) {
+ arg51=&rect;
+ cacheRectFids(env, arg5, &PGLOB(RectFc));
+ getRectFields(env, arg5, arg51, &PGLOB(RectFc));
+ }
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, arg2, arg3, arg4, (jint)arg51); /* cast it to an OLE function returning int */
+
+ if (arg1) {
+ setMsgFields(env, arg1, arg11, &PGLOB(MsgFc));
+ }
+ if (arg5) {
+ setRectFields(env, arg5, arg51, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/win32/SIZE;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_win32_SIZE_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1)
+{
+ DECL_GLOB(pGlob)
+ SIZE size, *arg11=NULL;
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIILorg_eclipse_swt_internal_win32_SIZE_2\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&size;
+ cacheSizeFids(env, arg1, &PGLOB(SizeFc));
+ getSizeFields(env, arg1, arg11, &PGLOB(SizeFc));
+ }
+
+ rc = fn(ppVtbl, arg0, (jint)arg11); /* cast it to an COM function returning int */
+
+ if (arg1) {
+ setSizeFields(env, arg1, arg11, &PGLOB(SizeFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIIZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIIZ
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jboolean arg1)
+{
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIIZ\n");
+#endif
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+
+ rc = fn(ppVtbl, arg0, arg1); /* cast it to an OLE function returning int */
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/CAUUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_CAUUID_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ DECL_GLOB(pGlob)
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ CAUUID cauuid, *arg01=&cauuid;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3C\n");
+#endif
+
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0) {
+ cacheCauuidFids(env, arg0, &PGLOB(CauuidFc));
+ getCauuidFields(env, arg0, arg01, &PGLOB(CauuidFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01); /* cast it to an OLE function returning int */
+
+ if (arg0) {
+ setCauuidFields(env, arg0, arg01, &PGLOB(CauuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/CONTROLINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_CONTROLINFO_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ DECL_GLOB(pGlob)
+ CONTROLINFO controlinfo, *arg01=NULL;
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_CONTROLINFO_2\n");
+#endif
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&controlinfo;
+ cacheControlinfoFids(env, arg0, &PGLOB(ControlinfoFc));
+ getControlinfoFields(env, arg0, arg01, &PGLOB(ControlinfoFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01); /* cast it to an OLE function returning int */
+
+ if (arg0) {
+ setControlinfoFields(env, arg0, arg01, &PGLOB(ControlinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/FORMATETC;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_FORMATETC_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ DECL_GLOB(pGlob)
+ P_OLE_FN_2 fn;
+ FORMATETC formatetc, *arg01=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_FORMATETC_2\n");
+#endif
+
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0) {
+ arg01 = &formatetc;
+ cacheFormatetcFids(env, arg0, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, arg0, arg01, &PGLOB(FormatetcFc));
+ }
+ rc = fn(ppVtbl, (jint)arg01);
+
+ if (arg0) {
+ setFormatetcFields(env, arg0, arg01, &PGLOB(FormatetcFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/FORMATETC;Lorg/eclipse/swt/internal/ole/win32/STGMEDIUM;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_FORMATETC_2Lorg_eclipse_swt_internal_ole_win32_STGMEDIUM_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jobject arg1)
+{
+ DECL_GLOB(pGlob)
+ P_OLE_FN_3 fn;
+ FORMATETC formatetc, *arg01=NULL;
+ STGMEDIUM stgmedium, *arg11=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_FORMATETC_2Lorg_eclipse_swt_internal_ole_win32_STGMEDIUM_2\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0) {
+ arg01 = &formatetc;
+ cacheFormatetcFids(env, arg0, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, arg0, arg01, &PGLOB(FormatetcFc));
+ }
+ if (arg1) {
+ arg11 = &stgmedium;
+ cacheStgmediumFids(env, arg1, &PGLOB(StgmediumFc));
+ getStgmediumFields(env, arg1, arg11, &PGLOB(StgmediumFc));
+ }
+ rc = fn(ppVtbl, (jint)arg01, (jint)arg11);
+
+ if (arg0) {
+ setFormatetcFields(env, arg0, arg01, &PGLOB(FormatetcFc));
+ }
+ if (arg1) {
+ setStgmediumFields(env, arg1, arg11, &PGLOB(StgmediumFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/FORMATETC;Lorg/eclipse/swt/internal/ole/win32/STGMEDIUM;Z)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_FORMATETC_2Lorg_eclipse_swt_internal_ole_win32_STGMEDIUM_2Z
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jobject arg1, jboolean arg2)
+{
+ DECL_GLOB(pGlob)
+ P_OLE_FN_4 fn;
+ FORMATETC formatetc, *arg01=NULL;
+ STGMEDIUM stgmedium, *arg11=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_FORMATETC_2Lorg_eclipse_swt_internal_ole_win32_STGMEDIUM_2Z\n");
+#endif
+
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0) {
+ arg01 = &formatetc;
+ cacheFormatetcFids(env, arg0, &PGLOB(FormatetcFc));
+ getFormatetcFields(env, arg0, arg01, &PGLOB(FormatetcFc));
+ }
+ if (arg1) {
+ arg11 = &stgmedium;
+ cacheStgmediumFids(env, arg1, &PGLOB(StgmediumFc));
+ getStgmediumFields(env, arg1, arg11, &PGLOB(StgmediumFc));
+ }
+ rc = fn(ppVtbl, (jint)arg01, (jint)arg11, (jint)arg2);
+
+ if (arg0) {
+ setFormatetcFields(env, arg0, arg01, &PGLOB(FormatetcFc));
+ }
+ if (arg1) {
+ setStgmediumFields(env, arg1, arg11, &PGLOB(StgmediumFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *arg01=NULL;
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2\n");
+#endif
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&guid;
+ cacheGuidFids(env, arg0, &PGLOB(GuidFc));
+ getGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01); /* cast it to an OLE function returning int */
+
+ if (arg0) {
+ setGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/GUID;[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jintArray arg1)
+{
+ DECL_GLOB(pGlob)
+ jint *arg11=NULL;
+ GUID guid, *arg01=NULL;
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2_3I\n");
+#endif
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0) {
+ arg01=&guid;
+ cacheGuidFids(env, arg0, &PGLOB(GuidFc));
+ getGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+
+ if (arg1)
+ arg11 = (*env)->GetIntArrayElements(env, arg1, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, (jint)arg11); /* cast it to an OLE function returning int */
+
+ if (arg1)
+ (*env)->ReleaseIntArrayElements(env, arg1, arg11, 0);
+
+ if (arg0) {
+ setGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/GUID;III[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2III_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jint arg1, jint arg2, jint arg3, jintArray arg4)
+{
+ DECL_GLOB(pGlob)
+ jint *arg41=NULL;
+ GUID guid, *arg01=NULL;
+ P_OLE_FN_6 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2III_3I\n");
+#endif
+ fn = (P_OLE_FN_6)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&guid;
+ cacheGuidFids(env, arg0, &PGLOB(GuidFc));
+ getGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+
+ if (arg4)
+ arg41 = (*env)->GetIntArrayElements(env, arg4, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, arg2, arg3, (jint)arg41); /* cast it to an OLE function returning int */
+
+ if (arg4)
+ (*env)->ReleaseIntArrayElements(env, arg4, arg41, 0);
+
+ if (arg0) {
+ setGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/GUID;IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2IIII
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jint arg1, jint arg2, jint arg3, jint arg4)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *arg01=NULL;
+ P_OLE_FN_6 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2IIII\n");
+#endif
+ fn = (P_OLE_FN_6)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&guid;
+ cacheGuidFids(env, arg0, &PGLOB(GuidFc));
+ getGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, arg2, arg3, arg4);
+
+ if (arg0) {
+ setGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/GUID;ILorg/eclipse/swt/internal/ole/win32/OLECMD;Lorg/eclipse/swt/internal/ole/win32/OLECMDTEXT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2ILorg_eclipse_swt_internal_ole_win32_OLECMD_2Lorg_eclipse_swt_internal_ole_win32_OLECMDTEXT_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jint arg1, jobject arg2, jobject arg3)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *arg01=NULL;
+ OLECMD olecmd, *arg21=NULL;
+ OLECMDTEXT olecmdtext, *arg31=NULL;
+
+ P_OLE_FN_5 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VtblCall__IILorg_eclipse_swt_internal_ole_win32_GUID_2ILorg_eclipse_swt_internal_ole_win32_OLECMD_2Lorg_eclipse_swt_internal_ole_win32_OLECMDTEXT_2\n");
+#endif
+ fn = (P_OLE_FN_5)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&guid;
+ cacheGuidFids(env, arg0, &PGLOB(GuidFc));
+ getGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+ if (arg2) {
+ arg21=&olecmd;
+ cacheOlecmdFids(env, arg2, &PGLOB(OlecmdFc));
+ getOlecmdFields(env, arg2, arg21, &PGLOB(OlecmdFc));
+ }
+ if (arg3) {
+ arg31=&olecmdtext;
+ cacheOlecmdtextFids(env, arg3, &PGLOB(OlecmdtextFc));
+ getOlecmdtextFields(env, arg3, arg31, &PGLOB(OlecmdtextFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, (jint)arg21, (jint)arg31);
+
+ if (arg0) {
+ setGuidFields(env, arg0, arg01, &PGLOB(GuidFc));
+ }
+ if (arg2) {
+ setOlecmdFields(env, arg2, arg21, &PGLOB(OlecmdFc));
+ }
+ if (arg3) {
+ setOlecmdtextFields(env, arg3, arg31, &PGLOB(OlecmdtextFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/LICINFO;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_LICINFO_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ DECL_GLOB(pGlob)
+ LICINFO licinfo, *arg01=NULL;
+ P_OLE_FN_2 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_LICINFO_2\n");
+#endif
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&licinfo;
+ cacheLicinfoFids(env, arg0, &PGLOB(LicinfoFc));
+ getLicinfoFields(env, arg0, arg01, &PGLOB(LicinfoFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01); /* cast it to an OLE function returning int */
+
+ if (arg0) {
+ setLicinfoFields(env, arg0, arg01, &PGLOB(LicinfoFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/win32/RECT;IZ)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_win32_RECT_2IZ
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jint arg1, jboolean arg2)
+{
+ DECL_GLOB(pGlob)
+ RECT rect, *arg01=NULL;
+ P_OLE_FN_4 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_win32_RECT_2IZ\n");
+#endif
+
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&rect;
+ cacheRectFids(env, arg0, &PGLOB(RectFc));
+ getRectFields(env, arg0, arg01, &PGLOB(RectFc));
+ }
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, arg2); /* cast it to an OLE function returning int */
+
+ if (arg0) {
+ setRectFields(env, arg0, arg01, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/win32/RECT;Lorg/eclipse/swt/internal/win32/RECT;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_win32_RECT_2Lorg_eclipse_swt_internal_win32_RECT_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0, jobject arg1)
+{
+ DECL_GLOB(pGlob)
+ RECT rect0, *arg01=NULL;
+ RECT rect1, *arg11=NULL;
+ P_OLE_FN_3 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_win32_RECT_2Lorg_eclipse_swt_internal_win32_RECT_2\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&rect0;
+ cacheRectFids(env, arg0, &PGLOB(RectFc));
+ getRectFields(env, arg0, arg01, &PGLOB(RectFc));
+ }
+ if (arg1) {
+ arg11=&rect1;
+ cacheRectFids(env, arg1, &PGLOB(RectFc));
+ getRectFields(env, arg1, arg11, &PGLOB(RectFc));
+ }
+ rc = fn(ppVtbl, (jint)arg01, (jint)arg11); /* cast it to an OLE function returning int */
+
+ if (arg1) {
+ setRectFields(env, arg1, arg11, &PGLOB(RectFc));
+ }
+ if (arg0) {
+ setRectFields(env, arg0, arg01, &PGLOB(RectFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (III[I[I[I[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__III_3I_3I_3I_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jintArray arg1, jintArray arg2, jintArray arg3, jintArray arg4)
+{
+ DECL_GLOB(pGlob)
+ jint *arg11=NULL;
+ jint *arg21=NULL;
+ jint *arg31=NULL;
+ jint *arg41=NULL;
+ P_OLE_FN_6 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__III_3I_3I_3I_31\n");
+#endif
+ fn = (P_OLE_FN_6)(*(int **)ppVtbl)[fnNumber];
+ if (arg1)
+ arg11 = (*env)->GetIntArrayElements(env, arg1, NULL);
+
+ if (arg2)
+ arg21 = (*env)->GetIntArrayElements(env, arg2, NULL);
+
+ if (arg3)
+ arg31 = (*env)->GetIntArrayElements(env, arg3, NULL);
+
+ if (arg4)
+ arg41 = (*env)->GetIntArrayElements(env, arg4, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, (jint)arg21, (jint)arg31, (jint)arg41); /* cast it to an OLE function returning int */
+
+ if (arg1)
+ (*env)->ReleaseIntArrayElements(env, arg1, arg11, 0);
+
+ if (arg2)
+ (*env)->ReleaseIntArrayElements(env, arg2, arg21, 0);
+
+ if (arg3)
+ (*env)->ReleaseIntArrayElements(env, arg3, arg31, 0);
+
+ if (arg4)
+ (*env)->ReleaseIntArrayElements(env, arg4, arg41, 0);
+
+
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (III[II[I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__III_3II_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jintArray arg1, jint arg2, jintArray arg3)
+{
+ DECL_GLOB(pGlob)
+ jint *arg11=NULL;
+ jint *arg31=NULL;
+ P_OLE_FN_5 fn; /* this is a function that returns int */
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__III_3II_3I\n");
+#endif
+ fn = (P_OLE_FN_5)(*(int **)ppVtbl)[fnNumber];
+ if (arg1)
+ arg11 = (*env)->GetIntArrayElements(env, arg1, NULL);
+
+ if (arg3)
+ arg31 = (*env)->GetIntArrayElements(env, arg3, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, arg2, (jint)arg31); /* cast it to an OLE function returning int */
+
+ if (arg1)
+ (*env)->ReleaseIntArrayElements(env, arg1, arg11, 0);
+
+ if (arg3)
+ (*env)->ReleaseIntArrayElements(env, arg3, arg31, 0);
+
+ return rc;
+}
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: WriteClassStg
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/GUID;)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_WriteClassStg
+ (JNIEnv *env, jclass that, jint pStg, jobject rclsid)
+{
+ DECL_GLOB(pGlob)
+ GUID guid, *rclsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "WriteClassStg\n");
+#endif
+ if (rclsid) {
+ rclsid1=&guid;
+ cacheGuidFids(env, rclsid, &PGLOB(GuidFc));
+ getGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ rc = (jint) WriteClassStg((IStorage *)pStg, rclsid1);
+
+ if (rclsid) {
+ setGuidFields(env, rclsid, rclsid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleGetClipboard
+ * Signature: ([I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleGetClipboard
+ (JNIEnv *env, jclass that, jintArray ppDataObj)
+{
+ IDataObject **ppDataObj1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleGetClipboard\n");
+#endif
+ if (ppDataObj)
+ ppDataObj1 = (IDataObject **)(*env)->GetIntArrayElements(env, ppDataObj, NULL);
+
+ rc = (jint) OleGetClipboard(ppDataObj1);
+
+ if (ppDataObj)
+ (*env)->ReleaseIntArrayElements(env, ppDataObj, (jint *)ppDataObj1, 0);
+
+ return rc;
+}
+
+ /*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleIsCurrentClipboard
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleIsCurrentClipboard
+ (JNIEnv *env, jclass that, jint pDataObj)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleIsCurrentClipboard\n");
+#endif
+ return (jint) OleIsCurrentClipboard((IDataObject *)pDataObj);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleSetClipboard
+ * Signature: (I)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleSetClipboard
+ (JNIEnv *env, jclass that, jint pDataObj)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleSetClipboard\n");
+#endif
+ return (jint) OleSetClipboard((IDataObject *)pDataObj);
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleFlushClipboard
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleFlushClipboard
+ (JNIEnv *env, jclass that)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleFlushClipboard\n");
+#endif
+ return (jint) OleFlushClipboard();
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: OleDraw
+ * Signature: (IIII)I
+ */
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_OleDraw
+ (JNIEnv *env, jclass that, jint pUnk, jint dwAspect, jint hdcDraw, jint lprcBounds)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "OleDraw\n");
+#endif
+ return (jint) OleDraw((LPUNKNOWN)pUnk, (DWORD)dwAspect, (HDC)hdcDraw, (LPRECT)lprcBounds);
+}
+
+/* ------------- obsolete OLE calls ------------- */
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: DispGetParam
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/DISPPARAMS;III[I)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_DispGetParam
+ (JNIEnv *env, jclass that, jobject pdispparams, jint position, jint vtTarg, jint pvarResult, jintArray puArgErr)
+{
+ unsigned int FAR *puArgErr1=NULL;
+ DISPPARAMS dispparams, *pdispparams1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "DispGetParam\n");
+#endif
+
+ if (pdispparams) {
+ pdispparams1=&dispparams;
+ cacheDispparamsFids(env, pdispparams, &DispparamsFc);
+ getDispparamsFields(env, pdispparams, pdispparams1, &DispparamsFc);
+ }
+ if (puArgErr)
+ puArgErr1 = (*env)->GetIntArrayElements(env, puArgErr, NULL);
+
+ rc = (jint) DispGetParam(pdispparams1, position, (VARTYPE)vtTarg, (VARIANT FAR *)pvarResult, puArgErr1);
+
+ if (puArgErr)
+ (*env)->ReleaseIntArrayElements(env, puArgErr, puArgErr1, 0);
+
+ if (pdispparams) {
+ setDispparamsFields(env, pdispparams, pdispparams1, &DispparamsFc);
+ }
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/win32/SIZE;I)V
+ */
+/*JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_win32_SIZE_2I
+ (JNIEnv *env, jclass that, jint DestinationPtr, jobject Source, jint Length)
+{
+ SIZE size, *Source1=&size;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_win32_SIZE_2I\n");
+#endif
+
+ if (Source) {
+ cacheSizeFids(env, Source, &SizeFc);
+ getSizeFields(env, Source, Source1, &SizeFc);
+ }
+
+ MoveMemory((PVOID)DestinationPtr, Source1, Length);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (II[CI[CI)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__II_3CI_3CI
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jcharArray arg0, jint arg1, jcharArray arg2, jint arg3)
+{
+ P_OLE_FN_5 fn;
+ jchar *arg01=NULL, *arg21=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__II_3CI_3CI\n");
+#endif
+
+ fn = (P_OLE_FN_5)(*(int **)ppVtbl)[fnNumber];
+
+ if (arg0)
+ arg01 = (*env)->GetCharArrayElements(env, arg0, NULL);
+
+ if (arg2)
+ arg21 = (*env)->GetCharArrayElements(env, arg2, NULL);
+
+ rc = fn(ppVtbl, (jint)arg01, arg1, (jint)arg21, arg3);
+
+ if (arg2)
+ (*env)->ReleaseCharArrayElements(env, arg2, arg21, 0);
+
+ if (arg0)
+ (*env)->ReleaseCharArrayElements(env, arg0, arg01, 0);
+
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIILorg/eclipse/swt/internal/ole/win32/GUID;[I)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2_3I
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jobject arg1, jintArray arg2)
+{
+ jint *arg21=NULL;
+ GUID guid, *arg11=NULL;
+ P_OLE_FN_4 fn;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIILorg_eclipse_swt_internal_ole_win32_GUID_2I_3I\n");
+#endif
+
+ fn = (P_OLE_FN_4)(*(int **)ppVtbl)[fnNumber];
+ if (arg1) {
+ arg11=&guid;
+ cacheGuidFids(env, arg1, &GuidFc);
+ getGuidFields(env, arg1, arg11, &GuidFc);
+ }
+
+ if (arg2)
+ arg21 = (*env)->GetIntArrayElements(env, arg2, NULL);
+
+ rc = fn(ppVtbl, arg0, (jint)arg11, (jint)arg21);
+
+ if (arg2)
+ (*env)->ReleaseIntArrayElements(env, arg2, arg21, 0);
+
+ if (arg1) {
+ setGuidFields(env, arg1, arg11, &GuidFc);
+ }
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IIII)I
+ */
+/*JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IIII
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jint arg0, jint arg1)
+{
+ P_OLE_FN_3 fn;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IIII\n");
+#endif
+
+ fn = (P_OLE_FN_3)(*(int **)ppVtbl)[fnNumber];
+ rc = fn(ppVtbl, arg0, arg1);
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/win32/MSG;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_win32_MSG_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ MSG msg, *arg01=NULL;
+ P_OLE_FN_2 fn;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_MSG_2\n");
+#endif
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&msg;
+ cacheMsgFids(env, arg0, &MsgFc);
+ getMsgFields(env, arg0, arg01, &MsgFc);
+ }
+
+ rc = fn(ppVtbl, (jint)arg01);
+
+ if (arg0) {
+ setMsgFields(env, arg0, arg01, &MsgFc);
+ }
+ return rc;
+}
+*/
+/* ------------- end obsolote OLE calls ------------- */
+
+/* ------------- deleted OLE calls ------------- */
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VtblCall
+ * Signature: (IILorg/eclipse/swt/internal/ole/win32/TYPEATTR;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_TYPEATTR_2
+ (JNIEnv *env, jclass that, jint fnNumber, jint ppVtbl, jobject arg0)
+{
+ TYPEATTR typeattr, *arg01=NULL;
+ P_OLE_FN_2 fn;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_VtblCall__IILorg_eclipse_swt_internal_ole_win32_TYPEATTR_2\n");
+#endif
+ fn = (P_OLE_FN_2)(*(int **)ppVtbl)[fnNumber];
+ if (arg0) {
+ arg01=&typeattr;
+ cacheTypeattrFids(env, arg0, &TypeattrFc);
+ getTypeattrFields(env, arg0, arg01, &TypeattrFc);
+ }
+
+ rc = fn(ppVtbl, (jint)arg01);
+ if (arg0) {
+ setTypeattrFields(env, arg0, arg01, &TypeattrFc);
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: MoveMemory
+ * Signature: (ILorg/eclipse/swt/internal/ole/win32/EXCEPINFO;I)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_EXCEPINFO_2I
+ (JNIEnv *env, jclass that, jint Destination, jobject SourcePtr, jint Length)
+{
+ EXCEPINFO excepinfo, *SourcePtr1=&excepinfo;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_MoveMemory__ILorg_eclipse_swt_internal_ole_win32_EXCEPINFO_2I\n");
+#endif
+
+ if (SourcePtr) {
+ cacheExcepinfoFids(env, SourcePtr, &ExcepinfoFc);
+ getExcepinfoFields(env, SourcePtr, SourcePtr1, &ExcepinfoFc);
+ }
+
+ MoveMemory((PVOID)Destination, SourcePtr1, Length);
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: ProgIDFromCLSID
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;[C)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_ProgIDFromCLSID__Lorg_eclipse_swt_internal_ole_win32_GUID_2_3C
+ (JNIEnv *env, jclass that, jobject pclsid, jcharArray lplpszProgID)
+{
+ LPOLESTR *lplpszProgID1=NULL;
+ GUID guid, *pclsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_ProgIDFromCLSID__Lorg_eclipse_swt_internal_ole_win32_GUID_2_3C\n");
+#endif
+
+ if (pclsid) {
+ pclsid1=&guid;
+ cacheGuidFids(env, pclsid, &GuidFc);
+ getGuidFields(env, pclsid, pclsid1, &GuidFc);
+ }
+
+ if (lplpszProgID)
+ lplpszProgID1 = (LPOLESTR *)(*env)->GetCharArrayElements(env, lplpszProgID, NULL);
+
+ rc = (jint) ProgIDFromCLSID(pclsid1, lplpszProgID1);
+
+ if (lplpszProgID)
+ (*env)->ReleaseCharArrayElements(env, lplpszProgID, (jchar *)lplpszProgID1, 0);
+
+ if (pclsid) {
+ setGuidFields(env, pclsid, pclsid1, &GuidFc);
+ }
+ return rc;
+}
+*/
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: ProgIDFromCLSID
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/GUID;[I)I
+ */
+ JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_ProgIDFromCLSID__Lorg_eclipse_swt_internal_ole_win32_GUID_2_3I
+ (JNIEnv *env, jclass that, jobject pclsid, jintArray lplpszProgID)
+{
+ DECL_GLOB(pGlob)
+ LPOLESTR *lplpszProgID1=NULL;
+ GUID guid, *pclsid1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "COM_ProgIDFromCLSID__Lorg_eclipse_swt_internal_ole_win32_GUID_2_3I\n");
+#endif
+
+ if (pclsid) {
+ pclsid1=&guid;
+ cacheGuidFids(env, pclsid, &PGLOB(GuidFc));
+ getGuidFields(env, pclsid, pclsid1, &PGLOB(GuidFc));
+ }
+
+ if (lplpszProgID)
+ lplpszProgID1 = (LPOLESTR *)(*env)->GetIntArrayElements(env, lplpszProgID, NULL);
+
+ rc = (jint) ProgIDFromCLSID(pclsid1, lplpszProgID1);
+
+ if (lplpszProgID)
+ (*env)->ReleaseIntArrayElements(env, lplpszProgID, (jint *)lplpszProgID1, 0);
+
+ if (pclsid) {
+ setGuidFields(env, pclsid, pclsid1, &PGLOB(GuidFc));
+ }
+ return rc;
+}
+
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: VariantCopyInd
+ * Signature: (II)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_VariantCopyInd
+ (JNIEnv *env, jclass that, jint pvarDest, jint pvarSrc)
+{
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "VariantCopyInd\n");
+#endif
+ return (jint) VariantCopyInd((VARIANT FAR*)pvarDest, (VARIANTARG FAR*)pvarSrc);
+}
+*/
+
+
+/* MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II removed after OS version 0.80 */
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: MoveMemory
+ * Signature: (Lorg/eclipse/swt/internal/win32/NMHEADER;II)V
+ */
+/* JNIEXPORT void JNICALL Java_org_eclipse_swt_internal_win32_OS_MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II
+ (JNIEnv *env, jclass that, jobject Destination, jint Source, jint Length)
+{
+ NMHEADER nmheader, *lpDestination1=NULL;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "MoveMemory__Lorg_eclipse_swt_internal_win32_NMHEADER_2II\n");
+#endif
+
+ MoveMemory((PVOID)&nmheader, (CONST VOID *)Source, Length);
+
+ if (Destination) {
+ lpDestination1 = &nmheader;
+ cacheNmheaderFids(env, Destination, &NmheaderFc);
+ setNmheaderFields(env, Destination, lpDestination1, &NmheaderFc);
+ }
+}
+*/
+
+/* SendMessage__IIILorg_eclipse_swt_internal_win32_HDITEM_2 removed after OS version 0.80 */
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/HDITEM;)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_HDITEM_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ HDITEM hditem, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_HDITEM_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &hditem;
+ cacheHditemFids(env, lParam, &HditemFc);
+ getHditemFields(env, lParam, lpParam1, &HditemFc);
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setHditemFields(env, lParam, lpParam1, &HditemFc);
+ }
+ return rc;
+}
+*/
+
+/* SendMessage__IIILorg_eclipse_swt_internal_win32_HDLAYOUT_2 removed after OS version 0.80 */
+/*
+ * Class: org_eclipse_swt_internal_win32_OS
+ * Method: SendMessage
+ * Signature: (IIILorg/eclipse/swt/internal/win32/HDLAYOUT;)I
+ */
+/* JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_win32_OS_SendMessage__IIILorg_eclipse_swt_internal_win32_HDLAYOUT_2
+ (JNIEnv *env, jclass that, jint hWnd, jint Msg, jint wParam, jobject lParam)
+{
+ HDLAYOUT hdlayout, *lpParam1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "SendMessage__IIILorg_eclipse_swt_internal_win32_HDLAYOUT_2\n");
+#endif
+
+ if (lParam) {
+ lpParam1 = &hdlayout;
+ cacheHdlayoutFids(env, lParam, &HdlayoutFc);
+ getHdlayoutFields(env, lParam, lpParam1, &HdlayoutFc);
+ }
+ rc = (jint) SendMessage((HWND)hWnd, Msg, wParam, (LPARAM)lpParam1);
+ if (lParam) {
+ setHdlayoutFields(env, lParam, lpParam1, &HdlayoutFc);
+ }
+ return rc;
+}
+*/
+/*
+ * Class: org_eclipse_swt_internal_ole_win32_COM
+ * Method: CoGetInstanceFromIStorage
+ * Signature: (Lorg/eclipse/swt/internal/ole/win32/COSERVERINFO;Lorg/eclipse/swt/internal/ole/win32/GUID;IIIILorg/eclipse/swt/internal/ole/win32/MULTI_QI;)I
+ */
+/*
+JNIEXPORT jint JNICALL Java_org_eclipse_swt_internal_ole_win32_COM_CoGetInstanceFromIStorage
+ (JNIEnv *env, jclass that, jobject pServerInfo, jobject pclsid, jint punkOuter, jint dwClsCtx,
+ jint pstg, jint cmq, jobject rgmqResults)
+{
+ GUID guid, *pclsid1=NULL;
+ COSERVERINFO coserverinfo, *pServerInfo1=NULL;
+ MULTI_QI multi_qi, *rgmqResults1=NULL;
+ jint rc;
+
+#ifdef DEBUG_CALL_PRINTS
+ fprintf(stderr, "CoGetInstanceFromIStorage\n");
+#endif
+
+ if (pclsid) {
+ pclsid1=&guid;
+ cacheGuidFids(env, pclsid, &GuidFc);
+ getGuidFields(env, pclsid, pclsid1, &GuidFc);
+ }
+ if (pServerInfo) {
+ pServerInfo1=&coserverinfo;
+ cacheCoserverinfoFids(env, pServerInfo, &CoserverinfoFc);
+ getCoserverinfoFields(env, pServerInfo, pServerInfo1, &CoserverinfoFc);
+ }
+ if (rgmqResults) {
+ rgmqResults1=&multi_qi;
+ cacheMulti_qiFids(env, rgmqResults, &MultiqiFc);
+ getMulti_qiFields(env, rgmqResults, rgmqResults1, &MultiqiFc);
+ }
+
+ rc = CoGetInstanceFromIStorage(pServerInfo1, pclsid1, (IUnknown *)punkOuter, dwClsCtx, (IStorage *)pstg, cmq, rgmqResults1);
+
+ if (pclsid) {
+ setGuidFields(env, pclsid, pclsid1, &GuidFc);
+ }
+ if (pServerInfo) {
+ setCoserverinfoFields(env, pServerInfo, pServerInfo1, &CoserverinfoFc);
+ }
+ if (rgmqResults) {
+ setMulti_qiFields(env, rgmqResults, rgmqResults1, &MultiqiFc);
+ }
+ return rc;
+}
+*/
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
new file mode 100755
index 0000000000..ff1b0e13d4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Color.java
@@ -0,0 +1,303 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+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
+ */
+
+public final class Color {
+
+ /**
+ * the handle to the OS color resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this color was created
+ */
+ Device device;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Color() {
+}
+
+/**
+ * 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_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) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, red, green, blue);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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_INVALID_ARGUMENT - if the red, green or blue components of the argument are not between 0 and 255</li>
+ * <li>ERROR_NULL_ARGUMENT - if the rgb argument is null</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+public Color (Device device, RGB rgb) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (rgb == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, rgb.red, rgb.green, rgb.blue);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the color. Applications must dispose of all colors which
+ * they allocate.
+ */
+public void dispose() {
+ if (handle == -1) return;
+ /*
+ * If this is a palette-based device,
+ * Decrease the reference count for this color.
+ * If the reference count reaches 0, the slot may
+ * be reused when another color is allocated.
+ */
+ int hPal = device.hPalette;
+ if (hPal != 0) {
+ int index = OS.GetNearestPaletteIndex(hPal, handle);
+ int[] colorRefCount = device.colorRefCount;
+ if (colorRefCount[index] > 0) {
+ colorRefCount[index]--;
+ }
+ }
+ handle = -1;
+ if (device.tracking) device.dispose_Object(this);
+ device = 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;
+ return device == color.device && (handle & 0xFFFFFF) == (color.handle & 0xFFFFFF);
+}
+
+/**
+ * Returns the amount of blue in the color, from 0 to 255.
+ *
+ * @return the blue component of the color
+ */
+public int getBlue () {
+ return (handle & 0xFF0000) >> 16;
+}
+
+/**
+ * Returns the amount of green in the color, from 0 to 255.
+ *
+ * @return the green component of the color
+ */
+public int getGreen () {
+ return (handle & 0xFF00) >> 8 ;
+}
+
+/**
+ * Returns the amount of red in the color, from 0 to 255.
+ *
+ * @return the red component of the color
+ */
+public int getRed () {
+ return handle & 0xFF;
+}
+
+/**
+ * Returns an <code>RGB</code> representing the receiver.
+ */
+public RGB getRGB () {
+ return new RGB(handle & 0xFF, (handle & 0xFF00) >> 8, (handle & 0xFF0000) >> 16);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 handle;
+}
+
+/**
+ * Allocates the operating system resources associated
+ * with the receiver.
+ *
+ * @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_INVALID_ARGUMENT - if the red, green or blue argument is not between 0 and 255</li>
+ * </ul>
+ *
+ * @see #dispose
+ */
+void init(Device device, 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.device = device;
+ handle = 0x02000000 | (red & 0xFF) | ((green & 0xFF) << 8) | ((blue & 0xFF) << 16);
+
+ /* If this is not a palette-based device, return */
+ int hPal = device.hPalette;
+ if (hPal == 0) return;
+
+ int[] colorRefCount = device.colorRefCount;
+ /* Add this color to the default palette now */
+ /* First find out if the color already exists */
+ int index = OS.GetNearestPaletteIndex(hPal, handle);
+ /* See if the nearest color actually is the color */
+ byte[] entry = new byte[4];
+ OS.GetPaletteEntries(hPal, index, 1, entry);
+ if ((entry[0] == (byte)red) && (entry[1] == (byte)green) &&
+ (entry[2] == (byte)blue)) {
+ /* Found the color. Increment the ref count and return */
+ colorRefCount[index]++;
+ return;
+ }
+ /* Didn't find the color, allocate it now. Find the first free entry */
+ int i = 0;
+ while (i < colorRefCount.length) {
+ if (colorRefCount[i] == 0) {
+ index = i;
+ break;
+ }
+ i++;
+ }
+ if (i == colorRefCount.length) {
+ /* No free entries, use the closest one */
+ /* Remake the handle from the actual rgbs */
+ handle = (entry[0] & 0xFF) | ((entry[1] & 0xFF) << 8) |
+ ((entry[2] & 0xFF) << 16);
+ } else {
+ /* Found a free entry */
+ int offset = index * 4;
+ entry = new byte[] { (byte)(red & 0xFF), (byte)(green & 0xFF), (byte)(blue & 0xFF), 0 };
+ OS.SetPaletteEntries(hPal, index, 1, entry);
+ }
+ colorRefCount[index]++;
+}
+
+/**
+ * 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 == -1;
+}
+
+/**
+ * Returns a string containing a concise, human-readable
+ * description of the receiver.
+ *
+ * @return a string representation of the receiver
+ */
+public String toString () {
+ return "Color {" + 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 win32_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Color color = new Color();
+ color.handle = handle;
+ color.device = device;
+ return color;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
new file mode 100755
index 0000000000..6c085722e8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Cursor.java
@@ -0,0 +1,344 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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>
+ */
+
+public final class Cursor {
+
+ /**
+ * the handle to the OS cursor resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this cursor was created
+ */
+ Device device;
+
+ /**
+ * data used to create a HAND cursor.
+ */
+ static final byte[] HandSrcData = {
+ (byte)0xf9,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0x3f,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0x07,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0x03,(byte)0xff,(byte)0xff,
+ (byte)0xf0,(byte)0x00,(byte)0xff,(byte)0xff,
+
+ (byte)0x10,(byte)0x00,(byte)0x7f,(byte)0xff,
+ (byte)0x00,(byte)0x00,(byte)0x7f,(byte)0xff,
+ (byte)0x80,(byte)0x00,(byte)0x7f,(byte)0xff,
+ (byte)0xc0,(byte)0x00,(byte)0x7f,(byte)0xff,
+ (byte)0xe0,(byte)0x00,(byte)0x7f,(byte)0xff,
+ (byte)0xf0,(byte)0x00,(byte)0x7f,(byte)0xff,
+ (byte)0xf8,(byte)0x00,(byte)0xff,(byte)0xff,
+ (byte)0xfc,(byte)0x01,(byte)0xff,(byte)0xff,
+
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff,
+ (byte)0xff,(byte)0xff,(byte)0xff,(byte)0xff
+ };
+ static final byte[] HandMaskData = {
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0xc0,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0xd8,(byte)0x00,(byte)0x00,
+ (byte)0x06,(byte)0xd8,(byte)0x00,(byte)0x00,
+
+ (byte)0x07,(byte)0xdb,(byte)0x00,(byte)0x00,
+ (byte)0x67,(byte)0xfb,(byte)0x00,(byte)0x00,
+ (byte)0x3f,(byte)0xff,(byte)0x00,(byte)0x00,
+ (byte)0x1f,(byte)0xff,(byte)0x00,(byte)0x00,
+ (byte)0x0f,(byte)0xff,(byte)0x00,(byte)0x00,
+ (byte)0x07,(byte)0xff,(byte)0x00,(byte)0x00,
+ (byte)0x03,(byte)0xfe,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,
+ (byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00
+ };
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Cursor() {
+}
+
+/**
+ * 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_INVALID_ARGUMENT - when an unknown style is specified</li>
+ * </ul>
+ *
+ * @see Cursor for the supported style values
+ */
+public Cursor(Device device, int style) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ int lpCursorName = 0;
+ switch (style) {
+ case SWT.CURSOR_HAND: lpCursorName = OS.IDC_HAND; break;
+ case SWT.CURSOR_ARROW: lpCursorName = OS.IDC_ARROW; break;
+ case SWT.CURSOR_WAIT: lpCursorName = OS.IDC_WAIT; break;
+ case SWT.CURSOR_CROSS: lpCursorName = OS.IDC_CROSS; break;
+ case SWT.CURSOR_APPSTARTING: lpCursorName = OS.IDC_APPSTARTING; break;
+ case SWT.CURSOR_HELP: lpCursorName = OS.IDC_HELP; break;
+ case SWT.CURSOR_SIZEALL: lpCursorName = OS.IDC_SIZEALL; break;
+ case SWT.CURSOR_SIZENESW: lpCursorName = OS.IDC_SIZENESW; break;
+ case SWT.CURSOR_SIZENS: lpCursorName = OS.IDC_SIZENS; break;
+ case SWT.CURSOR_SIZENWSE: lpCursorName = OS.IDC_SIZENWSE; break;
+ case SWT.CURSOR_SIZEWE: lpCursorName = OS.IDC_SIZEWE; break;
+ case SWT.CURSOR_SIZEN: lpCursorName = OS.IDC_SIZENS; break;
+ case SWT.CURSOR_SIZES: lpCursorName = OS.IDC_SIZENS; break;
+ case SWT.CURSOR_SIZEE: lpCursorName = OS.IDC_SIZEWE; break;
+ case SWT.CURSOR_SIZEW: lpCursorName = OS.IDC_SIZEWE; break;
+ case SWT.CURSOR_SIZENE: lpCursorName = OS.IDC_SIZENESW; break;
+ case SWT.CURSOR_SIZESE: lpCursorName = OS.IDC_SIZENWSE; break;
+ case SWT.CURSOR_SIZESW: lpCursorName = OS.IDC_SIZENESW; break;
+ case SWT.CURSOR_SIZENW: lpCursorName = OS.IDC_SIZENWSE; break;
+ case SWT.CURSOR_UPARROW: lpCursorName = OS.IDC_UPARROW; break;
+ case SWT.CURSOR_IBEAM: lpCursorName = OS.IDC_IBEAM; break;
+ case SWT.CURSOR_NO: lpCursorName = OS.IDC_NO; break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ handle = OS.LoadCursor(0, lpCursorName);
+ /*
+ * IDC_HAND is supported only on Windows 2000 and Windows 98.
+ * Create a hand cursor if running in other Windows platforms.
+ */
+ if (handle == 0 && style == SWT.CURSOR_HAND) {
+ int width = OS.GetSystemMetrics(OS.SM_CXCURSOR);
+ int height = OS.GetSystemMetrics(OS.SM_CYCURSOR);
+ if (width == 32 && height == 32) {
+ int hInst = OS.GetModuleHandle(null);
+ handle = OS.CreateCursor(hInst, 5, 0, 32, 32, HandSrcData, HandMaskData);
+
+ }
+ }
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Constructs a new cursor given a device, image and mask
+ * data describing the desired cursor appearance, and the x
+ * and y co-ordinates 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 - when a null argument is passed that is not allowed</li>
+ * <li>ERROR_INVALID_ARGUMENT - if the source and the mask are not the same
+ * size, or either is not of depth one, or if the hotspot is outside
+ * the bounds of the image</li>
+ * </ul>
+ * @exception SWTError <ul>
+ * <li>ERROR_NO_HANDLES - if an error occurred constructing the cursor</li>
+ * </ul>
+ */
+public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = 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 color depths */
+ if (mask.depth != 1) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ if (source.depth != 1) 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);
+ }
+ /* Create the cursor */
+ int hInst = OS.GetModuleHandle(null);
+ handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, source.data, mask.data);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the cursor. Applications must dispose of all cursors which
+ * they allocate.
+ */
+public void dispose () {
+ if (handle == 0) return;
+ /*
+ * The MSDN states that one should not destroy a shared
+ * cursor, that is, one obtained from LoadCursor.
+ * However, it does not appear to do any harm, so rather
+ * than keep track of how a cursor was created, we just
+ * destroy them all. If this causes problems in the future,
+ * put the flag back in.
+ */
+ OS.DestroyCursor(handle);
+ handle = 0;
+ if (device.tracking) device.dispose_Object(this);
+ device = 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 Cursor)) return false;
+ Cursor cursor = (Cursor) object;
+ return device == cursor.device && handle == cursor.handle;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 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;
+}
+
+/**
+ * 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 win32_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Cursor cursor = new Cursor();
+ cursor.handle = handle;
+ cursor.device = device;
+ return cursor;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
new file mode 100755
index 0000000000..d953280dea
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Device.java
@@ -0,0 +1,684 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+public abstract class Device implements Drawable {
+
+ /* Debugging */
+ public static boolean DEBUG;
+ boolean debug = DEBUG;
+ boolean tracking = DEBUG;
+ Error [] errors;
+ Object [] objects;
+
+ /* Palette */
+ public int hPalette = 0;
+ int [] colorRefCount;
+
+ /* Font Enumeration */
+ int nFonts = 256;
+ LOGFONT [] logFonts;
+
+ boolean disposed;
+
+/**
+ * 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) {
+ create (data);
+ init ();
+ if (data != null) {
+ debug = data.debug;
+ tracking = data.tracking;
+ }
+ if (tracking) {
+ errors = new Error [128];
+ objects = new Object [128];
+ }
+}
+
+/*
+ * Temporary code.
+ */
+static Device getDevice () {
+ Device device = null;
+ try {
+ Class clazz = Class.forName ("org.eclipse.swt.widgets.Display");
+ java.lang.reflect.Method method = clazz.getMethod("getCurrent", new Class[0]);
+ device = (Device) method.invoke(clazz, new Object[0]);
+ if (device == null) {
+ method = clazz.getMethod("getDefault", new Class[0]);
+ device = (Device)method.invoke(clazz, new Object[0]);
+ }
+ } catch (Throwable e) {};
+ return device;
+}
+
+/**
+ * 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) {
+}
+
+int computePixels(int height) {
+ int hDC = internal_new_GC (null);
+ /* Avoid using Math.round() */
+ int pixels = -(int)((height * OS.GetDeviceCaps(hDC, OS.LOGPIXELSY) / 72.0f) + 0.5f);
+ internal_dispose_GC (hDC, null);
+ return pixels;
+}
+
+int computePoints(LOGFONT logFont) {
+ int hDC = internal_new_GC (null);
+ int logPixelsY = OS.GetDeviceCaps(hDC, OS.LOGPIXELSY);
+ int pixels = 0;
+ if (logFont.lfHeight > 0) {
+ /*
+ * Feature in Windows. If the lfHeight of the LOGFONT structure
+ * is positive, the lfHeight measures the height of the entire
+ * cell, including internal leading, in logical units. Since the
+ * height of a font in points does not include the internal leading,
+ * we must subtract the internal leading, which requires a TEXTMETRIC,
+ * which in turn requires font creation.
+ */
+ int hFont = OS.CreateFontIndirect(logFont);
+ int oldFont = OS.SelectObject(hDC, hFont);
+ TEXTMETRIC lptm = new TEXTMETRIC();
+ OS.GetTextMetrics(hDC, lptm);
+ OS.SelectObject(hDC, oldFont);
+ OS.DeleteObject(hFont);
+ pixels = logFont.lfHeight - lptm.tmInternalLeading;
+ } else {
+ pixels = -logFont.lfHeight;
+ }
+ internal_dispose_GC (hDC, null);
+
+ /* Avoid using Math.round() */
+ return (int)((pixels * 72.0f / logPixelsY) + 0.5f);
+}
+
+/**
+ * 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 () {
+}
+
+/**
+ * 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 () {
+ if (isDisposed()) return;
+ checkDevice ();
+ release ();
+ destroy ();
+ disposed = true;
+ if (tracking) {
+ objects = null;
+ errors = null;
+ }
+}
+
+void dispose_Object (Object object) {
+ for (int i=0; i<objects.length; i++) {
+ if (objects [i] == object) {
+ objects [i] = null;
+ errors [i] = null;
+ return;
+ }
+ }
+}
+
+int EnumFontFamProc (int lpelfe, int lpntme, int FontType, int lParam) {
+ boolean isScalable = (FontType & OS.RASTER_FONTTYPE) == 0;
+ if ((lParam == 1) != isScalable) return 1;
+
+ /* Add the log font to the list of log fonts */
+ if (nFonts == logFonts.length) {
+ LOGFONT [] newLogFonts = new LOGFONT [logFonts.length + 128];
+ System.arraycopy (logFonts, 0, newLogFonts, 0, nFonts);
+ logFonts = newLogFonts;
+ }
+ LOGFONT logFont = logFonts [nFonts];
+ if (logFont == null) logFont = new LOGFONT ();
+ OS.MoveMemory (logFont, lpelfe, LOGFONT.sizeof);
+ logFonts [nFonts++] = logFont;
+ return 1;
+}
+
+/**
+ * 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 ();
+ int hDC = internal_new_GC (null);
+ int width = OS.GetDeviceCaps (hDC, OS.HORZRES);
+ int height = OS.GetDeviceCaps (hDC, OS.VERTRES);
+ internal_dispose_GC (hDC, null);
+ return new Rectangle (0, 0, width, height);
+}
+
+/**
+ * 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;
+ int count = 0, length = 0;
+ if (tracking) 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++;
+ }
+ }
+ 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
+ * @see #computeTrim
+ */
+public Rectangle getClientArea () {
+ 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 ();
+ int hDC = internal_new_GC (null);
+ int bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL);
+ int planes = OS.GetDeviceCaps (hDC, OS.PLANES);
+ internal_dispose_GC (hDC, null);
+ return bits * planes;
+}
+
+/**
+ * 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 ();
+ int hDC = internal_new_GC (null);
+ int dpiX = OS.GetDeviceCaps (hDC, OS.LOGPIXELSX);
+ int dpiY = OS.GetDeviceCaps (hDC, OS.LOGPIXELSY);
+ internal_dispose_GC (hDC, null);
+ return new Point (dpiX, dpiY);
+}
+
+/**
+ * Returns <code>FontData</code> objects which describe
+ * the fonts which 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 true if scalable fonts should be 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 ();
+
+ /* Create the callback */
+ Callback callback = new Callback (this, "EnumFontFamProc", 4);
+ int lpEnumFontFamProc = callback.getAddress ();
+
+ /* Initialize the instance variables */
+ logFonts = new LOGFONT [nFonts];
+ for (int i=0; i<logFonts.length; i++) {
+ logFonts [i] = new LOGFONT ();
+ }
+ nFonts = 0;
+
+ /* Enumerate */
+ int offset = 0;
+ int hDC = internal_new_GC (null);
+ if (faceName == null) {
+ /* The user did not specify a face name, so they want all versions of all available face names */
+ OS.EnumFontFamilies (hDC, null, lpEnumFontFamProc, scalable ? 1 : 0);
+
+ /**
+ * For bitmapped fonts, EnumFontFamilies only enumerates once for each font, regardless
+ * of how many styles are available. If the user wants bitmapped fonts, enumerate on
+ * each face name now.
+ */
+ offset = nFonts;
+ for (int i=0; i<offset; i++) {
+ LOGFONT lf = logFonts [i];
+ /**
+ * Bug in Windows 98. When EnumFontFamiliesEx is called with a specified face name, it
+ * should enumerate for each available style of that font. Instead, it only enumerates
+ * once. The fix is to call EnumFontFamilies, which works as expected.
+ */
+ byte [] lpFaceName = new byte [] {
+ lf.lfFaceName0, lf.lfFaceName1, lf.lfFaceName2, lf.lfFaceName3,
+ lf.lfFaceName4, lf.lfFaceName5, lf.lfFaceName6, lf.lfFaceName7,
+ lf.lfFaceName8, lf.lfFaceName9, lf.lfFaceName10, lf.lfFaceName11,
+ lf.lfFaceName12, lf.lfFaceName13, lf.lfFaceName14, lf.lfFaceName15,
+ lf.lfFaceName16, lf.lfFaceName17, lf.lfFaceName18, lf.lfFaceName19,
+ lf.lfFaceName20, lf.lfFaceName21, lf.lfFaceName22, lf.lfFaceName23,
+ lf.lfFaceName24, lf.lfFaceName25, lf.lfFaceName26, lf.lfFaceName27,
+ lf.lfFaceName28, lf.lfFaceName29, lf.lfFaceName30, lf.lfFaceName31,
+ };
+ OS.EnumFontFamilies (hDC, lpFaceName, lpEnumFontFamProc, scalable ? 1 : 0);
+ }
+ } else {
+ byte [] lpFaceName = Converter.wcsToMbcs (0, faceName, true);
+ /**
+ * Bug in Windows 98. When EnumFontFamiliesEx is called with a specified face name, it
+ * should enumerate for each available style of that font. Instead, it only enumerates
+ * once. The fix is to call EnumFontFamilies, which works as expected.
+ */
+ OS.EnumFontFamilies (hDC, lpFaceName, lpEnumFontFamProc, scalable ? 1 : 0);
+ }
+ internal_dispose_GC (hDC, null);
+
+ /* Create the fontData from the logfonts */
+ int count = nFonts - offset;
+ FontData [] result = new FontData [count];
+ for (int i=0; i<count; i++) {
+ LOGFONT logFont = logFonts [i+offset];
+ result [i] = FontData.win32_new (logFont, computePoints(logFont));
+ }
+
+ /* Clean up */
+ callback.dispose ();
+ logFonts = null;
+ 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 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_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ *
+ * @see SWT
+ */
+public Color getSystemColor (int id) {
+ checkDevice ();
+ int pixel = 0x02000000;
+ switch (id) {
+ case SWT.COLOR_WHITE: pixel = 0x02FFFFFF; break;
+ case SWT.COLOR_BLACK: pixel = 0x02000000; break;
+ case SWT.COLOR_RED: pixel = 0x020000FF; break;
+ case SWT.COLOR_DARK_RED: pixel = 0x02000080; break;
+ case SWT.COLOR_GREEN: pixel = 0x0200FF00; break;
+ case SWT.COLOR_DARK_GREEN: pixel = 0x02008000; break;
+ case SWT.COLOR_YELLOW: pixel = 0x0200FFFF; break;
+ case SWT.COLOR_DARK_YELLOW: pixel = 0x02008080; break;
+ case SWT.COLOR_BLUE: pixel = 0x02FF0000; break;
+ case SWT.COLOR_DARK_BLUE: pixel = 0x02800000; break;
+ case SWT.COLOR_MAGENTA: pixel = 0x02FF00FF; break;
+ case SWT.COLOR_DARK_MAGENTA: pixel = 0x02800080; break;
+ case SWT.COLOR_CYAN: pixel = 0x02FFFF00; break;
+ case SWT.COLOR_DARK_CYAN: pixel = 0x02808000; break;
+ case SWT.COLOR_GRAY: pixel = 0x02C0C0C0; break;
+ case SWT.COLOR_DARK_GRAY: pixel = 0x02808080; break;
+ }
+ return Color.win32_new (this, pixel);
+}
+
+/**
+ * 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_DEVICE_DISPOSED - if the receiver has been disposed</li>
+ * </ul>
+ */
+public Font getSystemFont () {
+ checkDevice ();
+ int hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ return Font.win32_new (this, hFont);
+}
+
+/**
+ * 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 false;
+}
+
+/**
+ * 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 we're not on a device which supports palettes,
+ * don't create one.
+ */
+ int hDC = internal_new_GC (null);
+ int rc = OS.GetDeviceCaps (hDC, OS.RASTERCAPS);
+ int bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL);
+ int planes = OS.GetDeviceCaps (hDC, OS.PLANES);
+ internal_dispose_GC (hDC, null);
+
+ bits *= planes;
+ if ((rc & OS.RC_PALETTE) == 0 || bits != 8) return;
+
+ /*
+ * The following colors are listed in the Windows
+ * Programmer's Reference as the colors guaranteed
+ * to be in the default system palette.
+ */
+ RGB [] rgbs = 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),
+ };
+
+ /* 4 bytes header + 4 bytes per entry * 256 entries */
+ byte [] logPalette = new byte [4 + 4 * 256];
+
+ /* 2 bytes = special header */
+ logPalette [0] = 0x00;
+ logPalette [1] = 0x03;
+
+ /* 2 bytes = number of colors, LSB first */
+ logPalette [2] = 0;
+ logPalette [3] = 1;
+
+ /* Create the palette and reference counter */
+ colorRefCount = new int [256];
+ for (int i = 0; i < rgbs.length; i++) {
+ colorRefCount [i] = 1;
+ int offset = i * 4 + 4;
+ logPalette [offset] = (byte) rgbs[i].red;
+ logPalette [offset + 1] = (byte) rgbs[i].green;
+ logPalette [offset + 2] = (byte) rgbs[i].blue;
+ }
+ hPalette = OS.CreatePalette (logPalette);
+}
+
+/**
+ * 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
+ *
+ * @private
+ */
+public abstract int 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 handle the platform specific GC handle
+ * @param data the platform specific GC data
+ *
+ * @private
+ */
+public abstract void internal_dispose_GC (int hDC, 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 () {
+ return disposed;
+}
+
+void new_Object (Object object) {
+ 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;
+}
+
+/**
+ * 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 (hPalette != 0) OS.DeleteObject (hPalette);
+ hPalette = 0;
+ colorRefCount = null;
+ logFonts = null;
+ nFonts = 0;
+}
+
+/**
+ * If the underlying window system supports printing warning messages
+ * to the console, setting warnings to <code>true</code> prevents these
+ * messages from being printed. If the argument is <code>false</code>
+ * message printing is not blocked.
+ *
+ * @param warnings <code>true</code>if warnings should be handled, 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 ();
+}
+
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/DeviceData.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/DeviceData.java
new file mode 100755
index 0000000000..f971a60537
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/DeviceData.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+public class DeviceData {
+ /*
+ * Debug fields - may not be honoured
+ * on some SWT platforms.
+ */
+ public boolean debug;
+ public boolean tracking;
+ public Error [] errors;
+ public Object [] objects;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java
new file mode 100755
index 0000000000..01e83c286a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Font.java
@@ -0,0 +1,203 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * 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
+ */
+
+public final class Font {
+
+ /**
+ * the handle to the OS font resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this font was created
+ */
+ Device device;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Font() {
+}
+
+/**
+ * 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 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) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, fd);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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 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) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new FontData (name, height, style));
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the font. Applications must dispose of all fonts which
+ * they allocate.
+ */
+public void dispose() {
+ if (handle == 0) return;
+ OS.DeleteObject(handle);
+ handle = 0;
+ if (device.tracking) device.dispose_Object(this);
+ device = 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 Font)) return false;
+ Font font = (Font) object;
+ return device == font.device && handle == font.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
+ */
+public FontData[] getFontData() {
+ LOGFONT logFont = new LOGFONT();
+ OS.GetObject(handle, LOGFONT.sizeof, logFont);
+ return new FontData[] {FontData.win32_new(logFont, device.computePoints(logFont))};
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 handle;
+}
+
+void init (Device device, FontData fd) {
+ if (fd == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ LOGFONT logFont = fd.data;
+ int lfHeight = logFont.lfHeight;
+ logFont.lfHeight = device.computePixels(fd.height);
+ handle = OS.CreateFontIndirect(logFont);
+ logFont.lfHeight = lfHeight;
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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 win32_new(Device device, int handle) {
+ if (device == null) device = Device.getDevice();
+ Font font = new Font();
+ font.handle = handle;
+ font.device = device;
+ return font;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java
new file mode 100755
index 0000000000..c860b80ce6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontData.java
@@ -0,0 +1,599 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class describe operating system fonts.
+ * Only the public API of this type is platform independent.
+ * <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
+ */
+
+public final class FontData {
+
+ /**
+ * A Win32 LOGFONT struct
+ * (Warning: This field is platform dependent)
+ */
+ public LOGFONT data;
+
+ /**
+ * The height of the font data in points
+ * (Warning: This field is platform dependent)
+ */
+ public int height;
+
+/**
+ * Constructs a new un-initialized font data.
+ */
+public FontData() {
+ data = new LOGFONT();
+ // We set the charset field so that
+ // wildcard searching will work properly
+ // out of the box
+ data.lfCharSet = OS.DEFAULT_CHARSET;
+ height = 12;
+}
+
+/**
+ * Constructs a new font data given the Windows <code>LOGFONT</code>
+ * that it should represent.
+ *
+ * @param data the <code>LOGFONT</code> for the result
+ */
+FontData(LOGFONT data, int height) {
+ this.data = data;
+ this.height = height;
+}
+
+/**
+ * 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);
+
+ 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);
+ int height = 0;
+ try {
+ height = Integer.parseInt(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);
+ data = new LOGFONT();
+ data.lfCharSet = OS.DEFAULT_CHARSET;
+ 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("WINDOWS") && version2.equals("1")) {
+ LOGFONT newData = new LOGFONT();
+ try {
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfHeight = Integer.parseInt(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfWidth = Integer.parseInt(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfEscapement = Integer.parseInt(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfOrientation = Integer.parseInt(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfWeight = Integer.parseInt(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfItalic = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfUnderline = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfStrikeOut = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfCharSet = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfOutPrecision = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfClipPrecision = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfQuality = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ end = string.indexOf('|', start);
+ if (end == -1) return;
+ newData.lfPitchAndFamily = Byte.parseByte(string.substring(start, end));
+ start = end + 1;
+ } catch (NumberFormatException e) {
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ return;
+ }
+ char[] lfFaceName = new char[32];
+ string.getChars(start, string.length(), lfFaceName, 0);
+ newData.lfFaceName0 = (byte)lfFaceName[0];
+ newData.lfFaceName1 = (byte)lfFaceName[1];
+ newData.lfFaceName2 = (byte)lfFaceName[2];
+ newData.lfFaceName3 = (byte)lfFaceName[3];
+ newData.lfFaceName4 = (byte)lfFaceName[4];
+ newData.lfFaceName5 = (byte)lfFaceName[5];
+ newData.lfFaceName6 = (byte)lfFaceName[6];
+ newData.lfFaceName7 = (byte)lfFaceName[7];
+ newData.lfFaceName8 = (byte)lfFaceName[8];
+ newData.lfFaceName9 = (byte)lfFaceName[9];
+ newData.lfFaceName10 = (byte)lfFaceName[10];
+ newData.lfFaceName11 = (byte)lfFaceName[11];
+ newData.lfFaceName12 = (byte)lfFaceName[12];
+ newData.lfFaceName13 = (byte)lfFaceName[13];
+ newData.lfFaceName14 = (byte)lfFaceName[14];
+ newData.lfFaceName15 = (byte)lfFaceName[15];
+ newData.lfFaceName16 = (byte)lfFaceName[16];
+ newData.lfFaceName17 = (byte)lfFaceName[17];
+ newData.lfFaceName18 = (byte)lfFaceName[18];
+ newData.lfFaceName19 = (byte)lfFaceName[19];
+ newData.lfFaceName20 = (byte)lfFaceName[20];
+ newData.lfFaceName21 = (byte)lfFaceName[21];
+ newData.lfFaceName22 = (byte)lfFaceName[22];
+ newData.lfFaceName23 = (byte)lfFaceName[23];
+ newData.lfFaceName24 = (byte)lfFaceName[24];
+ newData.lfFaceName25 = (byte)lfFaceName[25];
+ newData.lfFaceName26 = (byte)lfFaceName[26];
+ newData.lfFaceName27 = (byte)lfFaceName[27];
+ newData.lfFaceName28 = (byte)lfFaceName[28];
+ newData.lfFaceName29 = (byte)lfFaceName[29];
+ newData.lfFaceName30 = (byte)lfFaceName[30];
+ newData.lfFaceName31 = (byte)lfFaceName[31];
+ data = newData;
+ }
+}
+
+/**
+ * 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_INVALID_ARGUMENT - if the height is negative</li>
+ * </ul>
+ */
+public FontData(String name, int height, int style) {
+ data = new LOGFONT();
+ setName(name);
+ setHeight(height);
+ setStyle(style);
+ // We set the charset field so that
+ // wildcard searching will work properly
+ // out of the box
+ data.lfCharSet = OS.DEFAULT_CHARSET;
+}
+
+/**
+ * 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;
+ LOGFONT lf = ((FontData)object).data;
+ return data.lfCharSet == lf.lfCharSet &&
+ data.lfHeight == lf.lfHeight &&
+ data.lfWidth == lf.lfWidth &&
+ data.lfEscapement == lf.lfEscapement &&
+ data.lfOrientation == lf.lfOrientation &&
+ data.lfWeight == lf.lfWeight &&
+ data.lfItalic == lf.lfItalic &&
+ data.lfUnderline == lf.lfUnderline &&
+ data.lfStrikeOut == lf.lfStrikeOut &&
+ data.lfCharSet == lf.lfCharSet &&
+ data.lfOutPrecision == lf.lfOutPrecision &&
+ data.lfClipPrecision == lf.lfClipPrecision &&
+ data.lfQuality == lf.lfQuality &&
+ data.lfPitchAndFamily == lf.lfPitchAndFamily &&
+ data.lfFaceName0 == lf.lfFaceName0 &&
+ data.lfFaceName1 == lf.lfFaceName1 &&
+ data.lfFaceName2 == lf.lfFaceName2 &&
+ data.lfFaceName3 == lf.lfFaceName3 &&
+ data.lfFaceName4 == lf.lfFaceName4 &&
+ data.lfFaceName5 == lf.lfFaceName5 &&
+ data.lfFaceName6 == lf.lfFaceName6 &&
+ data.lfFaceName7 == lf.lfFaceName7 &&
+ data.lfFaceName8 == lf.lfFaceName8 &&
+ data.lfFaceName9 == lf.lfFaceName9 &&
+ data.lfFaceName10 == lf.lfFaceName10 &&
+ data.lfFaceName11 == lf.lfFaceName11 &&
+ data.lfFaceName12 == lf.lfFaceName12 &&
+ data.lfFaceName13 == lf.lfFaceName13 &&
+ data.lfFaceName14 == lf.lfFaceName14 &&
+ data.lfFaceName15 == lf.lfFaceName15 &&
+ data.lfFaceName16 == lf.lfFaceName16 &&
+ data.lfFaceName17 == lf.lfFaceName17 &&
+ data.lfFaceName18 == lf.lfFaceName18 &&
+ data.lfFaceName19 == lf.lfFaceName19 &&
+ data.lfFaceName20 == lf.lfFaceName20 &&
+ data.lfFaceName21 == lf.lfFaceName21 &&
+ data.lfFaceName22 == lf.lfFaceName22 &&
+ data.lfFaceName23 == lf.lfFaceName23 &&
+ data.lfFaceName24 == lf.lfFaceName24 &&
+ data.lfFaceName25 == lf.lfFaceName25 &&
+ data.lfFaceName26 == lf.lfFaceName26 &&
+ data.lfFaceName27 == lf.lfFaceName27 &&
+ data.lfFaceName28 == lf.lfFaceName28 &&
+ data.lfFaceName29 == lf.lfFaceName29 &&
+ data.lfFaceName30 == lf.lfFaceName30 &&
+ data.lfFaceName31 == lf.lfFaceName31;
+}
+
+/**
+ * Returns the height of the receiver in points.
+ *
+ * @return the height of this FontData
+ *
+ * @see #setHeight
+ */
+public int getHeight() {
+ return height;
+}
+
+/**
+ * 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() {
+ byte[] bytes = {
+ data.lfFaceName0, data.lfFaceName1, data.lfFaceName2, data.lfFaceName3,
+ data.lfFaceName4, data.lfFaceName5, data.lfFaceName6, data.lfFaceName7,
+ data.lfFaceName8, data.lfFaceName9, data.lfFaceName10, data.lfFaceName11,
+ data.lfFaceName12, data.lfFaceName13, data.lfFaceName14, data.lfFaceName15,
+ data.lfFaceName16, data.lfFaceName17, data.lfFaceName18, data.lfFaceName19,
+ data.lfFaceName20, data.lfFaceName21, data.lfFaceName22, data.lfFaceName23,
+ data.lfFaceName24, data.lfFaceName25, data.lfFaceName26, data.lfFaceName27,
+ data.lfFaceName28, data.lfFaceName29, data.lfFaceName30, data.lfFaceName31,
+ };
+ int index = 0;
+ while (index < bytes.length) {
+ if (bytes[index] == 0)
+ break;
+ index++;
+ }
+ if (index < bytes.length) {
+ byte[] newBytes = new byte[index];
+ System.arraycopy(bytes, 0, newBytes, 0, index);
+ bytes = newBytes;
+ }
+ char[] name = Converter.mbcsToWcs(0, bytes);
+ return new String(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() {
+ int style = SWT.NORMAL;
+ if (data.lfWeight == 700) style |= SWT.BOLD;
+ if (data.lfItalic != 0) style |= SWT.ITALIC;
+ return style;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 data.lfCharSet ^ data.lfHeight ^ data.lfWidth ^ data.lfEscapement ^
+ data.lfOrientation ^ data.lfWeight ^ data.lfItalic ^data.lfUnderline ^
+ data.lfStrikeOut ^ data.lfCharSet ^ data.lfOutPrecision ^
+ data.lfClipPrecision ^ data.lfQuality ^ data.lfPitchAndFamily ^
+ data.lfFaceName0 ^ data.lfFaceName1 ^ data.lfFaceName2 ^
+ data.lfFaceName3 ^ data.lfFaceName4 ^ data.lfFaceName5 ^
+ data.lfFaceName6 ^ data.lfFaceName7 ^ data.lfFaceName8 ^
+ data.lfFaceName9 ^ data.lfFaceName10 ^ data.lfFaceName11 ^
+ data.lfFaceName12 ^ data.lfFaceName13 ^ data.lfFaceName14 ^
+ data.lfFaceName15 ^ data.lfFaceName16 ^ data.lfFaceName17 ^
+ data.lfFaceName18 ^ data.lfFaceName19 ^ data.lfFaceName20 ^
+ data.lfFaceName21 ^ data.lfFaceName22 ^ data.lfFaceName23 ^
+ data.lfFaceName24 ^ data.lfFaceName25 ^ data.lfFaceName26 ^
+ data.lfFaceName27 ^ data.lfFaceName28 ^ data.lfFaceName29 ^
+ data.lfFaceName30 ^ data.lfFaceName31;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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
+ *
+ * @see #getName
+ */
+public void setName(String name) {
+ byte[] nameBytes = Converter.wcsToMbcs(0, name, true);
+ /* Pad nameBytes to 32 */
+ byte[] paddedNameBytes = new byte[32];
+ System.arraycopy(nameBytes, 0, paddedNameBytes, 0, nameBytes.length);
+ /* Copy into the log font */
+ data.lfFaceName0 = paddedNameBytes[0];
+ data.lfFaceName1 = paddedNameBytes[1];
+ data.lfFaceName2 = paddedNameBytes[2];
+ data.lfFaceName3 = paddedNameBytes[3];
+ data.lfFaceName4 = paddedNameBytes[4];
+ data.lfFaceName5 = paddedNameBytes[5];
+ data.lfFaceName6 = paddedNameBytes[6];
+ data.lfFaceName7 = paddedNameBytes[7];
+ data.lfFaceName8 = paddedNameBytes[8];
+ data.lfFaceName9 = paddedNameBytes[9];
+ data.lfFaceName10 = paddedNameBytes[10];
+ data.lfFaceName11 = paddedNameBytes[11];
+ data.lfFaceName12 = paddedNameBytes[12];
+ data.lfFaceName13 = paddedNameBytes[13];
+ data.lfFaceName14 = paddedNameBytes[14];
+ data.lfFaceName15 = paddedNameBytes[15];
+ data.lfFaceName16 = paddedNameBytes[16];
+ data.lfFaceName17 = paddedNameBytes[17];
+ data.lfFaceName18 = paddedNameBytes[18];
+ data.lfFaceName19 = paddedNameBytes[19];
+ data.lfFaceName20 = paddedNameBytes[20];
+ data.lfFaceName21 = paddedNameBytes[21];
+ data.lfFaceName22 = paddedNameBytes[22];
+ data.lfFaceName23 = paddedNameBytes[23];
+ data.lfFaceName24 = paddedNameBytes[24];
+ data.lfFaceName25 = paddedNameBytes[25];
+ data.lfFaceName26 = paddedNameBytes[26];
+ data.lfFaceName27 = paddedNameBytes[27];
+ data.lfFaceName28 = paddedNameBytes[28];
+ data.lfFaceName29 = paddedNameBytes[29];
+ data.lfFaceName30 = paddedNameBytes[30];
+ data.lfFaceName31 = paddedNameBytes[31];
+}
+
+/**
+ * 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.
+ *
+ * @param style the new style for this <code>FontData</code>
+ *
+ * @see #getStyle
+ */
+public void setStyle(int style) {
+ if ((style & SWT.BOLD) == SWT.BOLD) {
+ data.lfWeight = 700;
+ } else {
+ data.lfWeight = 0;
+ }
+ if ((style & SWT.ITALIC) == SWT.ITALIC) {
+ data.lfItalic = 1;
+ } else {
+ data.lfItalic = 0;
+ }
+}
+
+/**
+ * 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(getHeight());
+ buffer.append("|");
+ buffer.append(getStyle());
+ buffer.append("|");
+ buffer.append("WINDOWS|1|");
+ buffer.append(data.lfHeight);
+ buffer.append("|");
+ buffer.append(data.lfWidth);
+ buffer.append("|");
+ buffer.append(data.lfEscapement);
+ buffer.append("|");
+ buffer.append(data.lfOrientation);
+ buffer.append("|");
+ buffer.append(data.lfWeight);
+ buffer.append("|");
+ buffer.append(data.lfItalic);
+ buffer.append("|");
+ buffer.append(data.lfUnderline);
+ buffer.append("|");
+ buffer.append(data.lfStrikeOut);
+ buffer.append("|");
+ buffer.append(data.lfCharSet);
+ buffer.append("|");
+ buffer.append(data.lfOutPrecision);
+ buffer.append("|");
+ buffer.append(data.lfClipPrecision);
+ buffer.append("|");
+ buffer.append(data.lfQuality);
+ buffer.append("|");
+ buffer.append(data.lfPitchAndFamily);
+ buffer.append("|");
+ byte[] faceName = {
+ data.lfFaceName0, data.lfFaceName1, data.lfFaceName2, data.lfFaceName3,
+ data.lfFaceName4, data.lfFaceName5, data.lfFaceName6, data.lfFaceName7,
+ data.lfFaceName8, data.lfFaceName9, data.lfFaceName10, data.lfFaceName11,
+ data.lfFaceName12, data.lfFaceName13, data.lfFaceName14, data.lfFaceName15,
+ data.lfFaceName16, data.lfFaceName17, data.lfFaceName18, data.lfFaceName19,
+ data.lfFaceName20, data.lfFaceName21, data.lfFaceName22, data.lfFaceName23,
+ data.lfFaceName24, data.lfFaceName25, data.lfFaceName26, data.lfFaceName27,
+ data.lfFaceName28, data.lfFaceName29, data.lfFaceName30, data.lfFaceName31,
+ };
+ int i = 0;
+ while (i < faceName.length && faceName[i] != 0) {
+ buffer.append((char)faceName[i++]);
+ }
+ return buffer.toString();
+}
+
+/**
+ * Invokes platform specific functionality to allocate a new font data.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>FontData</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 <code>LOGFONT</code> for the font data
+ *
+ * @private
+ */
+public static FontData win32_new(LOGFONT data, int height) {
+ return new FontData(data, height);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java
new file mode 100755
index 0000000000..1769329a56
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/FontMetrics.java
@@ -0,0 +1,171 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * 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
+ */
+
+public final class FontMetrics {
+
+ /**
+ * a Win32 TEXTMETRIC struct
+ * (Warning: This field is platform dependent)
+ */
+ public TEXTMETRIC handle;
+
+/**
+ * Prevents instances from being created outside the package.
+ */
+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;
+ TEXTMETRIC metric = ((FontMetrics)object).handle;
+ return handle.tmHeight == metric.tmHeight &&
+ handle.tmAscent == metric.tmAscent &&
+ handle.tmDescent == metric.tmDescent &&
+ handle.tmInternalLeading == metric.tmInternalLeading &&
+ handle.tmExternalLeading == metric.tmExternalLeading &&
+ handle.tmAveCharWidth == metric.tmAveCharWidth &&
+ handle.tmMaxCharWidth == metric.tmMaxCharWidth &&
+ handle.tmWeight == metric.tmWeight &&
+ handle.tmOverhang == metric.tmOverhang &&
+ handle.tmDigitizedAspectX == metric.tmDigitizedAspectX &&
+ handle.tmDigitizedAspectY == metric.tmDigitizedAspectY &&
+ handle.tmFirstChar == metric.tmFirstChar &&
+ handle.tmLastChar == metric.tmLastChar &&
+ handle.tmDefaultChar == metric.tmDefaultChar &&
+ handle.tmBreakChar == metric.tmBreakChar &&
+ handle.tmItalic == metric.tmItalic &&
+ handle.tmUnderlined == metric.tmUnderlined &&
+ handle.tmStruckOut == metric.tmStruckOut &&
+ handle.tmPitchAndFamily == metric.tmPitchAndFamily &&
+ handle.tmCharSet == metric.tmCharSet;
+}
+
+/**
+ * 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 handle.tmAscent - handle.tmInternalLeading;
+}
+
+/**
+ * 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 handle.tmAveCharWidth;
+}
+
+/**
+ * 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 handle.tmDescent;
+}
+
+/**
+ * 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 handle.tmHeight;
+}
+
+/**
+ * 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 handle.tmInternalLeading;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 handle.tmHeight ^ handle.tmAscent ^ handle.tmDescent ^
+ handle.tmInternalLeading ^ handle.tmExternalLeading ^
+ handle.tmAveCharWidth ^ handle.tmMaxCharWidth ^ handle.tmWeight ^
+ handle.tmOverhang ^ handle.tmDigitizedAspectX ^
+ handle.tmDigitizedAspectY ^ handle.tmFirstChar ^
+ handle.tmLastChar ^ handle.tmDefaultChar ^ handle.tmBreakChar ^
+ handle.tmItalic ^ handle.tmUnderlined ^ handle.tmStruckOut ^
+ handle.tmPitchAndFamily ^ handle.tmCharSet;
+}
+
+/**
+ * Invokes platform specific functionality to allocate a new font metrics.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>FontMetrics</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 tm the <code>TEXTMETRIC</code> containing information about a font
+ *
+ * @private
+ */
+public static FontMetrics win32_new(TEXTMETRIC handle) {
+ FontMetrics fontMetrics = new FontMetrics();
+ fontMetrics.handle = handle;
+ return fontMetrics;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
new file mode 100755
index 0000000000..c207ecd998
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java
@@ -0,0 +1,1656 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+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>.
+ * <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>
+ *
+ * @see PaintEvent
+ */
+
+public final class GC {
+
+ /**
+ * the handle to the OS device context
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ Drawable drawable;
+ GCData data;
+
+ /**
+ * A pre-converted string containing a space character.
+ */
+ static final byte [] SPACE = new byte [] {(byte)' '};
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+GC() {
+}
+
+/**
+ * Constructs a new instance of this class which has been
+ * configured to draw on the specified drawable. Sets the
+ * foreground and background color 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_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>
+ */
+public GC(Drawable drawable) {
+ if (drawable == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ GCData data = new GCData ();
+ int hDC = drawable.internal_new_GC (data);
+ Device device = data.device;
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ data.device = device;
+ init (drawable, data, hDC);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Copies a rectangular area of the receiver at the specified
+ * position into the image, which must be of type <code>SWT.BITMAP</code>.
+ *
+ * @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</li>
+ * </ul>
+ */
+public void copyArea(Image image, int x, int y) {
+ if (image == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (image.type != SWT.BITMAP) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+
+ /* Get the HDC for the device */
+ Device device = data.device;
+ int hDC = device.internal_new_GC(null);
+
+ /* Copy the bitmap area */
+ Rectangle rect = image.getBounds();
+ int memHdc = OS.CreateCompatibleDC(hDC);
+ int hOldBitmap = OS.SelectObject(memHdc, image.handle);
+ OS.BitBlt(memHdc, 0, 0, rect.width, rect.height, handle, x, y, OS.SRCCOPY);
+ OS.SelectObject(memHdc, hOldBitmap);
+ OS.DeleteDC(memHdc);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+}
+
+/**
+ * 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
+ */
+public void copyArea(int srcX, int srcY, int width, int height, int destX, int destY) {
+ int hwnd = OS.WindowFromDC(handle);
+ if (hwnd == 0) {
+ OS.BitBlt(handle, destX, destY, width, height, handle, srcX, srcY, OS.SRCCOPY);
+ } else {
+ RECT lprcClip = null;
+ int hrgn = OS.CreateRectRgn(0, 0, 0, 0);
+ if (OS.GetClipRgn(handle, hrgn) == 1) {
+ lprcClip = new RECT();
+ OS.GetRgnBox(hrgn, lprcClip);
+ }
+ OS.DeleteObject(hrgn);
+ RECT lprcScroll = new RECT();
+ OS.SetRect(lprcScroll, srcX, srcY, srcX + width, srcY + height);
+ OS.ScrollWindowEx(hwnd, destX - srcX, destY - srcY, lprcScroll, lprcClip, 0, null, OS.SW_INVALIDATE | OS.SW_ERASE);
+ }
+}
+
+int createDIB(int width, int height, int depth) {
+ byte[] bmi = new byte[40];
+
+ /* DWORD biSize = 40 */
+ bmi[0] = 40; bmi[1] = 0; bmi[2] = 0; bmi[3] = 0;
+ /* LONG biWidth = width */
+ bmi[4] = (byte)(width & 0xFF);
+ bmi[5] = (byte)((width >> 8) & 0xFF);
+ bmi[6] = (byte)((width >> 16) & 0xFF);
+ bmi[7] = (byte)((width >> 24) & 0xFF);
+ /* LONG biHeight = height */
+ bmi[8] = (byte)(-height & 0xFF);
+ bmi[9] = (byte)((-height >> 8) & 0xFF);
+ bmi[10] = (byte)((-height >> 16) & 0xFF);
+ bmi[11] = (byte)((-height >> 24) & 0xFF);
+ /* WORD biPlanes = 1 */
+ bmi[12] = 1;
+ bmi[13] = 0;
+ /* WORD biBitCount = depth */
+ bmi[14] = (byte)(depth & 0xFF);
+ bmi[15] = (byte)((depth >> 8) & 0xFF);
+ /* DWORD biCompression = BI_RGB = 0 */
+ bmi[16] = bmi[17] = bmi[18] = bmi[19] = 0;
+ /* DWORD biSizeImage = 0 (default) */
+ bmi[20] = bmi[21] = bmi[22] = bmi[23] = 0;
+ /* LONG biXPelsPerMeter = 0 */
+ bmi[24] = bmi[25] = bmi[26] = bmi[27] = 0;
+ /* LONG biYPelsPerMeter = 0 */
+ bmi[28] = bmi[29] = bmi[30] = bmi[31] = 0;
+ /* DWORD biClrUsed */
+ bmi[32] = bmi[33] = bmi[34] = bmi[35] = 0;
+ /* DWORD biClrImportant = 0 */
+ bmi[36] = bmi[37] = bmi[38] = bmi[39] = 0;
+ /* Set the rgb colors into the bitmap info */
+ int[] pBits = new int[1];
+ int hDib = OS.CreateDIBSection(0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ if (hDib == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ return hDib;
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the graphics context. Applications must dispose of all GCs
+ * which they allocate.
+ */
+public void dispose() {
+ if (handle == 0) return;
+
+ /*
+ * The only way for pens and brushes to get
+ * selected into the HDC is for the receiver to
+ * create them. When we are destroying the
+ * hDC we also destroy any pens and brushes that
+ * we have allocated. This code assumes that it
+ * is OK to delete stock objects. This will
+ * happen when a GC is disposed and the user has
+ * not caused new pens or brushes to be allocated.
+ */
+ int nullPen = OS.GetStockObject(OS.NULL_PEN);
+ int oldPen = OS.SelectObject(handle, nullPen);
+ OS.DeleteObject(oldPen);
+ int nullBrush = OS.GetStockObject(OS.NULL_BRUSH);
+ int oldBrush = OS.SelectObject(handle, nullBrush);
+ OS.DeleteObject(oldBrush);
+
+ /*
+ * Put back the original bitmap into the device context.
+ * This will ensure that we have not left a bitmap
+ * selected in it when we delete the HDC.
+ */
+ int hNullBitmap = data.hNullBitmap;
+ if (hNullBitmap != 0) {
+ OS.SelectObject(handle, hNullBitmap);
+ data.hNullBitmap = 0;
+ }
+ Image image = data.image;
+ if (image != null) image.memGC = null;
+
+ /*
+ * Dispose the HDC.
+ */
+ Device device = data.device;
+ drawable.internal_dispose_GC(handle, data);
+ drawable = null;
+ handle = 0;
+ data.image = null;
+ data.ps = null;
+ if (device.tracking) device.dispose_Object(this);
+ data.device = 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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width, height or endAngle is zero.</li>
+ * </ul>
+ */
+public void drawArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ int x1, y1, x2, y2,tmp;
+ boolean isNegative;
+ double pi = 3.1415926535;
+ double toRadians = 2 * pi / 360;
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ if (endAngle >= 360 || endAngle <= -360) {
+ x1 = x2 = x + width;
+ y1 = y2 = y + height / 2;
+ } else {
+ isNegative = endAngle < 0;
+
+ endAngle = endAngle + startAngle;
+ if (isNegative) {
+ // swap angles
+ tmp = startAngle;
+ startAngle = endAngle;
+ endAngle = tmp;
+ }
+ x1 = (int) (Math.cos(startAngle * toRadians) * width) + x + width/2;;
+ y1 = (int) (-1 * Math.sin(startAngle * toRadians) * height) + y + height/2;
+
+ x2 = (int) (Math.cos(endAngle * toRadians) * width) + x + width/2;
+ y2 = (int) (-1 * Math.sin(endAngle * toRadians) * height) + y + height/2;
+
+ }
+ int nullBrush = OS.GetStockObject(OS.NULL_BRUSH);
+ int oldBrush = OS.SelectObject(handle, nullBrush);
+ OS.Arc(handle, x,y,x+width+1,y+height+1,x1,y1,x2,y2 );
+ OS.SelectObject(handle,oldBrush);
+}
+
+/**
+ * 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 forground 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
+ *
+ * @see drawRectangle
+ */
+public void drawFocus (int x, int y, int width, int height) {
+ RECT rect = new RECT();
+ OS.SetRect(rect, x, y, x + width, y + height);
+ OS.DrawFocusRect(handle, rect);
+}
+
+/**
+ * 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 given coordinates are outside the bounds of the image</li>
+ * @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 (image == null) SWT.error (SWT.ERROR_NULL_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 of the given coordinates
+ * are negative or lie outside the bounds of their respective images.
+ *
+ * @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_IMAGE - if the given coordinates are outside the bounds of their respective images</li>
+ * </ul>
+ * @exception SWTError <uo>
+ * <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 (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);
+ 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) {
+ switch (srcImage.type) {
+ case SWT.BITMAP:
+ drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple);
+ break;
+ case SWT.ICON:
+ drawIcon(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ }
+}
+
+void drawIcon(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ /* Simple case: no stretching, entire icon */
+ if (simple) {
+ OS.DrawIconEx(handle, destX, destY, srcImage.handle, 0, 0, 0, 0, OS.DI_NORMAL);
+ return;
+ }
+
+ /* Get the icon info */
+ ICONINFO srcIconInfo = new ICONINFO();
+ OS.GetIconInfo(srcImage.handle, srcIconInfo);
+
+ /* Get the icon width and height */
+ int hBitmap = srcIconInfo.hbmColor;
+ if (hBitmap == 0) hBitmap = srcIconInfo.hbmMask;
+ BITMAP bm = new BITMAP();
+ OS.GetObject(hBitmap, BITMAP.sizeof, bm);
+ int iconWidth = bm.bmWidth, iconHeight = bm.bmHeight;
+ if (hBitmap == srcIconInfo.hbmMask) iconHeight /= 2;
+
+ if (simple) {
+ srcWidth = destWidth = iconWidth;
+ srcHeight = destHeight = iconHeight;
+ }
+
+ /* Draw the icon */
+ boolean failed = srcX + srcWidth > iconWidth || srcY + srcHeight > iconHeight;
+ if (!failed) {
+ simple = srcX == 0 && srcY == 0 &&
+ srcWidth == destWidth && srcHeight == destHeight &&
+ srcWidth == iconWidth && srcHeight == iconHeight;
+ if (simple) {
+ /* Simple case: no stretching, entire icon */
+ OS.DrawIconEx(handle, destX, destY, srcImage.handle, 0, 0, 0, 0, OS.DI_NORMAL);
+ } else {
+ /* Get the HDC for the device */
+ Device device = data.device;
+ int hDC = device.internal_new_GC(null);
+
+ /* Create the icon info and HDC's */
+ ICONINFO newIconInfo = new ICONINFO();
+ newIconInfo.fIcon = true;
+ int srcHdc = OS.CreateCompatibleDC(hDC);
+ int dstHdc = OS.CreateCompatibleDC(hDC);
+
+ /* Blt the color bitmap */
+ int srcColorY = srcY;
+ int srcColor = srcIconInfo.hbmColor;
+ if (srcColor == 0) {
+ srcColor = srcIconInfo.hbmMask;
+ srcColorY += iconHeight;
+ }
+ int oldSrcBitmap = OS.SelectObject(srcHdc, srcColor);
+ newIconInfo.hbmColor = OS.CreateCompatibleBitmap(srcHdc, destWidth, destHeight);
+ if (newIconInfo.hbmColor == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int oldDestBitmap = OS.SelectObject(dstHdc, newIconInfo.hbmColor);
+ OS.SetStretchBltMode(dstHdc, OS.COLORONCOLOR);
+ OS.StretchBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcColorY, srcWidth, srcHeight, OS.SRCCOPY);
+
+ /* Blt the mask bitmap */
+ OS.SelectObject(srcHdc, srcIconInfo.hbmMask);
+ newIconInfo.hbmMask = OS.CreateBitmap(destWidth, destHeight, 1, 1, null);
+ if (newIconInfo.hbmMask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.SelectObject(dstHdc, newIconInfo.hbmMask);
+ OS.StretchBlt(dstHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCCOPY);
+
+ /* Select old bitmaps before creating the icon */
+ OS.SelectObject(srcHdc, oldSrcBitmap);
+ OS.SelectObject(dstHdc, oldDestBitmap);
+
+ /* Create the new icon */
+ int hIcon = OS.CreateIconIndirect(newIconInfo);
+ if (hIcon == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ /* Draw the new icon */
+ OS.DrawIconEx(handle, destX, destY, hIcon, destWidth, destHeight, 0, 0, OS.DI_NORMAL);
+
+ /* Destroy the new icon and hdc's*/
+ OS.DestroyIcon(hIcon);
+ OS.DeleteObject(newIconInfo.hbmMask);
+ OS.DeleteObject(newIconInfo.hbmColor);
+ OS.DeleteDC(dstHdc);
+ OS.DeleteDC(srcHdc);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+ }
+ }
+
+ /* Free icon info */
+ OS.DeleteObject(srcIconInfo.hbmMask);
+ if (srcIconInfo.hbmColor != 0) {
+ OS.DeleteObject(srcIconInfo.hbmColor);
+ }
+
+ if (failed) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+}
+
+void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple) {
+ BITMAP bm = new BITMAP();
+ OS.GetObject(srcImage.handle, BITMAP.sizeof, bm);
+ int imgWidth = bm.bmWidth;
+ int imgHeight = bm.bmHeight;
+ if (simple) {
+ srcWidth = destWidth = imgWidth;
+ srcHeight = destHeight = imgHeight;
+ } else {
+ if (srcX + srcWidth > imgWidth || srcY + srcHeight > imgHeight) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ simple = srcX == 0 && srcY == 0 &&
+ srcWidth == destWidth && destWidth == imgWidth &&
+ srcHeight == destHeight && destHeight == imgHeight;
+ }
+ boolean mustRestore = false;
+ GC memGC = srcImage.memGC;
+ if (memGC != null && !memGC.isDisposed()) {
+ mustRestore = true;
+ GCData data = memGC.data;
+ if (data.hNullBitmap != 0) {
+ OS.SelectObject(memGC.handle, data.hNullBitmap);
+ data.hNullBitmap = 0;
+ }
+ }
+ if (srcImage.alpha != -1 || srcImage.alphaData != null) {
+ drawBitmapAlpha(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight);
+ } else if (srcImage.transparentPixel != -1) {
+ drawBitmapTransparent(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight);
+ } else {
+ drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight);
+ }
+ if (mustRestore) {
+ int hOldBitmap = OS.SelectObject(memGC.handle, srcImage.handle);
+ memGC.data.hNullBitmap = hOldBitmap;
+ }
+}
+
+void drawBitmapAlpha(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, BITMAP bm, int imgWidth, int imgHeight) {
+ /* Simple cases */
+ if (srcImage.alpha == 0) return;
+ if (srcImage.alpha == 255) {
+ drawBitmap(srcImage, srcX, srcY, srcWidth, srcHeight, destX, destY, destWidth, destHeight, simple, bm, imgWidth, imgHeight);
+ return;
+ }
+
+ /* Check clipping */
+ Rectangle rect = getClipping();
+ rect = rect.intersection(new Rectangle(destX, destY, destWidth, destHeight));
+ if (rect.isEmpty()) return;
+
+ /*
+ * Optimization. Recalculate src and dest rectangles so that
+ * only the clipping area is drawn.
+ */
+ rect.width = Math.max(rect.width, (int)Math.ceil(destWidth / (float)srcWidth));
+ rect.height = Math.max(rect.height, (int)Math.ceil(destHeight / (float)srcHeight));
+ int sx1 = srcX + (((rect.x - destX) * srcWidth) / destWidth);
+ int sx2 = srcX + ((((rect.x + rect.width) - destX) * srcWidth) / destWidth);
+ int sy1 = srcY + (((rect.y - destY) * srcHeight) / destHeight);
+ int sy2 = srcY + ((((rect.y + rect.height) - destY) * srcHeight) / destHeight);
+ destX = rect.x;
+ destY = rect.y;
+ destWidth = rect.width;
+ destHeight = rect.height;
+ srcX = sx1;
+ srcY = sy1;
+ srcWidth = sx2 - sx1;
+ srcHeight = sy2 - sy1;
+
+ /* Create resources */
+ int srcHdc = OS.CreateCompatibleDC(handle);
+ int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
+ int memDib = createDIB(destWidth, destHeight, 32);
+ int memHdc = OS.CreateCompatibleDC(handle);
+ int oldMemBitmap = OS.SelectObject(memHdc, memDib);
+
+ BITMAP dibBM = new BITMAP();
+ OS.GetObject(memDib, BITMAP.sizeof, dibBM);
+ int sizeInBytes = dibBM.bmWidthBytes * dibBM.bmHeight;
+
+ /* Get the background pixels */
+ OS.BitBlt(memHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY);
+ byte[] destData = new byte[sizeInBytes];
+ OS.MoveMemory(destData, dibBM.bmBits, sizeInBytes);
+
+ /* Get the foreground pixels */
+ OS.SetStretchBltMode(memHdc, OS.COLORONCOLOR);
+ OS.StretchBlt(memHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCCOPY);
+ byte[] srcData = new byte[sizeInBytes];
+ OS.MoveMemory(srcData, dibBM.bmBits, sizeInBytes);
+
+ /* Compose the pixels */
+ int alpha = srcImage.alpha;
+ byte[] alphaData = null;
+ if (alpha == -1) {
+ alphaData = new byte[destWidth * destHeight];
+ ImageData.stretch8(srcImage.alphaData, imgWidth, srcX, srcY, srcWidth, srcHeight, alphaData, destWidth, 0, 0, destWidth, destHeight, null, false, false);
+ }
+ for (int i = 0; i < sizeInBytes; i += 4) {
+ if (alphaData != null) alpha = alphaData[i / 4] & 0xff;
+ destData[i] += ((srcData[i] & 0xFF) - (destData[i] & 0xFF)) * alpha / 255;
+ destData[i+1] += ((srcData[i+1] & 0xFF) - (destData[i+1] & 0xFF)) * alpha / 255;
+ destData[i+2] += ((srcData[i+2] & 0xFF) - (destData[i+2] & 0xFF)) * alpha / 255;
+ }
+
+ /* Draw the composed pixels */
+ OS.MoveMemory(dibBM.bmBits, destData, sizeInBytes);
+ OS.BitBlt(handle, destX, destY, destWidth, destHeight, memHdc, 0, 0, OS.SRCCOPY);
+
+ /* Free resources */
+ OS.SelectObject(memHdc, oldMemBitmap);
+ OS.DeleteDC(memHdc);
+ OS.DeleteObject(memDib);
+ OS.SelectObject(srcHdc, oldSrcBitmap);
+ OS.DeleteDC(srcHdc);
+}
+
+void drawBitmapTransparent(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, BITMAP bm, int imgWidth, int imgHeight) {
+
+ /* Get the HDC for the device */
+ Device device = data.device;
+ int hDC = device.internal_new_GC(null);
+
+ /* Find the RGB values for the transparent pixel. */
+ int transBlue = 0, transGreen = 0, transRed = 0;
+ boolean isDib = bm.bmBits != 0;
+ int hBitmap = srcImage.handle;
+ int srcHdc = OS.CreateCompatibleDC(handle);
+ int oldSrcBitmap = OS.SelectObject(srcHdc, hBitmap);
+ byte[] originalColors = null;
+ if (bm.bmBitsPixel <= 8) {
+ if (isDib) {
+ /* Palette-based DIBSECTION */
+ int maxColors = 1 << bm.bmBitsPixel;
+ byte[] oldColors = new byte[maxColors * 4];
+ int numColors = OS.GetDIBColorTable(srcHdc, 0, maxColors, oldColors);
+ int offset = srcImage.transparentPixel * 4;
+ byte[] newColors = new byte[oldColors.length];
+ transRed = transGreen = transBlue = 0xff;
+ newColors[offset] = (byte)transBlue;
+ newColors[offset+1] = (byte)transGreen;
+ newColors[offset+2] = (byte)transRed;
+ OS.SetDIBColorTable(srcHdc, 0, maxColors, newColors);
+ originalColors = oldColors;
+ } else {
+ /* Palette-based bitmap */
+ int numColors = 1 << bm.bmBitsPixel;
+ byte[] bmi = new byte[40 + numColors * 4];
+ /* Set the few fields necessary to get the RGB data out */
+ bmi[0] = 40;
+ bmi[12] = (byte)(bm.bmPlanes & 0xFF);
+ bmi[13] = (byte)((bm.bmPlanes >> 8) & 0xFF);
+ bmi[14] = (byte)(bm.bmBitsPixel & 0xFF);
+ bmi[15] = (byte)((bm.bmBitsPixel >> 8) & 0xFF);
+ OS.GetDIBits(srcHdc, srcImage.handle, 0, 0, 0, bmi, OS.DIB_RGB_COLORS);
+ int offset = 40 + 4 * srcImage.transparentPixel;
+ transRed = bmi[offset + 2] & 0xFF;
+ transGreen = bmi[offset + 1] & 0xFF;
+ transBlue = bmi[offset] & 0xFF;
+ }
+ } else {
+ /* Direct color image */
+ int pixel = srcImage.transparentPixel;
+ switch (bm.bmBitsPixel) {
+ case 16:
+ transBlue = (pixel & 0x1F) << 3;
+ transGreen = (pixel & 0x3E0) >> 2;
+ transRed = (pixel & 0x7C00) >> 7;
+ break;
+ case 24:
+ transBlue = (pixel & 0xFF0000) >> 16;
+ transGreen = (pixel & 0xFF00) >> 8;
+ transRed = pixel & 0xFF;
+ break;
+ case 32:
+ transBlue = (pixel & 0xFF000000) >>> 24;
+ transGreen = (pixel & 0xFF0000) >> 16;
+ transRed = (pixel & 0xFF00) >> 8;
+ break;
+ }
+ }
+
+ /* Create the mask for the source image */
+ int maskHdc = OS.CreateCompatibleDC(hDC);
+ int maskBitmap = OS.CreateBitmap(srcWidth, srcHeight, 1, 1, null);
+ int oldMaskBitmap = OS.SelectObject(maskHdc, maskBitmap);
+ OS.SetBkColor(srcHdc, (transBlue << 16) | (transGreen << 8) | transRed);
+ OS.BitBlt(maskHdc, 0, 0, srcWidth, srcHeight, srcHdc, 0, 0, OS.SRCCOPY);
+ if (originalColors != null) OS.SetDIBColorTable(srcHdc, 0, 1 << bm.bmBitsPixel, originalColors);
+
+ /* Draw the source bitmap transparently using invert/and mask/invert */
+ int tempHdc = OS.CreateCompatibleDC(hDC);
+ int tempBitmap = OS.CreateCompatibleBitmap(hDC, destWidth, destHeight);
+ int oldTempBitmap = OS.SelectObject(tempHdc, tempBitmap);
+ OS.BitBlt(tempHdc, 0, 0, destWidth, destHeight, handle, destX, destY, OS.SRCCOPY);
+ OS.SetStretchBltMode(tempHdc, OS.COLORONCOLOR);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, maskHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCAND);
+ OS.StretchBlt(tempHdc, 0, 0, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, OS.SRCINVERT);
+ OS.BitBlt(handle, destX, destY, destWidth, destHeight, tempHdc, 0, 0, OS.SRCCOPY);
+
+ /* Release resources */
+ OS.SelectObject(tempHdc, oldTempBitmap);
+ OS.DeleteDC(tempHdc);
+ OS.DeleteObject(tempBitmap);
+ OS.SelectObject(maskHdc, oldMaskBitmap);
+ OS.DeleteDC(maskHdc);
+ OS.DeleteObject(maskBitmap);
+ OS.SelectObject(srcHdc, oldSrcBitmap);
+ if (hBitmap != srcImage.handle) OS.DeleteObject(hBitmap);
+ OS.DeleteDC(srcHdc);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+}
+
+void drawBitmap(Image srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int destX, int destY, int destWidth, int destHeight, boolean simple, BITMAP bm, int imgWidth, int imgHeight) {
+ int srcHdc = OS.CreateCompatibleDC(handle);
+ int oldSrcBitmap = OS.SelectObject(srcHdc, srcImage.handle);
+ int bltRop = OS.SRCCOPY;
+ if (OS.GetROP2(handle) == OS.R2_XORPEN) bltRop = OS.SRCINVERT;
+ int oldStretchMode = OS.SetStretchBltMode(handle, OS.COLORONCOLOR);
+ OS.StretchBlt(handle, destX, destY, destWidth, destHeight, srcHdc, srcX, srcY, srcWidth, srcHeight, bltRop);
+ OS.SetStretchBltMode(handle, oldStretchMode);
+ OS.SelectObject(srcHdc, oldSrcBitmap);
+ OS.DeleteDC(srcHdc);
+}
+
+/**
+ * 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
+ */
+public void drawLine (int x1, int y1, int x2, int y2) {
+ OS.MoveToEx (handle, x1, y1, 0);
+ OS.LineTo (handle, x2, y2);
+ OS.SetPixel (handle, x2, y2, OS.GetTextColor (handle));
+}
+
+/**
+ * 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
+ */
+public void drawOval (int x, int y, int width, int height) {
+ // Check performance impact of always setting null brush. If the user has not
+ // set the background color, we may not have to do this work?
+ int nullBrush = OS.GetStockObject(OS.NULL_BRUSH);
+ int oldBrush = OS.SelectObject(handle, nullBrush);
+ OS.Ellipse(handle, x,y,x+width,y+height);
+ OS.SelectObject(handle,oldBrush);
+}
+
+/**
+ * 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>
+ */
+public void drawPolygon(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int nullBrush = OS.GetStockObject(OS.NULL_BRUSH);
+ int oldBrush = OS.SelectObject(handle, nullBrush);
+ OS.Polygon(handle, pointArray, pointArray.length / 2);
+ OS.SelectObject(handle, oldBrush);
+}
+
+/**
+ * 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>
+ */
+public void drawPolyline(int[] pointArray) {
+ if (pointArray == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ OS.Polyline(handle, pointArray, pointArray.length / 2);
+}
+
+/**
+ * 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
+ */
+public void drawRectangle (int x, int y, int width, int height) {
+ int hOld = OS.SelectObject (handle, OS.GetStockObject (OS.NULL_BRUSH));
+ OS.Rectangle (handle, x, y, x + width + 1, y + height + 1);
+ OS.SelectObject (handle, hOld);
+}
+
+/**
+ * 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>
+ */
+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.
+ *
+ * @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 horizontal diameter of the arc at the four corners
+ * @param arcHeight the vertical diameter of the arc at the four corners
+ */
+public void drawRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ int nullBrush = OS.GetStockObject(OS.NULL_BRUSH);
+ int oldBrush = OS.SelectObject(handle, nullBrush);
+ OS.RoundRect(handle, x,y,x+width,y+height, arcWidth, arcHeight);
+ OS.SelectObject(handle,oldBrush);
+}
+
+/**
+ * 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>
+ */
+public void drawString (String string, int x, int y) {
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ OS.TextOut (handle, x, y, buffer, buffer.length);
+}
+
+/**
+ * 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>
+ */
+public void drawString (String string, int x, int y, boolean isTransparent) {
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ if (isTransparent) {
+ int oldBkMode = OS.SetBkMode(handle, OS.TRANSPARENT);
+ OS.TextOut (handle, x, y, buffer, buffer.length);
+ OS.SetBkMode(handle, oldBkMode);
+ } else {
+ OS.TextOut (handle, x, y, buffer, buffer.length);
+ }
+}
+
+/**
+ * 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>
+ */
+public void drawText (String string, int x, int y) {
+ RECT rect = new RECT();
+ OS.SetRect(rect, x, y, 0x7FFF, 0x7FFF);
+ byte [] buffer = Converter.wcsToMbcs(0, string, false);
+ OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX);
+}
+
+/**
+ * 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>
+ */
+public void drawText (String string, int x, int y, boolean isTransparent) {
+ RECT rect = new RECT();
+ OS.SetRect(rect, x, y, 0x7FFF, 0x7FFF);
+ byte [] buffer = Converter.wcsToMbcs(0, string, false);
+ if (isTransparent) {
+ int oldBkMode = OS.SetBkMode(handle, OS.TRANSPARENT);
+ OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX);
+ OS.SetBkMode(handle, oldBkMode);
+ } else {
+ OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX);
+ }
+}
+
+/**
+ * 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) {
+ return (object == this) || ((object instanceof GC) && (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 IllegalArgumentException <ul>
+ * <li>ERROR_INVALID_ARGUMENT - if any of the width, height or endAngle is zero.</li>
+ * </ul>
+ *
+ * @see #drawArc
+ */
+public void fillArc (int x, int y, int width, int height, int startAngle, int endAngle) {
+ int x1, y1, x2, y2,tmp;
+ boolean isNegative;
+ double pi = 3.1415926535;
+ double toRadians = 2 * pi / 360;
+
+ if (width < 0) {
+ x = x + width;
+ width = -width;
+ }
+ if (height < 0) {
+ y = y + height;
+ height = -height;
+ }
+
+ if (width == 0 || height == 0 || endAngle == 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ if (endAngle >= 360 || endAngle <= -360) {
+ x1 = x2 = x + width;
+ y1 = y2 = y + height / 2;
+ } else {
+ isNegative = endAngle < 0;
+
+ endAngle = endAngle + startAngle;
+ if (isNegative) {
+ // swap angles
+ tmp = startAngle;
+ startAngle = endAngle;
+ endAngle = tmp;
+ }
+ x1 = (int) (Math.cos(startAngle * toRadians) * width) + x + width/2;;
+ y1 = (int) (-1 * Math.sin(startAngle * toRadians) * height) + y + height/2;
+
+ x2 = (int) (Math.cos(endAngle * toRadians) * width) + x + width/2;
+ y2 = (int) (-1 * Math.sin(endAngle * toRadians) * height) + y + height/2;
+
+ }
+
+ int nullPen = OS.GetStockObject(OS.NULL_PEN);
+ int oldPen = OS.SelectObject(handle, nullPen);
+ OS.Pie(handle, x,y,x+width+1,y+height+1,x1,y1,x2,y2 );
+ OS.SelectObject(handle,oldPen);
+
+}
+
+/**
+ * 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
+ *
+ * @see #drawOval
+ */
+public void fillOval (int x, int y, int width, int height) {
+
+ // Assumes that user sets the background color.
+
+ int nullPen = OS.GetStockObject(OS.NULL_PEN);
+ int oldPen = OS.SelectObject(handle, nullPen);
+
+ OS.Ellipse(handle, x,y,x+width,y+height);
+ OS.SelectObject(handle,oldPen);
+}
+
+/**
+ * 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>
+ *
+ * @see #drawPolygon
+ */
+public void fillPolygon(int[] pointArray) {
+ int nullPen = OS.GetStockObject(OS.NULL_PEN);
+ int oldPen = OS.SelectObject(handle, nullPen);
+ OS.Polygon(handle, pointArray, pointArray.length / 2);
+ OS.SelectObject(handle,oldPen);
+}
+
+/**
+ * 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
+ *
+ * @see #drawRectangle
+ */
+public void fillRectangle (int x, int y, int width, int height) {
+ if (OS.GetROP2(handle) == OS.R2_COPYPEN)
+ OS.PatBlt (handle, x, y, width, height, OS.PATCOPY);
+ else
+ OS.PatBlt (handle, x, y, width, height, OS.PATINVERT);
+}
+
+/**
+ * Fills the interior of the specified rectangle, using the receiver's
+ * background color.
+ *
+ * @param rectangle the rectangle to be filled
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>
+ *
+ * @see #drawRectangle
+ */
+public void fillRectangle (Rectangle rect) {
+ 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 horizontal diameter of the arc at the four corners
+ * @param arcHeight the vertical diameter of the arc at the four corners
+ *
+ * @see #drawRoundRectangle
+ */
+public void fillRoundRectangle (int x, int y, int width, int height, int arcWidth, int arcHeight) {
+ int nullPen = OS.GetStockObject(OS.NULL_PEN);
+ int oldPen = OS.SelectObject(handle, nullPen);
+ OS.RoundRect(handle, x,y,x+width,y+height,arcWidth, arcHeight);
+ OS.SelectObject(handle,oldPen);
+}
+
+/**
+ * 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
+ */
+public int getAdvanceWidth(char ch) {
+ byte[] buffer = Converter.wcsToMbcs(0, new char[] { ch });
+ int val = 0;
+ for (int i = 0; i < buffer.length; i++) {
+ val |= (buffer[i] & 0xFF) << (i * 8);
+ }
+ int[] width = new int[1];
+ OS.GetCharWidth(handle, val, val, width);
+ return width[0];
+}
+
+/**
+ * Returns the background color.
+ *
+ * @return the receiver's background color
+ */
+public Color getBackground() {
+ int color = OS.GetBkColor(handle);
+ if (color == OS.CLR_INVALID) {
+ color = OS.GetSysColor(OS.COLOR_WINDOW);
+ }
+ return Color.win32_new(data.device, color);
+}
+
+/**
+ * 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
+ */
+public int getCharWidth(char ch) {
+ byte[] buffer = Converter.wcsToMbcs(0, new char[] { ch });
+ int val = 0;
+ for (int i = 0; i < buffer.length; i++) {
+ val |= (buffer[i] & 0xFF) << (i * 8);
+ }
+ int[] width = new int[3];
+ /* GetCharABCWidths only succeeds on truetype fonts */
+ if (OS.GetCharABCWidths(handle, val, val, width)) {
+ return width[1];
+ }
+ /* It wasn't a truetype font */
+ TEXTMETRIC tm = new TEXTMETRIC();
+ OS.GetTextMetrics(handle, tm);
+ SIZE size = new SIZE();
+ OS.GetTextExtentPoint32(handle, buffer, buffer.length, size);
+ return size.cx - tm.tmOverhang;
+}
+
+/**
+ * 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
+ */
+public Rectangle getClipping() {
+ RECT rect = new RECT();
+ OS.GetClipBox(handle, rect);
+ return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public void getClipping (Region region) {
+ if (region == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ int result = OS.GetClipRgn (handle, region.handle);
+ if (result == 1) return;
+ RECT rect = new RECT();
+ OS.GetClipBox(handle, rect);
+ OS.SetRectRgn(region.handle, rect.left, rect.top, rect.right, rect.bottom);
+}
+
+/**
+ * Returns the font currently being used by the receiver
+ * to draw and measure text.
+ *
+ * @return the receiver's font
+ */
+public Font getFont () {
+ int hFont = OS.GetCurrentObject(handle, OS.OBJ_FONT);
+ return Font.win32_new(data.device, hFont);
+}
+
+/**
+ * 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
+ */
+public FontMetrics getFontMetrics() {
+ TEXTMETRIC lptm = new TEXTMETRIC();
+ OS.GetTextMetrics(handle, lptm);
+ return FontMetrics.win32_new(lptm);
+}
+
+/**
+ * Returns the receiver's foreground color.
+ *
+ * @return the color used for drawing foreground things
+ */
+public Color getForeground() {
+ int color = OS.GetTextColor(handle);
+ if (color == OS.CLR_INVALID) {
+ color = OS.GetSysColor(OS.COLOR_WINDOWTEXT);
+ }
+ return Color.win32_new(data.device, color);
+}
+
+/**
+ * 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
+ */
+public int getLineStyle() {
+ int hPen = OS.GetCurrentObject(handle, OS.OBJ_PEN);
+ LOGPEN logPen = new LOGPEN();
+ OS.GetObject(hPen, LOGPEN.sizeof, logPen);
+ switch (logPen.lopnStyle) {
+ case OS.PS_SOLID: return SWT.LINE_SOLID;
+ case OS.PS_DASH: return SWT.LINE_DASH;
+ case OS.PS_DOT: return SWT.LINE_DOT;
+ case OS.PS_DASHDOT: return SWT.LINE_DASHDOT;
+ case OS.PS_DASHDOTDOT: return SWT.LINE_DASHDOTDOT;
+ default: return SWT.LINE_SOLID;
+ }
+}
+
+/**
+ * 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
+ */
+public int getLineWidth() {
+ int hPen = OS.GetCurrentObject(handle, OS.OBJ_PEN);
+ LOGPEN logPen = new LOGPEN();
+ OS.GetObject(hPen, LOGPEN.sizeof, logPen);
+ return logPen.x;
+}
+
+/**
+ * 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
+ */
+public boolean getXORMode() {
+ return OS.GetROP2(handle) == OS.R2_XORPEN;
+}
+
+void init(Drawable drawable, GCData data, int hDC) {
+ int foreground = data.foreground;
+ if (foreground != -1 && OS.GetTextColor(hDC) != foreground) {
+ OS.SetTextColor(hDC, foreground);
+ int hPen = OS.CreatePen(OS.PS_SOLID, 0, foreground);
+ OS.SelectObject(hDC, hPen);
+ }
+ int background = data.background;
+ if (background != -1 && OS.GetBkColor(hDC) != background) {
+ OS.SetBkColor(hDC, background);
+ int hBrush = OS.CreateSolidBrush(background);
+ OS.SelectObject(hDC, hBrush);
+ }
+ int hFont = data.hFont;
+ if (hFont != 0) OS.SelectObject (hDC, hFont);
+ int hPalette = data.device.hPalette;
+ if (hPalette != 0) {
+ OS.SelectPalette(hDC, hPalette, true);
+ OS.RealizePalette(hDC);
+ }
+ Image image = data.image;
+ if (image != null) {
+ data.hNullBitmap = OS.SelectObject(hDC, image.handle);
+ image.memGC = this;
+ }
+ this.drawable = drawable;
+ this.data = data;
+ handle = hDC;
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 handle;
+}
+
+/**
+ * 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
+ */
+public boolean isClipped() {
+ int region = OS.CreateRectRgn(0, 0, 0, 0);
+ int result = OS.GetClipRgn(handle, region);
+ OS.DeleteObject(region);
+ return (result > 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;
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public void setBackground (Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (OS.GetBkColor(handle) == color.handle) return;
+ OS.SetBkColor (handle, color.handle);
+ int newBrush = OS.CreateSolidBrush (color.handle);
+ int oldBrush = OS.SelectObject (handle, newBrush);
+ OS.DeleteObject (oldBrush);
+}
+
+/**
+ * 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
+ *
+ */
+public void setClipping (int x, int y, int width, int height) {
+ int hRgn = OS.CreateRectRgn (x, y, x + width, y + height);
+ OS.SelectClipRgn (handle, hRgn);
+ OS.DeleteObject (hRgn);
+}
+
+/**
+ * Sets the area of the receiver which can be changed
+ * by drawing operations to the rectangular area specified
+ * by the argument.
+ *
+ * @param rect the clipping rectangle
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the rectangle is null</li>
+ * </ul>
+ */
+public void setClipping (Rectangle rect) {
+ if (rect == null) {
+ OS.SelectClipRgn (handle, 0);
+ return;
+ }
+ 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.
+ *
+ * @param rect the clipping region.
+ */
+public void setClipping (Region region) {
+ int hRegion = 0;
+ if (region != null) hRegion = region.handle;
+ OS.SelectClipRgn (handle, hRegion);
+}
+
+/**
+ * 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
+ */
+
+public void setFont (Font font) {
+ if (font == null) {
+ int hFont = OS.GetStockObject(OS.DEFAULT_GUI_FONT);
+ if (hFont == 0) hFont = OS.GetStockObject(OS.SYSTEM_FONT);
+ OS.SelectObject(handle, hFont);
+ } else {
+ OS.SelectObject(handle, font.handle);
+ }
+}
+
+/**
+ * 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
+ */
+public void setForeground (Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (OS.GetTextColor(handle) == color.handle) return;
+ int hPen = OS.GetCurrentObject(handle, OS.OBJ_PEN);
+ LOGPEN logPen = new LOGPEN();
+ OS.GetObject(hPen, LOGPEN.sizeof, logPen);
+ OS.SetTextColor (handle, color.handle);
+ int newPen = OS.CreatePen (logPen.lopnStyle, logPen.x, color.handle);
+ int oldPen = OS.SelectObject (handle, newPen);
+ OS.DeleteObject (oldPen);
+}
+
+/**
+ * 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
+ */
+public void setLineStyle(int lineStyle) {
+ int style = -1;
+ switch (lineStyle) {
+ case SWT.LINE_SOLID: style = OS.PS_SOLID; break;
+ case SWT.LINE_DASH: style = OS.PS_DASH; break;
+ case SWT.LINE_DOT: style = OS.PS_DOT; break;
+ case SWT.LINE_DASHDOT: style = OS.PS_DASHDOT; break;
+ case SWT.LINE_DASHDOTDOT: style = OS.PS_DASHDOTDOT; break;
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+ int hPen = OS.GetCurrentObject(handle, OS.OBJ_PEN);
+ LOGPEN logPen = new LOGPEN();
+ OS.GetObject(hPen, LOGPEN.sizeof, logPen);
+ if (logPen.lopnStyle == style) return;
+ int newPen = OS.CreatePen(style, logPen.x, logPen.lopnColor);
+ int oldPen = OS.SelectObject(handle, newPen);
+ OS.DeleteObject(oldPen);
+}
+
+/**
+ * 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.
+ *
+ * @param lineWidth the width of a line
+ */
+public void setLineWidth(int lineWidth) {
+ int hPen = OS.GetCurrentObject(handle, OS.OBJ_PEN);
+ LOGPEN logPen = new LOGPEN();
+ OS.GetObject(hPen, LOGPEN.sizeof, logPen);
+ if (logPen.x == lineWidth) return;
+ int newPen = OS.CreatePen(logPen.lopnStyle, lineWidth, logPen.lopnColor);
+ int oldPen = OS.SelectObject(handle, newPen);
+ OS.DeleteObject(oldPen);
+}
+
+/**
+ * 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.
+ *
+ * @param xor if <code>true</code>, then <em>xor</em> mode is used, otherwise <em>source copy</em> mode is used
+ */
+public void setXORMode(boolean xor) {
+ if (xor) {
+ OS.SetROP2(handle, OS.R2_XORPEN);
+ } else {
+ OS.SetROP2(handle, OS.R2_COPYPEN);
+ }
+}
+
+/**
+ * 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
+ */
+public Point stringExtent(String string) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ SIZE size = new SIZE();
+ if (string.length () == 0) {
+ OS.GetTextExtentPoint32(handle, SPACE, 1, size);
+ return new Point(0, size.cy);
+ } else {
+ byte [] buffer = Converter.wcsToMbcs(0, string, false);
+ OS.GetTextExtentPoint32(handle, buffer, buffer.length, size);
+ return new Point(size.cx, size.cy);
+ }
+}
+
+/**
+ * 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
+ */
+public Point textExtent(String string) {
+ if (string == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ if (string.length () == 0) {
+ SIZE size = new SIZE();
+ OS.GetTextExtentPoint32(handle, SPACE, 1, size);
+ return new Point(0, size.cy);
+ } else {
+ RECT rect = new RECT();
+ byte [] buffer = Converter.wcsToMbcs(0, string, false);
+ OS.DrawText(handle, buffer, buffer.length, rect, OS.DT_EXPANDTABS | OS.DT_LEFT | OS.DT_NOPREFIX | OS.DT_CALCRECT);
+ return new Point(rect.right, rect.bottom);
+ }
+}
+
+/**
+ * Invokes platform specific functionality to allocate a new graphics context.
+ * <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>
+ *
+ * @param drawable the Drawable for the receiver.
+ * @param data the data for the receiver.
+ *
+ * @return a new <code>GC</code>
+ *
+ * @private
+ */
+public static GC win32_new(Drawable drawable, GCData data) {
+ GC gc = new GC();
+ int hDC = drawable.internal_new_GC(data);
+ gc.init(drawable, data, hDC);
+ return gc;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
new file mode 100755
index 0000000000..ff0794deb1
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GCData.java
@@ -0,0 +1,31 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * 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>
+ *
+ * @private
+ */
+
+public final class GCData {
+ public Device device;
+ public Image image;
+ public int foreground = -1;
+ public int background = -1;
+ public int hFont;
+ public int hNullBitmap;
+ public PAINTSTRUCT ps;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
new file mode 100755
index 0000000000..73c9303fc5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -0,0 +1,1601 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.internal.win32.*;
+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);</code>
+ * </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 explicitely 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
+ */
+
+public final class Image implements Drawable {
+
+ /**
+ * specifies whether the receiver is a bitmap or an icon
+ * (one of <code>SWT.BITMAP</code>, <code>SWT.ICON</code>)
+ */
+ public int type;
+
+ /**
+ * the OS resource of the image
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ /**
+ * the device where this image was created
+ */
+ Device device;
+
+ /**
+ * specifies the transparent pixel
+ * (Warning: This field is platform dependent)
+ */
+ int transparentPixel = -1;
+
+ /**
+ * the GC which is drawing on the image
+ * (Warning: This field is platform dependent)
+ */
+ GC memGC;
+
+ /**
+ * the alpha data for the image
+ * (Warning: This field is platform dependent)
+ */
+ byte[] alphaData;
+
+ /**
+ * the global alpha value to be used for every pixel
+ * (Warning: This field is platform dependent)
+ */
+ int alpha = -1;
+
+ /**
+ * specifies the default scanline padding
+ * (Warning: This field is platform dependent)
+ */
+ static final int DEFAULT_SCANLINE_PAD = 4;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Image () {
+}
+
+/**
+ * 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>
+ *
+ * @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_INVALID_ARGUMENT - if either the width or height is negative</li>
+ * </ul>
+ */
+public Image(Device device, int width, int height) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, width, height);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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>IMAGE_COPY</b></dt>
+ * <dd>the result is an identical copy of srcImage</dd>
+ * <dt><b>IMAGE_DISABLE</b></dt>
+ * <dd>the result is a copy of srcImage which has a <em>disabled</em> look</dd>
+ * <dt><b>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 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>
+ * </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>
+ * </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) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ if (srcImage == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ switch (flag) {
+ case SWT.IMAGE_COPY: {
+ Rectangle r = srcImage.getBounds();
+ this.type = srcImage.type;
+ switch (type) {
+ case SWT.BITMAP:
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Copy the bitmap */
+ int hdcSource = OS.CreateCompatibleDC(hDC);
+ int hdcDest = OS.CreateCompatibleDC(hDC);
+ int hOldSrc = OS.SelectObject(hdcSource, srcImage.handle);
+ handle = OS.CreateCompatibleBitmap(hdcSource, r.width, r.height);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int hOldDest = OS.SelectObject(hdcDest, handle);
+ OS.BitBlt(hdcDest, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
+ OS.SelectObject(hdcSource, hOldSrc);
+ OS.SelectObject(hdcDest, hOldDest);
+ OS.DeleteDC(hdcSource);
+ OS.DeleteDC(hdcDest);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+
+ 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);
+ }
+ break;
+ case SWT.ICON:
+ handle = OS.CopyImage(srcImage.handle, OS.IMAGE_ICON, r.width, r.height, 0);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ }
+ if (device.tracking) device.new_Object(this);
+ return;
+ }
+ case SWT.IMAGE_DISABLE: {
+ Rectangle r = srcImage.getBounds();
+ this.type = srcImage.type;
+ byte[] rgbBwBitmapInfo = {
+ 40,0,0,0, /* biSize */
+ (byte)(r.width & 0xFF), /* biWidth */
+ (byte)((r.width & 0xFF00) >> 8),
+ (byte)((r.width & 0xFF0000) >> 16),
+ (byte)((r.width & 0xFF000000) >> 24),
+ (byte)(r.height & 0xFF), /* biHeight */
+ (byte)((r.height & 0xFF00) >> 8),
+ (byte)((r.height & 0xFF0000) >> 16),
+ (byte)((r.height & 0xFF000000) >> 24),
+ 1,0, /* biPlanes */
+ 1,0, /* biBitCount */
+ 0,0,0,0, /* biCompression */
+ 0,0,0,0, /* biSizeImage */
+ 0,0,0,0, /* biXPelsPerMeter */
+ 0,0,0,0, /* biYPelsPerMeter */
+ 0,0,0,0, /* biClrUsed */
+ 0,0,0,0, /* biClrImportant */
+ 0,0,0,0, /* First color: black */
+ (byte)0xFF,(byte)0xFF,(byte)0xFF,0 /* Second color: white */
+ };
+
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Source DC */
+ int hdcSource = OS.CreateCompatibleDC(hDC);
+ if (hdcSource == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Monochrome (Intermediate) DC */
+ int bwDC = OS.CreateCompatibleDC(hdcSource);
+ if (bwDC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Destination DC */
+ int hdcBmp = OS.CreateCompatibleDC(hDC);
+ if (hdcBmp == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Monochrome (Intermediate) DIB section */
+ int[] pbitsBW = new int[1];
+ int hbmBW = OS.CreateDIBSection(bwDC, rgbBwBitmapInfo, OS.DIB_RGB_COLORS, pbitsBW, 0, 0);
+ if (hbmBW == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ switch (type) {
+ case SWT.BITMAP:
+ /* Attach the bitmap to the source DC */
+ int hOldSrc = OS.SelectObject(hdcSource, srcImage.handle);
+ /* Create the destination bitmap */
+ handle = OS.CreateCompatibleBitmap(hDC, r.width, r.height);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Attach the DIB section and the new bitmap to the DCs */
+ int hOldBw = OS.SelectObject(bwDC, hbmBW);
+ int hOldBmp = OS.SelectObject(hdcBmp, handle);
+ /* BitBlt the bitmap into the monochrome DIB section */
+ OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
+ /* Paint the destination rectangle in gray */
+ RECT rect = new RECT();
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = r.width;
+ rect.bottom = r.height;
+ OS.FillRect(hdcBmp, rect, OS.GetSysColorBrush(OS.COLOR_3DFACE));
+ /*
+ * BitBlt the black bits in the monochrome bitmap into
+ * COLOR_3DHILIGHT bits in the destination DC.
+ * The magic ROP comes from Charles Petzold's book
+ */
+ int hb = OS.CreateSolidBrush(OS.GetSysColor(OS.COLOR_3DHILIGHT));
+ int oldBrush = OS.SelectObject(hdcBmp, hb);
+ OS.BitBlt(hdcBmp, 1, 1, r.width, r.height, bwDC, 0, 0, 0xB8074A);
+ /*
+ * BitBlt the black bits in the monochrome bitmap into
+ * COLOR_3DSHADOW bits in the destination DC.
+ */
+ hb = OS.CreateSolidBrush(OS.GetSysColor(OS.COLOR_3DSHADOW));
+ OS.DeleteObject(OS.SelectObject(hdcBmp, hb));
+ OS.BitBlt(hdcBmp, 0, 0, r.width, r.height, bwDC, 0, 0, 0xB8074A);
+ OS.DeleteObject(OS.SelectObject(hdcBmp, oldBrush));
+ /* Free resources */
+ OS.SelectObject(hdcSource, hOldSrc);
+ OS.SelectObject(hdcBmp, hOldBmp);
+ OS.SelectObject(bwDC, hOldBw);
+ OS.DeleteDC(hdcSource);
+ OS.DeleteDC(bwDC);
+ OS.DeleteDC(hdcBmp);
+ OS.DeleteObject(hbmBW);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+ break;
+ case SWT.ICON:
+ /* Get icon information */
+ ICONINFO iconInfo = new ICONINFO();
+ if (!OS.GetIconInfo(srcImage.handle, iconInfo))
+ SWT.error(SWT.ERROR_INVALID_IMAGE);
+ int hdcMask = OS.CreateCompatibleDC(hDC);
+ /* Create the destination bitmaps */
+ if (iconInfo.hbmColor == 0)
+ hOldSrc = OS.SelectObject(hdcSource, iconInfo.hbmMask);
+ else
+ hOldSrc = OS.SelectObject(hdcSource, iconInfo.hbmColor);
+ int newHbmp = OS.CreateCompatibleBitmap(hdcSource, r.width, r.height);
+ if (newHbmp == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int newHmask = OS.CreateBitmap(r.width, r.height, 1, 1, null);
+ if (newHmask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* BitBlt the source mask into the destination mask */
+ int hOldMask = OS.SelectObject(hdcMask, newHmask);
+ if (iconInfo.hbmColor != 0)
+ OS.SelectObject(hdcSource, iconInfo.hbmMask);
+ OS.SelectObject(hdcSource, iconInfo.hbmMask);
+ OS.BitBlt(hdcMask, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
+ /* Attach the monochrome DIB section and the destination bitmap to the DCs */
+ hOldBw = OS.SelectObject(bwDC, hbmBW);
+ /* BitBlt the bitmap into the monochrome DIB section */
+ if (iconInfo.hbmColor == 0) {
+ OS.SelectObject(hdcSource, iconInfo.hbmMask);
+ OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcSource, 0, r.height, OS.SRCCOPY);
+ } else {
+ OS.SelectObject(hdcSource, iconInfo.hbmColor);
+ OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcSource, 0, 0, OS.SRCCOPY);
+ }
+ /* Paint the destination rectangle in grey */
+ rect = new RECT();
+ rect.left = 0;
+ rect.top = 0;
+ rect.right = r.width;
+ rect.bottom = r.height;
+ hOldBmp = OS.SelectObject(hdcBmp, newHbmp);
+ OS.FillRect(hdcBmp, rect, OS.GetSysColorBrush(OS.COLOR_3DFACE));
+ /*
+ * BitBlt the black bits in the monochrome bitmap into
+ * COLOR_3DHILIGHT bits in the destination DC.
+ * The magic ROP comes from Charles Petzold's book
+ */
+ hb = OS.CreateSolidBrush(OS.GetSysColor(OS.COLOR_3DSHADOW));
+ oldBrush = OS.SelectObject(hdcBmp, hb);
+ OS.BitBlt(hdcBmp, 0, 0, r.width, r.height, bwDC, 0, 0, 0xB8074A);
+ /* Invert mask into hdcBw */
+ OS.BitBlt(bwDC, 0, 0, r.width, r.height, hdcMask, 0, 0, OS.NOTSRCCOPY);
+ /* Select black brush into destination */
+ hb = OS.CreateSolidBrush(0);
+ OS.DeleteObject(OS.SelectObject(hdcBmp, hb));
+ /*
+ * Copy black bits from monochrome bitmap into black bits in the
+ * destination DC.
+ */
+ OS.BitBlt(hdcBmp, 0, 0, r.width, r.height, bwDC, 0, 0, 0xB8074A);
+ OS.DeleteObject(OS.SelectObject(hdcBmp, oldBrush));
+ /* Free resources */
+ OS.SelectObject(hdcSource, hOldSrc);
+ OS.DeleteDC(hdcSource);
+ OS.SelectObject(bwDC, hOldBw);
+ OS.DeleteDC(bwDC);
+ OS.SelectObject(hdcBmp, hOldBmp);
+ OS.DeleteDC(hdcBmp);
+ OS.SelectObject(hdcMask, hOldMask);
+ OS.DeleteDC(hdcMask);
+ OS.DeleteObject(hbmBW);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+
+ /* Create the new iconinfo */
+ ICONINFO newIconInfo = new ICONINFO();
+ newIconInfo.fIcon = iconInfo.fIcon;
+ newIconInfo.hbmMask = newHmask;
+ newIconInfo.hbmColor = newHbmp;
+ /* Create the new icon */
+ handle = OS.CreateIconIndirect(newIconInfo);
+ if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* Free bitmaps */
+ OS.DeleteObject(newHbmp);
+ OS.DeleteObject(newHmask);
+ if (iconInfo.hbmColor != 0)
+ OS.DeleteObject(iconInfo.hbmColor);
+ OS.DeleteObject(iconInfo.hbmMask);
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ }
+ if (device.tracking) device.new_Object(this);
+ return;
+ }
+ case SWT.IMAGE_GRAY: {
+ Rectangle r = srcImage.getBounds();
+ ImageData data = srcImage.getImageData();
+ PaletteData palette = data.palette;
+ ImageData newData = data;
+ if (!palette.isDirect) {
+ /* Convert the palette entries to gray. */
+ RGB [] rgbs = palette.getRGBs();
+ for (int i=0; i<rgbs.length; i++) {
+ if (data.transparentPixel != i) {
+ RGB color = rgbs [i];
+ int red = color.red;
+ int green = color.green;
+ int blue = color.blue;
+ int intensity = (red+red+green+green+green+green+green+blue) >> 3;
+ color.red = color.green = color.blue = intensity;
+ }
+ }
+ newData.palette = new PaletteData(rgbs);
+ } else {
+ /* Create a 8 bit depth image data with a gray palette. */
+ RGB[] rgbs = new RGB[256];
+ for (int i=0; i<rgbs.length; i++) {
+ rgbs[i] = new RGB(i, i, i);
+ }
+ newData = new ImageData(r.width, r.height, 8, new PaletteData(rgbs));
+ newData.maskData = data.maskData;
+ newData.maskPad = data.maskPad;
+
+ /* Convert the pixels. */
+ int[] scanline = new int[r.width];
+ 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 y=0; y<r.height; y++) {
+ int offset = y * newData.bytesPerLine;
+ data.getPixels(0, y, r.width, scanline, 0);
+ for (int x=0; x<r.width; x++) {
+ int pixel = scanline[x];
+ int red = pixel & redMask;
+ red = (redShift < 0) ? red >>> -redShift : red << redShift;
+ int green = pixel & greenMask;
+ green = (greenShift < 0) ? green >>> -greenShift : green << greenShift;
+ int blue = pixel & blueMask;
+ blue = (blueShift < 0) ? blue >>> -blueShift : blue << blueShift;
+ newData.data[offset++] =
+ (byte)((red+red+green+green+green+green+green+blue) >> 3);
+ }
+ }
+ }
+ init (device, newData);
+ if (device.tracking) device.new_Object(this);
+ return;
+ }
+ default:
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+}
+
+/**
+ * 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>
+ *
+ * @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 the bounds rectangle is null</li>
+ * </ul>
+ */
+public Image(Device device, Rectangle bounds) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (bounds == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, bounds.width, bounds.height);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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 the image data is null</li>
+ * </ul>
+ */
+public Image(Device device, ImageData data) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, data);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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, and the mask image
+ * must have a color depth of 1. Pixel transparency in either image
+ * will be ignored. If either image is an icon to begin with, an
+ * exception is thrown.
+ * <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 either the source or mask is null </li>
+ * <li>ERROR_INVALID_ARGUMENT - if source and mask are different sizes or
+ * if the mask is not monochrome, or if either the source or mask
+ * is already an icon</li>
+ * </ul>
+ */
+public Image(Device device, ImageData source, ImageData mask) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ 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);
+ }
+ if (mask.depth != 1) {
+ /*
+ * Feature in Windows. 1-bit DIB sections are buggy on Win98, so we
+ * create 4-bit DIBs when given a 1-bit ImageData. In order to allow
+ * users to draw on the masks, we must also support 4-bit masks in
+ * icon creation by converting them into 1-bit masks.
+ */
+ if (mask.depth != 4) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ PaletteData palette = new PaletteData(new RGB[] {new RGB(0, 0, 0), new RGB(255,255,255)});
+ ImageData tempMask = new ImageData(mask.width, mask.height, 1, palette);
+ /* Find index of black in mask palette */
+ RGB[] rgbs = mask.getRGBs();
+ int blackIndex = 0;
+ while (blackIndex < rgbs.length) {
+ if (rgbs[blackIndex].equals(palette.colors[0])) break;
+ blackIndex++;
+ }
+ if (blackIndex == rgbs.length) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ 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;
+ }
+ }
+ tempMask.setPixels(0, y, mask.width, pixels, 0);
+ }
+ mask = tempMask;
+ }
+ /* Create a temporary image and locate the black pixel */
+ ImageData image;
+ int blackIndex = 0;
+ if (source.palette.isDirect) {
+ image = new ImageData(source.width, source.height, source.depth, source.palette);
+ } else {
+ RGB black = new RGB(0, 0, 0);
+ RGB[] rgbs = source.getRGBs();
+ if (source.transparentPixel != -1) {
+ /*
+ * The source had transparency, so we can use the transparent pixel
+ * for black.
+ */
+ RGB[] newRGBs = new RGB[rgbs.length];
+ System.arraycopy(rgbs, 0, newRGBs, 0, rgbs.length);
+ if (source.transparentPixel >= newRGBs.length) {
+ /* Grow the palette with black */
+ rgbs = new RGB[source.transparentPixel + 1];
+ System.arraycopy(newRGBs, 0, rgbs, 0, newRGBs.length);
+ for (int i = newRGBs.length; i <= source.transparentPixel; i++) {
+ rgbs[i] = new RGB(0, 0, 0);
+ }
+ } else {
+ newRGBs[source.transparentPixel] = black;
+ rgbs = newRGBs;
+ }
+ blackIndex = source.transparentPixel;
+ image = new ImageData(source.width, source.height, source.depth, new PaletteData(rgbs));
+ } else {
+ while (blackIndex < rgbs.length) {
+ if (rgbs[blackIndex].equals(black)) break;
+ blackIndex++;
+ }
+ if (blackIndex == rgbs.length) {
+ /*
+ * We didn't find black in the palette, and there is no transparent
+ * pixel we can use.
+ */
+ if ((1 << source.depth) > rgbs.length) {
+ /* We can grow the palette and add black */
+ RGB[] newRGBs = new RGB[rgbs.length + 1];
+ System.arraycopy(rgbs, 0, newRGBs, 0, rgbs.length);
+ newRGBs[rgbs.length] = black;
+ rgbs = newRGBs;
+ } else {
+ /* No room to grow the palette */
+ blackIndex = -1;
+ }
+ }
+ image = new ImageData(source.width, source.height, source.depth, new PaletteData(rgbs));
+ }
+ }
+ if (blackIndex == -1) {
+ /* There was no black in the palette, so just copy the data over */
+ System.arraycopy(source.data, 0, image.data, 0, image.data.length);
+ } else {
+ /* Modify the source image to contain black wherever the mask is 0 */
+ int[] imagePixels = new int[image.width];
+ int[] maskPixels = new int[mask.width];
+ for (int y = 0; y < image.height; y++) {
+ source.getPixels(0, y, image.width, imagePixels, 0);
+ mask.getPixels(0, y, mask.width, maskPixels, 0);
+ for (int i = 0; i < imagePixels.length; i++) {
+ if (maskPixels[i] == 0) imagePixels[i] = blackIndex;
+ }
+ image.setPixels(0, y, source.width, imagePixels, 0);
+ }
+ }
+ /*
+ * Make sure the mask is padded properly. Windows requires icon masks
+ * to have a scanline pad of 2.
+ */
+ int bytesPerLine = (((mask.width + 7) / 8) + 1) / 2 * 2;
+ byte[] newMaskData = new byte[bytesPerLine * mask.height];
+ ImageData newMask = new ImageData(mask.width, mask.height, 1, mask.palette, 2, newMaskData);
+ int[] maskPixels = new int[mask.width];
+ for (int y = 0; y < mask.height; y++) {
+ mask.getPixels(0, y, mask.width, maskPixels, 0);
+ newMask.setPixels(0, y, newMask.width, maskPixels, 0);
+ }
+ /* Set the fields and create the icon */
+ image.maskPad = newMask.scanlinePad;
+ image.maskData = newMask.data;
+ init(device, image);
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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.
+ * <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>
+ * new Image(device, clazz.getResourceAsStream("file.gif"));
+ * </pre>
+ *
+ * @param device the device on which to create the image
+ * @param stream the input stream to load the image from
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ */
+public Image (Device device, InputStream stream) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new ImageData(stream));
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_INVALID_IMAGE - if the image file contains invalid data </li>
+ * <li>ERROR_IO - if an IO error occurs while reading data</li>
+ * </ul>
+ */
+public Image (Device device, String filename) {
+ if (device == null) device = Device.getDevice();
+ if (device == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ init(device, new ImageData(filename));
+ if (device.tracking) device.new_Object(this);
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the image. Applications must dispose of all images which
+ * they allocate.
+ */
+public void dispose () {
+ if (handle == 0) return;
+ if (type == SWT.ICON) {
+ OS.DestroyIcon (handle);
+ } else {
+ OS.DeleteObject (handle);
+ }
+ handle = 0;
+ memGC = null;
+ if (device.tracking) device.dispose_Object(this);
+ device = 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 && handle == image.handle;
+}
+
+/**
+ * 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
+ */
+public Color getBackground() {
+ if (transparentPixel == -1) return null;
+
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Compute the background color */
+ BITMAP bm = new BITMAP();
+ OS.GetObject(handle, BITMAP.sizeof, bm);
+ int hdcMem = OS.CreateCompatibleDC(hDC);
+ int hOldObject = OS.SelectObject(hdcMem, handle);
+ int red = 0, green = 0, blue = 0;
+ if (bm.bmBitsPixel <= 8) {
+ byte[] color = new byte[4];
+ int numColors = OS.GetDIBColorTable(hdcMem, transparentPixel, 1, color);
+ blue = color[0] & 0xFF;
+ green = color[1] & 0xFF;
+ red = color[2] & 0xFF;
+ } else {
+ switch (bm.bmBitsPixel) {
+ case 16:
+ blue = (transparentPixel & 0x1F) << 3;
+ green = (transparentPixel & 0x3E0) >> 2;
+ red = (transparentPixel & 0x7C00) >> 7;
+ break;
+ case 24:
+ blue = (transparentPixel & 0xFF0000) >> 16;
+ green = (transparentPixel & 0xFF00) >> 8;
+ red = transparentPixel & 0xFF;
+ break;
+ case 32:
+ blue = (transparentPixel & 0xFF000000) >>> 24;
+ green = (transparentPixel & 0xFF0000) >> 16;
+ red = (transparentPixel & 0xFF00) >> 8;
+ break;
+ default:
+ return null;
+ }
+ }
+ OS.SelectObject(hdcMem, hOldObject);
+ OS.DeleteDC(hdcMem);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+ return Color.win32_new(device, 0x02000000 | (blue << 16) | (green << 8) | red);
+}
+
+/**
+ * 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_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ */
+public Rectangle getBounds() {
+ switch (type) {
+ case SWT.BITMAP:
+ BITMAP bm = new BITMAP();
+ OS.GetObject(handle, BITMAP.sizeof, bm);
+ return new Rectangle(0, 0, bm.bmWidth, bm.bmHeight);
+ case SWT.ICON:
+ ICONINFO info = new ICONINFO();
+ OS.GetIconInfo(handle, info);
+ int hBitmap = info.hbmColor;
+ if (hBitmap == 0) hBitmap = info.hbmMask;
+ bm = new BITMAP();
+ OS.GetObject(hBitmap, BITMAP.sizeof, bm);
+ if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
+ if (info.hbmColor != 0) OS.DeleteObject(info.hbmColor);
+ if (info.hbmMask != 0) OS.DeleteObject(info.hbmMask);
+ return new Rectangle(0, 0, bm.bmWidth, bm.bmHeight);
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ return null;
+ }
+}
+
+/**
+ * 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_INVALID_IMAGE - if the image is not a bitmap or an icon</li>
+ * </ul>
+ *
+ * @see ImageData
+ */
+public ImageData getImageData() {
+ BITMAP bm;
+ int depth, width, height;
+ switch (type) {
+ case SWT.ICON: {
+ ICONINFO info = new ICONINFO();
+ OS.GetIconInfo(handle, info);
+ /* Get the basic BITMAP information */
+ int hBitmap = info.hbmColor;
+ if (hBitmap == 0) hBitmap = info.hbmMask;
+ bm = new BITMAP();
+ OS.GetObject(hBitmap, BITMAP.sizeof, bm);
+ depth = bm.bmPlanes * bm.bmBitsPixel;
+ width = bm.bmWidth;
+ if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
+ height = bm.bmHeight;
+ int numColors = 0;
+ if (depth <= 8) numColors = 1 << depth;
+ /* Create the BITMAPINFO */
+ byte[] bmi = new byte[40 + numColors * 4];
+ /* DWORD biSize = 40 */
+ bmi[0] = 40; bmi[1] = bmi[2] = bmi[3] = 0;
+ /* LONG biWidth = width */
+ bmi[4] = (byte)(width & 0xFF);
+ bmi[5] = (byte)((width >> 8) & 0xFF);
+ bmi[6] = (byte)((width >> 16) & 0xFF);
+ bmi[7] = (byte)((width >> 24) & 0xFF);
+ /* LONG biHeight = height */
+ bmi[8] = (byte)(-height & 0xFF);
+ bmi[9] = (byte)((-height >> 8) & 0xFF);
+ bmi[10] = (byte)((-height >> 16) & 0xFF);
+ bmi[11] = (byte)((-height >> 24) & 0xFF);
+ /* WORD biPlanes = 1 */
+ bmi[12] = 1;
+ bmi[13] = 0;
+ /* WORD biBitCount = bm.bmPlanes * bm.bmBitsPixel */
+ bmi[14] = (byte)(depth & 0xFF);
+ bmi[15] = (byte)((depth >> 8) & 0xFF);
+ /* DWORD biCompression = BI_RGB = 0 */
+ bmi[16] = bmi[17] = bmi[18] = bmi[19] = 0;
+ /* DWORD biSizeImage = 0 (default) */
+ bmi[20] = bmi[21] = bmi[22] = bmi[23] = 0;
+ /* LONG biXPelsPerMeter = 0 */
+ bmi[24] = bmi[25] = bmi[26] = bmi[27] = 0;
+ /* LONG biYPelsPerMeter = 0 */
+ bmi[28] = bmi[29] = bmi[30] = bmi[31] = 0;
+ /* DWORD biClrUsed = 0 */
+ bmi[32] = bmi[33] = bmi[34] = bmi[35] = 0;
+ /* DWORD biClrImportant = 0 */
+ bmi[36] = bmi[37] = bmi[38] = bmi[39] = 0;
+
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Create the DC and select the bitmap */
+ int hBitmapDC = OS.CreateCompatibleDC(hDC);
+ int hOldBitmap = OS.SelectObject(hBitmapDC, hBitmap);
+ /* Select the palette if necessary */
+ int oldPalette = 0;
+ if (depth <= 8) {
+ int hPalette = device.hPalette;
+ if (hPalette != 0) {
+ oldPalette = OS.SelectPalette(hBitmapDC, hPalette, false);
+ OS.RealizePalette(hBitmapDC);
+ }
+ }
+ /* Find the size of the image and allocate data */
+ int imageSize;
+ /* Call with null lpBits to get the image size */
+ OS.GetDIBits(hBitmapDC, hBitmap, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
+ imageSize = (bmi[20] & 0xFF) | ((bmi[21] & 0xFF) << 8) | ((bmi[22] & 0xFF) << 16) | ((bmi[23] & 0xFF) << 24);
+ byte[] data = new byte[imageSize];
+ /* Get the bitmap data */
+ int hHeap = OS.GetProcessHeap();
+ int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+ OS.GetDIBits(hBitmapDC, hBitmap, 0, height, lpvBits, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(data, lpvBits, imageSize);
+ /* Calculate the palette */
+ PaletteData palette = null;
+ if (depth <= 8) {
+ RGB[] rgbs = new RGB[numColors];
+ int srcIndex = 40;
+ for (int i = 0; i < numColors; i++) {
+ rgbs[i] = new RGB(bmi[srcIndex + 2] & 0xFF, bmi[srcIndex + 1] & 0xFF, bmi[srcIndex] & 0xFF);
+ srcIndex += 4;
+ }
+ palette = new PaletteData(rgbs);
+ } else if (depth == 16) {
+ palette = new PaletteData(0x7C00, 0x3E0, 0x1F);
+ } else if (depth == 24) {
+ palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ } else if (depth == 32) {
+ palette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ } else {
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+
+ /* Do the mask */
+ byte [] maskData = null;
+ if (info.hbmColor == 0) {
+ /* Do the bottom half of the mask */
+ maskData = new byte[imageSize];
+ OS.GetDIBits(hBitmapDC, hBitmap, height, height, lpvBits, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(maskData, lpvBits, imageSize);
+ } else {
+ /* Do the entire mask */
+ /* Create the BITMAPINFO */
+ bmi = new byte[48];
+ /* DWORD biSize = 40 */
+ bmi[0] = 40; bmi[1] = bmi[2] = bmi[3] = 0;
+ /* LONG biWidth = width */
+ bmi[4] = (byte)(width & 0xFF);
+ bmi[5] = (byte)((width >> 8) & 0xFF);
+ bmi[6] = (byte)((width >> 16) & 0xFF);
+ bmi[7] = (byte)((width >> 24) & 0xFF);
+ /* LONG biHeight = height */
+ bmi[8] = (byte)(-height & 0xFF);
+ bmi[9] = (byte)((-height >> 8) & 0xFF);
+ bmi[10] = (byte)((-height >> 16) & 0xFF);
+ bmi[11] = (byte)((-height >> 24) & 0xFF);
+ /* WORD biPlanes = 1 */
+ bmi[12] = 1;
+ bmi[13] = 0;
+ /* WORD biBitCount = 1 */
+ bmi[14] = 1;
+ bmi[15] = 0;
+ /* DWORD biCompression = BI_RGB = 0 */
+ bmi[16] = bmi[17] = bmi[18] = bmi[19] = 0;
+ /* DWORD biSizeImage = 0 (default) */
+ bmi[20] = bmi[21] = bmi[22] = bmi[23] = 0;
+ /* LONG biXPelsPerMeter = 0 */
+ bmi[24] = bmi[25] = bmi[26] = bmi[27] = 0;
+ /* LONG biYPelsPerMeter = 0 */
+ bmi[28] = bmi[29] = bmi[30] = bmi[31] = 0;
+ /* DWORD biClrUsed = 0 */
+ bmi[32] = bmi[33] = bmi[34] = bmi[35] = 0;
+ /* DWORD biClrImportant = 0 */
+ bmi[36] = bmi[37] = bmi[38] = bmi[39] = 0;
+ /* First color black */
+ bmi[40] = bmi[41] = bmi[42] = bmi[43] = 0;
+ /* Second color white */
+ bmi[44] = bmi[45] = bmi[46] = (byte)0xFF;
+ bmi[47] = 0;
+ OS.SelectObject(hBitmapDC, info.hbmMask);
+ /* Call with null lpBits to get the image size */
+ OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
+ imageSize = (bmi[20] & 0xFF) | ((bmi[21] & 0xFF) << 8) | ((bmi[22] & 0xFF) << 16) | ((bmi[23] & 0xFF) << 24);
+ maskData = new byte[imageSize];
+ int lpvMaskBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+ OS.GetDIBits(hBitmapDC, info.hbmMask, 0, height, lpvMaskBits, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(maskData, lpvMaskBits, imageSize);
+ OS.HeapFree(hHeap, 0, lpvMaskBits);
+ /* Loop to invert the mask */
+ for (int i = 0; i < maskData.length; i++) {
+ maskData[i] ^= -1;
+ }
+ /* Make sure mask scanlinePad is 2 */
+ int desiredScanline = (width + 7) / 8;
+ desiredScanline = desiredScanline + (desiredScanline % 2);
+ int realScanline = imageSize / height;
+ if (realScanline != desiredScanline) {
+ byte[] newData = new byte[desiredScanline * height];
+ int srcIndex = 0;
+ int destIndex = 0;
+ for (int i = 0; i < height; i++) {
+ System.arraycopy(maskData, srcIndex, newData, destIndex, desiredScanline);
+ destIndex += desiredScanline;
+ srcIndex += realScanline;
+ }
+ maskData = newData;
+ }
+ }
+ /* Clean up */
+ OS.HeapFree(hHeap, 0, lpvBits);
+ OS.SelectObject(hBitmapDC, hOldBitmap);
+ if (oldPalette != 0) {
+ OS.SelectPalette(hBitmapDC, oldPalette, false);
+ OS.RealizePalette(hBitmapDC);
+ }
+ OS.DeleteDC(hBitmapDC);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+
+ if (info.hbmColor != 0) OS.DeleteObject(info.hbmColor);
+ if (info.hbmMask != 0) OS.DeleteObject(info.hbmMask);
+ /* Construct and return the ImageData */
+ ImageData imageData = new ImageData(width, height, depth, palette, 4, data);
+ imageData.maskData = maskData;
+// imageData.maskPad = 4;
+ imageData.maskPad = 2;
+ return imageData;
+ }
+ case SWT.BITMAP: {
+ /* Get the basic BITMAP information */
+ bm = new BITMAP();
+ OS.GetObject(handle, BITMAP.sizeof, bm);
+ depth = bm.bmPlanes * bm.bmBitsPixel;
+ width = bm.bmWidth;
+ height = bm.bmHeight;
+ /* Find out whether this is a DIB or a DDB. */
+ boolean isDib = (bm.bmBits != 0);
+ DIBSECTION dib = null;
+ if (isDib) {
+ dib = new DIBSECTION();
+ OS.GetObject(handle, DIBSECTION.sizeof, dib);
+ }
+ /* Calculate number of colors */
+ int numColors = 0;
+ if (depth <= 8) {
+ if (isDib) {
+ numColors = dib.biClrUsed;
+ } else {
+ numColors = 1 << depth;
+ }
+ }
+ /* Create the BITMAPINFO */
+ byte[] bmi = null;
+ if (!isDib) {
+ bmi = new byte[40 + numColors * 4];
+ /* DWORD biSize = 40 */
+ bmi[0] = 40; bmi[1] = bmi[2] = bmi[3] = 0;
+ /* LONG biWidth = width */
+ bmi[4] = (byte)(width & 0xFF);
+ bmi[5] = (byte)((width >> 8) & 0xFF);
+ bmi[6] = (byte)((width >> 16) & 0xFF);
+ bmi[7] = (byte)((width >> 24) & 0xFF);
+ /* LONG biHeight = height */
+ bmi[8] = (byte)(-height & 0xFF);
+ bmi[9] = (byte)((-height >> 8) & 0xFF);
+ bmi[10] = (byte)((-height >> 16) & 0xFF);
+ bmi[11] = (byte)((-height >> 24) & 0xFF);
+ /* WORD biPlanes = 1 */
+ bmi[12] = 1;
+ bmi[13] = 0;
+ /* WORD biBitCount = bm.bmPlanes * bm.bmBitsPixel */
+ bmi[14] = (byte)(depth & 0xFF);
+ bmi[15] = (byte)((depth >> 8) & 0xFF);
+ /* DWORD biCompression = BI_RGB = 0 */
+ bmi[16] = bmi[17] = bmi[18] = bmi[19] = 0;
+ /* DWORD biSizeImage = 0 (default) */
+ bmi[20] = bmi[21] = bmi[22] = bmi[23] = 0;
+ /* LONG biXPelsPerMeter = 0 */
+ bmi[24] = bmi[25] = bmi[26] = bmi[27] = 0;
+ /* LONG biYPelsPerMeter = 0 */
+ bmi[28] = bmi[29] = bmi[30] = bmi[31] = 0;
+ /* DWORD biClrUsed = 0 */
+ bmi[32] = bmi[33] = bmi[34] = bmi[35] = 0;
+ /* DWORD biClrImportant = 0 */
+ bmi[36] = bmi[37] = bmi[38] = bmi[39] = 0;
+ }
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Create the DC and select the bitmap */
+ int hBitmapDC = OS.CreateCompatibleDC(hDC);
+ int hOldBitmap = OS.SelectObject(hBitmapDC, handle);
+ /* Select the palette if necessary */
+ int oldPalette = 0;
+ if (!isDib && depth <= 8) {
+ int hPalette = device.hPalette;
+ if (hPalette != 0) {
+ oldPalette = OS.SelectPalette(hBitmapDC, hPalette, false);
+ OS.RealizePalette(hBitmapDC);
+ }
+ }
+ /* Find the size of the image and allocate data */
+ int imageSize;
+ if (isDib) {
+ imageSize = dib.biSizeImage;
+ } else {
+ /* Call with null lpBits to get the image size */
+ OS.GetDIBits(hBitmapDC, handle, 0, height, 0, bmi, OS.DIB_RGB_COLORS);
+ imageSize = (bmi[20] & 0xFF) | ((bmi[21] & 0xFF) << 8) | ((bmi[22] & 0xFF) << 16) | ((bmi[23] & 0xFF) << 24);
+ }
+ byte[] data = new byte[imageSize];
+ /* Get the bitmap data */
+ if (isDib) {
+ OS.MoveMemory(data, bm.bmBits, imageSize);
+ } else {
+ int hHeap = OS.GetProcessHeap();
+ int lpvBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, imageSize);
+ OS.GetDIBits(hBitmapDC, handle, 0, height, lpvBits, bmi, OS.DIB_RGB_COLORS);
+ OS.MoveMemory(data, lpvBits, imageSize);
+ OS.HeapFree(hHeap, 0, lpvBits);
+ }
+ /* Calculate the palette */
+ PaletteData palette = null;
+ if (isDib) {
+ if (depth <= 8) {
+ byte[] colors = new byte[numColors * 4];
+ OS.GetDIBColorTable(hBitmapDC, 0, numColors, colors);
+ RGB[] rgbs = new RGB[numColors];
+ int colorIndex = 0;
+ for (int i = 0; i < rgbs.length; i++) {
+ rgbs[i] = new RGB(colors[colorIndex + 2] & 0xFF, colors[colorIndex + 1] & 0xFF, colors[colorIndex] & 0xFF);
+ colorIndex += 4;
+ }
+ palette = new PaletteData(rgbs);
+ } else if (depth == 16) {
+ palette = new PaletteData(0x7C00, 0x3E0, 0x1F);
+ } else if (depth == 24 || depth == 32) {
+ palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ } else {
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ } else {
+ if (depth <= 8) {
+ RGB[] rgbs = new RGB[numColors];
+ int srcIndex = 40;
+ for (int i = 0; i < numColors; i++) {
+ rgbs[i] = new RGB(bmi[srcIndex + 2] & 0xFF, bmi[srcIndex + 1] & 0xFF, bmi[srcIndex] & 0xFF);
+ srcIndex += 4;
+ }
+ palette = new PaletteData(rgbs);
+ } else if (depth == 16) {
+ palette = new PaletteData(0x7C00, 0x3E0, 0x1F);
+ } else if (depth == 24) {
+ palette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ } else if (depth == 32) {
+ palette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ } else {
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ }
+ /* Clean up */
+ OS.SelectObject(hBitmapDC, hOldBitmap);
+ if (oldPalette != 0) {
+ OS.SelectPalette(hBitmapDC, oldPalette, false);
+ OS.RealizePalette(hBitmapDC);
+ }
+ OS.DeleteDC(hBitmapDC);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+
+ /* Construct and return the ImageData */
+ ImageData imageData = new ImageData(width, height, depth, palette, 4, data);
+ imageData.transparentPixel = this.transparentPixel;
+ imageData.alpha = alpha;
+ if (alpha == -1 && alphaData != null) {
+ imageData.alphaData = new byte[alphaData.length];
+ System.arraycopy(alphaData, 0, imageData.alphaData, 0, alphaData.length);
+ }
+ return imageData;
+ }
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_FORMAT);
+ return null;
+ }
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 handle;
+}
+
+void init(Device device, int width, int height) {
+ if (width <= 0 || height <= 0) {
+ SWT.error (SWT.ERROR_INVALID_ARGUMENT);
+ }
+ this.device = device;
+ type = SWT.BITMAP;
+
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Fill the bitmap with the current background color */
+ handle = OS.CreateCompatibleBitmap(hDC, width, height);
+ int memDC = OS.CreateCompatibleDC(hDC);
+ int hOldBitmap = OS.SelectObject(memDC, handle);
+ OS.PatBlt(memDC, 0, 0, width, height, OS.PATCOPY);
+ OS.SelectObject(memDC, hOldBitmap);
+ OS.DeleteDC(memDC);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+}
+
+void init(Device device, ImageData i) {
+ if (i == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ this.device = device;
+ /*
+ * BUG in Windows 98:
+ * A monochrome DIBSection will display as solid black
+ * on Windows 98 machines, even though it contains the
+ * correct data. The fix is to convert 1-bit ImageData
+ * into 4-bit ImageData before creating the image.
+ */
+ /* Windows does not support 2-bit images. Convert to 4-bit image. */
+ if ((i.depth == 1 && i.getTransparencyType() != SWT.TRANSPARENCY_MASK) || i.depth == 2) {
+ ImageData img = new ImageData(i.width, i.height, 4, i.palette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, ImageData.MSB_FIRST, 0, 0, i.width, i.height, null, null, null, -1, null, 0,
+ img.data, img.depth, img.bytesPerLine, ImageData.MSB_FIRST, 0, 0, img.width, img.height, null, null, null,
+ false, false);
+ img.transparentPixel = i.transparentPixel;
+ img.maskPad = i.maskPad;
+ img.maskData = i.maskData;
+ img.alpha = i.alpha;
+ img.alphaData = i.alphaData;
+ i = img;
+ }
+ /*
+ * Windows supports 16-bit mask of (0x7C00, 0x3E0, 0x1F),
+ * 24-bit mask of (0xFF0000, 0xFF00, 0xFF) and 32-bit mask
+ * (0xFF000000, 0xFF0000, 0xFF00). Make sure the image is
+ * Windows-supported.
+ */
+ if (i.palette.isDirect) {
+ PaletteData newPalette = null;
+ PaletteData palette = i.palette;
+ int redMask = palette.redMask;
+ int greenMask = palette.greenMask;
+ int blueMask = palette.blueMask;
+ int order = ImageData.MSB_FIRST;
+ switch (i.depth) {
+ case 16:
+ order = ImageData.LSB_FIRST;
+ if (!(redMask == 0x7C00 && greenMask == 0x3E0 && blueMask == 0x1F)) {
+ newPalette = new PaletteData(0x7C00, 0x3E0, 0x1F);
+ }
+ break;
+ case 24:
+ if (!(redMask == 0xFF && greenMask == 0xFF00 && blueMask == 0xFF0000)) {
+ newPalette = new PaletteData(0xFF, 0xFF00, 0xFF0000);
+ }
+ break;
+ case 32:
+ if (!(redMask == 0xFF && greenMask == 0xFF00 && blueMask == 0xFF0000)) {
+ newPalette = new PaletteData(0xFF00, 0xFF0000, 0xFF000000);
+ }
+ break;
+ default:
+ SWT.error(SWT.ERROR_UNSUPPORTED_DEPTH);
+ }
+ if (newPalette != null) {
+ ImageData img = new ImageData(i.width, i.height, i.depth, newPalette);
+ ImageData.blit(ImageData.BLIT_SRC,
+ i.data, i.depth, i.bytesPerLine, order, 0, 0, i.width, i.height, redMask, greenMask, blueMask, -1, null, 0,
+ img.data, img.depth, img.bytesPerLine, order, 0, 0, img.width, img.height, newPalette.redMask, newPalette.greenMask, newPalette.blueMask,
+ false, false);
+ if (i.transparentPixel != -1) {
+ img.transparentPixel = newPalette.getPixel(palette.getRGB(i.transparentPixel));
+ }
+ img.maskPad = i.maskPad;
+ img.maskData = i.maskData;
+ img.alpha = i.alpha;
+ img.alphaData = i.alphaData;
+ i = img;
+ }
+ }
+ /* Construct bitmap info header by hand */
+ RGB[] rgbs = i.palette.getRGBs();
+ byte[] bmi;
+ if (i.palette.isDirect)
+ bmi = new byte[40];
+ else
+ bmi = new byte[40 + rgbs.length * 4];
+ /* DWORD biSize = 40 */
+ bmi[0] = 40; bmi[1] = 0; bmi[2] = 0; bmi[3] = 0;
+ /* LONG biWidth = width */
+ bmi[4] = (byte)(i.width & 0xFF);
+ bmi[5] = (byte)((i.width >> 8) & 0xFF);
+ bmi[6] = (byte)((i.width >> 16) & 0xFF);
+ bmi[7] = (byte)((i.width >> 24) & 0xFF);
+ /* LONG biHeight = height */
+ int height = -i.height;
+ bmi[8] = (byte)(height & 0xFF);
+ bmi[9] = (byte)((height >> 8) & 0xFF);
+ bmi[10] = (byte)((height >> 16) & 0xFF);
+ bmi[11] = (byte)((height >> 24) & 0xFF);
+ /* WORD biPlanes = 1 */
+ bmi[12] = 1;
+ bmi[13] = 0;
+ /* WORD biBitCount = depth */
+ bmi[14] = (byte)(i.depth & 0xFF);
+ bmi[15] = (byte)((i.depth >> 8) & 0xFF);
+ /* DWORD biCompression = BI_RGB = 0 */
+ bmi[16] = bmi[17] = bmi[18] = bmi[19] = 0;
+ /* DWORD biSizeImage = 0 (default) */
+ bmi[20] = bmi[21] = bmi[22] = bmi[23] = 0;
+ /* LONG biXPelsPerMeter = 0 */
+ bmi[24] = bmi[25] = bmi[26] = bmi[27] = 0;
+ /* LONG biYPelsPerMeter = 0 */
+ bmi[28] = bmi[29] = bmi[30] = bmi[31] = 0;
+ /* DWORD biClrUsed */
+ if (rgbs == null) {
+ bmi[32] = bmi[33] = bmi[34] = bmi[35] = 0;
+ } else {
+ bmi[32] = (byte)(rgbs.length & 0xFF);
+ bmi[33] = (byte)((rgbs.length >> 8) & 0xFF);
+ bmi[34] = (byte)((rgbs.length >> 16) & 0xFF);
+ bmi[35] = (byte)((rgbs.length >> 24) & 0xFF);
+ }
+ /* DWORD biClrImportant = 0 */
+ bmi[36] = bmi[37] = bmi[38] = bmi[39] = 0;
+ /* Set the rgb colors into the bitmap info */
+ int offset = 40;
+ if (!i.palette.isDirect) {
+ for (int j = 0; j < rgbs.length; j++) {
+ bmi[offset] = (byte)rgbs[j].blue;
+ bmi[offset + 1] = (byte)rgbs[j].green;
+ bmi[offset + 2] = (byte)rgbs[j].red;
+ bmi[offset + 3] = 0;
+ offset += 4;
+ }
+ }
+ int[] pBits = new int[1];
+ int hDib = OS.CreateDIBSection(0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0);
+ if (hDib == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ /* In case of a scanline pad other than 4, do the work to convert it */
+ byte[] data = i.data;
+ if (i.scanlinePad != 4 && (i.bytesPerLine % 4 != 0)) {
+ int newBpl = i.bytesPerLine + (4 - (i.bytesPerLine % 4));
+ byte[] newData = new byte[i.height * newBpl];
+ int srcPtr = 0;
+ int destPtr = 0;
+ for (int y = 0; y < i.height; y++) {
+ System.arraycopy(data, srcPtr, newData, destPtr, i.bytesPerLine);
+ srcPtr += i.bytesPerLine;
+ destPtr += newBpl;
+ }
+ data = newData;
+ }
+ OS.MoveMemory(pBits[0], data, data.length);
+ if (i.getTransparencyType() == SWT.TRANSPARENCY_MASK) {
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Create the color bitmap */
+ int hdcSrc = OS.CreateCompatibleDC(hDC);
+ OS.SelectObject(hdcSrc, hDib);
+ int hBitmap = OS.CreateCompatibleBitmap(hDC, i.width, i.height);
+ if (hBitmap == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ int hdcDest = OS.CreateCompatibleDC(hDC);
+ OS.SelectObject(hdcDest, hBitmap);
+ OS.BitBlt(hdcDest, 0, 0, i.width, i.height, hdcSrc, 0, 0, OS.SRCCOPY);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+
+ /* Create the mask */
+// int hHeap = OS.GetProcessHeap();
+// int bmBits = OS.HeapAlloc(hHeap, OS.HEAP_ZERO_MEMORY, i.maskData.length);
+// OS.MoveMemory(bmBits, i.maskData, i.maskData.length);
+// BITMAP bm = new BITMAP();
+// bm.bmWidth = i.width;
+// bm.bmHeight = i.height;
+// bm.bmWidthBytes = (((i.width + 7) / 8) + 3) / 4 * 4;
+// bm.bmPlanes = 1;
+// bm.bmBitsPixel = 1;
+// bm.bmBits = bmBits;
+// int hMask = OS.CreateBitmapIndirect(bm);
+// OS.HeapFree(hHeap, 0, bmBits);
+ int hMask = OS.CreateBitmap(i.width, i.height, 1, 1, i.maskData);
+ if (hMask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.SelectObject(hdcSrc, hMask);
+ OS.PatBlt(hdcSrc, 0, 0, i.width, i.height, OS.DSTINVERT);
+ OS.DeleteDC(hdcSrc);
+ OS.DeleteDC(hdcDest);
+
+ /* Create the icon */
+ ICONINFO info = new ICONINFO();
+ info.fIcon = true;
+ info.hbmColor = hBitmap;
+ info.hbmMask = hMask;
+ int hIcon = OS.CreateIconIndirect(info);
+ if (hIcon == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ OS.DeleteObject(hBitmap);
+ OS.DeleteObject(hMask);
+ OS.DeleteObject(hDib);
+ this.handle = hIcon;
+ this.type = SWT.ICON;
+ } else {
+ this.handle = hDib;
+ this.type = SWT.BITMAP;
+ this.transparentPixel = i.transparentPixel;
+ if (this.transparentPixel == -1) {
+ this.alpha = i.alpha;
+ if (i.alpha == -1 && i.alphaData != null) {
+ this.alphaData = new byte[i.alphaData.length];
+ System.arraycopy(i.alphaData, 0, this.alphaData, 0, alphaData.length);
+ }
+ }
+ }
+}
+
+/**
+ * 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
+ *
+ * @private
+ */
+public int internal_new_GC (GCData data) {
+ /*
+ * Create a new GC that can draw into the image.
+ * Only supported for bitmaps.
+ */
+ if (type != SWT.BITMAP || memGC != null) {
+ SWT.error(SWT.ERROR_INVALID_ARGUMENT);
+ }
+
+ /* Create a compatible HDC for the device */
+ int hDC = device.internal_new_GC(null);
+ int imageDC = OS.CreateCompatibleDC(hDC);
+ device.internal_dispose_GC(hDC, null);
+ if (imageDC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+
+ if (data != null) {
+ /* Set the GCData fields */
+ data.device = device;
+ data.image = this;
+ data.hFont = device.getSystemFont().handle;
+ }
+ return imageDC;
+}
+
+/**
+ * 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 handle the platform specific GC handle
+ * @param data the platform specific GC data
+ *
+ * @private
+ */
+public void internal_dispose_GC (int hDC, GCData data) {
+ OS.DeleteDC(hDC);
+}
+
+/**
+ * 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 handle == 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>
+ * This method has no effect if the receiver does not have a transparent
+ * pixel value.
+ *
+ * @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>
+ * </ul>
+ */
+public void setBackground(Color color) {
+ if (color == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ if (transparentPixel == -1) return;
+
+ /* Get the HDC for the device */
+ int hDC = device.internal_new_GC(null);
+
+ /* Change the background color in the image */
+ BITMAP bm = new BITMAP();
+ OS.GetObject(handle, BITMAP.sizeof, bm);
+ int hdcMem = OS.CreateCompatibleDC(hDC);
+ OS.SelectObject(hdcMem, handle);
+ int maxColors = 1 << bm.bmBitsPixel;
+ byte[] colors = new byte[maxColors * 4];
+ int numColors = OS.GetDIBColorTable(hdcMem, 0, maxColors, colors);
+ int offset = transparentPixel * 4;
+ colors[offset] = (byte)color.getBlue();
+ colors[offset + 1] = (byte)color.getGreen();
+ colors[offset + 2] = (byte)color.getRed();
+ OS.SetDIBColorTable(hdcMem, 0, numColors, colors);
+ OS.DeleteDC(hdcMem);
+
+ /* Release the HDC for the device */
+ device.internal_dispose_GC(hDC, null);
+}
+/**
+ * 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 handle the OS handle for the image
+ * @param hPalette the OS handle for the palette, or 0
+ *
+ * @private
+ */
+public static Image win32_new(Device device, int type, int handle) {
+ if (device == null) device = Device.getDevice();
+ Image image = new Image();
+ image.type = type;
+ image.handle = handle;
+ image.device = device;
+ return image;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
new file mode 100755
index 0000000000..4e5480999b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Region.java
@@ -0,0 +1,252 @@
+package org.eclipse.swt.graphics;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+
+/**
+ * Instances of this class represent areas of an x-y coordinate
+ * system that are agregates of the areas covered by a number
+ * of rectangles.
+ * <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>
+ */
+
+public final class Region {
+
+ /**
+ * the OS resource for the region
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+/**
+ * Constructs a new empty region.
+ */
+public Region () {
+ handle = OS.CreateRectRgn (0, 0, 0, 0);
+}
+
+/**
+ * Constructs a new region given a handle to the operating
+ * system resources that it should represent.
+ *
+ * @param handle the handle for the result
+ */
+Region(int handle) {
+ this.handle = handle;
+}
+
+/**
+ * Adds the given rectangle to the collection of rectangles
+ * 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>
+ * </ul>
+ */
+public void add (Rectangle rect) {
+ if (rect == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ int rectRgn = OS.CreateRectRgn (rect.x, rect.y, rect.x + rect.width, rect.y + rect.height);
+ OS.CombineRgn (handle, handle, rectRgn, OS.RGN_OR);
+ OS.DeleteObject (rectRgn);
+}
+
+/**
+ * Adds all of the rectangles which make up the area covered
+ * by the argument to the collection of rectangles 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>
+ * </ul>
+ */
+public void add (Region region) {
+ if (region == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ OS.CombineRgn (handle, handle, region.handle, OS.RGN_OR);
+}
+
+/**
+ * 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
+ */
+public boolean contains (int x, int y) {
+ return OS.PtInRegion (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>
+ */
+public boolean contains (Point pt) {
+ if (pt == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
+ return contains(pt.x, pt.y);
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the region. Applications must dispose of all regions which
+ * they allocate.
+ */
+public void dispose () {
+ if (handle != 0) OS.DeleteObject (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;
+ int rgn = ((Region)object).handle;
+ if (handle == rgn) return true;
+ if (rgn == 0) return false;
+ return OS.EqualRgn (handle, rgn);
+}
+
+/**
+ * Returns a rectangle which represents the rectangular
+ * union of the collection of rectangles the receiver
+ * maintains to describe its area.
+ *
+ * @return a bounding rectangle for the region
+ *
+ * @see Rectangle#union
+ */
+public Rectangle getBounds() {
+ RECT rect = new RECT();
+ OS.GetRgnBox(handle, rect);
+ return new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+}
+
+/**
+ * Returns an integer hash code for the receiver. Any two
+ * objects which 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 handle;
+}
+
+/**
+ * Returns <code>true</code> if the rectangle described by the
+ * arguments intersects with any of the rectangles the receiver
+ * mainains 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
+ *
+ * @see Rectangle#intersects
+ */
+public boolean intersects (int x, int y, int width, int height) {
+ RECT r = new RECT ();
+ OS.SetRect (r, x, y, x + width, y + height);
+ return OS.RectInRegion (handle, r);
+}
+
+/**
+ * Returns <code>true</code> if the given rectangle intersects
+ * with any of the rectangles the receiver mainains 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>
+ *
+ * @see Rectangle#intersects
+ */
+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
+ */
+public boolean isEmpty () {
+ RECT rect = new RECT ();
+ int result = OS.GetRgnBox (handle, rect);
+ if (result == OS.NULLREGION) return true;
+ return ((rect.right - rect.left) <= 0) || ((rect.bottom - rect.top) <= 0);
+}
+
+/**
+ * Invokes platform specific functionality to allocate a new region.
+ * <p>
+ * <b>IMPORTANT:</b> This method is <em>not</em> part of the public
+ * API for <code>Region</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 handle for the region
+ *
+ * @private
+ */
+public static Region win32_new(int handle) {
+ return new Region(handle);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Converter.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Converter.java
new file mode 100755
index 0000000000..6079208d46
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/Converter.java
@@ -0,0 +1,181 @@
+package org.eclipse.swt.internal;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * 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 {
+
+ static final byte [] NULL_BYTE_ARRAY = new byte [1];
+ static final byte [] EMPTY_BYTE_ARRAY = new byte [0];
+ static final char [] EMPTY_CHAR_ARRAY = new char [0];
+
+ static int CodePage;
+ static {
+ CodePage = OS.GetACP ();
+ }
+
+/**
+ * Returns the default code page for the platform where the
+ * application is currently running.
+ *
+ * @return the default code page
+ */
+public static int defaultCodePage () {
+ return CodePage;
+}
+
+/**
+ * Converts an array of bytes representing the platform's encoding,
+ * in the given code page, of some character data into an array of
+ * matching unicode characters.
+ *
+ * @param codePage the code page to use for conversion
+ * @param buffer the array of bytes to be converted
+ * @return the unicode conversion
+ */
+public static char [] mbcsToWcs (int codePage, byte [] buffer) {
+
+ /* Check for the simple cases */
+ if (codePage < 0 || buffer == null) {
+ return EMPTY_CHAR_ARRAY;
+ }
+ int length = buffer.length;
+ if (length == 0) {
+ return EMPTY_CHAR_ARRAY;
+ }
+
+ /*
+ * Optimize for English ASCII encoding. If no conversion is
+ * performed, it is safe to return any object that will also not
+ * be converted if this routine is called again with the result.
+ * This ensures that double conversion will not be performed
+ * on the same bytes. Note that this relies on the fact that
+ * lead bytes are never in the range 0..0x7F.
+ */
+ char [] lpWideCharStr = new char [length];
+ for (int i=0; i<length; i++) {
+ if ((buffer [i] & 0xFF) <= 0x7F) {
+ lpWideCharStr [i] = (char) buffer [i]; // all bytes <= 0x7F, so no ((char) (buffer[i]&0xFF)) needed
+ } else {
+ /* Convert from DBCS to UNICODE */
+ int cp = codePage != 0 ? codePage : CodePage;
+ int cchWideChar = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, length, null, 0);
+ if (cchWideChar == 0) return EMPTY_CHAR_ARRAY;
+ lpWideCharStr = new char [cchWideChar];
+ OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, length, lpWideCharStr, cchWideChar);
+ }
+ }
+ return lpWideCharStr;
+}
+
+/**
+ * Converts an array of chars (containing unicode data) to an array
+ * of bytes representing the platform's encoding, of those characters
+ * in the given code page.
+ *
+ * @param codePage the code page to use for conversion
+ * @param buffer the array of chars to be converted
+ * @return the platform encoding
+ */
+public static byte [] wcsToMbcs (int codePage, char [] buffer) {
+ return wcsToMbcs (0, buffer, false);
+}
+
+/**
+ * Converts an array of chars (containing unicode data) to an array
+ * of bytes representing the platform's encoding, of those characters
+ * in the given code page. If the termination flag is true, the resulting
+ * byte data will be null (zero) terminated.
+ *
+ * @param codePage the code page to use for conversion
+ * @param buffer the array of chars to be converted
+ * @param terminate <code>true</code> if the result should be null terminated and false otherwise.
+ * @return the platform encoding
+ */
+public static byte [] wcsToMbcs (int codePage, char [] buffer, boolean terminate) {
+
+ /* Check for the simple cases */
+ if (codePage < 0 || buffer == null) {
+ return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
+ }
+ int length = buffer.length;
+ if (length == 0) {
+ return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
+ }
+
+ /*
+ * Optimize for English ASCII encoding. This optimization
+ * relies on the fact that lead bytes can never be in the
+ * range 0..0x7F.
+ */
+ byte [] mbcs = new byte [(terminate) ? length + 1 : length];
+ for (int i=0; i<length; i++) {
+ if ((buffer [i] & 0xFF) <= 0x7F) {
+ mbcs [i] = (byte) buffer [i];
+ } else {
+ /* Convert from UNICODE to DBCS */
+ int cp = codePage != 0 ? codePage : CodePage;
+ int cchMultiByte = OS.WideCharToMultiByte (cp, 0, buffer, length, null, 0, null, null);
+ if (cchMultiByte == 0) return (terminate) ? NULL_BYTE_ARRAY : EMPTY_BYTE_ARRAY;
+ byte [] lpMultiByteStr = new byte [(terminate) ? cchMultiByte + 1 : cchMultiByte];
+ OS.WideCharToMultiByte (cp, 0, buffer, length, lpMultiByteStr, cchMultiByte, null, null);
+ return lpMultiByteStr;
+ }
+ }
+ return mbcs;
+}
+
+/**
+ * Converts a String (containing unicode data) to an array
+ * of bytes representing the platform's encoding, of those characters
+ * in the given code page.
+ *
+ * @param codePage the code page to use for conversion
+ * @param string the string to be converted
+ * @return the platform encoding
+ */
+public static byte [] wcsToMbcs (int codePage, String string) {
+ return wcsToMbcs (0, string, false);
+}
+
+/**
+ * Converts a String (containing unicode data) to an array
+ * of bytes representing the platform's encoding, of those characters
+ * in the given code page. If the termination flag is true, the resulting
+ * byte data will be null (zero) terminated.
+ *
+ * @param codePage the code page to use for conversion
+ * @param string the string to be converted
+ * @param terminate <code>true</code> if the result should be null terminated and false otherwise.
+ * @return the platform encoding
+ */
+public static byte [] wcsToMbcs (int codePage, String string, boolean terminate) {
+ if (terminate) {
+ if (string == null) return NULL_BYTE_ARRAY;
+ int count = string.length ();
+ char [] buffer = new char [count + 1];
+ string.getChars (0, count, buffer, 0);
+ return wcsToMbcs (codePage, buffer, false);
+ } else {
+ if (string == null) return EMPTY_BYTE_ARRAY;
+ int count = string.length ();
+ char [] buffer = new char [count];
+ string.getChars (0, count, buffer, 0);
+ return wcsToMbcs (codePage, buffer, false);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ACCEL.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ACCEL.java
new file mode 100755
index 0000000000..a1635211f0
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ACCEL.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class ACCEL {
+ public byte fVirt;
+ public short key;
+ public short cmd;
+ public static final int sizeof = 6;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BITMAP.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BITMAP.java
new file mode 100755
index 0000000000..56bb1f7609
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BITMAP.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class BITMAP {
+ public int bmType;
+ public int bmWidth;
+ public int bmHeight;
+ public int bmWidthBytes;
+ public short bmPlanes;
+ public short bmBitsPixel;
+ public int bmBits;
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java
new file mode 100755
index 0000000000..70dfd29124
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/BROWSEINFO.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class BROWSEINFO {
+ public int hwndOwner;
+ public int pidlRoot;
+ public int pszDisplayName;
+ public int lpszTitle;
+ public int ulFlags;
+ public int lpfn;
+ public int lParam;
+ public int iImage;
+ public static final int sizeof = 32;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java
new file mode 100755
index 0000000000..53942a1ab8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSECOLOR.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class CHOOSECOLOR {
+ public int lStructSize;
+ public int hwndOwner;
+ public int hInstance;
+ public int rgbResult;
+ public int lpCustColors;
+ public int Flags;
+ public int lCustData;
+ public int lpfnHook;
+ public int lpTemplateName;
+ public static final int sizeof = 36;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java
new file mode 100755
index 0000000000..e109598954
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CHOOSEFONT.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class CHOOSEFONT {
+ public int lStructSize;
+ public int hwndOwner;
+ public int hDC;
+ public int lpLogFont;
+ public int iPointSize;
+ public int Flags;
+ public int rgbColors;
+ public int lCustData;
+ public int lpfnHook;
+ public int lpTemplateName;
+ public int hInstance;
+ public int lpszStyle;
+ public short nFontType;
+ public short ___MISSING_ALIGNMENT__;
+ public int nSizeMin;
+ public int nSizeMax;
+ public static final int sizeof = 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java
new file mode 100755
index 0000000000..5e9e840ae2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/COMPOSITIONFORM.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class COMPOSITIONFORM {
+ public int dwStyle;
+// POINT ptCurrentPos;
+ public int x, y;
+// RECT rcArea;
+ public int left, top, right, bottom;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java
new file mode 100755
index 0000000000..ab2f691500
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/CREATESTRUCT.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class CREATESTRUCT {
+ public int lpCreateParams;
+ public int hInstance;
+ public int hMenu;
+ public int hwndParent;
+ public int cy;
+ public int cx;
+ public int y;
+ public int x;
+ public int style;
+ public int lpszName;
+ public int lpszClass;
+ public int dwExStyle;
+ public static final int sizeof = 48;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DIBSECTION.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DIBSECTION.java
new file mode 100755
index 0000000000..765c55bc06
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DIBSECTION.java
@@ -0,0 +1,26 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class DIBSECTION extends BITMAP {
+ public int biSize;
+ public int biWidth;
+ public int biHeight;
+ public short biPlanes;
+ public short biBitCount;
+ public int biCompression;
+ public int biSizeImage;
+ public int biXPelsPerMeter;
+ public int biYPelsPerMeter;
+ public int biClrUsed;
+ public int biClrImportant;
+ public int dsBitfields0;
+ public int dsBitfields1;
+ public int dsBitfields2;
+ public int dshSection;
+ public int dsOffset;
+ public static final int sizeof = 84;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java
new file mode 100755
index 0000000000..e29656f767
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DLLVERSIONINFO.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class DLLVERSIONINFO {
+ public int cbSize;
+ public int dwMajorVersion;
+ public int dwMinorVersion;
+ public int dwBuildNumber;
+ public int dwPlatformID;
+ public static final int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DOCINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DOCINFO.java
new file mode 100755
index 0000000000..3e3ebffa98
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DOCINFO.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class DOCINFO {
+ public int cbSize;
+ public int lpszDocName; // LPCTSTR
+ public int lpszOutput; // LPCTSTR
+ public int lpszDatatype;// LPCTSTR
+ public int fwType; // DWORD
+ public static final int sizeof = 20;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java
new file mode 100755
index 0000000000..127cfcfc1f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/DRAWITEMSTRUCT.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class DRAWITEMSTRUCT {
+ public int CtlType;
+ public int CtlID;
+ public int itemID;
+ public int itemAction;
+ public int itemState;
+ public int hwndItem;
+ public int hDC;
+// public RECT rcItem;
+ public int left, top, bottom, right;
+ public int itemData;
+ public static final int sizeof = 48;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HDITEM.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HDITEM.java
new file mode 100755
index 0000000000..0db94be9cc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HDITEM.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class HDITEM {
+ public int mask;
+ public int cxy;
+ public int pszText;
+ public int hbm;
+ public int cchTextMax;
+ public int fmt;
+ public int lParam;
+ public int iImage;
+ public int iOrder;
+ public static int sizeof = 36;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HELPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HELPINFO.java
new file mode 100755
index 0000000000..29e6ea3b8c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/HELPINFO.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class HELPINFO {
+ public int cbSize;
+ public int iContextType;
+ public int iCtrlId;
+ public int hItemHandle;
+ public int dwContextId;
+// POINT MousePos
+ public int x;
+ public int y;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ICONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ICONINFO.java
new file mode 100755
index 0000000000..1a2aa1c096
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/ICONINFO.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class ICONINFO {
+ public boolean fIcon;
+ public int xHotspot;
+ public int yHotspot;
+ public int hbmMask;
+ public int hbmColor;
+ public static final int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java
new file mode 100755
index 0000000000..0a3b430608
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/INITCOMMONCONTROLSEX.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class INITCOMMONCONTROLSEX {
+ public int dwSize;
+ public int dwICC;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java
new file mode 100755
index 0000000000..8e5a2f57f8
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGBRUSH.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LOGBRUSH {
+ public int lbStyle;
+ public int lbColor;
+ public int lbHatch;
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGFONT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGFONT.java
new file mode 100755
index 0000000000..b93622ba3b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGFONT.java
@@ -0,0 +1,33 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LOGFONT {
+ public int lfHeight;
+ public int lfWidth;
+ public int lfEscapement;
+ public int lfOrientation;
+ public int lfWeight;
+ public byte lfItalic;
+ public byte lfUnderline;
+ public byte lfStrikeOut;
+ public byte lfCharSet;
+ public byte lfOutPrecision;
+ public byte lfClipPrecision;
+ public byte lfQuality;
+ public byte lfPitchAndFamily;
+// TCHAR lfFaceName[LF_FACESIZE];
+ public byte
+ lfFaceName0, lfFaceName1, lfFaceName2, lfFaceName3,
+ lfFaceName4, lfFaceName5, lfFaceName6, lfFaceName7,
+ lfFaceName8, lfFaceName9, lfFaceName10, lfFaceName11,
+ lfFaceName12, lfFaceName13, lfFaceName14, lfFaceName15,
+ lfFaceName16, lfFaceName17, lfFaceName18, lfFaceName19,
+ lfFaceName20, lfFaceName21, lfFaceName22, lfFaceName23,
+ lfFaceName24, lfFaceName25, lfFaceName26, lfFaceName27,
+ lfFaceName28, lfFaceName29, lfFaceName30, lfFaceName31;
+ public static final int sizeof = 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGPEN.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGPEN.java
new file mode 100755
index 0000000000..dd603d3fbb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LOGPEN.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LOGPEN {
+ public int lopnStyle;
+// POINT lopnWidth;
+ public int x;
+ public int y;
+ public int lopnColor;
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LRESULT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LRESULT.java
new file mode 100755
index 0000000000..ef10f2502c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LRESULT.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LRESULT {
+ public int value;
+ public static final LRESULT ONE = new LRESULT (1);
+ public static final LRESULT ZERO = new LRESULT (0);
+public LRESULT (int value) {
+ this.value = value;
+}
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java
new file mode 100755
index 0000000000..1b24d98729
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVCOLUMN.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LVCOLUMN {
+ public int mask;
+ public int fmt;
+ public int cx;
+ public int pszText;
+ public int cchTextMax;
+ public int iSubItem;
+ public int iImage;
+ public int iOrder;
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java
new file mode 100755
index 0000000000..308d8570a9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVHITTESTINFO.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LVHITTESTINFO {
+// POINT pt;
+ public int x;
+ public int y;
+ public int flags;
+ public int iItem;
+ public int iSubItem;
+ public static int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVITEM.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVITEM.java
new file mode 100755
index 0000000000..148f75af15
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/LVITEM.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class LVITEM {
+ public int mask;
+ public int iItem;
+ public int iSubItem;
+ public int state;
+ public int stateMask;
+ public int pszText;
+ public int cchTextMax;
+ public int iImage;
+ public int lParam;
+ public int iIndent;
+ public static final int sizeof = 40;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java
new file mode 100755
index 0000000000..af35f68a5e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MEASUREITEMSTRUCT.java
@@ -0,0 +1,16 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class MEASUREITEMSTRUCT {
+ public int CtlType;
+ public int CtlID;
+ public int itemID;
+ public int itemWidth;
+ public int itemHeight;
+ public int itemData;
+ public static final int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUINFO.java
new file mode 100755
index 0000000000..c37823cac9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUINFO.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class MENUINFO {
+ public int cbSize;
+ public int fMask;
+ public int dwStyle;
+ public int cyMax;
+ public int hbrBack;
+ public int dwContextHelpID;
+ public int dwMenuData;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java
new file mode 100755
index 0000000000..86e7f9aa47
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MENUITEMINFO.java
@@ -0,0 +1,35 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class MENUITEMINFO {
+ public int cbSize;
+ public int fMask;
+ public int fType;
+ public int fState;
+ public int wID;
+ public int hSubMenu;
+ public int hbmpChecked;
+ public int hbmpUnchecked;
+ public int dwItemData;
+ public int dwTypeData;
+ public int cch;
+ public int hbmpItem;
+ public static final int sizeof;
+
+ /*
+ * Feature in Windows. The hbmpItem field requires Windows 4.10
+ * or greater. On Windows NT 4.0, passing in a larger struct size
+ * in the cbSize field does nothing. On Windows 95, the MENUITEMINFO
+ * calls fail when the struct size is too large. The fix is to ensure
+ * that the correct struct size is used for the Windows platform.
+ */
+ static {
+ int version = OS.GetVersion ();
+ int WIN32_MAJOR = version & 0x00FF, WIN32_MINOR = (version & 0xFFFF) >> 8;
+ sizeof = (WIN32_MAJOR << 16 | WIN32_MINOR) < (4 << 16 | 10) ? 44 : 48;
+ }
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MSG.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MSG.java
new file mode 100755
index 0000000000..5a6d263bbe
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/MSG.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class MSG {
+ public int hwnd;
+ public int message;
+ public int wParam;
+ public int lParam;
+ public int time;
+// public POINT pt;
+ public int x, y;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHDR.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHDR.java
new file mode 100755
index 0000000000..0e75279985
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHDR.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class NMHDR {
+ public int hwndFrom;
+ public int idFrom;
+ public int code;
+ public static final int sizeof = 12;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHEADER.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHEADER.java
new file mode 100755
index 0000000000..ffc6575b13
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMHEADER.java
@@ -0,0 +1,13 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class NMHEADER extends NMHDR {
+ public int iItem;
+ public int iButton;
+ public int pitem;
+ public static int sizeof = 24;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java
new file mode 100755
index 0000000000..b994609ff5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMLISTVIEW.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class NMLISTVIEW extends NMHDR {
+ public int iItem;
+ public int iSubItem;
+ public int uNewState;
+ public int uOldState;
+ public int uChanged;
+// public POINT ptAction;
+ public int x, y;
+ public int lParam;
+ public static int sizeof = 44;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
new file mode 100755
index 0000000000..b609a1a251
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTOOLBAR.java
@@ -0,0 +1,23 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class NMTOOLBAR extends NMHDR {
+ public int iItem;
+// TBBUTTON tbButton;
+ public int iBitmap;
+ public int idCommand;
+ public byte fsState;
+ public byte fsStyle;
+ public short ___MISSING_ALIGNMENT__;
+ public int dwData;
+ public int iString;
+ public int cchText;
+ public int pszText;
+// RECT rcButton;
+ public int left, top, right, bottom;
+ public static final int sizeof = 60;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java
new file mode 100755
index 0000000000..46326a0a88
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/NMTTDISPINFO.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class NMTTDISPINFO extends NMHDR {
+ public int lpszText;
+// public byte szText[80];
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7, pad8, pad9;
+ public int pad10, pad11, pad12, pad13, pad14, pad15, pad16, pad17, pad18, pad19;
+ public int hinst;
+ public int uFlags;
+ public int lParam;
+ public static final int sizeof = 108;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java
new file mode 100755
index 0000000000..40dbee0308
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OPENFILENAME.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class OPENFILENAME {
+ public int lStructSize;
+ public int hwndOwner;
+ public int hInstance;
+ public int lpstrFilter;
+ public int lpstrCustomFilter;
+ public int nMaxCustFilter;
+ public int nFilterIndex;
+ public int lpstrFile;
+ public int nMaxFile;
+ public int lpstrFileTitle;
+ public int nMaxFileTitle;
+ public int lpstrInitialDir;
+ public int lpstrTitle;
+ public int Flags;
+ public short nFileOffset;
+ public short nFileExtension;
+ public int lpstrDefExt;
+ public int lCustData;
+ public int lpfnHook;
+ public int lpTemplateName;
+ public static final int sizeof = 76;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
new file mode 100755
index 0000000000..dab3063332
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/OS.java
@@ -0,0 +1,4445 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+
+import org.eclipse.swt.internal.*;
+
+public class OS {
+
+ /* Load the SWT library */
+ static {
+ Callback.loadLibrary ();
+ }
+
+ /*
+ * NOTE: There is a bug in JVM 1.2 where loading
+ * a class with a large number of constants causes
+ * a segment fault to occur sometime later after
+ * the class is loaded. The fix is to break the
+ * class up into a hierarchy of classes that each
+ * contain a smaller number of constants. This
+ * fix is not necessary at this time but is required
+ * when all constants are uncommented. We have not
+ * done the research to determine the limit.
+ */
+
+ /* OLE Constants */
+ public static final int S_OK = 0;
+
+ /* Window Constants */
+ public static final int COLOR_BTNFACE = 15;
+ public static final int COLOR_BTNHIGHLIGHT = 20;
+ public static final int COLOR_BTNSHADOW = 16;
+ public static final int HDM_FIRST = 4608;
+ public static final int HDN_FIRST = -300;
+ public static final int LVM_FIRST = 0x1000;
+ public static final int NM_FIRST = 0;
+ public static final int TBN_FIRST = 0xFFFFFD44;
+ public static final int READ_CONTROL = 0x00020000;
+// public static final int STANDARD_RIGHTS_REQUIRED = 0x000F0000;
+ public static final int STANDARD_RIGHTS_READ = READ_CONTROL;
+// public static final int STANDARD_RIGHTS_WRITE = READ_CONTROL;
+// public static final int STANDARD_RIGHTS_EXECUTE = READ_CONTROL;
+// public static final int STANDARD_RIGHTS_ALL = 0x001F0000;
+ public static final int SYNCHRONIZE = 0x00100000;
+ public static final int TVHT_ONITEMICON = 0x0002;
+ public static final int TVHT_ONITEMLABEL = 0x0004;
+ public static final int TVHT_ONITEMSTATEICON = 0x0040;
+ public static final int TVN_FIRST = 0xFFFFFE70;
+ public static final int WM_USER = 0x400;
+
+// public static final byte [] LBSELCHSTRING = {0x63, 0x6F, 0x6D, 0x6D, 0x64, 0x6C, 0x67, 0x5F, 0x4C, 0x42, 0x53, 0x65, 0x6C, 0x43, 0x68, 0x61, 0x6E, 0x67, 0x65, 0x64, 0x4E, 0x6F, 0x74, 0x69, 0x66, 0x79, 0x0};
+ public static final byte [] PROGRESS_CLASS = {0x6D, 0x73, 0x63, 0x74, 0x6C, 0x73, 0x5F, 0x70, 0x72, 0x6F, 0x67, 0x72, 0x65, 0x73, 0x73, 0x33, 0x32, 0x0};
+ public static final byte [] RICHEDIT_CLASS = {0x52, 0x69, 0x63, 0x68, 0x45, 0x64, 0x69, 0x74, 0x32, 0x30, 0x41, 0x0};
+// public static final byte [] RICHEDIT_CLASS10 = {0x52, 0x49, 0x43, 0x48, 0x45, 0x44, 0x49, 0x54, 0x0};
+ public static final byte [] TOOLBARCLASSNAME = {0x54, 0x6F, 0x6F, 0x6C, 0x62, 0x61, 0x72, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0x33, 0x32, 0x0};
+ public static final byte [] TOOLTIPS_CLASS = {0x74, 0x6F, 0x6F, 0x6C, 0x74, 0x69, 0x70, 0x73, 0x5F, 0x63, 0x6C, 0x61, 0x73, 0x73, 0x33, 0x32, 0x0};
+ public static final byte [] TRACKBAR_CLASS = {0x6D, 0x73, 0x63, 0x74, 0x6C, 0x73, 0x5F, 0x74, 0x72, 0x61, 0x63, 0x6B, 0x62, 0x61, 0x72, 0x33, 0x32, 0x0};
+// public static final byte [] WC_HEADER = {0x53, 0x79, 0x73, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x33, 0x32, 0x0};
+ public static final byte [] WC_LISTVIEW = {0x53, 0x79, 0x73, 0x4C, 0x69, 0x73, 0x74, 0x56, 0x69, 0x65, 0x77, 0x33, 0x32, 0x0};
+ public static final byte [] WC_TABCONTROL = {0x53, 0x79, 0x73, 0x54, 0x61, 0x62, 0x43, 0x6F, 0x6E, 0x74, 0x72, 0x6F, 0x6C, 0x33, 0x32, 0x0};
+ public static final byte [] WC_TREEVIEW = {0x53, 0x79, 0x73, 0x54, 0x72, 0x65, 0x65, 0x56, 0x69, 0x65, 0x77, 0x33, 0x32, 0x0};
+
+// public static final byte WBF_BREAKAFTER = 0x40;
+// public static final byte WBF_BREAKLINE = 0x20;
+// public static final byte WBF_CLASS = 0x0F;
+// public static final byte WBF_ISWHITE = 0x10;
+
+/*** BEGIN SHGetFileInfo ***/
+// public static final int FILE_ATTRIBUTE_READONLY = 0x00000001;
+// public static final int FILE_ATTRIBUTE_HIDDEN = 0x00000002;
+// public static final int FILE_ATTRIBUTE_SYSTEM = 0x00000004;
+// public static final int FILE_ATTRIBUTE_DIRECTORY = 0x00000010;
+// public static final int FILE_ATTRIBUTE_ARCHIVE = 0x00000020;
+// public static final int FILE_ATTRIBUTE_DEVICE = 0x00000040;
+// public static final int FILE_ATTRIBUTE_NORMAL = 0x00000080;
+// public static final int FILE_ATTRIBUTE_TEMPORARY = 0x00000100;
+// public static final int FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200;
+// public static final int FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400;
+// public static final int FILE_ATTRIBUTE_COMPRESSED = 0x00000800;
+// public static final int FILE_ATTRIBUTE_OFFLINE = 0x00001000;
+// public static final int FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000;
+// public static final int FILE_ATTRIBUTE_ENCRYPTED = 0x00004000;
+// public static final int SHGFI_ICON = 0x000000100; // get icon
+// public static final int SHGFI_DISPLAYNAME = 0x000000200; // get display name
+// public static final int SHGFI_TYPENAME = 0x000000400; // get type name
+// public static final int SHGFI_ATTRIBUTES = 0x000000800; // get attributes
+// public static final int SHGFI_ICONLOCATION = 0x000001000; // get icon location
+// public static final int SHGFI_EXETYPE = 0x000002000; // return exe type
+// public static final int SHGFI_SYSICONINDEX = 0x000004000; // get system icon index
+// public static final int SHGFI_LINKOVERLAY = 0x000008000; // put a link overlay on icon
+// public static final int SHGFI_SELECTED = 0x000010000; // show icon in selected state
+// public static final int SHGFI_ATTR_SPECIFIED = 0x000020000; // get only specified attributes
+// public static final int SHGFI_LARGEICON = 0x000000000; // get large icon
+// public static final int SHGFI_SMALLICON = 0x000000001; // get small icon
+// public static final int SHGFI_OPENICON = 0x000000002; // get open icon
+// public static final int SHGFI_SHELLICONSIZE = 0x000000004; // get shell size icon
+// public static final int SHGFI_PIDL = 0x000000008; // pszPath is a pidl
+// public static final int SHGFI_USEFILEATTRIBUTES = 0x000000010; // use passed dwFileAttribute
+// public static final int SHGFI_ADDOVERLAYS = 0x000000020; // apply the appropriate overlays
+// public static final int SHGFI_OVERLAYINDEX = 0x000000040; // Get the index of the overlay
+/*** END SHGetFileInfo ***/
+
+/*** BEGIN DrawState ***/
+// public static final int DST_COMPLEX = 0x0000;
+// public static final int DST_TEXT = 0x0001;
+// public static final int DST_PREFIXTEXT = 0x0002;
+ public static final int DST_ICON = 0x0003;
+ public static final int DST_BITMAP = 0x0004;
+// public static final int DSS_NORMAL = 0x0000;
+// public static final int DSS_UNION = 0x0010;
+ public static final int DSS_DISABLED = 0x0020;
+// public static final int DSS_MONO = 0x0080;
+// public static final int DSS_HIDEPREFIX = 0x0200;
+// public static final int DSS_PREFIXONLY = 0x0400;
+// public static final int DSS_RIGHT = 0x8000;
+/*** END DrawState ***/
+
+/*** BEGIN Toolbar ***/
+// public static final int TBN_GETDISPINFOA = (TBN_FIRST - 16);
+// public static final int TBN_GETDISPINFOW = (TBN_FIRST - 17);
+// public static final int TBN_GETDISPINFO = (TBN_FIRST - 16);
+// public static final int I_IMAGECALLBACK = -1;
+ public static final int I_IMAGENONE = -2;
+/*** END Toolbar ***/
+
+/*** BEGIN TrackMouseEvent ***/
+ public static final int TME_HOVER = 0x00000001;
+ public static final int TME_LEAVE = 0x00000002;
+// public static final int TME_NONCLIENT = 0x00000010;
+ public static final int TME_QUERY = 0x40000000;
+// public static final int TME_CANCEL = 0x80000000;
+// public static final int HOVER_DEFAULT = 0xFFFFFFFF;
+ public static final int WM_MOUSEHOVER = 0x02A1;
+ public static final int WM_MOUSELEAVE = 0x02A3;
+// public static final int WM_NCMOUSEHOVER = 0x02A0;
+// public static final int WM_NCMOUSELEAVE = 0x02A2;
+/*** END TrackMouseEvent ***/
+
+/*** BEGIN ICC ***/
+// public static final int ICC_LISTVIEW_CLASSES = 0x00000001;
+// public static final int ICC_TREEVIEW_CLASSES = 0x00000002;
+// public static final int ICC_BAR_CLASSES = 0x00000004;
+// public static final int ICC_TAB_CLASSES = 0x00000008;
+// public static final int ICC_UPDOWN_CLASS = 0x00000010;
+// public static final int ICC_PROGRESS_CLASS = 0x00000020;
+// public static final int ICC_HOTKEY_CLASS = 0x00000040;
+// public static final int ICC_ANIMATE_CLASS = 0x00000080;
+// public static final int ICC_WIN95_CLASSES = 0x000000FF;
+// public static final int ICC_DATE_CLASSES = 0x00000100;
+// public static final int ICC_USEREX_CLASSES = 0x00000200;
+ public static final int ICC_COOL_CLASSES = 0x00000400;
+// public static final int ICC_INTERNET_CLASSES = 0x00000800;
+// public static final int ICC_PAGESCROLLER_CLASS = 0x00001000;
+// public static final int ICC_NATIVEFNTCTL_CLASS = 0x00002000;
+/*** END ICC ***/
+
+/*** BEGIN REBAR ***/
+ public static final int RBN_FIRST = -831;
+// public static final int RBN_LAST = -859;
+ public static final byte [] REBARCLASSNAME = {0x52, 0x65, 0x42, 0x61, 0x72, 0x57, 0x69, 0x6E, 0x64, 0x6F, 0x77, 0x33, 0x32, 0x0};
+// public static final int RBIM_IMAGELIST = 0x00000001;
+// public static final int RBS_TOOLTIPS = 0x0100;
+ public static final int RBS_VARHEIGHT = 0x0200;
+ public static final int RBS_BANDBORDERS = 0x0400;
+// public static final int RBS_FIXEDORDER = 0x0800;
+// public static final int RBS_REGISTERDROP = 0x1000;
+// public static final int RBS_AUTOSIZE = 0x2000;
+// public static final int RBS_VERTICALGRIPPER = 0x4000;
+// public static final int RBS_DBLCLKTOGGLE = 0x8000;
+ public static final int RBBS_BREAK = 0x00000001;
+// public static final int RBBS_FIXEDSIZE = 0x00000002;
+// public static final int RBBS_CHILDEDGE = 0x00000004;
+// public static final int RBBS_HIDDEN = 0x00000008;
+// public static final int RBBS_NOVERT = 0x00000010;
+// public static final int RBBS_FIXEDBMP = 0x00000020;
+ public static final int RBBS_VARIABLEHEIGHT = 0x00000040;
+ public static final int RBBS_GRIPPERALWAYS = 0x00000080;
+// public static final int RBBS_NOGRIPPER = 0x00000100;
+ public static final int RBBIM_STYLE = 0x00000001;
+ public static final int RBBIM_COLORS = 0x00000002;
+ public static final int RBBIM_TEXT = 0x00000004;
+// public static final int RBBIM_IMAGE = 0x00000008;
+ public static final int RBBIM_CHILD = 0x00000010;
+ public static final int RBBIM_CHILDSIZE = 0x00000020;
+ public static final int RBBIM_SIZE = 0x00000040;
+// public static final int RBBIM_BACKGROUND = 0x00000080;
+ public static final int RBBIM_ID = 0x00000100;
+ public static final int RBBIM_IDEALSIZE = 0x00000200;
+// public static final int RBBIM_LPARAM = 0x00000400;
+ public static final int RBBIM_HEADERSIZE = 0x00000800;
+ public static final int RB_INSERTBAND = (WM_USER + 1);
+ public static final int RB_DELETEBAND = (WM_USER + 2);
+// public static final int RB_GETBARINFO = (WM_USER + 3);
+// public static final int RB_SETBARINFO = (WM_USER + 4);
+ public static final int RB_GETBANDINFO = (WM_USER + 5);
+ public static final int RB_SETBANDINFO = (WM_USER + 6);
+// public static final int RB_SETPARENT = (WM_USER + 7);
+// public static final int RB_HITTEST = (WM_USER + 8);
+ public static final int RB_GETRECT = (WM_USER + 9);
+ public static final int RB_GETBANDCOUNT = (WM_USER + 12);
+// public static final int RB_GETROWCOUNT = (WM_USER + 13);
+// public static final int RB_GETROWHEIGHT = (WM_USER + 14);
+ public static final int RB_IDTOINDEX = (WM_USER + 16);
+// public static final int RB_GETTOOLTIPS = (WM_USER + 17);
+// public static final int RB_SETTOOLTIPS = (WM_USER + 18);
+ public static final int RB_SETBKCOLOR = (WM_USER + 19);
+ public static final int RB_GETBKCOLOR = (WM_USER + 20);
+ public static final int RB_SETTEXTCOLOR = (WM_USER + 21);
+ public static final int RB_GETTEXTCOLOR = (WM_USER + 22);
+// public static final int RB_SIZETORECT = (WM_USER + 23);
+// public static final int RB_SETCOLORSCHEME = CCM_SETCOLORSCHEME;
+// public static final int RB_GETCOLORSCHEME = CCM_GETCOLORSCHEME;
+// public static final int RB_BEGINDRAG = (WM_USER + 24);
+// public static final int RB_ENDDRAG = (WM_USER + 25);
+// public static final int RB_DRAGMOVE = (WM_USER + 26);
+ public static final int RB_GETBARHEIGHT = (WM_USER + 27);
+// public static final int RB_MINIMIZEBAND = (WM_USER + 30);
+// public static final int RB_MAXIMIZEBAND = (WM_USER + 31);
+// public static final int RB_GETDROPTARGET = (CCM_GETDROPTARGET);
+ public static final int RB_GETBANDBORDERS = (WM_USER + 34);
+// public static final int RB_SHOWBAND = (WM_USER + 35);
+// public static final int RB_SETPALETTE = (WM_USER + 37);
+// public static final int RB_GETPALETTE = (WM_USER + 38);
+ public static final int RB_MOVEBAND = (WM_USER + 39);
+// public static final int RB_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+// public static final int RB_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+ public static final int RBN_HEIGHTCHANGE = (RBN_FIRST - 0);
+// public static final int RBN_GETOBJECT = (RBN_FIRST - 1);
+// public static final int RBN_LAYOUTCHANGED = (RBN_FIRST - 2);
+// public static final int RBN_AUTOSIZE = (RBN_FIRST - 3);
+// public static final int RBN_BEGINDRAG = (RBN_FIRST - 4);
+// public static final int RBN_ENDDRAG = (RBN_FIRST - 5);
+// public static final int RBN_DELETINGBAND = (RBN_FIRST - 6);
+// public static final int RBN_DELETEDBAND = (RBN_FIRST - 7);
+// public static final int RBN_CHILDSIZE = (RBN_FIRST - 8);
+// public static final int RBNM_ID = 0x00000001;
+// public static final int RBNM_STYLE = 0x00000002;
+// public static final int RBNM_LPARAM = 0x00000004;
+// public static final int RBHT_NOWHERE = 0x0001;
+// public static final int RBHT_CLIENT = 0x0003;
+// public static final int RBHT_GRABBER = 0x0004;
+/*** END REBAR ***/
+
+/*** BEGIN IE5.01 TOOLBAR ***/
+ public static final int BTNS_BUTTON = 0x0000;
+ public static final int BTNS_SEP = 0x0001;
+ public static final int BTNS_CHECK = 0x0002;
+ public static final int BTNS_GROUP = 0x0004;
+ public static final int BTNS_CHECKGROUP = BTNS_GROUP | BTNS_CHECK;
+ public static final int BTNS_DROPDOWN = 0x0008;
+ public static final int BTNS_AUTOSIZE = 0x0010; // automatically calculate the cx of the button
+// public static final int BTNS_NOPREFIX = 0x0020; // this button should not have accel prefix
+// public static final int BTNS_SHOWTEXT = 0x0040; // ignored unless TBSTYLE_EX_MIXEDBUTTONS is set
+// public static final int BTNS_WHOLEDROPDOWN = 0x0080; // draw drop-down arrow, but without split arrow section
+// public static final int TBSTYLE_EX_MIXEDBUTTONS = 0x00000008;
+// public static final int TBSTYLE_EX_HIDECLIPPEDBUTTONS = 0x00000010; // don't show partially obscured buttons
+/*** END IE5.01 TOOLBAR ***/
+
+/** BEGIN IME **/
+// public static final int GCS_COMPREADSTR = 0x0001;
+// public static final int GCS_COMPREADATTR = 0x0002;
+// public static final int GCS_COMPREADCLAUSE = 0x0004;
+ public static final int GCS_COMPSTR = 0x0008;
+// public static final int GCS_COMPATTR = 0x0010;
+// public static final int GCS_COMPCLAUSE = 0x0020;
+// public static final int GCS_CURSORPOS = 0x0080;
+// public static final int GCS_DELTASTART = 0x0100;
+// public static final int GCS_RESULTREADSTR = 0x0200;
+// public static final int GCS_RESULTREADCLAUSE = 0x0400;
+ public static final int GCS_RESULTSTR = 0x0800;
+// public static final int GCS_RESULTCLAUSE = 0x1000;
+// public static final int CS_INSERTCHAR = 0x2000;
+// public static final int CS_NOMOVECARET = 0x4000;
+// public static final int IME_CMODE_ALPHANUMERIC = 0x0000;
+ public static final int IME_CMODE_NATIVE = 0x0001;
+// public static final int IME_CMODE_CHINESE = IME_CMODE_NATIVE;
+// public static final int IME_CMODE_HANGEUL = IME_CMODE_NATIVE;
+// public static final int IME_CMODE_HANGUL = IME_CMODE_NATIVE;
+// public static final int IME_CMODE_JAPANESE = IME_CMODE_NATIVE;
+ public static final int IME_CMODE_KATAKANA = 0x0002;
+// public static final int IME_CMODE_LANGUAGE = 0x0003;
+ public static final int IME_CMODE_FULLSHAPE = 0x0008;
+ public static final int IME_CMODE_ROMAN = 0x0010;
+// public static final int IME_CMODE_CHARCODE = 0x0020;
+// public static final int IME_CMODE_HANJACONVERT = 0x0040;
+// public static final int IME_CMODE_SOFTKBD = 0x0080;
+// public static final int IME_CMODE_NOCONVERSION = 0x0100;
+// public static final int IME_CMODE_EUDC = 0x0200;
+// public static final int IME_CMODE_SYMBOL = 0x0400;
+// public static final int IME_CMODE_FIXED = 0x0800;
+// public static final int CFS_DEFAULT = 0x0000;
+// public static final int CFS_RECT = 0x0001;
+ public static final int CFS_POINT = 0x0002;
+// public static final int CFS_FORCE_POSITION = 0x0020;
+// public static final int CFS_CANDIDATEPOS = 0x0040;
+// public static final int CFS_EXCLUDE = 0x0080;
+/* END IME */
+
+/* BEGIN 98/2000 MENUS */
+// public static final int MNS_NOCHECK = 0x80000000;
+// public static final int MNS_MODELESS = 0x40000000;
+// public static final int MNS_DRAGDROP = 0x20000000;
+// public static final int MNS_AUTODISMISS = 0x10000000;
+// public static final int MNS_NOTIFYBYPOS = 0x08000000;
+ public static final int MNS_CHECKORBMP = 0x04000000;
+// public static final int MIM_MAXHEIGHT = 0x00000001;
+// public static final int MIM_BACKGROUND = 0x00000002;
+// public static final int MIM_HELPID = 0x00000004;
+// public static final int MIM_MENUDATA = 0x00000008;
+ public static final int MIM_STYLE = 0x00000010;
+// public static final int MIM_APPLYTOSUBMENUS = 0x80000000;
+/* END 98/2000 MENUS */
+
+// public static final int ANSI_FIXED_FONT = 0xB;
+// public static final int ANSI_VAR_FONT = 0xC;
+// public static final int BDR_INNER = 0xC;
+// public static final int BDR_OUTER = 0x3;
+// public static final int BDR_RAISED = 0x5;
+// public static final int BDR_RAISEDINNER = 0x4;
+// public static final int BDR_RAISEDOUTER = 0x1;
+// public static final int BDR_SUNKEN = 0xA;
+// public static final int BDR_SUNKENINNER = 0x8;
+// public static final int BDR_SUNKENOUTER = 0x2;
+// public static final int BF_ADJUST = 0x2000;
+ public static final int BF_BOTTOM = 0x8;
+// public static final int BF_BOTTOMLEFT = 0x9;
+// public static final int BF_BOTTOMRIGHT = 0xC;
+// public static final int BF_DIAGONAL = 0x10;
+// public static final int BF_DIAGONAL_ENDBOTTOMLEFT = 0x19;
+// public static final int BF_DIAGONAL_ENDBOTTOMRIGHT = 0x1C;
+// public static final int BF_DIAGONAL_ENDTOPLEFT = 0x13;
+// public static final int BF_DIAGONAL_ENDTOPRIGHT = 0x16;
+// public static final int BF_FLAT = 0x4000;
+// public static final int BF_LEFT = 0x1;
+// public static final int BF_MIDDLE = 0x800;
+// public static final int BF_RIGHT = 0x4;
+// public static final int BF_MONO = 0x8000;
+// public static final int BF_RECT = 0xF;
+ public static final int BF_RIGHT = 0x4;
+// public static final int BF_SOFT = 0x1000;
+// public static final int BF_TOP = 0x2;
+// public static final int BF_TOPLEFT = 0x3;
+// public static final int BF_TOPRIGHT = 0x6;
+// public static final int BFFM_ENABLEOK = (WM_USER + 101);
+ public static final int BFFM_INITIALIZED = 1;
+// public static final int BFFM_SELCHANGED = 2;
+ public static final int BFFM_SETSELECTION = (WM_USER + 102);
+// public static final int BFFM_SETSELECTIONA = (WM_USER + 102);
+// public static final int BFFM_SETSELECTIONW = (WM_USER + 103);
+// public static final int BFFM_SETSTATUSTEXT = (WM_USER + 100);
+// public static final int BFFM_SETSTATUSTEXTA = (WM_USER + 100);
+// public static final int BFFM_SETSTATUSTEXTW = (WM_USER + 104);
+ public static final int BFFM_VALIDATEFAILED = 3;
+// public static final int BFFM_VALIDATEFAILEDA = 3; // lParam:szPath ret:1(cont),0(EndDialog)
+// public static final int BFFM_VALIDATEFAILEDW = 4; // lParam:wzPath ret:1(cont),0(EndDialog)
+// public static final int BIF_BROWSEFORCOMPUTER = 0x1000; // Browsing for Computers.
+// public static final int BIF_BROWSEFORPRINTER = 0x2000; // Browsing for Printers
+// public static final int BIF_BROWSEINCLUDEFILES = 0x4000; // Browsing for Everything
+// public static final int BIF_DONTGOBELOWDOMAIN = 0x0002; // For starting the Find Computer
+ public static final int BIF_EDITBOX = 0x0010;
+// public static final int BIF_RETURNFSANCESTORS = 0x0008;
+ public static final int BIF_RETURNONLYFSDIRS = 0x0001; // For finding a folder to start document searching
+// public static final int BIF_STATUSTEXT = 0x0004;
+ public static final int BIF_VALIDATE = 0x0020; // insist on valid result (or CANCEL)
+ public static final int BITSPIXEL = 12;
+// public static final int BLACK_BRUSH = 0x4;
+// public static final int BLACK_PEN = 0x7;
+// public static final int BLACKNESS = 0x42;
+ public static final int BM_CLICK = 0xF5;
+ public static final int BM_GETCHECK = 0xF0;
+// public static final int BM_GETIMAGE = 0xF6;
+// public static final int BM_GETSTATE = 0xF2;
+ public static final int BM_SETCHECK = 0xF1;
+ public static final int BM_SETIMAGE = 0xF7;
+// public static final int BM_SETSTATE = 0xF3;
+ public static final int BM_SETSTYLE = 0xF4;
+ public static final int BN_CLICKED = 0x0;
+// public static final int BN_DBLCLK = 0x5;
+// public static final int BN_DISABLE = 0x4;
+ public static final int BN_DOUBLECLICKED = 0x5;
+// public static final int BN_HILITE = 0x2;
+// public static final int BN_KILLFOCUS = 0x7;
+// public static final int BN_PAINT = 0x1;
+// public static final int BN_PUSHED = 0x2;
+// public static final int BN_SETFOCUS = 0x6;
+// public static final int BN_UNHILITE = 0x3;
+// public static final int BN_UNPUSHED = 0x3;
+// public static final int BOE_CONTEXTALIGNMENT = 0x0010;
+// public static final int BOE_CONTEXTREADING = 0x0008;
+// public static final int BOE_NEUTRALOVERRIDE = 0x0004;
+// public static final int BOE_PLAINTEXT = 0x0002;
+// public static final int BOE_RTLDIR = 0x0001;
+// public static final int BOM_CONTEXTALIGNMENT = 0x0010;
+// public static final int BOM_CONTEXTREADING = 0x0008;
+// public static final int BOM_DEFPARADIR = 0x0001;
+// public static final int BOM_NEUTRALOVERRIDE = 0x0004;
+// public static final int BOM_PLAINTEXT = 0x0002;
+// public static final int BS_AUTO3STATE = 0x6;
+// public static final int BS_AUTOCHECKBOX = 0x3;
+// public static final int BS_AUTORADIOBUTTON = 0x9;
+ public static final int BS_BITMAP = 0x80;
+// public static final int BS_BOTTOM = 0x800;
+ public static final int BS_CENTER = 0x300;
+ public static final int BS_CHECKBOX = 0x2;
+// public static final int BS_CHECKBOX = 0x2;
+ public static final int BS_DEFPUSHBUTTON = 0x1;
+// public static final int BS_DIBPATTERN = 0x5;
+// public static final int BS_DIBPATTERN8X8 = 0x8;
+// public static final int BS_DIBPATTERNPT = 0x6;
+ public static final int BS_FLAT = 0x8000;
+ public static final int BS_GROUPBOX = 0x7;
+// public static final int BS_HATCHED = 0x2;
+// public static final int BS_HOLLOW = 0x1;
+ public static final int BS_ICON = 0x40;
+// public static final int BS_INDEXED = 0x4;
+ public static final int BS_LEFT = 0x100;
+// public static final int BS_LEFTTEXT = 0x20;
+// public static final int BS_MULTILINE = 0x2000;
+ public static final int BS_NOTIFY = 0x4000;
+// public static final int BS_NULL = 0x1;
+ public static final int BS_OWNERDRAW = 0xB;
+// public static final int BS_PATTERN = 0x3;
+// public static final int BS_PATTERN8X8 = 0x7;
+ public static final int BS_PUSHBUTTON = 0x0;
+ public static final int BS_PUSHLIKE = 0x1000;
+ public static final int BS_RADIOBUTTON = 0x4;
+// public static final int BS_RADIOBUTTON = 0x4;
+ public static final int BS_RIGHT = 0x200;
+// public static final int BS_RIGHTBUTTON = 0x20;
+ public static final int BS_SOLID = 0x0;
+// public static final int BS_TEXT = 0x0;
+// public static final int BS_TOP = 0x400;
+// public static final int BS_USERBUTTON = 0x8;
+// public static final int BS_VCENTER = 0xC00;
+// public static final int BS3STATE = 0x5;
+// public static final int BSF_FLUSHDISK = 0x4;
+// public static final int BSF_FORCEIFHUNG = 0x20;
+// public static final int BSF_IGNORECURRENTTASK = 0x2;
+// public static final int BSF_NOHANG = 0x8;
+// public static final int BSF_NOTIMEOUTIFNOTHUNG = 0x40;
+// public static final int BSF_POSTMESSAGE = 0x10;
+// public static final int BSF_QUERY = 0x1;
+// public static final int BSM_ALLCOMPONENTS = 0x0;
+// public static final int BSM_APPLICATIONS = 0x8;
+// public static final int BSM_INSTALLABLEDRIVERS = 0x4;
+// public static final int BSM_NETDRIVER = 0x2;
+// public static final int BSM_VXDS = 0x1;
+ public static final int BST_CHECKED = 0x1;
+// public static final int BST_FOCUS = 0x8;
+// public static final int BST_INDETERMINATE = 0x2;
+// public static final int BST_PUSHED = 0x4;
+ public static final int BST_UNCHECKED = 0x0;
+ public static final int CB_ADDSTRING = 0x143;
+ public static final int CB_DELETESTRING = 0x144;
+// public static final int CB_DIR = 0x145;
+ public static final int CB_ERR = 0xFFFFFFFF;
+ public static final int CB_ERRSPACE = 0xFFFFFFFE;
+// public static final int CB_FINDSTRING = 0x14C;
+ public static final int CB_FINDSTRINGEXACT = 0x158;
+ public static final int CB_GETCOUNT = 0x146;
+ public static final int CB_GETCURSEL = 0x147;
+// public static final int CB_GETDROPPEDCONTROLRECT = 0x152;
+ public static final int CB_GETDROPPEDSTATE = 0x157;
+// public static final int CB_GETDROPPEDWIDTH = 0x15F;
+ public static final int CB_GETEDITSEL = 0x140;
+// public static final int CB_GETEXTENDEDUI = 0x156;
+// public static final int CB_GETHORIZONTALEXTENT = 0x15D;
+// public static final int CB_GETITEMDATA = 0x150;
+ public static final int CB_GETITEMHEIGHT = 0x154;
+ public static final int CB_GETLBTEXT = 0x148;
+ public static final int CB_GETLBTEXTLEN = 0x149;
+// public static final int CB_GETLOCALE = 0x15A;
+// public static final int CB_GETTOPINDEX = 0x15B;
+// public static final int CB_INITSTORAGE = 0x161;
+ public static final int CB_INSERTSTRING = 0x14A;
+ public static final int CB_LIMITTEXT = 0x141;
+// public static final int CB_MSGMAX = 0x162;
+// public static final int CB_N_D_R_CONTEXT = 0x14;
+// public static final int CB_OKAY = 0x0;
+ public static final int CB_RESETCONTENT = 0x14B;
+ public static final int CB_SELECTSTRING = 0x14D;
+ public static final int CB_SETCURSEL = 0x14E;
+// public static final int CB_SETDROPPEDWIDTH = 0x160;
+ public static final int CB_SETEDITSEL = 0x142;
+// public static final int CB_SETEXTENDEDUI = 0x155;
+// public static final int CB_SETHORIZONTALEXTENT = 0x15E;
+// public static final int CB_SETITEMDATA = 0x151;
+// public static final int CB_SETITEMHEIGHT = 0x153;
+// public static final int CB_SETLOCALE = 0x159;
+// public static final int CB_SETTOPINDEX = 0x15C;
+// public static final int CB_SHOWDROPDOWN = 0x14F;
+// public static final int CBF_FAIL_ADVISES = 0x4000;
+// public static final int CBF_FAIL_ALLSVRXACTIONS = 0x3F000;
+// public static final int CBF_FAIL_CONNECTIONS = 0x2000;
+// public static final int CBF_FAIL_EXECUTES = 0x8000;
+// public static final int CBF_FAIL_POKES = 0x10000;
+// public static final int CBF_FAIL_REQUESTS = 0x20000;
+// public static final int CBF_FAIL_SELFCONNECTIONS = 0x1000;
+// public static final int CBF_SKIP_ALLNOTIFICATIONS = 0x3C0000;
+// public static final int CBF_SKIP_CONNECT_CONFIRMS = 0x40000;
+// public static final int CBF_SKIP_DISCONNECTS = 0x200000;
+// public static final int CBF_SKIP_REGISTRATIONS = 0x80000;
+// public static final int CBF_SKIP_UNREGISTRATIONS = 0x100000;
+// public static final int CBM_INIT = 0x4;
+// public static final int CBN_CLOSEUP = 0x8;
+// public static final int CBN_DBLCLK = 0x2;
+// public static final int CBN_DROPDOWN = 0x7;
+ public static final int CBN_EDITCHANGE = 0x5;
+// public static final int CBN_EDITUPDATE = 0x6;
+// public static final int CBN_ERRSPACE = 0xFFFFFFFF;
+ public static final int CBN_KILLFOCUS = 0x4;
+ public static final int CBN_SELCHANGE = 0x1;
+// public static final int CBN_SELENDCANCEL = 0xA;
+// public static final int CBN_SELENDOK = 0x9;
+ public static final int CBN_SETFOCUS = 0x3;
+// public static final int CBR_BLOCK = 0xFFFFFFFF;
+// public static final int CBR110 = 0x6E;
+// public static final int CBR115200 = 0x1C200;
+// public static final int CBR1200 = 0x4B0;
+// public static final int CBR128000 = 0x1F400;
+// public static final int CBR14400 = 0x3840;
+// public static final int CBR19200 = 0x4B00;
+// public static final int CBR2400 = 0x960;
+// public static final int CBR256000 = 0x3E800;
+// public static final int CBR300 = 0x12C;
+// public static final int CBR38400 = 0x9600;
+// public static final int CBR4800 = 0x12C0;
+// public static final int CBR56000 = 0xDAC0;
+// public static final int CBR57600 = 0xE100;
+// public static final int CBR600 = 0x258;
+// public static final int CBR9600 = 0x2580;
+ public static final int CBS_AUTOHSCROLL = 0x40;
+// public static final int CBS_DISABLENOSCROLL = 0x800;
+ public static final int CBS_DROPDOWN = 0x2;
+ public static final int CBS_DROPDOWNLIST = 0x3;
+// public static final int CBS_HASSTRINGS = 0x200;
+// public static final int CBS_LOWERCASE = 0x4000;
+ public static final int CBS_NOINTEGRALHEIGHT = 0x400;
+// public static final int CBS_OEMCONVERT = 0x80;
+// public static final int CBS_OWNERDRAWFIXED = 0x10;
+// public static final int CBS_OWNERDRAWVARIABLE = 0x20;
+ public static final int CBS_SIMPLE = 0x1;
+// public static final int CBS_SORT = 0x100;
+// public static final int CBS_UPPERCASE = 0x2000;
+ public static final int CC_ANYCOLOR = 0x00000100;
+ public static final int CC_ENABLEHOOK = 0x00000010;
+// public static final int CC_ENABLETEMPLATE = 0x00000020;
+// public static final int CC_ENABLETEMPLATEHANDLE = 0x00000040;
+// public static final int CC_FULLOPEN = 0x00000002;
+// public static final int CC_PREVENTFULLOPEN = 0x00000004;
+ public static final int CC_RGBINIT = 0x00000001;
+// public static final int CC_SHOWHELP = 0x00000008;
+// public static final int CC_SOLIDCOLOR = 0x00000080;
+ public static final int CCM_FIRST = 0x2000;
+ public static final int CCM_SETBKCOLOR = CCM_FIRST + 1;
+// public static final int CCS_ADJUSTABLE = 0x00000020;
+// public static final int CCS_BOTTOM = 0x00000003;
+// public static final int CCS_LEFT = CCS_VERT | CCS_TOP;
+ public static final int CCS_NODIVIDER = 0x00000040;
+// public static final int CCS_NOMOVEX = CCS_VERT | CCS_NOMOVEY;
+// public static final int CCS_NOMOVEY = 0x00000002;
+// public static final int CCS_NOPARENTALIGN = 0x00000008;
+ public static final int CCS_NORESIZE = 0x00000004;
+// public static final int CCS_RIGHT = CCS_VERT | CCS_BOTTOM;
+// public static final int CCS_TOP = 0x00000001;
+// public static final int CCS_VERT = 0x00000080;
+// public static final int CDDS_ITEM = 0x00010000;
+// public static final int CDDS_ITEMPOSTERASE = (CDDS_ITEM | CDDS_POSTERASE);
+// public static final int CDDS_ITEMPOSTPAINT = (CDDS_ITEM | CDDS_POSTPAINT);
+// public static final int CDDS_ITEMPREERASE = (CDDS_ITEM | CDDS_PREERASE);
+// public static final int CDDS_ITEMPREPAINT = (CDDS_ITEM | CDDS_PREPAINT);
+// public static final int CDDS_POSTERASE = 0x00000004;
+// public static final int CDDS_POSTPAINT = 0x00000002;
+// public static final int CDDS_PREERASE = 0x00000003;
+// public static final int CDDS_PREPAINT = 0x00000001;
+// public static final int CDDS_SUBITEM = 0x00020000;
+// public static final int CDERR_DIALOGFAILURE = 0xFFFF;
+// public static final int CDERR_FINDRESFAILURE = 0x6;
+// public static final int CDERR_GENERALCODES = 0x0;
+// public static final int CDERR_INITIALIZATION = 0x2;
+// public static final int CDERR_LOADRESFAILURE = 0x7;
+// public static final int CDERR_LOADSTRFAILURE = 0x5;
+// public static final int CDERR_LOCKRESFAILURE = 0x8;
+// public static final int CDERR_MEMALLOCFAILURE = 0x9;
+// public static final int CDERR_MEMLOCKFAILURE = 0xA;
+// public static final int CDERR_NOHINSTANCE = 0x4;
+// public static final int CDERR_NOHOOK = 0xB;
+// public static final int CDERR_NOTEMPLATE = 0x3;
+// public static final int CDERR_REGISTERMSGFAIL = 0xC;
+// public static final int CDERR_STRUCTSIZE = 0x1;
+// public static final int CDIS_CHECKED = 0x0008;
+// public static final int CDIS_DEFAULT = 0x0020;
+// public static final int CDIS_DISABLED = 0x0004;
+// public static final int CDIS_FOCUS = 0x0010;
+// public static final int CDIS_GRAYED = 0x0002;
+// public static final int CDIS_HOT = 0x0040;
+// public static final int CDIS_INDETERMINATE = 0x0100;
+// public static final int CDIS_MARKED = 0x0080;
+// public static final int CDIS_SELECTED = 0x0001;
+// public static final int CDRF_DODEFAULT = 0x00000000;
+// public static final int CDRF_NEWFONT = 0x00000002;
+// public static final int CDRF_NOTIFYITEMDRAW = 0x00000020;
+// public static final int CDRF_NOTIFYPOSTERASE = 0x00000040;
+// public static final int CDRF_NOTIFYPOSTPAINT = 0x00000010;
+// public static final int CDRF_NOTIFYSUBITEMDRAW = 0x00000020;
+// public static final int CDRF_SKIPDEFAULT = 0x00000004;
+// public static final int CF_ANSIONLY = 0x00000400;
+// public static final int CF_APPLY = 0x00000200;
+// public static final int CF_BITMAP = 2;
+// public static final int CF_BOTH = (CF_SCREENFONTS | CF_PRINTERFONTS);
+// public static final int CF_DIB = 8;
+// public static final int CF_DIF = 5;
+// public static final int CF_DSPBITMAP = 0x0082;
+// public static final int CF_DSPENHMETAFILE = 0x008E;
+// public static final int CF_DSPMETAFILEPICT = 0x0083;
+// public static final int CF_DSPTEXT = 0x0081;
+ public static final int CF_EFFECTS = 0x00000100;
+// public static final int CF_ENABLEHOOK = 0x00000008;
+// public static final int CF_ENABLETEMPLATE = 0x00000010;
+// public static final int CF_ENABLETEMPLATEHANDLE = 0x00000020;
+// public static final int CF_ENHMETAFILE = 14;
+// public static final int CF_FIXEDPITCHONLY = 0x00004000;
+// public static final int CF_FORCEFONTEXIST = 0x00010000;
+// public static final int CF_GDIOBJFIRST = 0x0300;
+// public static final int CF_GDIOBJLAST = 0x03FF;
+// public static final int CF_HDROP = 15;
+ public static final int CF_INITTOLOGFONTSTRUCT = 0x00000040;
+// public static final int CF_LIMITSIZE = 0x00002000;
+// public static final int CF_LOCALE = 16;
+// public static final int CF_MAX = 17;
+// public static final int CF_METAFILEPICT = 3;
+// public static final int CF_NOFACESEL = 0x00080000;
+// public static final int CF_NOOEMFONTS = CF_NOVECTORFONTS;
+// public static final int CF_NOSCRIPTSEL = 0x00800000;
+// public static final int CF_NOSIMULATIONS = 0x00001000;
+// public static final int CF_NOSIZESEL = 0x00200000;
+// public static final int CF_NOSTYLESEL = 0x00100000;
+// public static final int CF_NOVECTORFONTS = 0x00000800;
+// public static final int CF_NOVERTFONTS = 0x01000000;
+// public static final int CF_OEMTEXT = 7;
+// public static final int CF_OWNERDISPLAY = 0x0080;
+// public static final int CF_PALETTE = 9;
+// public static final int CF_PENDATA = 10;
+// public static final int CF_PRINTERFONTS =0x00000002;
+// public static final int CF_PRIVATEFIRST = 0x0200;
+// public static final int CF_PRIVATELAST = 0x02FF;
+// public static final int CF_RETEXTOBJ = TEXT("RichEdit Text and Objects");
+// public static final int CF_RIFF = 11;
+// public static final int CF_RTF = TEXT("Rich Text Format");
+// public static final int CF_RTFNOOBJS = TEXT("Rich Text Format Without Objects");
+// public static final int CF_SCALABLEONLY = 0x00020000;
+ public static final int CF_SCREENFONTS = 0x00000001;
+// public static final int CF_SCRIPTSONLY = CF_ANSIONLY;
+// public static final int CF_SELECTSCRIPT = 0x00400000;
+// public static final int CF_SHOWHELP = 0x00000004;
+// public static final int CF_SYLK = 4;
+ public static final int CF_TEXT = 1;
+// public static final int CF_TIFF = 6;
+// public static final int CF_TTONLY = 0x00040000;
+// public static final int CF_UNICODETEXT = 13;
+ public static final int CF_USESTYLE = 0x00000080;
+// public static final int CF_WAVE = 12;
+// public static final int CF_WYSIWYG = 0x00008000;
+// public static final int CFE_ALLCAPS = CFM_ALLCAPS;
+// public static final int CFE_AUTOBACKCOLOR = CFM_BACKCOLOR;
+ public static final int CFE_AUTOCOLOR = 0x40000000;
+// public static final int CFE_BOLD = 0x0001;
+// public static final int CFE_DISABLED = CFM_DISABLED;
+// public static final int CFE_EMBOSS = CFM_EMBOSS;
+// public static final int CFE_HIDDEN = CFM_HIDDEN;
+// public static final int CFE_IMPRINT = CFM_IMPRINT;
+ public static final int CFE_ITALIC = 0x0002;
+// public static final int CFE_LINK = 0x0020;
+// public static final int CFE_OUTLINE = CFM_OUTLINE;
+// public static final int CFE_PROTECTED = 0x0010;
+// public static final int CFE_REVISED = CFM_REVISED;
+// public static final int CFE_SHADOW = CFM_SHADOW;
+// public static final int CFE_SMALLCAPS = CFM_SMALLCAPS;
+ public static final int CFE_STRIKEOUT = 0x0008;
+// public static final int CFE_SUBSCRIPT = 0x00010000;
+// public static final int CFE_SUPERSCRIPT = 0x00020000;
+ public static final int CFE_UNDERLINE = 0x0004;
+// public static final int CFM_ALL = (CFM_EFFECTS | CFM_SIZE | CFM_FACE | CFM_OFFSET | CFM_CHARSET);
+// public static final int CFM_ALL2 = (CFM_ALL | CFM_EFFECTS2 | CFM_BACKCOLOR | CFM_LCID | CFM_UNDERLINETYPE | CFM_WEIGHT | CFM_REVAUTHOR | CFM_SPACING | CFM_KERNING | CFM_STYLE | CFM_ANIMATION);
+// public static final int CFM_ALLCAPS = 0x0080;
+// public static final int CFM_ANIMATION = 0x00040000;
+// public static final int CFM_BACKCOLOR = 0x04000000;
+ public static final int CFM_BOLD = 0x00000001;
+ public static final int CFM_CHARSET = 0x08000000;
+ public static final int CFM_COLOR = 0x40000000;
+// public static final int CFM_DISABLED = 0x2000;
+// public static final int CFM_EFFECTS = (CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_COLOR | CFM_STRIKEOUT | CFE_PROTECTED | CFM_LINK);
+// public static final int CFM_EFFECTS2 = (CFM_EFFECTS | CFM_DISABLED | CFM_SMALLCAPS | CFM_ALLCAPS | CFM_HIDDEN | CFM_OUTLINE | CFM_SHADOW | CFM_EMBOSS | CFM_IMPRINT | CFM_DISABLED | CFM_REVISED | CFM_SUBSCRIPT | CFM_SUPERSCRIPT | CFM_BACKCOLOR);
+// public static final int CFM_EMBOSS = 0x0800;
+ public static final int CFM_FACE = 0x20000000;
+// public static final int CFM_HIDDEN = 0x0100;
+// public static final int CFM_IMPRINT = 0x1000;
+ public static final int CFM_ITALIC = 0x00000002;
+// public static final int CFM_KERNING = 0x00100000;
+// public static final int CFM_LCID = 0x02000000;
+// public static final int CFM_LINK = 0x00000020;
+// public static final int CFM_OFFSET = 0x10000000;
+// public static final int CFM_OUTLINE = 0x0200;
+// public static final int CFM_PROTECTED = 0x00000010;
+// public static final int CFM_REVAUTHOR = 0x00008000;
+// public static final int CFM_REVISED = 0x4000;
+// public static final int CFM_SHADOW = 0x0400;
+ public static final int CFM_SIZE = 0x80000000;
+// public static final int CFM_SMALLCAPS = 0x0040;
+// public static final int CFM_SPACING = 0x00200000;
+ public static final int CFM_STRIKEOUT = 0x00000008;
+// public static final int CFM_STYLE = 0x00080000;
+// public static final int CFM_SUBSCRIPT = CFE_SUBSCRIPT | CFE_SUPERSCRIPT;
+// public static final int CFM_SUPERSCRIPT = CFM_SUBSCRIPT;
+ public static final int CFM_UNDERLINE = 0x00000004;
+// public static final int CFM_UNDERLINETYPE = 0x00800000;
+ public static final int CFM_WEIGHT = 0x00400000;
+// public static final int CFU_CF1UNDERLINE = 0xFF;
+// public static final int CFU_INVERT = 0xFE;
+// public static final int CFU_UNDERLINE = 0x1;
+// public static final int CFU_UNDERLINEDOTTED = 0x4;
+// public static final int CFU_UNDERLINEDOUBLE = 0x3;
+// public static final int CFU_UNDERLINENONE = 0x0;
+// public static final int CFU_UNDERLINEWORD = 0x2;
+ public static final int CLR_INVALID = 0xFFFFFFFF;
+ public static final int COLOR_3DDKSHADOW = 21;
+ public static final int COLOR_3DFACE = COLOR_BTNFACE;
+ public static final int COLOR_3DHIGHLIGHT = COLOR_BTNHIGHLIGHT;
+ public static final int COLOR_3DHILIGHT = COLOR_BTNHIGHLIGHT;
+// public static final int COLOR_3DHILIGHT = COLOR_BTNHIGHLIGHT;
+ public static final int COLOR_3DLIGHT = 22;
+ public static final int COLOR_3DSHADOW = COLOR_BTNSHADOW;
+// public static final int COLOR_ACTIVEBORDER = 10;
+ public static final int COLOR_ACTIVECAPTION = 2;
+// public static final int COLOR_APPWORKSPACE = 12;
+// public static final int COLOR_BACKGROUND = 1;
+// public static final int COLOR_BTNHILIGHT = COLOR_BTNHIGHLIGHT;
+ public static final int COLOR_BTNTEXT = 18;
+ public static final int COLOR_CAPTIONTEXT = 9;
+// public static final int COLOR_DESKTOP = COLOR_BACKGROUND;
+ public static final int COLOR_GRADIENTACTIVECAPTION = 27;
+ public static final int COLOR_GRADIENTINACTIVECAPTION = 28;
+// public static final int COLOR_GRAYTEXT = 17;
+ public static final int COLOR_HIGHLIGHT = 13;
+ public static final int COLOR_HIGHLIGHTTEXT = 14;
+// public static final int COLOR_HOTLIGHT = 26;
+// public static final int COLOR_INACTIVEBORDER = 11;
+ public static final int COLOR_INACTIVECAPTION = 3;
+ public static final int COLOR_INACTIVECAPTIONTEXT = 19;
+ public static final int COLOR_INFOBK = 24;
+ public static final int COLOR_INFOTEXT = 23;
+ public static final int COLOR_MENU = 4;
+ public static final int COLOR_MENUTEXT = 7;
+ public static final int COLOR_SCROLLBAR = 0;
+ public static final int COLOR_WINDOW = 5;
+ public static final int COLOR_WINDOWFRAME = 6;
+ public static final int COLOR_WINDOWTEXT = 8;
+ public static final int COLORONCOLOR = 3;
+ public static final int COMPLEXREGION = 0x3;
+ public static final int CP_ACP = 0;
+// public static final int CP_MACCP = 2;
+// public static final int CP_OEMCP = 1;
+// public static final int CP_SYMBOL = 42;
+// public static final int CP_THREAD_ACP = 3;
+// public static final int CP_UTF7 = 65000;
+// public static final int CP_UTF8 = 65001;
+// public static final int CS_BYTEALIGNCLIENT = 0x1000;
+ public static final int CS_BYTEALIGNWINDOW = 0x2000;
+// public static final int CS_CLASSDC = 0x40;
+ public static final int CS_DBLCLKS = 0x8;
+// public static final int CS_GLOBALCLASS = 0x4000;
+ public static final int CS_HREDRAW = 0x2;
+// public static final int CS_IME = 0x10000;
+// public static final int CS_INSERTCHAR = 0x2000;
+// public static final int CS_KEYCVTWINDOW = 0x4;
+// public static final int CS_NOCLOSE = 0x200;
+// public static final int CS_NOKEYCVT = 0x100;
+// public static final int CS_NOMOVECARET = 0x4000;
+// public static final int CS_OWNDC = 0x20;
+// public static final int CS_PARENTDC = 0x80;
+// public static final int CS_SAVEBITS = 0x800;
+ public static final int CS_VREDRAW = 0x1;
+// public static final int CSF_EXPLORER = 0x8;
+// public static final int CSF_ONLYGETSOURCE = 0x4;
+// public static final int CSF_SHOWHELP = 0x1;
+// public static final int CSF_VALIDSOURCE = 0x2;
+ public static final int CW_USEDEFAULT = 0x80000000;
+ public static final int DCX_CACHE = 0x2;
+ public static final int DCX_CLIPCHILDREN = 0x8;
+ public static final int DCX_CLIPSIBLINGS = 0x10;
+// public static final int DCX_EXCLUDERGN = 0x40;
+// public static final int DCX_EXCLUDEUPDATE = 0x100;
+// public static final int DCX_INTERSECTRGN = 0x80;
+// public static final int DCX_INTERSECTUPDATE = 0x200;
+// public static final int DCX_LOCKWINDOWUPDATE = 0x400;
+// public static final int DCX_NORESETATTRS = 0x4;
+// public static final int DCX_PARENTCLIP = 0x20;
+// public static final int DCX_VALIDATE = 0x200000;
+// public static final int DCX_WINDOW = 0x1;
+ public static final int DEFAULT_CHARSET = 1;
+ public static final int DEFAULT_GUI_FONT = 0x11;
+// public static final int DEFAULT_PALETTE = 0xF;
+// public static final int DEVICE_DEFAULT_FONT = 0xE;
+// public static final int DEVICE_FONTTYPE = 0x0002;
+// public static final int DI_APPBANDING = 0x1;
+// public static final int DI_CHANNEL = 0x1;
+// public static final int DI_CHANNEL_WRITE = 0x2;
+// public static final int DI_COMPAT = 0x4;
+// public static final int DI_DEFAULTSIZE = 0x8;
+// public static final int DI_IMAGE = 0x2;
+// public static final int DI_MASK = 0x1;
+ public static final int DI_NORMAL = 0x3;
+// public static final int DI_READ_SPOOL_JOB = 0x3;
+// public static final int DIB_PAL_COLORS = 0x1;
+ public static final int DIB_RGB_COLORS = 0x0;
+// public static final int DIFFERENCE = 0xB;
+// public static final int DIGIT = 0x4;
+// public static final int DISABLE_LOAD = 0x4;
+// public static final int DISC_NO_FORCE = 0x40;
+// public static final int DISC_UPDATE_PROFILE = 0x1;
+// public static final int DISCARDCACHE_NOSAVE = 0x1;
+// public static final int DISCARDCACHE_SAVEIFDIRTY = 0x0;
+// public static final int DISP_CHANGE_BADFLAGS = 0xFFFFFFFC;
+// public static final int DISP_CHANGE_BADMODE = 0xFFFFFFFE;
+// public static final int DISP_CHANGE_FAILED = 0xFFFFFFFF;
+// public static final int DISP_CHANGE_NOTUPDATED = 0xFFFFFFFD;
+// public static final int DISP_CHANGE_RESTART = 0x1;
+// public static final int DISP_CHANGE_SUCCESSFUL = 0x0;
+// public static final int DISP_E_ARRAYISLOCKED = 0x8002000D;
+// public static final int DISP_E_BADCALLEE = 0x80020010;
+// public static final int DISP_E_BADINDEX = 0x8002000B;
+// public static final int DISP_E_BADPARAMCOUNT = 0x8002000E;
+// public static final int DISP_E_BADVARTYPE = 0x80020008;
+ public static final int DISP_E_EXCEPTION = 0x80020009;
+// public static final int DISP_E_EXCEPTION = 0x80020009;
+// public static final int DISP_E_MEMBERNOTFOUND = 0x80020003;
+// public static final int DISP_E_NONAMEDARGS = 0x80020007;
+// public static final int DISP_E_NOTACOLLECTION = 0x80020011;
+// public static final int DISP_E_OVERFLOW = 0x8002000A;
+// public static final int DISP_E_PARAMNOTFOUND = 0x80020004;
+// public static final int DISP_E_PARAMNOTOPTIONAL = 0x8002000F;
+// public static final int DISP_E_TYPEMISMATCH = 0x80020005;
+// public static final int DISP_E_UNKNOWNINTERFACE = 0x80020001;
+// public static final int DISP_E_UNKNOWNLCID = 0x8002000C;
+// public static final int DISP_E_UNKNOWNNAME = 0x80020006;
+// public static final int DISPATCH_METHOD = 0x1;
+// public static final int DISPATCH_PROPERTYGET = 0x2;
+// public static final int DISPATCH_PROPERTYPUT = 0x4;
+// public static final int DISPATCH_PROPERTYPUTREF = 0x8;
+// public static final int DISPID_ABOUTBOX = 0xFFFFFDD8;
+// public static final int DISPID_AMBIENT_APPEARANCE = 0xFFFFFD34;
+// public static final int DISPID_AMBIENT_AUTOCLIP = 0xFFFFFD35;
+// public static final int DISPID_AMBIENT_BACKCOLOR = 0xFFFFFD43;
+// public static final int DISPID_AMBIENT_DISPLAYASDEFAULT = 0xFFFFFD37;
+// public static final int DISPID_AMBIENT_DISPLAYNAME = 0xFFFFFD42;
+// public static final int DISPID_AMBIENT_FONT = 0xFFFFFD41;
+// public static final int DISPID_AMBIENT_FORECOLOR = 0xFFFFFD40;
+// public static final int DISPID_AMBIENT_LOCALEID = 0xFFFFFD3F;
+// public static final int DISPID_AMBIENT_MESSAGEREFLECT = 0xFFFFFD3E;
+// public static final int DISPID_AMBIENT_SCALEUNITS = 0xFFFFFD3D;
+// public static final int DISPID_AMBIENT_SHOWGRABHANDLES = 0xFFFFFD39;
+// public static final int DISPID_AMBIENT_SHOWHATCHING = 0xFFFFFD38;
+// public static final int DISPID_AMBIENT_SUPPORTSMNEMONICS = 0xFFFFFD36;
+// public static final int DISPID_AMBIENT_TEXTALIGN = 0xFFFFFD3C;
+// public static final int DISPID_AMBIENT_UIDEAD = 0xFFFFFD3A;
+// public static final int DISPID_AMBIENT_USERMODE = 0xFFFFFD3B;
+// public static final int DISPID_APPEARANCE = 0xFFFFFDF8;
+// public static final int DISPID_AUTOSIZE = 0xFFFFFE0C;
+// public static final int DISPID_BACKCOLOR = 0xFFFFFE0B;
+// public static final int DISPID_BACKSTYLE = 0xFFFFFE0A;
+// public static final int DISPID_BORDERCOLOR = 0xFFFFFE09;
+// public static final int DISPID_BORDERSTYLE = 0xFFFFFE08;
+// public static final int DISPID_BORDERVISIBLE = 0xFFFFFDF9;
+// public static final int DISPID_BORDERWIDTH = 0xFFFFFE07;
+// public static final int DISPID_CAPTION = 0xFFFFFDFA;
+// public static final int DISPID_CLICK = 0xFFFFFDA8;
+// public static final int DISPID_COLLECT = 0xFFFFFFF8;
+// public static final int DISPID_CONSTRUCTOR = 0xFFFFFFFA;
+// public static final int DISPID_DBLCLICK = 0xFFFFFDA7;
+// public static final int DISPID_DESTRUCTOR = 0xFFFFFFF9;
+// public static final int DISPID_DOCLICK = 0xFFFFFDD9;
+// public static final int DISPID_DRAWMODE = 0xFFFFFE05;
+// public static final int DISPID_DRAWSTYLE = 0xFFFFFE04;
+// public static final int DISPID_DRAWWIDTH = 0xFFFFFE03;
+// public static final int DISPID_ENABLED = 0xFFFFFDFE;
+// public static final int DISPID_ERROREVENT = 0xFFFFFDA0;
+// public static final int DISPID_EVALUATE = 0xFFFFFFFB;
+// public static final int DISPID_FILLCOLOR = 0xFFFFFE02;
+// public static final int DISPID_FILLSTYLE = 0xFFFFFE01;
+// public static final int DISPID_FONT = 0xFFFFFE00;
+// public static final int DISPID_FONT_BOLD = 0x3;
+// public static final int DISPID_FONT_CHARSET = 0x8;
+// public static final int DISPID_FONT_ITALIC = 0x4;
+// public static final int DISPID_FONT_NAME = 0x0;
+// public static final int DISPID_FONT_SIZE = 0x2;
+// public static final int DISPID_FONT_STRIKE = 0x6;
+// public static final int DISPID_FONT_UNDER = 0x5;
+// public static final int DISPID_FONT_WEIGHT = 0x7;
+// public static final int DISPID_FORECOLOR = 0xFFFFFDFF;
+// public static final int DISPID_HWND = 0xFFFFFDFD;
+// public static final int DISPID_KEYDOWN = 0xFFFFFDA6;
+// public static final int DISPID_KEYPRESS = 0xFFFFFDA5;
+// public static final int DISPID_KEYUP = 0xFFFFFDA4;
+// public static final int DISPID_MOUSEDOWN = 0xFFFFFDA3;
+// public static final int DISPID_MOUSEMOVE = 0xFFFFFDA2;
+// public static final int DISPID_MOUSEUP = 0xFFFFFDA1;
+// public static final int DISPID_NEWENUM = 0xFFFFFFFC;
+// public static final int DISPID_PICT_HANDLE = 0x0;
+// public static final int DISPID_PICT_HEIGHT = 0x5;
+// public static final int DISPID_PICT_HPAL = 0x2;
+// public static final int DISPID_PICT_RENDER = 0x6;
+// public static final int DISPID_PICT_TYPE = 0x3;
+// public static final int DISPID_PICT_WIDTH = 0x4;
+// public static final int DISPID_PROPERTYPUT = 0xFFFFFFFD;
+// public static final int DISPID_REFRESH = 0xFFFFFDDA;
+// public static final int DISPID_TABSTOP = 0xFFFFFDFC;
+// public static final int DISPID_TEXT = 0xFFFFFDFB;
+// public static final int DISPID_UNKNOWN = 0xFFFFFFFF;
+// public static final int DISPID_VALUE = 0x0;
+ public static final int DFC_BUTTON = 0x4;
+// public static final int DFC_CAPTION = 0x1;
+// public static final int DFC_MENU = 0x2;
+// public static final int DFCS_ADJUSTRECT = 0x2000;
+// public static final int DFCS_BUTTON3STATE = 0x8;
+ public static final int DFCS_BUTTONCHECK = 0x0;
+// public static final int DFCS_BUTTONPUSH = 0x10;
+// public static final int DFCS_BUTTONRADIO = 0x4;
+// public static final int DFCS_BUTTONRADIOIMAGE = 0x1;
+// public static final int DFCS_BUTTONRADIOMASK = 0x2;
+// public static final int DFCS_CAPTIONCLOSE = 0x0;
+// public static final int DFCS_CAPTIONHELP = 0x4;
+// public static final int DFCS_CAPTIONMAX = 0x2;
+// public static final int DFCS_CAPTIONMIN = 0x1;
+// public static final int DFCS_CAPTIONRESTORE = 0x3;
+ public static final int DFCS_CHECKED = 0x400;
+ public static final int DFC_SCROLL = 0x3;
+ public static final int DFCS_FLAT = 0x4000;
+ public static final int DFCS_INACTIVE = 0x100;
+// public static final int DFCS_MENUARROW = 0x0;
+// public static final int DFCS_MENUARROWRIGHT = 0x4;
+// public static final int DFCS_MENUBULLET = 0x2;
+// public static final int DFCS_MENUCHECK = 0x1;
+// public static final int DFCS_MONO = 0x8000;
+ public static final int DFCS_PUSHED = 0x200;
+// public static final int DFCS_SCROLLCOMBOBOX = 0x5;
+ public static final int DFCS_SCROLLDOWN = 0x1;
+ public static final int DFCS_SCROLLLEFT = 0x2;
+ public static final int DFCS_SCROLLRIGHT = 0x3;
+// public static final int DFCS_SCROLLSIZEGRIP = 0x8;
+// public static final int DFCS_SCROLLSIZEGRIPRIGHT = 0x10;
+ public static final int DFCS_SCROLLUP = 0x0;
+// public static final int DKGRAY_BRUSH = 0x3;
+ public static final int DLGC_BUTTON = 0x2000;
+// public static final int DLGC_DEFPUSHBUTTON = 0x10;
+// public static final int DLGC_HASSETSEL = 0x8;
+// public static final int DLGC_RADIOBUTTON = 0x40;
+ public static final int DLGC_STATIC = 0x100;
+// public static final int DLGC_UNDEFPUSHBUTTON = 0x20;
+ public static final int DLGC_WANTALLKEYS = 0x4;
+ public static final int DLGC_WANTARROWS = 0x1;
+// public static final int DLGC_WANTCHARS = 0x80;
+// public static final int DLGC_WANTMESSAGE = 0x4;
+ public static final int DLGC_WANTTAB = 0x2;
+ public static final int DSTINVERT = 0x550009;
+// public static final int DT_BOTTOM = 0x8;
+ public static final int DT_CALCRECT = 0x400;
+// public static final int DT_CENTER = 0x1;
+// public static final int DT_CHARSTREAM = 0x4;
+// public static final int DT_DISPFILE = 0x6;
+ public static final int DT_EDITCONTROL = 0x2000;
+// public static final int DT_END_ELLIPSIS = 0x8000;
+ public static final int DT_EXPANDTABS = 0x40;
+// public static final int DT_EXTERNALLEADING = 0x200;
+// public static final int DT_INTERNAL = 0x1000;
+ public static final int DT_LEFT = 0x0;
+// public static final int DT_METAFILE = 0x5;
+// public static final int DT_MODIFYSTRING = 0x10000;
+// public static final int DT_NOCLIP = 0x100;
+ public static final int DT_NOPREFIX = 0x800;
+// public static final int DT_PATH_ELLIPSIS = 0x4000;
+// public static final int DT_PLOTTER = 0x0;
+// public static final int DT_RASCAMERA = 0x3;
+// public static final int DT_RASDISPLAY = 0x1;
+// public static final int DT_RASPRINTER = 0x2;
+// public static final int DT_RIGHT = 0x2;
+// public static final int DT_RTLREADING = 0x20000;
+ public static final int DT_SINGLELINE = 0x20;
+// public static final int DT_TABSTOP = 0x80;
+// public static final int DT_TOP = 0x0;
+// public static final int DT_VCENTER = 0x4;
+// public static final int DT_WORD_ELLIPSIS = 0x40000;
+ public static final int DT_WORDBREAK = 0x10;
+// public static final int DTR_CONTROL_DISABLE = 0x0;
+// public static final int DTR_CONTROL_ENABLE = 0x1;
+// public static final int DTR_CONTROL_HANDSHAKE = 0x2;
+// public static final int E_NOINTERFACE = 0x80004002;
+// public static final int E_NOTIMPL = 0x80004001;
+ public static final int ECO_AUTOHSCROLL = 0x00000080;
+// public static final int ECO_AUTOVSCROLL = 0x00000040;
+// public static final int ECO_AUTOWORDSELECTION = 0x00000001;
+// public static final int ECO_NOHIDESEL = 0x00000100;
+// public static final int ECO_READONLY = 0x00000800;
+// public static final int ECO_SAVESEL = 0x00008000;
+// public static final int ECO_SELECTIONBAR = 0x01000000;
+// public static final int ECO_VERTICAL = 0x00400000;
+// public static final int ECO_WANTRETURN = 0x00001000;
+ public static final int ECOOP_AND = 0x0003;
+ public static final int ECOOP_OR = 0x0002;
+// public static final int ECOOP_SET = 0x0001;
+// public static final int ECOOP_XOR = 0x0004;
+// public static final int EDGE_BUMP = 0x9;
+ public static final int EDGE_ETCHED = 0x6;
+// public static final int EDGE_RAISED = 0x5;
+ public static final int EDGE_SUNKEN = 0xA;
+// public static final int EM_AUTOURLDETECT = (WM_USER + 91);
+// public static final int EM_CANPASTE = (WM_USER + 50);
+// public static final int EM_CANREDO = (WM_USER + 85);
+ public static final int EM_CANUNDO = 0xC6;
+ public static final int EM_CHARFROMPOS = 0xD7;
+ public static final int EM_DISPLAYBAND = (WM_USER + 51);
+// public static final int EM_EMPTYUNDOBUFFER = 0xCD;
+// public static final int EM_EXGETSEL = (WM_USER + 52);
+// public static final int EM_EXLIMITTEXT = (WM_USER + 53);
+// public static final int EM_EXLINEFROMCHAR = (WM_USER + 54);
+// public static final int EM_EXSETSEL = (WM_USER + 55);
+// public static final int EM_FINDTEXT = (WM_USER + 56);
+// public static final int EM_FINDTEXTEX = (WM_USER + 79);
+// public static final int EM_FINDTEXTEXW = (WM_USER + 124);
+// public static final int EM_FINDTEXTW = (WM_USER + 123);
+// public static final int EM_FINDWORDBREAK = (WM_USER + 76);
+// public static final int EM_FMTLINES = 0xC8;
+// public static final int EM_FORMATRANGE = (WM_USER + 57);
+// public static final int EM_GETAUTOURLDETECT = (WM_USER + 92);
+// public static final int EM_GETBIDIOPTIONS = (WM_USER + 201);
+// public static final int EM_GETCHARFORMAT = (WM_USER + 58);
+// public static final int EM_GETEVENTMASK = (WM_USER + 59);
+ public static final int EM_GETFIRSTVISIBLELINE = 0xCE;
+// public static final int EM_GETHANDLE = 0xBD;
+// public static final int EM_GETIMECOMPMODE = (WM_USER + 122);
+// public static final int EM_GETLANGOPTIONS = (WM_USER + 121);
+ public static final int EM_GETLIMITTEXT = 0xD5;
+ public static final int EM_GETLINE = 0xC4;
+ public static final int EM_GETLINECOUNT = 0xBA;
+// public static final int EM_GETMARGINS = 0xD4;
+// public static final int EM_GETMODIFY = 0xB8;
+// public static final int EM_GETOLEINTERFACE = (WM_USER + 60);
+// public static final int EM_GETOPTIONS = (WM_USER + 78);
+// public static final int EM_GETPARAFORMAT = (WM_USER + 61);
+ public static final int EM_GETPASSWORDCHAR = 0xD2;
+ public static final int EM_GETRECT = 0xB2;
+// public static final int EM_GETREDONAME = (WM_USER + 87);
+ public static final int EM_GETSCROLLPOS = (WM_USER + 221);
+ public static final int EM_GETSEL = 0xB0;
+// public static final int EM_GETSELTEXT = (WM_USER + 62);
+// public static final int EM_GETTEXTEX = (WM_USER + 94);
+// public static final int EM_GETTEXTLENGTHEX = (WM_USER + 95);
+// public static final int EM_GETTEXTMODE = (WM_USER + 90);
+// public static final int EM_GETTEXTRANGE = (WM_USER + 75);
+// public static final int EM_GETTHUMB = 0xBE;
+// public static final int EM_GETUNDONAME = (WM_USER + 86);
+// public static final int EM_GETWORDBREAKPROC = 0xD1;
+// public static final int EM_GETWORDBREAKPROCEX = (WM_USER + 80);
+// public static final int EM_HIDESELECTION = (WM_USER + 63);
+ public static final int EM_LIMITTEXT = 0xC5;
+ public static final int EM_LINEFROMCHAR = 0xC9;
+ public static final int EM_LINEINDEX = 0xBB;
+ public static final int EM_LINELENGTH = 0xC1;
+ public static final int EM_LINESCROLL = 0xB6;
+// public static final int EM_PASTESPECIAL = (WM_USER + 64);
+ public static final int EM_POSFROMCHAR = 0xD6;
+// public static final int EM_REDO = (WM_USER + 84);
+ public static final int EM_REPLACESEL = 0xC2;
+// public static final int EM_REQUESTRESIZE = (WM_USER + 65);
+// public static final int EM_SCROLL = 0xB5;
+ public static final int EM_SCROLLCARET = 0xB7;
+// public static final int EM_SELECTIONTYPE = (WM_USER + 66);
+// public static final int EM_SETBIDIOPTIONS = (WM_USER + 200);
+ public static final int EM_SETBKGNDCOLOR = (WM_USER + 67);
+// public static final int EM_SETCHARFORMAT = (WM_USER + 68);
+// public static final int EM_SETEVENTMASK = (WM_USER + 69);
+// public static final int EM_SETHANDLE = 0xBC;
+// public static final int EM_SETLANGOPTIONS = (WM_USER + 120);
+ public static final int EM_SETLIMITTEXT = 0xC5;
+// public static final int EM_SETMARGINS = 0xD3;
+// public static final int EM_SETMODIFY = 0xB9;
+// public static final int EM_SETOLECALLBACK = (WM_USER + 70);
+ public static final int EM_SETOPTIONS = (WM_USER + 77);
+// public static final int EM_SETPALETTE = (WM_USER + 93);
+ public static final int EM_SETPARAFORMAT = (WM_USER + 71);
+ public static final int EM_SETPASSWORDCHAR = 0xCC;
+ public static final int EM_SETREADONLY = 0xCF;
+// public static final int EM_SETRECT = 0xB3;
+// public static final int EM_SETRECTNP = 0xB4;
+// public static final int EM_SETSCROLLPOS = (WM_USER + 222);
+ public static final int EM_SETSEL = 0xB1;
+ public static final int EM_SETTABSTOPS = 0xCB;
+// public static final int EM_SETTARGETDEVICE = (WM_USER + 72);
+// public static final int EM_SETTEXTMODE = (WM_USER + 89);
+// public static final int EM_SETUNDOLIMIT = (WM_USER + 82);
+// public static final int EM_SETWORDBREAKPROC = 0xD0;
+// public static final int EM_SETWORDBREAKPROCEX = (WM_USER + 81);
+// public static final int EM_SHOWSCROLLBAR = (WM_USER + 96);
+// public static final int EM_STOPGROUPTYPING = (WM_USER + 88);
+// public static final int EM_STREAMIN = (WM_USER + 73);
+// public static final int EM_STREAMOUT = (WM_USER + 74);
+// public static final int EM_UNDO = 0xC7;
+// public static final int EMBDHLP_CREATENOW = 0x0;
+// public static final int EMBDHLP_DELAYCREATE = 0x10000;
+// public static final int EMBDHLP_INPROC_HANDLER = 0x0;
+// public static final int EMBDHLP_INPROC_SERVER = 0x1;
+// public static final int EMR_ABORTPATH = 0x44;
+// public static final int EMR_ANGLEARC = 0x29;
+// public static final int EMR_ARC = 0x2D;
+// public static final int EMR_ARCTO = 0x37;
+// public static final int EMR_BEGINPATH = 0x3B;
+// public static final int EMR_BITBLT = 0x4C;
+// public static final int EMR_CHORD = 0x2E;
+// public static final int EMR_CLOSEFIGURE = 0x3D;
+// public static final int EMR_CREATEBRUSHINDIRECT = 0x27;
+// public static final int EMR_CREATECOLORSPACE = 0x63;
+// public static final int EMR_CREATEDIBPATTERNBRUSHPT = 0x5E;
+// public static final int EMR_CREATEMONOBRUSH = 0x5D;
+// public static final int EMR_CREATEPALETTE = 0x31;
+// public static final int EMR_CREATEPEN = 0x26;
+// public static final int EMR_DELETECOLORSPACE = 0x65;
+// public static final int EMR_DELETEOBJECT = 0x28;
+// public static final int EMR_ELLIPSE = 0x2A;
+// public static final int EMR_ENDPATH = 0x3C;
+// public static final int EMR_EOF = 0xE;
+// public static final int EMR_EXCLUDECLIPRECT = 0x1D;
+// public static final int EMR_EXTCREATEFONTINDIRECTW = 0x52;
+// public static final int EMR_EXTCREATEPEN = 0x5F;
+// public static final int EMR_EXTFLOODFILL = 0x35;
+// public static final int EMR_EXTSELECTCLIPRGN = 0x4B;
+// public static final int EMR_EXTTEXTOUTA = 0x53;
+// public static final int EMR_EXTTEXTOUTW = 0x54;
+// public static final int EMR_FILLPATH = 0x3E;
+// public static final int EMR_FILLRGN = 0x47;
+// public static final int EMR_FLATTENPATH = 0x41;
+// public static final int EMR_FRAMERGN = 0x48;
+// public static final int EMR_GDICOMMENT = 0x46;
+// public static final int EMR_HEADER = 0x1;
+// public static final int EMR_INTERSECTCLIPRECT = 0x1E;
+// public static final int EMR_INVERTRGN = 0x49;
+// public static final int EMR_LINETO = 0x36;
+// public static final int EMR_MASKBLT = 0x4E;
+// public static final int EMR_MAX = 0x65;
+// public static final int EMR_MIN = 0x1;
+// public static final int EMR_MODIFYWORLDTRANSFORM = 0x24;
+// public static final int EMR_MOVETOEX = 0x1B;
+// public static final int EMR_OFFSETCLIPRGN = 0x1A;
+// public static final int EMR_PAINTRGN = 0x4A;
+// public static final int EMR_PIE = 0x2F;
+// public static final int EMR_PLGBLT = 0x4F;
+// public static final int EMR_POLYBEZIER = 0x2;
+// public static final int EMR_POLYBEZIER16 = 0x55;
+// public static final int EMR_POLYBEZIERTO = 0x5;
+// public static final int EMR_POLYBEZIERTO16 = 0x58;
+// public static final int EMR_POLYDRAW = 0x38;
+// public static final int EMR_POLYDRAW16 = 0x5C;
+// public static final int EMR_POLYGON = 0x3;
+// public static final int EMR_POLYGON16 = 0x56;
+// public static final int EMR_POLYLINE = 0x4;
+// public static final int EMR_POLYLINE16 = 0x57;
+// public static final int EMR_POLYLINETO = 0x6;
+// public static final int EMR_POLYLINETO16 = 0x59;
+// public static final int EMR_POLYPOLYGON = 0x8;
+// public static final int EMR_POLYPOLYGON16 = 0x5B;
+// public static final int EMR_POLYPOLYLINE = 0x7;
+// public static final int EMR_POLYPOLYLINE16 = 0x5A;
+// public static final int EMR_POLYTEXTOUTA = 0x60;
+// public static final int EMR_POLYTEXTOUTW = 0x61;
+// public static final int EMR_REALIZEPALETTE = 0x34;
+// public static final int EMR_RECTANGLE = 0x2B;
+// public static final int EMR_RESIZEPALETTE = 0x33;
+// public static final int EMR_RESTOREDC = 0x22;
+// public static final int EMR_ROUNDRECT = 0x2C;
+// public static final int EMR_SAVEDC = 0x21;
+// public static final int EMR_SCALEVIEWPORTEXTEX = 0x1F;
+// public static final int EMR_SCALEWINDOWEXTEX = 0x20;
+// public static final int EMR_SELECTCLIPPATH = 0x43;
+// public static final int EMR_SELECTOBJECT = 0x25;
+// public static final int EMR_SELECTPALETTE = 0x30;
+// public static final int EMR_SETARCDIRECTION = 0x39;
+// public static final int EMR_SETBKCOLOR = 0x19;
+// public static final int EMR_SETBKMODE = 0x12;
+// public static final int EMR_SETBRUSHORGEX = 0xD;
+// public static final int EMR_SETCOLORADJUSTMENT = 0x17;
+// public static final int EMR_SETCOLORSPACE = 0x64;
+// public static final int EMR_SETDIBITSTODEVICE = 0x50;
+// public static final int EMR_SETICMMODE = 0x62;
+// public static final int EMR_SETMAPMODE = 0x11;
+// public static final int EMR_SETMAPPERFLAGS = 0x10;
+// public static final int EMR_SETMETARGN = 0x1C;
+// public static final int EMR_SETMITERLIMIT = 0x3A;
+// public static final int EMR_SETPALETTEENTRIES = 0x32;
+// public static final int EMR_SETPIXELV = 0xF;
+// public static final int EMR_SETPOLYFILLMODE = 0x13;
+// public static final int EMR_SETROP2 = 0x14;
+// public static final int EMR_SETSTRETCHBLTMODE = 0x15;
+// public static final int EMR_SETTEXTALIGN = 0x16;
+// public static final int EMR_SETTEXTCOLOR = 0x18;
+// public static final int EMR_SETVIEWPORTEXTEX = 0xB;
+// public static final int EMR_SETVIEWPORTORGEX = 0xC;
+// public static final int EMR_SETWINDOWEXTEX = 0x9;
+// public static final int EMR_SETWINDOWORGEX = 0xA;
+// public static final int EMR_SETWORLDTRANSFORM = 0x23;
+// public static final int EMR_STRETCHBLT = 0x4D;
+// public static final int EMR_STRETCHDIBITS = 0x51;
+// public static final int EMR_STROKEANDFILLPATH = 0x3F;
+// public static final int EMR_STROKEPATH = 0x40;
+// public static final int EMR_WIDENPATH = 0x42;
+// public static final int EN_ALIGN_LTR = 0x0710;
+// public static final int EN_ALIGN_RTL = 0x0711;
+ public static final int EN_CHANGE = 0x300;
+// public static final int EN_CORRECTTEXT = 0x0705;
+// public static final int EN_DRAGDROPDONE = 0x070c;
+// public static final int EN_DROPFILES = 0x0703;
+// public static final int EN_ERRSPACE = 0x500;
+// public static final int EN_HSCROLL = 0x601;
+// public static final int EN_IMECHANGE = 0x0707;
+// public static final int EN_KILLFOCUS = 0x200;
+// public static final int EN_LINK = 0x070b;
+// public static final int EN_MAXTEXT = 0x501;
+// public static final int EN_MSGFILTER = 0x0700;
+// public static final int EN_OBJECTPOSITIONS = 0x070a;
+// public static final int EN_OLEOPFAILED = 0x0709;
+// public static final int EN_PROTECTED = 0x0704;
+// public static final int EN_REQUESTRESIZE = 0x0701;
+// public static final int EN_SAVECLIPBOARD = 0x0708;
+// public static final int EN_SELCHANGE = 0x0702;
+// public static final int EN_SETFOCUS = 0x100;
+// public static final int EN_STOPNOUNDO = 0x0706;
+// public static final int EN_UPDATE = 0x400;
+// public static final int EN_VSCROLL = 0x602;
+// public static final int ENABLE_ECHO_INPUT = 0x4;
+// public static final int ENABLE_LINE_INPUT = 0x2;
+// public static final int ENABLE_MOUSE_INPUT = 0x10;
+// public static final int ENABLE_PROCESSED_INPUT = 0x1;
+// public static final int ENABLE_PROCESSED_OUTPUT = 0x1;
+// public static final int ENABLE_WINDOW_INPUT = 0x8;
+// public static final int ENABLE_WRAP_AT_EOL_OUTPUT = 0x2;
+// public static final int ENABLEDUPLEX = 0x1C;
+// public static final int ENABLEPAIRKERNING = 0x301;
+// public static final int ENABLERELATIVEWIDTHS = 0x300;
+// public static final int ENCAPSULATED_POSTSCRIPT = 0x1014;
+// public static final int ENDDOC = 0xB;
+// public static final int ENHANCED_KEY = 0x100;
+// public static final int ENHMETA_SIGNATURE = 0x464D4520;
+// public static final int ENHMETA_STOCK_OBJECT = 0x80000000;
+// public static final int ENM_CHANGE = 0x00000001;
+// public static final int ENM_CORRECTTEXT = 0x00400000;
+// public static final int ENM_DRAGDROPDONE = 0x00000010;
+// public static final int ENM_DROPFILES = 0x00100000;
+// public static final int ENM_IMECHANGE = 0x00800000;
+// public static final int ENM_KEYEVENTS = 0x00010000;
+// public static final int ENM_LANGCHANGE = 0x01000000;
+// public static final int ENM_LINK = 0x04000000;
+// public static final int ENM_MOUSEEVENTS = 0x00020000;
+// public static final int ENM_NONE = 0x00000000;
+// public static final int ENM_OBJECTPOSITIONS = 0x02000000;
+// public static final int ENM_PROTECTED = 0x00200000;
+// public static final int ENM_REQUESTRESIZE = 0x00040000;
+// public static final int ENM_SCROLL = 0x00000004;
+// public static final int ENM_SCROLLEVENTS = 0x00000008;
+// public static final int ENM_SELCHANGE = 0x00080000;
+// public static final int ENM_UPDATE = 0x00000002;
+// public static final int ENUM_ALL_CALENDARS = 0xFFFFFFFF;
+// public static final int ENUM_E_FIRST = 0x800401B0;
+// public static final int ENUM_E_LAST = 0x800401BF;
+// public static final int ENUM_S_FIRST = 0x401B0;
+// public static final int ENUM_S_LAST = 0x401BF;
+// public static final int ENUMPAPERBINS = 0x1F;
+// public static final int ENUMPAPERMETRICS = 0x22;
+// public static final int ERROR = 0x0;
+ public static final int ERROR_NO_MORE_ITEMS = 259;
+ public static final int ES_AUTOHSCROLL = 0x80;
+// public static final int ES_AUTOVSCROLL = 0x40;
+// public static final int ES_CENTER = 0x1;
+// public static final int ES_DISABLENOSCROLL = 0x00002000;
+// public static final int ES_EX_NOCALLOLEINIT = 0x01000000;
+// public static final int ES_LEFT = 0x0;
+// public static final int ES_LOWERCASE = 0x10;
+ public static final int ES_MULTILINE = 0x4;
+ public static final int ES_NOHIDESEL = 0x100;
+// public static final int ES_NOIME = 0x00080000;
+// public static final int ES_NOOLEDRAGDROP = 0x00000008;
+// public static final int ES_NUMBER = 0x2000;
+// public static final int ES_OEMCONVERT = 0x400;
+// public static final int ES_PASSWORD = 0x20;
+ public static final int ES_READONLY = 0x800;
+// public static final int ES_RIGHT = 0x2;
+// public static final int ES_SAVESEL = 0x00008000;
+// public static final int ES_SELECTIONBAR = 0x01000000;
+// public static final int ES_SELFIME = 0x00040000;
+// public static final int ES_SUNKEN = 0x00004000;
+// public static final int ES_UPPERCASE = 0x8;
+// public static final int ES_VERTICAL = 0x00400000;
+// public static final int ES_WANTRETURN = 0x1000;
+ public static final int ESB_DISABLE_BOTH = 0x3;
+// public static final int ESB_DISABLE_DOWN = 0x2;
+// public static final int ESB_DISABLE_LEFT = 0x1;
+// public static final int ESB_DISABLE_LTUP = 0x1;
+// public static final int ESB_DISABLE_RIGHT = 0x2;
+// public static final int ESB_DISABLE_RTDN = 0x2;
+// public static final int ESB_DISABLE_UP = 0x1;
+ public static final int ESB_ENABLE_BOTH = 0x0;
+ public static final int FALT = 0x10;
+ public static final int FCONTROL = 0x8;
+// public static final int FNERR_BUFFERTOOSMALL = 0x3003;
+// public static final int FNERR_FILENAMECODES = 0x3000;
+ public static final int FNERR_INVALIDFILENAME = 0x3002;
+// public static final int FNERR_SUBCLASSFAILURE = 0x3001;
+// public static final int FNOINVERT = 0x2;
+// public static final int FR_MATCHALEFHAMZA = 0x80000000;
+// public static final int FR_MATCHDIAC = 0x20000000;
+// public static final int FR_MATCHKASHIDA = 0x40000000;
+ public static final int FSHIFT = 0x4;
+ public static final int FVIRTKEY = 0x1;
+// public static final int GCL_CBCLSEXTRA = 0xFFFFFFEC;
+// public static final int GCL_CBWNDEXTRA = 0xFFFFFFEE;
+// public static final int GCL_CONVERSION = 0x1;
+// public static final int GCL_HBRBACKGROUND = 0xFFFFFFF6;
+// public static final int GCL_HCURSOR = 0xFFFFFFF4;
+// public static final int GCL_HICON = 0xFFFFFFF2;
+// public static final int GCL_HICONSM = 0xFFFFFFDE;
+// public static final int GCL_HMODULE = 0xFFFFFFF0;
+// public static final int GCL_MENUNAME = 0xFFFFFFF8;
+// public static final int GCL_REVERSE_LENGTH = 0x3;
+// public static final int GCL_REVERSECONVERSION = 0x2;
+// public static final int GCL_STYLE = 0xFFFFFFE6;
+// public static final int GCL_WNDPROC = 0xFFFFFFE8;
+// public static final int GCM_RIGHTMOUSEDROP = 0x8000;
+// public static final int GHND = (GMEM_MOVEABLE | GMEM_ZEROINIT);
+// public static final int GMDI_GOINTOPOPUPS = 0x2;
+ public static final int GMDI_USEDISABLED = 0x1;
+// public static final int GMEM_DDESHARE = 0x2000;
+// public static final int GMEM_DISCARDABLE = 0x0100;
+// public static final int GMEM_DISCARDED = 0x4000;
+ public static final int GMEM_FIXED = 0x0000;
+// public static final int GMEM_INVALID_HANDLE = 0x8000;
+// public static final int GMEM_LOCKCOUNT = 0x00FF;
+// public static final int GMEM_LOWER = GMEM_NOT_BANKED;
+// public static final int GMEM_MODIFY = 0x0080;
+// public static final int GMEM_MOVEABLE = 0x0002;
+// public static final int GMEM_NOCOMPACT = 0x0010;
+// public static final int GMEM_NODISCARD = 0x0020;
+// public static final int GMEM_NOT_BANKED = 0x1000;
+// public static final int GMEM_NOTIFY = 0x4000;
+// public static final int GMEM_SHARE = 0x2000;
+// public static final int GMEM_VALID_FLAGS = 0x7F72;
+ public static final int GMEM_ZEROINIT = 0x0040;
+ public static final int GPTR = (GMEM_FIXED | GMEM_ZEROINIT);
+// public static final int GRAY_BRUSH = 0x2;
+ public static final int GT_DEFAULT = 0;
+// public static final int GT_USECRLF = 1;
+// public static final int GTL_CLOSE = 4;
+// public static final int GTL_DEFAULT = 0;
+ public static final int GTL_NUMBYTES = 16;
+ public static final int GTL_NUMCHARS = 8;
+ public static final int GTL_PRECISE = 2;
+// public static final int GTL_USECRLF = 1;
+ public static final int GW_CHILD = 0x5;
+ public static final int GW_HWNDFIRST = 0x0;
+ public static final int GW_HWNDLAST = 0x1;
+ public static final int GW_HWNDNEXT = 0x2;
+ public static final int GW_HWNDPREV = 0x3;
+// public static final int GW_MAX = 0x5;
+// public static final int GW_OWNER = 0x4;
+ public static final int GWL_EXSTYLE = 0xFFFFFFEC;
+// public static final int GWL_HINSTANCE = 0xFFFFFFFA;
+// public static final int GWL_HWNDPARENT = 0xFFFFFFF8;
+// public static final int GWL_ID = 0xFFFFFFF4;
+ public static final int GWL_STYLE = 0xFFFFFFF0;
+ public static final int GWL_USERDATA = 0xFFFFFFEB;
+ public static final int GWL_WNDPROC = 0xFFFFFFFC;
+ public static final int HBMMENU_CALLBACK = -1;
+// public static final int HBMMENU_SYSTEM = 1;
+// public static final int HBMMENU_MBAR_RESTORE = 2;
+// public static final int HBMMENU_MBAR_MINIMIZE = 3;
+// public static final int HBMMENU_MBAR_CLOSE = 5;
+// public static final int HBMMENU_MBAR_CLOSE_D = 6;
+// public static final int HBMMENU_MBAR_MINIMIZE_D = 7;
+// public static final int HBMMENU_POPUP_CLOSE = 8;
+// public static final int HBMMENU_POPUP_RESTORE = 9;
+// public static final int HBMMENU_POPUP_MAXIMIZE = 10;
+// public static final int HBMMENU_POPUP_MINIMIZE = 11;
+// public static final int HDF_BITMAP = 0x2000;
+// public static final int HDF_BITMAP_ON_RIGHT = 0x1000;
+// public static final int HDF_CENTER = 2;
+// public static final int HDF_IMAGE = 0x0800;
+// public static final int HDF_JUSTIFYMASK = 0x0003;
+// public static final int HDF_LEFT = 0;
+// public static final int HDF_OWNERDRAW = 0x8000;
+// public static final int HDF_RIGHT = 1;
+// public static final int HDF_RTLREADING = 4;
+// public static final int HDF_STRING = 0x4000;
+// public static final int HDI_BITMAP = 0x0010;
+// public static final int HDI_DI_SETITEM = 0x0040;
+// public static final int HDI_FORMAT = 0x0004;
+// public static final int HDI_HEIGHT = HDI_WIDTH;
+// public static final int HDI_IMAGE = 0x0020;
+// public static final int HDI_LPARAM = 0x0008;
+// public static final int HDI_ORDER = 0x0080;
+// public static final int HDI_TEXT = 0x0002;
+ public static final int HDI_WIDTH = 0x0001;
+// public static final int HDM_CREATEDRAGIMAGE = (HDM_FIRST + 16);
+// public static final int HDM_DELETEITEM = (HDM_FIRST + 2);
+// public static final int HDM_GETIMAGELIST = (HDM_FIRST + 9);
+// public static final int HDM_GETITEM = (HDM_FIRST + 3);
+ public static final int HDM_GETITEMCOUNT = (HDM_FIRST + 0);
+// public static final int HDM_GETITEMRECT = (HDM_FIRST + 7);
+// public static final int HDM_GETORDERARRAY = (HDM_FIRST + 17);
+// public static final int HDM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+// public static final int HDM_HITTEST = (HDM_FIRST + 6);
+// public static final int HDM_INSERTITEM = (HDM_FIRST + 1);
+// public static final int HDM_LAYOUT = (HDM_FIRST + 5);
+// public static final int HDM_ORDERTOINDEX = (HDM_FIRST + 15);
+// public static final int HDM_SETHOTDIVIDER = (HDM_FIRST + 19);
+// public static final int HDM_SETIMAGELIST = (HDM_FIRST + 8);
+// public static final int HDM_SETITEM = (HDM_FIRST + 4);
+// public static final int HDM_SETORDERARRAY = (HDM_FIRST + 18);
+// public static final int HDM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+// public static final int HDN_BEGINDRAG = (HDN_FIRST-10);
+ public static final int HDN_BEGINTRACK = (HDN_FIRST-6);
+ public static final int HDN_BEGINTRACKW = (HDN_FIRST-26);
+// public static final int HDN_DIVIDERDBLCLICK = (HDN_FIRST-5);
+// public static final int HDN_ENDDRAG = (HDN_FIRST-11);
+// public static final int HDN_ENDTRACK = (HDN_FIRST-7);
+// public static final int HDN_GETDISPINFO = (HDN_FIRST-9);
+ public static final int HDN_ITEMCHANGED = (HDN_FIRST-1);
+ public static final int HDN_ITEMCHANGEDW = (HDN_FIRST-21);
+// public static final int HDN_ITEMCHANGING = (HDN_FIRST-0);
+// public static final int HDN_ITEMCHANGINGW = (HDN_FIRST-20);
+// public static final int HDN_ITEMCLICK = (HDN_FIRST-2);
+// public static final int HDN_ITEMDBLCLICK = (HDN_FIRST-3);
+// public static final int HDN_TRACK = (HDN_FIRST-8);
+// public static final int HDS_BUTTONS = 0x0002;
+// public static final int HDS_DRAGDROP = 0x0040;
+// public static final int HDS_FULLDRAG = 0x0080;
+// public static final int HDS_HIDDEN = 0x0008;
+// public static final int HDS_HORZ = 0x0000;
+// public static final int HDS_HOTTRACK = 0x0004;
+// public static final int HEAP_CREATE_ALIGN16 = 0x10000;
+// public static final int HEAP_CREATE_ENABLE_TRACING = 0x20000;
+// public static final int HEAP_DISABLE_COALESCE_ON_FREE = 0x80;
+// public static final int HEAP_FREE_CHECKING_ENABLED = 0x40;
+// public static final int HEAP_GENERATE_EXCEPTIONS = 0x4;
+// public static final int HEAP_GROWABLE = 0x2;
+// public static final int HEAP_MAXIMUM_TAG = 0xFFF;
+// public static final int HEAP_NO_SERIALIZE = 0x1;
+// public static final int HEAP_PSEUDO_TAG_FLAG = 0x8000;
+// public static final int HEAP_REALLOC_IN_PLACE_ONLY = 0x10;
+// public static final int HEAP_TAG_SHIFT = 0x10;
+// public static final int HEAP_TAIL_CHECKING_ENABLED = 0x20;
+ public static final int HEAP_ZERO_MEMORY = 0x8;
+ public static final int HELPINFO_MENUITEM = 0x2;
+// public static final int HELPINFO_WINDOW = 0x1;
+// public static final int HHT_ABOVE = 0x0100;
+// public static final int HHT_BELOW = 0x0200;
+// public static final int HHT_NOWHERE = 0x0001;
+// public static final int HHT_ONDIVIDER = 0x0004;
+// public static final int HHT_ONDIVOPEN = 0x0008;
+// public static final int HHT_ONHEADER = 0x0002;
+// public static final int HHT_TOLEFT = 0x0800;
+// public static final int HHT_TORIGHT = 0x0400;
+ public static final int HINST_COMMCTRL = 0xFFFFFFFF;
+ public static final int HKEY_CLASSES_ROOT = 0x80000000;
+ public static final int HKEY_CURRENT_USER = 0x80000001;
+// public static final int HKEY_LOCAL_MACHINE = 0x80000002;
+// public static final int HKEY_USERS = 0x80000003;
+// public static final int HKEY_PERFORMANCE_DATA = 0x80000004;
+// public static final int HKEY_CURRENT_CONFIG = 0x80000005;
+// public static final int HKEY_DYN_DATA = 0x80000006;
+// public static final int HOLLOW_BRUSH = 0x5;
+ public static final int HORZRES = 8;
+ public static final int HTBORDER = 0x12;
+// public static final int HTBOTTOM = 0xF;
+// public static final int HTBOTTOMLEFT = 0x10;
+// public static final int HTBOTTOMRIGHT = 0x11;
+// public static final int HTCAPTION = 0x2;
+ public static final int HTCLIENT = 0x1;
+// public static final int HTCLOSE = 0x14;
+// public static final int HTERROR = 0xFFFFFFFE;
+// public static final int HTGROWBOX = 0x4;
+// public static final int HTHELP = 0x15;
+ public static final int HTHSCROLL = 0x6;
+// public static final int HTLEFT = 0xA;
+// public static final int HTMAXBUTTON = 0x9;
+ public static final int HTMENU = 0x5;
+// public static final int HTMINBUTTON = 0x8;
+ public static final int HTNOWHERE = 0x0;
+// public static final int HTOBJECT = 0x13;
+// public static final int HTREDUCE = 0x8;
+// public static final int HTRIGHT = 0xB;
+// public static final int HTSIZE = 0x4;
+// public static final int HTSIZEFIRST = 0xA;
+// public static final int HTSIZELAST = 0x11;
+// public static final int HTSYSMENU = 0x3;
+// public static final int HTTOP = 0xC;
+// public static final int HTTOPLEFT = 0xD;
+// public static final int HTTOPRIGHT = 0xE;
+ public static final int HTTRANSPARENT = 0xFFFFFFFF;
+ public static final int HTVSCROLL = 0x7;
+// public static final int HTZOOM = 0x9;
+ public static final int HWND_BOTTOM = 0x1;
+// public static final int HWND_BROADCAST = 0xFFFF;
+// public static final int HWND_DESKTOP = 0x0;
+// public static final int HWND_NOTOPMOST = 0xFFFFFFFE;
+ public static final int HWND_TOP = 0x0;
+// public static final int HWND_TOPMOST = 0xFFFFFFFF;
+// public static final int I_CHILDRENCALLBACK = -1;
+// public static final int ICM_LEVEL2 = 0x0002;
+// public static final int ICM_LEVEL2_5 = 0x0003;
+// public static final int ICM_LEVEL2_SUI = 0x0004;
+// public static final int ICM_LEVEL3 = 0x0001;
+ public static final int ICM_NOTOPEN = 0x0000;
+ public static final int ICON_BIG = 1;
+ public static final int ICON_SMALL = 0;
+// public static final int ID_BROWSE_ADDCONTROL = 0x3;
+// public static final int ID_BROWSE_CHANGEICON = 0x1;
+// public static final int ID_BROWSE_CHANGESOURCE = 0x4;
+// public static final int ID_BROWSE_INSERTFILE = 0x2;
+// public static final int ID_DEFAULTINST = 0xFFFFFFFE;
+// public static final int ID_PSREBOOTSYSTEM = 0x3;
+// public static final int ID_PSRESTARTWINDOWS = 0x2;
+ public static final int IDABORT = 0x3;
+// public static final int IDANI_CAPTION = 0x3;
+// public static final int IDANI_CLOSE = 0x2;
+// public static final int IDANI_OPEN = 0x1;
+// public static final int IDB_STD_LARGE_COLOR = 0x1;
+ public static final int IDB_STD_SMALL_COLOR = 0x0;
+// public static final int IDB_VIEW_LARGE_COLOR = 0x5;
+// public static final int IDB_VIEW_SMALL_COLOR = 0x4;
+ public static final int IDC_APPSTARTING = 0x7F8A;
+ public static final int IDC_ARROW = 0x7F00;
+// public static final int IDC_BZ_ICON = 0x259;
+// public static final int IDC_BZ_MESSAGE1 = 0x25A;
+// public static final int IDC_BZ_RETRY = 0x258;
+// public static final int IDC_BZ_SWITCHTO = 0x25C;
+// public static final int IDC_CI_BROWSE = 0x82;
+// public static final int IDC_CI_CURRENT = 0x79;
+// public static final int IDC_CI_CURRENTICON = 0x7A;
+// public static final int IDC_CI_DEFAULT = 0x7B;
+// public static final int IDC_CI_DEFAULTICON = 0x7C;
+// public static final int IDC_CI_FROMFILE = 0x7D;
+// public static final int IDC_CI_FROMFILEEDIT = 0x7E;
+// public static final int IDC_CI_GROUP = 0x78;
+// public static final int IDC_CI_ICONDISPLAY = 0x83;
+// public static final int IDC_CI_ICONLIST = 0x7F;
+// public static final int IDC_CI_LABEL = 0x80;
+// public static final int IDC_CI_LABELEDIT = 0x81;
+ public static final int IDC_CROSS = 0x7F03;
+// public static final int IDC_CV_ACTIVATEAS = 0x9C;
+// public static final int IDC_CV_ACTIVATELIST = 0x9A;
+// public static final int IDC_CV_CHANGEICON = 0x99;
+// public static final int IDC_CV_CONVERTLIST = 0x9E;
+// public static final int IDC_CV_CONVERTTO = 0x9B;
+// public static final int IDC_CV_DISPLAYASICON = 0x98;
+// public static final int IDC_CV_ICONDISPLAY = 0xA5;
+// public static final int IDC_CV_OBJECTTYPE = 0x96;
+// public static final int IDC_CV_RESULTTEXT = 0x9D;
+// public static final int IDC_EL_AUTOMATIC = 0xCA;
+// public static final int IDC_EL_CANCELLINK = 0xD1;
+// public static final int IDC_EL_CHANGESOURCE = 0xC9;
+// public static final int IDC_EL_COL1 = 0xDC;
+// public static final int IDC_EL_COL2 = 0xDD;
+// public static final int IDC_EL_COL3 = 0xDE;
+// public static final int IDC_EL_LINKSLISTBOX = 0xCE;
+// public static final int IDC_EL_LINKSOURCE = 0xD8;
+// public static final int IDC_EL_LINKTYPE = 0xD9;
+// public static final int IDC_EL_MANUAL = 0xD4;
+// public static final int IDC_EL_OPENSOURCE = 0xD3;
+// public static final int IDC_EL_UPDATENOW = 0xD2;
+// public static final int IDC_GP_CONVERT = 0x3F5;
+// public static final int IDC_GP_OBJECTICON = 0x3F6;
+// public static final int IDC_GP_OBJECTLOCATION = 0x3FE;
+// public static final int IDC_GP_OBJECTNAME = 0x3F1;
+// public static final int IDC_GP_OBJECTSIZE = 0x3F3;
+// public static final int IDC_GP_OBJECTTYPE = 0x3F2;
+ public static final int IDC_HAND = 0x7F89;
+ public static final int IDC_HELP = 0x7F8B;
+ public static final int IDC_IBEAM = 0x7F01;
+// public static final int IDC_ICON = 0x7F81;
+// public static final int IDC_IO_ADDCONTROL = 0x843;
+// public static final int IDC_IO_CHANGEICON = 0x839;
+// public static final int IDC_IO_CONTROLTYPELIST = 0x844;
+// public static final int IDC_IO_CREATEFROMFILE = 0x835;
+// public static final int IDC_IO_CREATENEW = 0x834;
+// public static final int IDC_IO_DISPLAYASICON = 0x838;
+// public static final int IDC_IO_FILE = 0x83A;
+// public static final int IDC_IO_FILEDISPLAY = 0x83B;
+// public static final int IDC_IO_FILETEXT = 0x840;
+// public static final int IDC_IO_FILETYPE = 0x841;
+// public static final int IDC_IO_ICONDISPLAY = 0x83E;
+// public static final int IDC_IO_INSERTCONTROL = 0x842;
+// public static final int IDC_IO_LINKFILE = 0x836;
+// public static final int IDC_IO_OBJECTTYPELIST = 0x837;
+// public static final int IDC_IO_OBJECTTYPETEXT = 0x83F;
+// public static final int IDC_IO_RESULTIMAGE = 0x83C;
+// public static final int IDC_IO_RESULTTEXT = 0x83D;
+// public static final int IDC_LP_AUTOMATIC = 0x3F8;
+// public static final int IDC_LP_BREAKLINK = 0x3F0;
+// public static final int IDC_LP_CHANGESOURCE = 0x3F7;
+// public static final int IDC_LP_DATE = 0x3FA;
+// public static final int IDC_LP_LINKSOURCE = 0x3F4;
+// public static final int IDC_LP_MANUAL = 0x3F9;
+// public static final int IDC_LP_OPENSOURCE = 0x3EE;
+// public static final int IDC_LP_TIME = 0x3FB;
+// public static final int IDC_LP_UPDATENOW = 0x3EF;
+ public static final int IDC_NO = 0x7F88;
+// public static final int IDC_OLEUIHELP = 0x63;
+// public static final int IDC_PS_CHANGEICON = 0x1FC;
+// public static final int IDC_PS_DISPLAYASICON = 0x1FA;
+// public static final int IDC_PS_DISPLAYLIST = 0x1F9;
+// public static final int IDC_PS_ICONDISPLAY = 0x1FB;
+// public static final int IDC_PS_PASTE = 0x1F4;
+// public static final int IDC_PS_PASTELINK = 0x1F5;
+// public static final int IDC_PS_PASTELINKLIST = 0x1F8;
+// public static final int IDC_PS_PASTELIST = 0x1F7;
+// public static final int IDC_PS_RESULTIMAGE = 0x1FD;
+// public static final int IDC_PS_RESULTTEXT = 0x1FE;
+// public static final int IDC_PS_SOURCETEXT = 0x1F6;
+// public static final int IDC_PU_CONVERT = 0x386;
+// public static final int IDC_PU_ICON = 0x38C;
+// public static final int IDC_PU_LINKS = 0x384;
+// public static final int IDC_PU_TEXT = 0x385;
+ public static final int IDC_SIZE = 0x7F80;
+ public static final int IDC_SIZEALL = 0x7F86;
+ public static final int IDC_SIZENESW = 0x7F83;
+ public static final int IDC_SIZENS = 0x7F85;
+ public static final int IDC_SIZENWSE = 0x7F82;
+ public static final int IDC_SIZEWE = 0x7F84;
+// public static final int IDC_UL_METER = 0x405;
+// public static final int IDC_UL_PERCENT = 0x407;
+// public static final int IDC_UL_PROGRESS = 0x408;
+// public static final int IDC_UL_STOP = 0x406;
+ public static final int IDC_UPARROW = 0x7F04;
+// public static final int IDC_VP_ASICON = 0x3EB;
+// public static final int IDC_VP_CHANGEICON = 0x3E9;
+// public static final int IDC_VP_EDITABLE = 0x3EA;
+// public static final int IDC_VP_ICONDISPLAY = 0x3FD;
+// public static final int IDC_VP_PERCENT = 0x3E8;
+// public static final int IDC_VP_RELATIVE = 0x3ED;
+// public static final int IDC_VP_RESULTIMAGE = 0x409;
+// public static final int IDC_VP_SCALETXT = 0x40A;
+// public static final int IDC_VP_SPIN = 0x3EE;
+ public static final int IDC_WAIT = 0x7F02;
+// public static final int IDCANCEL = 0x2;
+// public static final int IDCLOSE = 0x8;
+// public static final int IDD_BUSY = 0x3EE;
+// public static final int IDD_CANNOTUPDATELINK = 0x3F0;
+// public static final int IDD_CHANGEICON = 0x3E9;
+// public static final int IDD_CHANGEICONBROWSE = 0x3F3;
+// public static final int IDD_CHANGESOURCE = 0x3F1;
+// public static final int IDD_CHANGESOURCE4 = 0x3F5;
+// public static final int IDD_CONVERT = 0x3EA;
+// public static final int IDD_CONVERTONLY = 0x3F4;
+// public static final int IDD_EDITLINKS = 0x3EC;
+// public static final int IDD_GNRLPROPS = 0x44C;
+// public static final int IDD_INSERTFILEBROWSE = 0x3F2;
+// public static final int IDD_INSERTOBJECT = 0x3E8;
+// public static final int IDD_LINKPROPS = 0x44E;
+// public static final int IDD_LINKSOURCEUNAVAILABLE = 0x3FC;
+// public static final int IDD_LINKTYPECHANGED = 0x402;
+// public static final int IDD_LINKTYPECHANGEDA = 0x402;
+// public static final int IDD_LINKTYPECHANGEDW = 0x3FE;
+// public static final int IDD_OUTOFMEMORY = 0x400;
+// public static final int IDD_PASTESPECIAL = 0x3EB;
+// public static final int IDD_SERVERNOTFOUND = 0x3FF;
+// public static final int IDD_SERVERNOTREG = 0x401;
+// public static final int IDD_SERVERNOTREGA = 0x401;
+// public static final int IDD_SERVERNOTREGW = 0x3FD;
+// public static final int IDD_UPDATELINKS = 0x3EF;
+// public static final int IDD_VIEWPROPS = 0x44D;
+// public static final int IDH_CANCEL = 0x6F1C;
+// public static final int IDH_GENERIC_HELP_BUTTON = 0x6F1A;
+// public static final int IDH_HELP = 0x6F1D;
+// public static final int IDH_MISSING_CONTEXT = 0x6F19;
+// public static final int IDH_NO_HELP = 0x6F18;
+// public static final int IDH_OK = 0x6F1B;
+// public static final int IDHELP = 0x9;
+// public static final int IDHOT_SNAPDESKTOP = 0xFFFFFFFE;
+// public static final int IDHOT_SNAPWINDOW = 0xFFFFFFFF;
+// public static final int IDI_APPLICATION = 0x7F00;
+// public static final int IDI_ASTERISK = 0x7F04;
+// public static final int IDI_ERROR = 0x7F01;
+// public static final int IDI_EXCLAMATION = 0x7F03;
+// public static final int IDI_HAND = 0x7F01;
+// public static final int IDI_INFORMATION = 0x7F04;
+// public static final int IDI_QUESTION = 0x7F02;
+// public static final int IDI_WARNING = 0x7F03;
+ public static final int IDI_WINLOGO = 0x7F05;
+// public static final int IDIGNORE = 0x5;
+// public static final int IDLE_PRIORITY_CLASS = 0x40;
+// public static final int IDLFLAG_FIN = 0x1;
+// public static final int IDLFLAG_FLCID = 0x4;
+// public static final int IDLFLAG_FOUT = 0x2;
+// public static final int IDLFLAG_FRETVAL = 0x8;
+// public static final int IDLFLAG_NONE = 0x0;
+ public static final int IDNO = 0x7;
+ public static final int IDOK = 0x1;
+ public static final int IDRETRY = 0x4;
+ public static final int IDYES = 0x6;
+ public static final int ILC_COLOR = 0x0;
+ public static final int ILC_COLOR16 = 0x10;
+ public static final int ILC_COLOR24 = 0x18;
+ public static final int ILC_COLOR32 = 0x20;
+ public static final int ILC_COLOR4 = 0x4;
+ public static final int ILC_COLOR8 = 0x8;
+// public static final int ILC_COLORDDB = 0xFE;
+ public static final int ILC_MASK = 0x1;
+// public static final int ILC_PALETTE = 0x800;
+// public static final int ILD_BLEND = 0x4;
+// public static final int ILD_BLEND25 = 0x2;
+// public static final int ILD_BLEND50 = 0x4;
+// public static final int ILD_FOCUS = 0x2;
+// public static final int ILD_IMAGE = 0x20;
+// public static final int ILD_MASK = 0x10;
+ public static final int ILD_NORMAL = 0x0;
+// public static final int ILD_OVERLAYMASK = 0xF00;
+// public static final int ILD_SELECTED = 0x4;
+// public static final int ILD_TRANSPARENT = 0x1;
+ public static final int IMAGE_BITMAP = 0x0;
+ public static final int IMAGE_CURSOR = 0x2;
+ public static final int IMAGE_ICON = 0x1;
+// public static final int IMF_AUTOFONT = 0x0002;
+// public static final int IMF_AUTOKEYBOARD = 0x0001;
+// public static final int IMF_CLOSESTATUSWINDOW = 0x0008;
+// public static final int IMF_FORCEACTIVE = 0x0040;
+// public static final int IMF_FORCEDISABLE = 0x0004;
+// public static final int IMF_FORCEENABLE = 0x0002;
+// public static final int IMF_FORCEINACTIVE = 0x0080;
+// public static final int IMF_FORCENONE = 0x0001;
+// public static final int IMF_FORCEREMEMBER = 0x0100;
+// public static final int IMF_IMEALWAYSSENDNOTIFY = 0x0008;
+// public static final int IMF_IMECANCELCOMPLETE = 0x0004;
+// public static final int IMF_MULTIPLEEDIT = 0x0400;
+// public static final int IMF_VERTICAL = 0x0020;
+ public static final int KEY_QUERY_VALUE = 0x0001;
+// public static final int KEY_SET_VALUE = 0x0002;
+// public static final int KEY_CREATE_SUB_KEY = 0x0004;
+ public static final int KEY_ENUMERATE_SUB_KEYS = 0x0008;
+ public static final int KEY_NOTIFY = 0x0010;
+// public static final int KEY_CREATE_LINK = 0x0020;
+ public static final int KEY_READ = (STANDARD_RIGHTS_READ | KEY_QUERY_VALUE | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY) & ~SYNCHRONIZE;
+// public static final int KEY_WRITE = (STANDARD_RIGHTS_WRITE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY) & ~SYNCHRONIZE;
+// public static final int KEY_EXECUTE = (KEY_READ & ~SYNCHRONIZE);
+// public static final int KEY_ALL_ACCESS = (STANDARD_RIGHTS_ALL | KEY_QUERY_VALUE | KEY_SET_VALUE | KEY_CREATE_SUB_KEY | KEY_ENUMERATE_SUB_KEYS | KEY_NOTIFY | KEY_CREATE_LINK) & ~SYNCHRONIZE;
+// public static final int LB_ADDFILE = 0x196;
+// public static final int LB_ADDSTRING = 0x180;
+ public static final int LB_ADDSTRING = 0x180;
+// public static final int LB_CTLCODE = 0x0;
+ public static final int LB_DELETESTRING = 0x182;
+// public static final int LB_DIR = 0x18D;
+ public static final int LB_ERR = 0xFFFFFFFF;
+ public static final int LB_ERRSPACE = 0xFFFFFFFE;
+// public static final int LB_ERRSPACE = 0xFFFFFFFE;
+// public static final int LB_FINDSTRING = 0x18F;
+ public static final int LB_FINDSTRINGEXACT = 0x1A2;
+// public static final int LB_GETANCHORINDEX = 0x19D;
+ public static final int LB_GETCARETINDEX = 0x19F;
+ public static final int LB_GETCOUNT = 0x18B;
+ public static final int LB_GETCURSEL = 0x188;
+ public static final int LB_GETHORIZONTALEXTENT = 0x193;
+// public static final int LB_GETITEMDATA = 0x199;
+ public static final int LB_GETITEMHEIGHT = 0x1A1;
+ public static final int LB_GETITEMRECT = 0x198;
+// public static final int LB_GETLOCALE = 0x1A6;
+ public static final int LB_GETSEL = 0x187;
+ public static final int LB_GETSELCOUNT = 0x190;
+ public static final int LB_GETSELITEMS = 0x191;
+ public static final int LB_GETTEXT = 0x189;
+ public static final int LB_GETTEXTLEN = 0x18A;
+ public static final int LB_GETTOPINDEX = 0x18E;
+ public static final int LB_INITSTORAGE = 0x1A8;
+ public static final int LB_INSERTSTRING = 0x181;
+// public static final int LB_INSERTSTRING = 0x181;
+// public static final int LB_ITEMFROMPOINT = 0x1A9;
+// public static final int LB_MSGMAX = 0x1B0;
+// public static final int LB_OKAY = 0x0;
+ public static final int LB_RESETCONTENT = 0x184;
+// public static final int LB_SELECTSTRING = 0x18C;
+ public static final int LB_SELITEMRANGE = 0x19B;
+ public static final int LB_SELITEMRANGEEX = 0x183;
+// public static final int LB_SETANCHORINDEX = 0x19C;
+ public static final int LB_SETCARETINDEX = 0x19E;
+// public static final int LB_SETCOLUMNWIDTH = 0x195;
+// public static final int LB_SETCOUNT = 0x1A7;
+ public static final int LB_SETCURSEL = 0x186;
+ public static final int LB_SETHORIZONTALEXTENT = 0x194;
+// public static final int LB_SETITEMDATA = 0x19A;
+// public static final int LB_SETITEMHEIGHT = 0x1A0;
+// public static final int LB_SETLOCALE = 0x1A5;
+ public static final int LB_SETSEL = 0x185;
+// public static final int LB_SETTABSTOPS = 0x192;
+ public static final int LB_SETTOPINDEX = 0x197;
+ public static final int LBN_DBLCLK = 0x2;
+// public static final int LBN_ERRSPACE = 0xFFFFFFFE;
+// public static final int LBN_KILLFOCUS = 0x5;
+// public static final int LBN_SELCANCEL = 0x3;
+ public static final int LBN_SELCHANGE = 0x1;
+// public static final int LBN_SETFOCUS = 0x4;
+// public static final int LBS_DISABLENOSCROLL = 0x1000;
+ public static final int LBS_EXTENDEDSEL = 0x800;
+// public static final int LBS_HASSTRINGS = 0x40;
+// public static final int LBS_MULTICOLUMN = 0x200;
+ public static final int LBS_MULTIPLESEL = 0x8;
+// public static final int LBS_NODATA = 0x2000;
+ public static final int LBS_NOINTEGRALHEIGHT = 0x100;
+// public static final int LBS_NOREDRAW = 0x4;
+// public static final int LBS_NOSEL = 0x4000;
+ public static final int LBS_NOTIFY = 0x1;
+// public static final int LBS_OWNERDRAWFIXED = 0x10;
+// public static final int LBS_OWNERDRAWVARIABLE = 0x20;
+// public static final int LBS_SORT = 0x2;
+// public static final int LBS_STANDARD = 0xA00003;
+// public static final int LBS_USETABSTOPS = 0x80;
+// public static final int LBS_WANTKEYBOARDINPUT = 0x400;
+ public static final int LOGPIXELSX = 88;
+ public static final int LOGPIXELSY = 90;
+ public static final int LPSTR_TEXTCALLBACK = 0xFFFFFFFF;
+// public static final int LR_COLOR = 0x2;
+// public static final int LR_COPYDELETEORG = 0x8;
+// public static final int LR_COPYFROMRESOURCE = 0x4000;
+// public static final int LR_COPYRETURNORG = 0x4;
+// public static final int LR_CREATEDIBSECTION = 0x2000;
+ public static final int LR_DEFAULTCOLOR = 0x0;
+// public static final int LR_DEFAULTSIZE = 0x40;
+// public static final int LR_LOADFROMFILE = 0x10;
+// public static final int LR_LOADMAP3DCOLORS = 0x1000;
+// public static final int LR_LOADTRANSPARENT = 0x20;
+// public static final int LR_MONOCHROME = 0x1;
+// public static final int LR_SHARED = 0x8000;
+// public static final int LTGRAY_BRUSH = 0x1;
+// public static final int LVA_ALIGNLEFT = 0x1;
+// public static final int LVA_ALIGNTOP = 0x2;
+// public static final int LVA_DEFAULT = 0x0;
+// public static final int LVA_SNAPTOGRID = 0x5;
+ public static final int LVCF_FMT = 0x1;
+// public static final int LVCF_SUBITEM = 0x8;
+ public static final int LVCF_TEXT = 0x4;
+ public static final int LVCF_WIDTH = 0x2;
+ public static final int LVCFMT_CENTER = 0x2;
+// public static final int LVCFMT_JUSTIFYMASK = 0x3;
+ public static final int LVCFMT_LEFT = 0x0;
+ public static final int LVCFMT_RIGHT = 0x1;
+// public static final int LVFI_NEARESTXY = 0x40;
+// public static final int LVFI_PARAM = 0x1;
+// public static final int LVFI_PARTIAL = 0x8;
+// public static final int LVFI_STRING = 0x2;
+// public static final int LVFI_WRAP = 0x20;
+// public static final int LVHT_ABOVE = 0x8;
+// public static final int LVHT_BELOW = 0x10;
+// public static final int LVHT_NOWHERE = 0x1;
+ public static final int LVHT_ONITEM = 0xE;
+ public static final int LVHT_ONITEMICON = 0x2;
+ public static final int LVHT_ONITEMLABEL = 0x4;
+ public static final int LVHT_ONITEMSTATEICON = 0x8;
+// public static final int LVHT_TOLEFT = 0x40;
+// public static final int LVHT_TORIGHT = 0x20;
+// public static final int LVIF_DI_SETITEM = 0x1000;
+ public static final int LVIF_IMAGE = 0x2;
+ public static final int LVIF_INDENT = 0x0010;
+// public static final int LVIF_PARAM = 0x4;
+ public static final int LVIF_STATE = 0x8;
+ public static final int LVIF_TEXT = 0x1;
+ public static final int LVIR_BOUNDS = 0x0;
+ public static final int LVIR_ICON = 0x1;
+ public static final int LVIR_LABEL = 0x2;
+// public static final int LVIR_SELECTBOUNDS = 0x3;
+// public static final int LVIS_ACTIVATING = 0x0020;
+// public static final int LVIS_CUT = 0x4;
+ public static final int LVIS_DROPHILITED = 0x8;
+ public static final int LVIS_FOCUSED = 0x1;
+// public static final int LVIS_OVERLAYMASK = 0xF00;
+ public static final int LVIS_SELECTED = 0x2;
+ public static final int LVIS_STATEIMAGEMASK = 0xF000;
+ public static final int LVM_APPROXIMATEVIEWRECT = (LVM_FIRST+64);
+// public static final int LVM_ARRANGE = 0x1016;
+// public static final int LVM_CREATEDRAGIMAGE = 0x1021;
+ public static final int LVM_DELETEALLITEMS = 0x1009;
+ public static final int LVM_DELETECOLUMN = 0x101C;
+ public static final int LVM_DELETEITEM = 0x1008;
+// public static final int LVM_EDITLABEL = 0x1017;
+// public static final int LVM_EDITLABELA = 0x1017;
+// public static final int LVM_EDITLABELW = 0x1076;
+ public static final int LVM_ENSUREVISIBLE = 0x1013;
+// public static final int LVM_FINDITEM = 0x100D;
+// public static final int LVM_FINDITEMA = 0x100D;
+// public static final int LVM_FINDITEMW = 0x1053;
+ public static final int LVM_GETBKCOLOR = 0x1000;
+// public static final int LVM_GETCALLBACKMASK = 0x100A;
+ public static final int LVM_GETCOLUMN = 0x1019;
+// public static final int LVM_GETCOLUMNA = 0x1019;
+// public static final int LVM_GETCOLUMNW = 0x105F;
+ public static final int LVM_GETCOLUMNWIDTH = 0x101D;
+ public static final int LVM_GETCOUNTPERPAGE = 0x1028;
+// public static final int LVM_GETEDITCONTROL = 0x1018;
+ public static final int LVM_GETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 55);
+ public static final int LVM_GETHEADER = (LVM_FIRST + 31);
+ public static final int LVM_GETIMAGELIST = 0x1002;
+// public static final int LVM_GETISEARCHSTRING = 0x1034;
+// public static final int LVM_GETISEARCHSTRINGA = 0x1034;
+// public static final int LVM_GETISEARCHSTRINGW = 0x1075;
+ public static final int LVM_GETITEM = 0x1005;
+// public static final int LVM_GETITEMA = 0x1005;
+ public static final int LVM_GETITEMCOUNT = 0x1004;
+// public static final int LVM_GETITEMPOSITION = 0x1010;
+ public static final int LVM_GETITEMRECT = 0x100E;
+// public static final int LVM_GETITEMSPACING = 0x1033;
+ public static final int LVM_GETITEMSTATE = 0x102C;
+// public static final int LVM_GETITEMTEXT = 0x102D;
+// public static final int LVM_GETITEMTEXTA = 0x102D;
+// public static final int LVM_GETITEMTEXTW = 0x1073;
+// public static final int LVM_GETITEMW = 0x104B;
+ public static final int LVM_GETNEXTITEM = 0x100C;
+// public static final int LVM_GETORIGIN = 0x1029;
+ public static final int LVM_GETSELECTEDCOUNT = 0x1032;
+ public static final int LVM_GETSTRINGWIDTH = 0x1011;
+// public static final int LVM_GETSTRINGWIDTHA = 0x1011;
+// public static final int LVM_GETSTRINGWIDTHW = 0x1057;
+ public static final int LVM_GETSUBITEMRECT = OS.LVM_FIRST + 56;
+// public static final int LVM_GETTEXTBKCOLOR = 0x1025;
+ public static final int LVM_GETTEXTCOLOR = 0x1023;
+ public static final int LVM_GETTOPINDEX = 0x1027;
+// public static final int LVM_GETVIEWRECT = 0x1022;
+ public static final int LVM_HITTEST = 0x1012;
+ public static final int LVM_INSERTCOLUMN = 0x101B;
+// public static final int LVM_INSERTCOLUMNA = 0x101B;
+// public static final int LVM_INSERTCOLUMNW = 0x1061;
+ public static final int LVM_INSERTITEM = 0x1007;
+// public static final int LVM_INSERTITEMA = 0x1007;
+// public static final int LVM_INSERTITEMW = 0x104D;
+// public static final int LVM_REDRAWITEMS = 0x1015;
+ public static final int LVM_SCROLL = 0x1014;
+ public static final int LVM_SETBKCOLOR = 0x1001;
+// public static final int LVM_SETCALLBACKMASK = 0x100B;
+ public static final int LVM_SETCOLUMN = 0x101A;
+// public static final int LVM_SETCOLUMNA = 0x101A;
+// public static final int LVM_SETCOLUMNW = 0x1060;
+ public static final int LVM_SETCOLUMNWIDTH = 0x101E;
+ public static final int LVM_SETEXTENDEDLISTVIEWSTYLE = (LVM_FIRST + 54);
+ public static final int LVM_SETIMAGELIST = 0x1003;
+ public static final int LVM_SETITEM = 0x1006;
+// public static final int LVM_SETITEMA = 0x1006;
+// public static final int LVM_SETITEMCOUNT = 0x102F;
+// public static final int LVM_SETITEMPOSITION = 0x100F;
+// public static final int LVM_SETITEMPOSITION32 = 0x1031;
+ public static final int LVM_SETITEMSTATE = 0x102B;
+// public static final int LVM_SETITEMTEXT = 0x102E;
+// public static final int LVM_SETITEMTEXTA = 0x102E;
+// public static final int LVM_SETITEMTEXTW = 0x1074;
+// public static final int LVM_SETITEMW = 0x104C;
+ public static final int LVM_SETTEXTBKCOLOR = 0x1026;
+ public static final int LVM_SETTEXTCOLOR = 0x1024;
+// public static final int LVM_SORTITEMS = 0x1030;
+// public static final int LVM_UPDATE = 0x102A;
+ public static final int LVN_BEGINDRAG = 0xFFFFFF93;
+// public static final int LVN_BEGINLABELEDIT = 0xFFFFFF97;
+// public static final int LVN_BEGINLABELEDITA = 0xFFFFFF97;
+// public static final int LVN_BEGINLABELEDITW = 0xFFFFFF51;
+ public static final int LVN_BEGINRDRAG = 0xFFFFFF91;
+ public static final int LVN_COLUMNCLICK = 0xFFFFFF94;
+// public static final int LVN_DELETEALLITEMS = 0xFFFFFF98;
+// public static final int LVN_DELETEITEM = 0xFFFFFF99;
+// public static final int LVN_ENDLABELEDIT = 0xFFFFFF96;
+// public static final int LVN_ENDLABELEDITA = 0xFFFFFF96;
+// public static final int LVN_ENDLABELEDITW = 0xFFFFFF50;
+ public static final int LVN_FIRST = 0xFFFFFF9C;
+// public static final int LVN_GETDISPINFO = 0xFFFFFF6A;
+// public static final int LVN_GETDISPINFOA = 0xFFFFFF6A;
+// public static final int LVN_GETDISPINFOW = 0xFFFFFF4F;
+// public static final int LVN_HOTTRACK = (LVN_FIRST-21);
+// public static final int LVN_INSERTITEM = 0xFFFFFF9A;
+ public static final int LVN_ITEMACTIVATE = (LVN_FIRST-14);
+ public static final int LVN_ITEMCHANGED = 0xFFFFFF9B;
+// public static final int LVN_ITEMCHANGING = 0xFFFFFF9C;
+// public static final int LVN_KEYDOWN = 0xFFFFFF65;
+// public static final int LVN_LAST = 0xFFFFFF39;
+ public static final int LVN_MARQUEEBEGIN = (LVN_FIRST-56);
+// public static final int LVN_ODCACHEHINT = (LVN_FIRST-13);
+// public static final int LVN_ODFINDITEM = LVN_ODFINDITEMA;
+// public static final int LVN_ODFINDITEMA = (LVN_FIRST-52);
+// public static final int LVN_ODFINDITEMW = (LVN_FIRST-79);
+// public static final int LVN_ODSTATECHANGED = (LVN_FIRST-15);
+// public static final int LVN_SETDISPINFO = 0xFFFFFF69;
+// public static final int LVN_SETDISPINFOA = 0xFFFFFF69;
+// public static final int LVN_SETDISPINFOW = 0xFFFFFF4E;
+// public static final int LVNI_ABOVE = 0x100;
+// public static final int LVNI_ALL = 0x0;
+// public static final int LVNI_BELOW = 0x200;
+// public static final int LVNI_CUT = 0x4;
+// public static final int LVNI_DROPHILITED = 0x8;
+ public static final int LVNI_FOCUSED = 0x1;
+ public static final int LVNI_SELECTED = 0x2;
+// public static final int LVNI_TOLEFT = 0x400;
+// public static final int LVNI_TORIGHT = 0x800;
+// public static final int LVS_ALIGNLEFT = 0x800;
+// public static final int LVS_ALIGNMASK = 0xC00;
+// public static final int LVS_ALIGNTOP = 0x0;
+// public static final int LVS_AUTOARRANGE = 0x100;
+// public static final int LVS_EDITLABELS = 0x200;
+// public static final int LVS_EX_CHECKBOXES = 0x00000004;
+// public static final int LVS_EX_FLATSB = 0x00000100;
+ public static final int LVS_EX_FULLROWSELECT = 0x00000020; // applies to report mode only
+ public static final int LVS_EX_GRIDLINES = 0x00000001;
+// public static final int LVS_EX_HEADERDRAGDROP = 0x00000010;
+// public static final int LVS_EX_INFOTIP = 00000400; // listview does InfoTips for you
+ public static final int LVS_EX_LABELTIP = 0x00004000;
+// public static final int LVS_EX_MULTIWORKAREAS = 0x00002000;
+ public static final int LVS_EX_ONECLICKACTIVATE = 0x00000040;
+// public static final int LVS_EX_REGIONAL = 0x00000200;
+ public static final int LVS_EX_SUBITEMIMAGES = 0x00000002;
+ public static final int LVS_EX_TRACKSELECT = 0x00000008;
+ public static final int LVS_EX_TWOCLICKACTIVATE = 0x00000080;
+// public static final int LVS_EX_UNDERLINECOLD = 0x00001000;
+// public static final int LVS_EX_UNDERLINEHOT = 0x00000800;
+// public static final int LVS_ICON = 0x0;
+// public static final int LVS_LIST = 0x3;
+ public static final int LVS_NOCOLUMNHEADER = 0x4000;
+// public static final int LVS_NOLABELWRAP = 0x80;
+ public static final int LVS_NOSCROLL = 0x2000;
+// public static final int LVS_NOSORTHEADER = 0x8000;
+// public static final int LVS_OWNERDRAWFIXED = 0x400;
+ public static final int LVS_REPORT = 0x1;
+ public static final int LVS_SHAREIMAGELISTS = 0x40;
+ public static final int LVS_SHOWSELALWAYS = 0x8;
+ public static final int LVS_SINGLESEL = 0x4;
+// public static final int LVS_SMALLICON = 0x2;
+// public static final int LVS_SORTASCENDING = 0x10;
+// public static final int LVS_SORTDESCENDING = 0x20;
+// public static final int LVS_TYPEMASK = 0x3;
+// public static final int LVS_TYPESTYLEMASK = 0xFC00;
+ public static final int LVSCW_AUTOSIZE = 0xFFFFFFFF;
+ public static final int LVSCW_AUTOSIZE_USEHEADER = 0xFFFFFFFE;
+// public static final int LVSIL_NORMAL = 0x0;
+ public static final int LVSIL_SMALL = 0x1;
+ public static final int LVSIL_STATE = 0x2;
+// public static final int MAX_TAB_STOPS = 32;
+// public static final int MA_ACTIVATE = 0x1;
+// public static final int MA_ACTIVATEANDEAT = 0x2;
+ public static final int MA_NOACTIVATE = 0x3;
+// public static final int MA_NOACTIVATEANDEAT = 0x4;
+ public static final int MB_ABORTRETRYIGNORE = 0x2;
+ public static final int MB_APPLMODAL = 0x0;
+// public static final int MB_COMPOSITE = 0x2;
+// public static final int MB_DEFAULT_DESKTOP_ONLY = 0x20000;
+// public static final int MB_DEFBUTTON1 = 0x0;
+// public static final int MB_DEFBUTTON2 = 0x100;
+// public static final int MB_DEFBUTTON3 = 0x200;
+// public static final int MB_DEFBUTTON4 = 0x300;
+// public static final int MB_DEFMASK = 0xF00;
+// public static final int MB_ERR_INVALID_CHARS = 0x8;
+// public static final int MB_HELP = 0x4000;
+// public static final int MB_ICONASTERISK = 0x40;
+ public static final int MB_ICONERROR = 0x10;
+// public static final int MB_ICONEXCLAMATION = 0x30;
+// public static final int MB_ICONHAND = 0x10;
+ public static final int MB_ICONINFORMATION = 0x40;
+// public static final int MB_ICONMASK = 0xF0;
+ public static final int MB_ICONQUESTION = 0x20;
+// public static final int MB_ICONSTOP = 0x10;
+ public static final int MB_ICONWARNING = 0x30;
+// public static final int MB_MISCMASK = 0xC000;
+// public static final int MB_MODEMASK = 0x3000;
+// public static final int MB_NOFOCUS = 0x8000;
+ public static final int MB_OK = 0x0;
+ public static final int MB_OKCANCEL = 0x1;
+ public static final int MB_PRECOMPOSED = 0x1;
+ public static final int MB_RETRYCANCEL = 0x5;
+// public static final int MB_RIGHT = 0x80000;
+// public static final int MB_RTLREADING = 0x100000;
+// public static final int MB_SERVICE_NOTIFICATION = 0x40000;
+// public static final int MB_SETFOREGROUND = 0x10000;
+ public static final int MB_SYSTEMMODAL = 0x1000;
+ public static final int MB_TASKMODAL = 0x2000;
+// public static final int MB_TOPMOST = 0x40000;
+// public static final int MB_TYPEMASK = 0xF;
+// public static final int MB_USEGLYPHCHARS = 0x4;
+// public static final int MB_USERICON = 0x80;
+ public static final int MB_YESNO = 0x4;
+ public static final int MB_YESNOCANCEL = 0x3;
+// public static final int MERGECOPY = 0xC000CA;
+// public static final int MERGEPAINT = 0xBB0226;
+// public static final int MF_APPEND = 0x100;
+// public static final int MF_BITMAP = 0x4;
+ public static final int MF_BYCOMMAND = 0x0;
+ public static final int MF_BYPOSITION = 0x400;
+// public static final int MF_CALLBACKS = 0x8000000;
+// public static final int MF_CHANGE = 0x80;
+// public static final int MF_CHECKED = 0x8;
+// public static final int MF_CONV = 0x40000000;
+// public static final int MF_DEFAULT = 0x1000;
+// public static final int MF_DELETE = 0x200;
+ public static final int MF_DISABLED = 0x2;
+ public static final int MF_ENABLED = 0x0;
+// public static final int MF_END = 0x80;
+// public static final int MF_ERRORS = 0x10000000;
+ public static final int MF_GRAYED = 0x1;
+// public static final int MF_HELP = 0x4000;
+ public static final int MF_HILITE = 0x80;
+// public static final int MF_HSZ_INFO = 0x1000000;
+// public static final int MF_INSERT = 0x0;
+// public static final int MF_LINKS = 0x20000000;
+// public static final int MF_MASK = 0xFF000000;
+// public static final int MF_MENUBARBREAK = 0x20;
+// public static final int MF_MENUBREAK = 0x40;
+// public static final int MF_MOUSESELECT = 0x8000;
+// public static final int MF_OWNERDRAW = 0x100;
+ public static final int MF_POPUP = 0x10;
+// public static final int MF_POSTMSGS = 0x4000000;
+// public static final int MF_REMOVE = 0x1000;
+// public static final int MF_RIGHTJUSTIFY = 0x4000;
+// public static final int MF_SENDMSGS = 0x2000000;
+// public static final int MF_SEPARATOR = 0x800;
+// public static final int MF_STRING = 0x0;
+ public static final int MF_SYSMENU = 0x2000;
+// public static final int MF_UNCHECKED = 0x0;
+// public static final int MF_UNHILITE = 0x0;
+// public static final int MF_USECHECKBITMAPS = 0x200;
+// public static final int MFCOMMENT = 0xF;
+ public static final int MFS_CHECKED = 0x8;
+// public static final int MFS_DEFAULT = 0x1000;
+ public static final int MFS_DISABLED = 0x3;
+// public static final int MFS_ENABLED = 0x0;
+ public static final int MFS_GRAYED = 0x3;
+// public static final int MFS_HILITE = 0x80;
+// public static final int MFS_UNCHECKED = 0x0;
+// public static final int MFS_UNHILITE = 0x0;
+// public static final int MFT_BITMAP = 0x4;
+// public static final int MFT_MENUBARBREAK = 0x20;
+// public static final int MFT_MENUBREAK = 0x40;
+// public static final int MFT_OWNERDRAW = 0x100;
+ public static final int MFT_RADIOCHECK = 0x200;
+// public static final int MFT_RIGHTJUSTIFY = 0x4000;
+// public static final int MFT_RIGHTORDER = 0x2000;
+ public static final int MFT_SEPARATOR = 0x800;
+ public static final int MFT_STRING = 0x0;
+ public static final int MIIM_BITMAP = 0x80;
+// public static final int MIIM_CHECKMARKS = 0x8;
+// public static final int MIIM_DATA = 0x20;
+// public static final int MIIM_FTYPE = 0x00000100;
+ public static final int MIIM_ID = 0x2;
+ public static final int MIIM_STATE = 0x1;
+// public static final int MIIM_STRING = 0x00000040;
+ public static final int MIIM_SUBMENU = 0x4;
+ public static final int MIIM_TYPE = 0x10;
+// public static final int MK_ALT = 0x20;
+ public static final int MK_CONTROL = 0x8;
+ public static final int MK_LBUTTON = 0x1;
+ public static final int MK_MBUTTON = 0x10;
+ public static final int MK_RBUTTON = 0x2;
+ public static final int MK_SHIFT = 0x4;
+ public static final int MM_TEXT = 1;
+ public static final int MNC_CLOSE = 0x1;
+// public static final int MNC_EXECUTE = 0x2;
+// public static final int MNC_IGNORE = 0x0;
+// public static final int MNC_SELECT = 0x3;
+// public static final int NM_CHAR = (NM_FIRST-18);
+ public static final int NM_CLICK = (NM_FIRST-2);
+// public static final int NM_CUSTOMDRAW = (NM_FIRST-12);
+ public static final int NM_DBLCLK = (NM_FIRST-3);
+// public static final int NM_HOVER = (NM_FIRST-13);
+// public static final int NM_KEYDOWN = (NM_FIRST-15);
+// public static final int NM_KILLFOCUS = (NM_FIRST-8);
+// public static final int NM_LAST = -99;
+// public static final int NM_NCHITTEST = (NM_FIRST-14);
+// public static final int NM_OUTOFMEMORY = (NM_FIRST-1);
+// public static final int NM_RCLICK = (NM_FIRST-5);
+// public static final int NM_RDBLCLK = (NM_FIRST-6);
+// public static final int NM_RELEASEDCAPTURE = (NM_FIRST-16);
+ public static final int NM_RETURN = (NM_FIRST-4);
+// public static final int NM_SETCURSOR = (NM_FIRST-17);
+// public static final int NM_SETFOCUS = (NM_FIRST-7);
+ public static final int NOTSRCCOPY = 0x330008;
+// public static final int NOTSRCERASE = 0x1100A6;
+ public static final int NULL_BRUSH = 0x5;
+ public static final int NULL_PEN = 0x8;
+ public static final int NULLREGION = 0x1;
+// public static final int OBJ_BITMAP = 0x7;
+// public static final int OBJ_BRUSH = 0x2;
+// public static final int OBJ_DC = 0x3;
+// public static final int OBJ_ENHMETADC = 0xC;
+// public static final int OBJ_ENHMETAFILE = 0xD;
+// public static final int OBJ_EXTPEN = 0xB;
+ public static final int OBJ_FONT = 0x6;
+// public static final int OBJ_MEMDC = 0xA;
+// public static final int OBJ_METADC = 0x4;
+// public static final int OBJ_METAFILE = 0x9;
+// public static final int OBJ_PAL = 0x5;
+ public static final int OBJ_PEN = 0x1;
+// public static final int OBJ_REGION = 0x8;
+// public static final int OBJECT_INHERIT_ACE = 0x1;
+// public static final int OBM_BTNCORNERS = 0x7FF6;
+// public static final int OBM_BTSIZE = 0x7FF9;
+// public static final int OBM_CHECK = 0x7FF8;
+ public static final int OBM_CHECKBOXES = 0x7FF7;
+// public static final int OBM_CLOSE = 0x7FF2;
+// public static final int OBM_COMBO = 0x7FE2;
+// public static final int OBM_DNARROW = 0x7FF0;
+// public static final int OBM_DNARROWD = 0x7FE6;
+// public static final int OBM_DNARROWI = 0x7FE0;
+// public static final int OBM_LFARROW = 0x7FEE;
+// public static final int OBM_LFARROWD = 0x7FE4;
+// public static final int OBM_LFARROWI = 0x7FDE;
+// public static final int OBM_MNARROW = 0x7FE3;
+// public static final int OBM_OLD_CLOSE = 0x7FFF;
+// public static final int OBM_OLD_DNARROW = 0x7FFC;
+// public static final int OBM_OLD_LFARROW = 0x7FFA;
+// public static final int OBM_OLD_REDUCE = 0x7FF5;
+// public static final int OBM_OLD_RESTORE = 0x7FF3;
+// public static final int OBM_OLD_RGARROW = 0x7FFB;
+// public static final int OBM_OLD_UPARROW = 0x7FFD;
+// public static final int OBM_OLD_ZOOM = 0x7FF4;
+// public static final int OBM_REDUCE = 0x7FED;
+// public static final int OBM_REDUCED = 0x7FEA;
+// public static final int OBM_RESTORE = 0x7FEB;
+// public static final int OBM_RESTORED = 0x7FE8;
+// public static final int OBM_RGARROW = 0x7FEF;
+// public static final int OBM_RGARROWD = 0x7FE5;
+// public static final int OBM_RGARROWI = 0x7FDF;
+// public static final int OBM_SIZE = 0x7FFE;
+// public static final int OBM_UPARROW = 0x7FF1;
+// public static final int OBM_UPARROWD = 0x7FE7;
+// public static final int OBM_UPARROWI = 0x7FE1;
+// public static final int OBM_ZOOM = 0x7FEC;
+// public static final int OBM_ZOOMD = 0x7FE9;
+// public static final int OCR_APPSTARTING = 0x7F8A;
+// public static final int OCR_CROSS = 0x7F03;
+// public static final int OCR_IBEAM = 0x7F01;
+// public static final int OCR_ICOCUR = 0x7F87;
+// public static final int OCR_ICON = 0x7F81;
+// public static final int OCR_NO = 0x7F88;
+// public static final int OCR_NORMAL = 0x7F00;
+// public static final int OCR_SIZE = 0x7F80;
+// public static final int OCR_SIZEALL = 0x7F86;
+// public static final int OCR_SIZENESW = 0x7F83;
+// public static final int OCR_SIZENS = 0x7F85;
+// public static final int OCR_SIZENWSE = 0x7F82;
+// public static final int OCR_SIZEWE = 0x7F84;
+// public static final int OCR_UP = 0x7F04;
+// public static final int OCR_WAIT = 0x7F02;
+// public static final int ODA_DRAWENTIRE = 0x1;
+// public static final int ODA_FOCUS = 0x4;
+// public static final int ODA_SELECT = 0x2;
+// public static final int ODDPARITY = 0x1;
+// public static final int ODS_CHECKED = 0x8;
+// public static final int ODS_COMBOBOXEDIT = 0x1000;
+// public static final int ODS_DEFAULT = 0x20;
+// public static final int ODS_DISABLED = 0x4;
+// public static final int ODS_FOCUS = 0x10;
+// public static final int ODS_GRAYED = 0x2;
+ public static final int ODS_SELECTED = 0x1;
+// public static final int ODT_BUTTON = 0x4;
+// public static final int ODT_COMBOBOX = 0x3;
+// public static final int ODT_HEADER = 0x64;
+// public static final int ODT_LISTBOX = 0x2;
+// public static final int ODT_LISTVIEW = 0x66;
+ public static final int ODT_MENU = 0x1;
+// public static final int ODT_STATIC = 0x5;
+// public static final int ODT_TAB = 0x65;
+// public static final int OEM_FIXED_FONT = 0xA;
+ public static final int OFN_ALLOWMULTISELECT = 0x200;
+// public static final int OFN_CREATEPROMPT = 0x2000;
+// public static final int OFN_ENABLEHOOK = 0x20;
+// public static final int OFN_ENABLETEMPLATE = 0x40;
+// public static final int OFN_ENABLETEMPLATEHANDLE = 0x80;
+ public static final int OFN_EXPLORER = 0x80000;
+// public static final int OFN_EXTENSIONDIFFERENT = 0x400;
+// public static final int OFN_FILEMUSTEXIST = 0x1000;
+ public static final int OFN_HIDEREADONLY = 0x4;
+// public static final int OFN_LONGNAMES = 0x200000;
+ public static final int OFN_NOCHANGEDIR = 0x8;
+// public static final int OFN_NODEREFERENCELINKS = 0x100000;
+// public static final int OFN_NOLONGNAMES = 0x40000;
+// public static final int OFN_NONETWORKBUTTON = 0x20000;
+// public static final int OFN_NOREADONLYRETURN = 0x8000;
+// public static final int OFN_NOTESTFILECREATE = 0x10000;
+// public static final int OFN_NOVALIDATE = 0x100;
+// public static final int OFN_OVERWRITEPROMPT = 0x2;
+// public static final int OFN_PATHMUSTEXIST = 0x800;
+// public static final int OFN_READONLY = 0x1;
+// public static final int OFN_SHAREAWARE = 0x4000;
+// public static final int OFN_SHAREFALLTHROUGH = 0x2;
+// public static final int OFN_SHARENOWARN = 0x1;
+// public static final int OFN_SHAREWARN = 0x0;
+// public static final int OFN_SHOWHELP = 0x10;
+// public static final int OIC_BANG = 0x7F03;
+// public static final int OIC_ERROR = 0x7F01;
+// public static final int OIC_HAND = 0x7F01;
+// public static final int OIC_INFORMATION = 0x7F04;
+// public static final int OIC_NOTE = 0x7F04;
+// public static final int OIC_QUES = 0x7F02;
+// public static final int OIC_SAMPLE = 0x7F00;
+// public static final int OIC_WARNING = 0x7F03;
+// public static final int OIC_WINLOGO = 0x7F05;
+// public static final int OLEOP_DOVERB = 1;
+ public static final int OPAQUE = 0x2;
+ public static final int PATCOPY = 0xF00021;
+ public static final int PATINVERT = 0x5A0049;
+// public static final int PATPAINT = 0xFB0A09;
+// public static final int PBM_DELTAPOS = 0x403;
+ public static final int PBM_GETPOS = (WM_USER+8);
+ public static final int PBM_GETRANGE = (WM_USER+7); // wParam = return (TRUE ? low : high). lParam = PPBRANGE or NULL
+ public static final int PBM_SETBARCOLOR = (WM_USER+9); // lParam = bar color
+ public static final int PBM_SETBKCOLOR = CCM_SETBKCOLOR; // lParam = bkColor
+ public static final int PBM_SETPOS = 0x402;
+// public static final int PBM_SETRANGE = 0x401;
+ public static final int PBM_SETRANGE32 = (WM_USER+6); // lParam = high, wParam = low
+// public static final int PBM_SETSTEP = 0x404;
+// public static final int PBM_STEPIT = 0x405;
+ public static final int PBS_SMOOTH = 0x01;
+ public static final int PBS_VERTICAL = 0x04;
+// public static final int PC_DELIMITER = 4;
+// public static final int PC_FOLLOWING = 1;
+// public static final int PC_LEADING = 2;
+// public static final int PC_OVERFLOW = 3;
+ public static final int PD_ALLPAGES = 0x00000000;
+ public static final int PD_SELECTION = 0x00000001;
+ public static final int PD_PAGENUMS = 0x00000002;
+// public static final int PD_NOSELECTION = 0x00000004;
+// public static final int PD_NOPAGENUMS = 0x00000008;
+ public static final int PD_COLLATE = 0x00000010;
+ public static final int PD_PRINTTOFILE = 0x00000020;
+// public static final int PD_PRINTSETUP = 0x00000040;
+// public static final int PD_NOWARNING = 0x00000080;
+ public static final int PD_RETURNDC = 0x00000100;
+// public static final int PD_RETURNIC = 0x00000200;
+// public static final int PD_RETURNDEFAULT = 0x00000400;
+// public static final int PD_SHOWHELP = 0x00000800;
+// public static final int PD_ENABLEPRINTHOOK = 0x00001000;
+// public static final int PD_ENABLESETUPHOOK = 0x00002000;
+// public static final int PD_ENABLEPRINTTEMPLATE = 0x00004000;
+// public static final int PD_ENABLESETUPTEMPLATE = 0x00008000;
+// public static final int PD_ENABLEPRINTTEMPLATEHANDLE = 0x00010000;
+// public static final int PD_ENABLESETUPTEMPLATEHANDLE = 0x00020000;
+// public static final int PD_USEDEVMODECOPIES = 0x00040000;
+ public static final int PD_USEDEVMODECOPIESANDCOLLATE = 0x00040000;
+// public static final int PD_DISABLEPRINTTOFILE = 0x00080000;
+// public static final int PD_HIDEPRINTTOFILE = 0x00100000;
+// public static final int PD_NONETWORKBUTTON = 0x00200000;
+ public static final int RC_BITBLT = 1;
+// public static final int PRINTER_ENUM_NAME = 0x00000008;
+// public static final int PRINTER_ENUM_EXPAND = 0x00004000;
+// public static final int PRINTER_ENUM_CONTAINER = 0x00008000;
+// public static final int PRINTER_ENUM_ICON1 = 0x00010000;
+// public static final int PRINTER_ENUM_ICON2 = 0x00020000;
+// public static final int PRINTER_ENUM_ICON3 = 0x00040000;
+// public static final int PRINTER_ENUM_ICON4 = 0x00080000;
+// public static final int PRINTER_ENUM_ICON5 = 0x00100000;
+// public static final int PRINTER_ENUM_ICON6 = 0x00200000;
+// public static final int PRINTER_ENUM_ICON7 = 0x00400000;
+// public static final int PRINTER_ENUM_ICON8 = 0x00800000;
+// public static final int PFA_CENTER = 0x0003;
+// public static final int PFA_JUSTIFY = 4;
+// public static final int PFA_LEFT = 0x0001;
+// public static final int PFA_RIGHT = 0x0002;
+// public static final int PFE_DONOTHYPHEN = (PFM_DONOTHYPHEN >> 16);
+// public static final int PFE_KEEP = (PFM_KEEP >> 16);
+// public static final int PFE_KEEPNEXT = (PFM_KEEPNEXT >> 16);
+// public static final int PFE_NOLINENUMBER = (PFM_NOLINENUMBER >> 16);
+// public static final int PFE_NOWIDOWCONTROL = (PFM_NOWIDOWCONTROL >> 16);
+// public static final int PFE_PAGEBREAKBEFORE = (PFM_PAGEBREAKBEFORE >> 16);
+// public static final int PFE_RTLPAR = (PFM_RTLPARA >> 16);
+// public static final int PFE_RTLPARA = (PFM_DIR >> 16);
+// public static final int PFE_SIDEBYSIDE = (PFM_SIDEBYSIDE >> 16);
+// public static final int PFE_TABLECELL = 0x4000;
+// public static final int PFE_TABLECELLEND = 0x8000;
+// public static final int PFE_TABLEROW = 0xC000;
+// public static final int PFM_ALIGNMENT = 0x00000008;
+// public static final int PFM_ALL = (PFM_STARTINDENT | PFM_RIGHTINDENT | PFM_OFFSET | PFM_ALIGNMENT | PFM_TABSTOPS | PFM_NUMBERING | PFM_OFFSETINDENT | PFM_DIR);
+// public static final int PFM_ALL2 = (PFM_ALL | PFM_EFFECTS | PFM_SPACEBEFORE | PFM_SPACEAFTER | PFM_LINESPACING | PFM_STYLE | PFM_SHADING | PFM_BORDER | PFM_NUMBERINGTAB | PFM_NUMBERINGSTART | PFM_NUMBERINGSTYLE);
+// public static final int PFM_BORDER = 0x00000800;
+// public static final int PFM_DIR = 0x00010000;
+// public static final int PFM_DONOTHYPHEN = 0x00400000;
+// public static final int PFM_EFFECTS = (PFM_DIR | PFM_KEEP | PFM_KEEPNEXT | PFM_TABLE | PFM_PAGEBREAKBEFORE | PFM_NOLINENUMBER | PFM_NOWIDOWCONTROL | PFM_DONOTHYPHEN | PFM_SIDEBYSIDE | PFM_TABLE);
+// public static final int PFM_KEEP = 0x00020000;
+// public static final int PFM_KEEPNEXT = 0x00040000;
+// public static final int PFM_LINESPACING = 0x00000100;
+// public static final int PFM_NOLINENUMBER = 0x00100000;
+// public static final int PFM_NOWIDOWCONTROL = 0x00200000;
+// public static final int PFM_NUMBERING = 0x00000020;
+// public static final int PFM_NUMBERINGSTART = 0x00008000;
+// public static final int PFM_NUMBERINGSTYLE = 0x00002000;
+// public static final int PFM_NUMBERINGTAB = 0x00004000;
+// public static final int PFM_OFFSET = 0x00000004;
+// public static final int PFM_OFFSETINDENT = 0x80000000;
+// public static final int PFM_PAGEBREAKBEFORE = 0x00080000;
+// public static final int PFM_RIGHTINDENT = 0x00000002;
+// public static final int PFM_RTLPARA = 0x00010000;
+// public static final int PFM_SHADING = 0x00001000;
+// public static final int PFM_SIDEBYSIDE = 0x00800000;
+// public static final int PFM_SPACEAFTER = 0x00000080;
+// public static final int PFM_SPACEBEFORE = 0x00000040;
+// public static final int PFM_STARTINDENT = 0x00000001;
+// public static final int PFM_STYLE = 0x00000400;
+// public static final int PFM_TABLE = 0xC0000000;
+ public static final int PFM_TABSTOPS = 0x00000010;
+// public static final int PFN_BULLET = 0x0001;
+ public static final int PLANES = 14;
+ public static final int PHYSICALOFFSETX = 112;
+ public static final int PHYSICALOFFSETY = 113;
+ public static final int PHYSICALWIDTH = 110;
+ public static final int PHYSICALHEIGHT = 111;
+// public static final int PM_NOREMOVE = 0x0;
+// public static final int PM_NOYIELD = 0x2;
+ public static final int PM_REMOVE = 0x1;
+// public static final int PS_ALTERNATE = 0x8;
+// public static final int PS_COSMETIC = 0x0;
+ public static final int PS_DASH = 0x1;
+ public static final int PS_DASHDOT = 0x3;
+ public static final int PS_DASHDOTDOT = 0x4;
+ public static final int PS_DOT = 0x2;
+ public static final int PS_ENDCAP_FLAT = 0x200;
+// public static final int PS_ENDCAP_MASK = 0xF00;
+// public static final int PS_ENDCAP_ROUND = 0x0;
+// public static final int PS_ENDCAP_SQUARE = 0x100;
+ public static final int PS_GEOMETRIC = 0x10000;
+// public static final int PS_INSIDEFRAME = 0x6;
+// public static final int PS_JOIN_BEVEL = 0x1000;
+// public static final int PS_JOIN_MASK = 0xF000;
+ public static final int PS_JOIN_MITER = 0x2000;
+// public static final int PS_JOIN_ROUND = 0x0;
+// public static final int PS_MAXLINKTYPES = 0x8;
+// public static final int PS_NULL = 0x5;
+ public static final int PS_SOLID = 0x0;
+ public static final int PS_STYLE_MASK = 0xF;
+// public static final int PS_TYPE_MASK = 0xF0000;
+// public static final int PS_USERSTYLE = 0x7;
+// public static final int PSBTN_APPLYNOW = 0x4;
+// public static final int PSBTN_BACK = 0x0;
+// public static final int PSBTN_CANCEL = 0x5;
+// public static final int PSBTN_FINISH = 0x2;
+// public static final int PSBTN_HELP = 0x6;
+// public static final int PSBTN_MAX = 0x6;
+// public static final int PSBTN_NEXT = 0x1;
+// public static final int PSBTN_OK = 0x3;
+// public static final int PSCB_INITIALIZED = 0x1;
+// public static final int PSCB_PRECREATE = 0x2;
+// public static final int PSD_DEFAULTMINMARGINS = 0x0;
+// public static final int PSD_DISABLEMARGINS = 0x10;
+// public static final int PSD_DISABLEORIENTATION = 0x100;
+// public static final int PSD_DISABLEPAGEPAINTING = 0x80000;
+// public static final int PSD_DISABLEPAPER = 0x200;
+// public static final int PSD_DISABLEPRINTER = 0x20;
+// public static final int PSD_ENABLEPAGEPAINTHOOK = 0x40000;
+// public static final int PSD_ENABLEPAGESETUPHOOK = 0x2000;
+// public static final int PSD_ENABLEPAGESETUPTEMPLATE = 0x8000;
+// public static final int PSD_ENABLEPAGESETUPTEMPLATEHANDLE = 0x20000;
+// public static final int PSD_INHUNDREDTHSOFMILLIMETERS = 0x8;
+// public static final int PSD_INTHOUSANDTHSOFINCHES = 0x4;
+// public static final int PSD_INWININIINTLMEASURE = 0x0;
+// public static final int PSD_MARGINS = 0x2;
+// public static final int PSD_MINMARGINS = 0x1;
+// public static final int PSD_NOWARNING = 0x80;
+// public static final int PSD_RETURNDEFAULT = 0x400;
+// public static final int PSD_SHOWHELP = 0x800;
+// public static final int PSF_CHECKDISPLAYASICON = 0x8;
+// public static final int PSF_DISABLEDISPLAYASICON = 0x10;
+// public static final int PSF_HIDECHANGEICON = 0x20;
+// public static final int PSF_NOREFRESHDATAOBJECT = 0x80;
+// public static final int PSF_SELECTPASTE = 0x2;
+// public static final int PSF_SELECTPASTELINK = 0x4;
+// public static final int PSF_SHOWHELP = 0x1;
+// public static final int PSF_STAYONCLIPBOARDCHANGE = 0x40;
+// public static final int PSH_DEFAULT = 0x0;
+// public static final int PSH_HASHELP = 0x200;
+// public static final int PSH_HELP = 0x40E;
+// public static final int PSH_MODELESS = 0x400;
+// public static final int PSH_NOAPPLYNOW = 0x80;
+// public static final int PSH_PROPSHEETPAGE = 0x8;
+// public static final int PSH_PROPTITLE = 0x1;
+// public static final int PSH_RTLREADING = 0x800;
+// public static final int PSH_USECALLBACK = 0x100;
+// public static final int PSH_USEHICON = 0x2;
+// public static final int PSH_USEICONID = 0x4;
+// public static final int PSH_USEPSTARTPAGE = 0x40;
+// public static final int PSH_WIZARD = 0x20;
+// public static final int PSH1 = 0x400;
+// public static final int PSH10 = 0x409;
+// public static final int PSH11 = 0x40A;
+// public static final int PSH12 = 0x40B;
+// public static final int PSH13 = 0x40C;
+// public static final int PSH14 = 0x40D;
+// public static final int PSH15 = 0x40E;
+// public static final int PSH16 = 0x40F;
+// public static final int PSH2 = 0x401;
+// public static final int PSH3 = 0x402;
+// public static final int PSH4 = 0x403;
+// public static final int PSH5 = 0x404;
+// public static final int PSH6 = 0x405;
+// public static final int PSH7 = 0x406;
+// public static final int PSH8 = 0x407;
+// public static final int PSH9 = 0x408;
+// public static final int PSI_APPLY = 0x3;
+// public static final int PSI_CHANGED = 0x1;
+// public static final int PSI_GETSIBLINGS = 0x4;
+// public static final int PSI_GUISTART = 0x2;
+// public static final int PSI_HASHELP = 0x5;
+// public static final int PSI_HELP = 0x6;
+// public static final int PSI_KILLACTIVE = 0x2;
+// public static final int PSI_REBOOT = 0x3;
+// public static final int PSI_RESET = 0x4;
+// public static final int PSI_SETACTIVE = 0x1;
+// public static final int PSM_ADDPAGE = 0x467;
+// public static final int PSM_APPLY = 0x46E;
+// public static final int PSM_CANCELTOCLOSE = 0x46B;
+// public static final int PSM_CHANGED = 0x468;
+// public static final int PSM_GETCURRENTPAGEHWND = 0x476;
+// public static final int PSM_GETTABCONTROL = 0x474;
+// public static final int PSM_ISDIALOGMESSAGE = 0x475;
+// public static final int PSM_PAGEINFO = 0x464;
+// public static final int PSM_PRESSBUTTON = 0x471;
+// public static final int PSM_QUERYSIBLINGS = 0x46C;
+// public static final int PSM_REBOOTSYSTEM = 0x46A;
+// public static final int PSM_REMOVEPAGE = 0x466;
+// public static final int PSM_RESTARTWINDOWS = 0x469;
+// public static final int PSM_SETCURSEL = 0x465;
+// public static final int PSM_SETCURSELID = 0x472;
+// public static final int PSM_SETFINISHTEXT = 0x473;
+// public static final int PSM_SETFINISHTEXTA = 0x473;
+// public static final int PSM_SETFINISHTEXTW = 0x479;
+// public static final int PSM_SETTITLE = 0x46F;
+// public static final int PSM_SETTITLEA = 0x46F;
+// public static final int PSM_SETTITLEW = 0x478;
+// public static final int PSM_SETWIZBUTTONS = 0x470;
+// public static final int PSM_SHEETINFO = 0x465;
+// public static final int PSM_UNCHANGED = 0x46D;
+// public static final int PSNRET_INVALID = 0x1;
+// public static final int PSNRET_INVALID_NOCHANGEPAGE = 0x2;
+// public static final int PSNRET_NOERROR = 0x0;
+// public static final int PSP_DEFAULT = 0x0;
+// public static final int PSP_DLGINDIRECT = 0x1;
+// public static final int PSP_HASHELP = 0x20;
+// public static final int PSP_RTLREADING = 0x10;
+// public static final int PSP_USECALLBACK = 0x80;
+// public static final int PSP_USEHICON = 0x2;
+// public static final int PSP_USEICONID = 0x4;
+// public static final int PSP_USEREFPARENT = 0x40;
+// public static final int PSP_USETITLE = 0x8;
+// public static final int PSPCB_CREATE = 0x2;
+// public static final int PSPCB_RELEASE = 0x1;
+// public static final int PST_FAX = 0x21;
+// public static final int PST_LAT = 0x101;
+// public static final int PST_MODEM = 0x6;
+// public static final int PST_NETWORK_BRIDGE = 0x100;
+// public static final int PST_PARALLELPORT = 0x2;
+// public static final int PST_RS232 = 0x1;
+// public static final int PST_RS422 = 0x3;
+// public static final int PST_RS423 = 0x4;
+// public static final int PST_RS449 = 0x5;
+// public static final int PST_SCANNER = 0x22;
+// public static final int PST_TCPIP_TELNET = 0x102;
+// public static final int PST_UNSPECIFIED = 0x0;
+// public static final int PST_X25 = 0x103;
+// public static final int PSWIZB_BACK = 0x1;
+// public static final int PSWIZB_DISABLEDFINISH = 0x8;
+// public static final int PSWIZB_FINISH = 0x4;
+// public static final int PSWIZB_NEXT = 0x2;
+ public static final int R2_COPYPEN = 13;
+ public static final int R2_XORPEN = 7;
+ public static final int RASTER_FONTTYPE = 0x0001;
+ public static final int RASTERCAPS = 38;
+ public static final int RC_PALETTE = 0x0100;
+ public static final int RDW_ALLCHILDREN = 0x80;
+ public static final int RDW_ERASE = 0x4;
+// public static final int RDW_ERASENOW = 0x200;
+ public static final int RDW_FRAME = 0x400;
+// public static final int RDW_INTERNALPAINT = 0x2;
+ public static final int RDW_INVALIDATE = 0x1;
+// public static final int RDW_NOCHILDREN = 0x40;
+// public static final int RDW_NOERASE = 0x20;
+// public static final int RDW_NOFRAME = 0x800;
+// public static final int RDW_NOINTERNALPAINT = 0x10;
+ public static final int RDW_UPDATENOW = 0x100;
+// public static final int RDW_VALIDATE = 0x8;
+// public static final int RGN_AND = 0x1;
+// public static final int RGN_COPY = 0x5;
+// public static final int RGN_DIFF = 0x4;
+// public static final int RGN_ERROR = 0x0;
+// public static final int RGN_MAX = 0x5;
+// public static final int RGN_MIN = 0x1;
+ public static final int RGN_OR = 0x2;
+// public static final int RGN_XOR = 0x3;
+// public static final int S_SERBDNT = 0xFFFFFFFB;
+// public static final int S_SERDCC = 0xFFFFFFF9;
+// public static final int S_SERDDR = 0xFFFFFFF2;
+// public static final int S_SERDFQ = 0xFFFFFFF3;
+// public static final int S_SERDLN = 0xFFFFFFFA;
+// public static final int S_SERDMD = 0xFFFFFFF6;
+// public static final int S_SERDPT = 0xFFFFFFF4;
+// public static final int S_SERDSH = 0xFFFFFFF5;
+// public static final int S_SERDSR = 0xFFFFFFF1;
+// public static final int S_SERDST = 0xFFFFFFF0;
+// public static final int S_SERDTP = 0xFFFFFFF8;
+// public static final int S_SERDVL = 0xFFFFFFF7;
+// public static final int S_SERDVNA = 0xFFFFFFFF;
+// public static final int S_SERMACT = 0xFFFFFFFD;
+// public static final int S_SEROFM = 0xFFFFFFFE;
+// public static final int S_SERQFUL = 0xFFFFFFFC;
+// public static final int S_STACCATO = 0x2;
+// public static final int S_WHITE1024 = 0x5;
+// public static final int S_WHITE2048 = 0x6;
+// public static final int S_WHITE512 = 0x4;
+// public static final int S_WHITEVOICE = 0x7;
+// public static final int SB_BOTH = 0x3;
+ public static final int SB_BOTTOM = 0x7;
+ public static final int SB_CTL = 0x2;
+ public static final int SB_ENDSCROLL = 0x8;
+// public static final int SB_GETBORDERS = 0x407;
+// public static final int SB_GETPARTS = 0x406;
+// public static final int SB_GETRECT = 0x40A;
+// public static final int SB_GETTEXT = 0x402;
+// public static final int SB_GETTEXTA = 0x402;
+// public static final int SB_GETTEXTLENGTH = 0x403;
+// public static final int SB_GETTEXTLENGTHA = 0x403;
+// public static final int SB_GETTEXTLENGTHW = 0x40C;
+// public static final int SB_GETTEXTW = 0x40D;
+ public static final int SB_HORZ = 0x0;
+// public static final int SB_LEFT = 0x6;
+ public static final int SB_LINEDOWN = 0x1;
+// public static final int SB_LINELEFT = 0x0;
+// public static final int SB_LINERIGHT = 0x1;
+ public static final int SB_LINEUP = 0x0;
+ public static final int SB_PAGEDOWN = 0x3;
+// public static final int SB_PAGELEFT = 0x2;
+// public static final int SB_PAGERIGHT = 0x3;
+ public static final int SB_PAGEUP = 0x2;
+// public static final int SB_RIGHT = 0x7;
+// public static final int SB_SETMINHEIGHT = 0x408;
+// public static final int SB_SETPARTS = 0x404;
+// public static final int SB_SETTEXT = 0x401;
+// public static final int SB_SETTEXTA = 0x401;
+// public static final int SB_SETTEXTW = 0x40B;
+// public static final int SB_SIMPLE = 0x409;
+ public static final int SB_THUMBPOSITION = 0x4;
+ public static final int SB_THUMBTRACK = 0x5;
+ public static final int SB_TOP = 0x6;
+ public static final int SB_VERT = 0x1;
+// public static final int SBARS_SIZEGRIP = 0x100;
+// public static final int SBM_ENABLE_ARROWS = 0xE4;
+// public static final int SBM_GETPOS = 0xE1;
+// public static final int SBM_GETRANGE = 0xE3;
+// public static final int SBM_GETSCROLLINFO = 0xEA;
+// public static final int SBM_SETPOS = 0xE0;
+// public static final int SBM_SETRANGE = 0xE2;
+// public static final int SBM_SETRANGEREDRAW = 0xE6;
+// public static final int SBM_SETSCROLLINFO = 0xE9;
+// public static final int SBS_BOTTOMALIGN = 0x4;
+ public static final int SBS_HORZ = 0x0;
+// public static final int SBS_LEFTALIGN = 0x2;
+// public static final int SBS_RIGHTALIGN = 0x4;
+// public static final int SBS_SIZEBOX = 0x8;
+// public static final int SBS_SIZEBOXBOTTOMRIGHTALIGN = 0x4;
+// public static final int SBS_SIZEBOXTOPLEFTALIGN = 0x2;
+// public static final int SBS_SIZEGRIP = 0x10;
+// public static final int SBS_TOPALIGN = 0x2;
+ public static final int SBS_VERT = 0x1;
+// public static final int SBT_NOBORDERS = 0x100;
+// public static final int SBT_OWNERDRAW = 0x1000;
+// public static final int SBT_POPOUT = 0x200;
+// public static final int SBT_RTLREADING = 0x400;
+// public static final int SC_ARRANGE = 0xF110;
+ public static final int SC_CLOSE = 0xF060;
+// public static final int SC_CLOSE = 0xF060;
+// public static final int SC_CONTEXTHELP = 0xF180;
+// public static final int SC_DEFAULT = 0xF160;
+// public static final int SC_HOTKEY = 0xF150;
+ public static final int SC_HSCROLL = 0xF080;
+// public static final int SC_ICON = 0xF020;
+ public static final int SC_KEYMENU = 0xF100;
+// public static final int SC_MANAGER_ALL_ACCESS = 0xF003F;
+// public static final int SC_MANAGER_CONNECT = 0x1;
+// public static final int SC_MANAGER_CREATE_SERVICE = 0x2;
+// public static final int SC_MANAGER_ENUMERATE_SERVICE = 0x4;
+// public static final int SC_MANAGER_LOCK = 0x8;
+// public static final int SC_MANAGER_MODIFY_BOOT_CONFIG = 0x20;
+// public static final int SC_MANAGER_QUERY_LOCK_STATUS = 0x10;
+ public static final int SC_MAXIMIZE = 0xF030;
+ public static final int SC_MINIMIZE = 0xF020;
+// public static final int SC_MONITORPOWER = 0xF170;
+// public static final int SC_MOUSEMENU = 0xF090;
+// public static final int SC_MOVE = 0xF010;
+// public static final int SC_NEXTWINDOW = 0xF040;
+// public static final int SC_PREVWINDOW = 0xF050;
+ public static final int SC_RESTORE = 0xF120;
+// public static final int SC_SCREENSAVE = 0xF140;
+// public static final int SC_SEPARATOR = 0xF00F;
+ public static final int SC_SIZE = 0xF000;
+ public static final int SC_TASKLIST = 0xF130;
+ public static final int SC_VSCROLL = 0xF070;
+// public static final int SC_ZOOM = 0xF030;
+// public static final int SCALINGFACTORX = 0x72;
+// public static final int SCALINGFACTORY = 0x73;
+ public static final int SCF_ALL = 0x0004;
+ public static final int SCF_DEFAULT = 0x0000;
+ public static final int SCF_SELECTION = 0x0001;
+// public static final int SCF_USEUIRULES = 0x0008;
+// public static final int SCF_WORD = 0x0002;
+// public static final int SCR1 = 0x490;
+// public static final int SCR2 = 0x491;
+// public static final int SCR3 = 0x492;
+// public static final int SCR4 = 0x493;
+// public static final int SCR5 = 0x494;
+// public static final int SCR6 = 0x495;
+// public static final int SCR7 = 0x496;
+// public static final int SCR8 = 0x497;
+// public static final int SCREEN_FONTTYPE = 0x2000;
+// public static final int SCROLLLOCK_ON = 0x40;
+// public static final int SCS_CAP_COMPSTR = 0x1;
+// public static final int SCS_CAP_MAKEREAD = 0x2;
+// public static final int SCS_CHANGEATTR = 0x12;
+// public static final int SCS_CHANGECLAUSE = 0x24;
+// public static final int SCS_DOS_BINARY = 0x1;
+// public static final int SCS_OS216_BINARY = 0x5;
+// public static final int SCS_PIF_BINARY = 0x3;
+// public static final int SCS_POSIX_BINARY = 0x4;
+// public static final int SCS_SETSTR = 0x9;
+// public static final int SCS_WOW_BINARY = 0x2;
+// public static final int SCS32BIT_BINARY = 0x0;
+// public static final int SEL_EMPTY = 0x0000;
+// public static final int SEL_MULTICHAR = 0x0004;
+// public static final int SEL_MULTIOBJECT = 0x0008;
+// public static final int SEL_OBJECT = 0x0002;
+// public static final int SEL_TEXT = 0x0001;
+ public static final int SF_RTF = 0x0002;
+// public static final int SF_RTFNOOBJS = 0x0003;
+// public static final int SF_TEXT = 0x0001;
+// public static final int SF_TEXTIZED = 0x0004;
+// public static final int SF_UNICODE = 0x0010;
+// public static final int SFF_PLAINRTF = 0x4000;
+// public static final int SFF_SELECTION = 0x8000;
+ public static final int SIF_ALL = 0x17;
+ public static final int SIF_DISABLENOSCROLL = 0x8;
+ public static final int SIF_PAGE = 0x2;
+ public static final int SIF_POS = 0x4;
+ public static final int SIF_RANGE = 0x1;
+ public static final int SIF_TRACKPOS = 0x10;
+// public static final int SIMPLEREGION = 0x2;
+// public static final int SIZE_MAXHIDE = 0x4;
+// public static final int SIZE_MAXIMIZED = 0x2;
+// public static final int SIZE_MAXSHOW = 0x3;
+ public static final int SIZE_MINIMIZED = 0x1;
+// public static final int SIZE_OF80387_REGISTERS = 0x50;
+// public static final int SIZE_RESTORED = 0x0;
+// public static final int SIZEFULLSCREEN = 0x2;
+// public static final int SIZEICONIC = 0x1;
+// public static final int SIZENORMAL = 0x0;
+// public static final int SIZEOF_RFPO_DATA = 0x10;
+// public static final int SIZEPALETTE = 0x68;
+// public static final int SIZEZOOMHIDE = 0x4;
+// public static final int SIZEZOOMSHOW = 0x3;
+// public static final int SM_ARRANGE = 0x38;
+// public static final int SM_CLEANBOOT = 0x43;
+// public static final int SM_CMETRICS = 0x4B;
+// public static final int SM_CMOUSEBUTTONS = 0x2B;
+ public static final int SM_CXBORDER = 0x5;
+ public static final int SM_CXCURSOR = 0xD;
+// public static final int SM_CXDLGFRAME = 0x7;
+// public static final int SM_CXDOUBLECLK = 0x24;
+// public static final int SM_CXDRAG = 0x44;
+ public static final int SM_CXEDGE = 0x2D;
+// public static final int SM_CXFIXEDFRAME = 0x7;
+// public static final int SM_CXFRAME = 0x20;
+// public static final int SM_CXFULLSCREEN = 0x10;
+ public static final int SM_CXHSCROLL = 0x15;
+// public static final int SM_CXHTHUMB = 0xA;
+// public static final int SM_CXICON = 0xB;
+// public static final int SM_CXICONSPACING = 0x26;
+// public static final int SM_CXMAXIMIZED = 0x3D;
+// public static final int SM_CXMAXTRACK = 0x3B;
+// public static final int SM_CXMENUCHECK = 0x47;
+// public static final int SM_CXMENUSIZE = 0x36;
+// public static final int SM_CXMIN = 0x1C;
+// public static final int SM_CXMINIMIZED = 0x39;
+// public static final int SM_CXMINSPACING = 0x2F;
+// public static final int SM_CXMINTRACK = 0x22;
+ public static final int SM_CXSCREEN = 0x0;
+// public static final int SM_CXSIZE = 0x1E;
+// public static final int SM_CXSIZEFRAME = 0x20;
+// public static final int SM_CXSMICON = 0x31;
+// public static final int SM_CXSMSIZE = 0x34;
+ public static final int SM_CXVSCROLL = 0x2;
+ public static final int SM_CYBORDER = 0x6;
+// public static final int SM_CYCAPTION = 0x4;
+ public static final int SM_CYCURSOR = 0xE;
+// public static final int SM_CYDLGFRAME = 0x8;
+// public static final int SM_CYDOUBLECLK = 0x25;
+// public static final int SM_CYDRAG = 0x45;
+// public static final int SM_CYEDGE = 0x2E;
+// public static final int SM_CYFIXEDFRAME = 0x8;
+// public static final int SM_CYFRAME = 0x21;
+// public static final int SM_CYFULLSCREEN = 0x11;
+ public static final int SM_CYHSCROLL = 0x3;
+// public static final int SM_CYICON = 0xC;
+// public static final int SM_CYICONSPACING = 0x27;
+// public static final int SM_CYKANJIWINDOW = 0x12;
+// public static final int SM_CYMAXIMIZED = 0x3E;
+// public static final int SM_CYMAXTRACK = 0x3C;
+ public static final int SM_CYMENU = 0xF;
+// public static final int SM_CYMENUCHECK = 0x48;
+// public static final int SM_CYMENUSIZE = 0x37;
+// public static final int SM_CYMIN = 0x1D;
+// public static final int SM_CYMINIMIZED = 0x3A;
+// public static final int SM_CYMINSPACING = 0x30;
+// public static final int SM_CYMINTRACK = 0x23;
+ public static final int SM_CYSCREEN = 0x1;
+// public static final int SM_CYSIZE = 0x1F;
+// public static final int SM_CYSIZEFRAME = 0x21;
+// public static final int SM_CYSMCAPTION = 0x33;
+// public static final int SM_CYSMICON = 0x32;
+// public static final int SM_CYSMSIZE = 0x35;
+ public static final int SM_CYVSCROLL = 0x14;
+// public static final int SM_CYVTHUMB = 0x9;
+// public static final int SM_DBCSENABLED = 0x2A;
+// public static final int SM_DEBUG = 0x16;
+// public static final int SM_MENUDROPALIGNMENT = 0x28;
+// public static final int SM_MIDEASTENABLED = 0x4A;
+// public static final int SM_MOUSEPRESENT = 0x13;
+// public static final int SM_NETWORK = 0x3F;
+// public static final int SM_PENWINDOWS = 0x29;
+// public static final int SM_RESERVED1 = 0x18;
+// public static final int SM_RESERVED2 = 0x19;
+// public static final int SM_RESERVED3 = 0x1A;
+// public static final int SM_RESERVED4 = 0x1B;
+// public static final int SM_SECURE = 0x2C;
+// public static final int SM_SHOWSOUNDS = 0x46;
+// public static final int SM_SLOWMACHINE = 0x49;
+// public static final int SM_SWAPBUTTON = 0x17;
+// public static final int SMTO_ABORTIFHUNG = 0x2;
+// public static final int SMTO_BLOCK = 0x1;
+// public static final int SMTO_NORMAL = 0x0;
+ public static final int SRCAND = 0x8800C6;
+ public static final int SRCCOPY = 0xCC0020;
+// public static final int SRCERASE = 0x440328;
+ public static final int SRCINVERT = 0x660046;
+// public static final int SRCINVERT = 0x660046;
+ public static final int SRCPAINT = 0xEE0086;
+ public static final int SS_BITMAP = 0xE;
+// public static final int SS_BLACKFRAME = 0x7;
+// public static final int SS_BLACKRECT = 0x4;
+ public static final int SS_CENTER = 0x1;
+ public static final int SS_CENTERIMAGE = 0x200;
+// public static final int SS_ENHMETAFILE = 0xF;
+// public static final int SS_ETCHEDFRAME = 0x12;
+// public static final int SS_ETCHEDHORZ = 0x10;
+// public static final int SS_ETCHEDVERT = 0x11;
+// public static final int SS_GRAYFRAME = 0x8;
+// public static final int SS_GRAYRECT = 0x5;
+ public static final int SS_ICON = 0x3;
+ public static final int SS_LEFT = 0x0;
+ public static final int SS_LEFTNOWORDWRAP = 0xC;
+// public static final int SS_NOPREFIX = 0x80;
+ public static final int SS_NOTIFY = 0x100;
+ public static final int SS_OWNERDRAW = 0xD;
+ public static final int SS_REALSIZEIMAGE = 0x800;
+ public static final int SS_RIGHT = 0x2;
+// public static final int SS_RIGHTJUST = 0x400;
+// public static final int SS_SIMPLE = 0xB;
+// public static final int SS_SUNKEN = 0x1000;
+// public static final int SS_TYPEMASK = 0x1F;
+// public static final int SS_USERITEM = 0xA;
+// public static final int SS_WHITEFRAME = 0x9;
+// public static final int SS_WHITERECT = 0x6;
+// public static final int SSF_AVAILABLE = 0x2;
+// public static final int SSF_INDICATOR = 0x4;
+// public static final int SSF_SOUNDSENTRYON = 0x1;
+// public static final int SSGF_DISPLAY = 0x3;
+// public static final int SSGF_NONE = 0x0;
+// public static final int SSTF_BORDER = 0x2;
+// public static final int SSTF_CHARS = 0x1;
+// public static final int SSTF_DISPLAY = 0x3;
+// public static final int SSTF_NONE = 0x0;
+// public static final int SSWF_CUSTOM = 0x4;
+// public static final int SSWF_DISPLAY = 0x3;
+// public static final int SSWF_NONE = 0x0;
+// public static final int SSWF_TITLE = 0x1;
+// public static final int SSWF_WINDOW = 0x2;
+ public static final int STD_COPY = 0x1;
+ public static final int STD_CUT = 0x0;
+// public static final int STD_DELETE = 0x5;
+ public static final int STD_FILENEW = 0x6;
+ public static final int STD_FILEOPEN = 0x7;
+ public static final int STD_FILESAVE = 0x8;
+// public static final int STD_FIND = 0xC;
+// public static final int STD_HELP = 0xB;
+ public static final int STD_PASTE = 0x2;
+// public static final int STD_PRINT = 0xE;
+// public static final int STD_PRINTPRE = 0x9;
+// public static final int STD_PROPERTIES = 0xA;
+// public static final int STD_REDOW = 0x4;
+// public static final int STD_REPLACE = 0xD;
+// public static final int STD_UNDO = 0x3;
+// public static final int STM_GETICON = 0x171;
+// public static final int STM_GETIMAGE = 0x173;
+// public static final int STM_MSGMAX = 0x174;
+// public static final int STM_SETICON = 0x170;
+ public static final int STM_SETIMAGE = 0x172;
+// public static final int STN_CLICKED = 0x0;
+// public static final int STN_DBLCLK = 0x1;
+// public static final int STN_DISABLE = 0x3;
+// public static final int STN_ENABLE = 0x2;
+ public static final int SW_ERASE = 0x4;
+ public static final int SW_HIDE = 0x0;
+ public static final int SW_INVALIDATE = 0x2;
+// public static final int SW_MAX = 0xA;
+// public static final int SW_MAXIMIZE = 0x3;
+// public static final int SW_MINIMIZE = 0x6;
+// public static final int SW_NORMAL = 0x1;
+// public static final int SW_OTHERUNZOOM = 0x4;
+// public static final int SW_OTHERZOOM = 0x2;
+// public static final int SW_PARENTCLOSING = 0x1;
+ public static final int SW_PARENTOPENING = 0x3;
+ public static final int SW_RESTORE = 0x9;
+ public static final int SW_SCROLLCHILDREN = 0x1;
+ public static final int SW_SHOW = 0x5;
+// public static final int SW_SHOWDEFAULT = 0xA;
+ public static final int SW_SHOWMAXIMIZED = 0x3;
+// public static final int SW_SHOWMINIMIZED = 0x2;
+ public static final int SW_SHOWMINNOACTIVE = 0x7;
+ public static final int SW_SHOWNA = 0x8;
+ public static final int SW_SHOWNOACTIVATE = 0x4;
+// public static final int SW_SHOWNORMAL = 0x1;
+// public static final int SWP_ASYNCWINDOWPOS = 0x4000;
+// public static final int SWP_DEFERERASE = 0x2000;
+ public static final int SWP_DRAWFRAME = 0x20;
+// public static final int SWP_FRAMECHANGED = 0x20;
+// public static final int SWP_HIDEWINDOW = 0x80;
+ public static final int SWP_NOACTIVATE = 0x10;
+ public static final int SWP_NOCOPYBITS = 0x100;
+ public static final int SWP_NOMOVE = 0x2;
+// public static final int SWP_NOOWNERZORDER = 0x200;
+ public static final int SWP_NOREDRAW = 0x8;
+// public static final int SWP_NOREPOSITION = 0x200;
+// public static final int SWP_NOSENDCHANGING = 0x400;
+ public static final int SWP_NOSIZE = 0x1;
+ public static final int SWP_NOZORDER = 0x4;
+// public static final int SWP_SHOWWINDOW = 0x40;
+// public static final int SYSTEM_FIXED_FONT = 0x10;
+ public static final int SYSTEM_FONT = 0xD;
+// public static final int TB_ADDBITMAP = 0x413;
+// public static final int TB_ADDBUTTONS = 0x414;
+ public static final int TB_ADDSTRING = 0x41C;
+// public static final int TB_ADDSTRINGA = 0x41C;
+// public static final int TB_ADDSTRINGW = 0x44D;
+// public static final int TB_AUTOSIZE = 0x421;
+// public static final int TB_BOTTOM = 0x7;
+ public static final int TB_BUTTONCOUNT = 0x418;
+ public static final int TB_BUTTONSTRUCTSIZE = 0x41E;
+// public static final int TB_CHANGEBITMAP = 0x42B;
+// public static final int TB_CHECKBUTTON = 0x402;
+ public static final int TB_COMMANDTOINDEX = 0x419;
+// public static final int TB_CUSTOMIZE = 0x41B;
+ public static final int TB_DELETEBUTTON = 0x416;
+// public static final int TB_ENABLEBUTTON = 0x401;
+ public static final int TB_ENDTRACK = 0x8;
+// public static final int TB_GETBITMAP = 0x42C;
+// public static final int TB_GETBITMAPFLAGS = 0x429;
+ public static final int TB_GETBUTTON = 0x417;
+ public static final int TB_GETBUTTONINFO = WM_USER + 65;
+// public static final int TB_GETBUTTONINFOW (WM_USER + 63)
+ public static final int TB_GETBUTTONSIZE = (WM_USER + 58);
+ public static final int TB_GETBUTTONTEXT = 0x42D;
+// public static final int TB_GETBUTTONTEXTA = 0x42D;
+// public static final int TB_GETBUTTONTEXTW = 0x44B;
+ public static final int TB_GETDISABLEDIMAGELIST = (WM_USER + 55);
+// public static final int TB_GETEXTENDEDSTYLE = (WM_USER + 85);
+ public static final int TB_GETHOTIMAGELIST = (WM_USER + 53);
+ public static final int TB_GETIMAGELIST = (WM_USER + 49);
+ public static final int TB_GETITEMRECT = 0x41D;
+// public static final int TB_GETRECT = (WM_USER + 51); // wParam is the Cmd instead of index
+ public static final int TB_GETROWS = 0x428;
+ public static final int TB_GETSTATE = 0x412;
+// public static final int TB_GETSTYLE = (WM_USER + 57);
+// public static final int TB_GETTEXTROWS = (WM_USER + 61);
+ public static final int TB_GETTOOLTIPS = 0x423;
+// public static final int TB_HIDEBUTTON = 0x404;
+// public static final int TB_INDETERMINATE = 0x405;
+ public static final int TB_INSERTBUTTON = 0x415;
+// public static final int TB_ISBUTTONCHECKED = 0x40A;
+// public static final int TB_ISBUTTONENABLED = 0x409;
+// public static final int TB_ISBUTTONHIDDEN = 0x40C;
+// public static final int TB_ISBUTTONINDETERMINATE = 0x40D;
+// public static final int TB_ISBUTTONPRESSED = 0x40B;
+// public static final int TB_LINEDOWN = 0x1;
+// public static final int TB_LINEUP = 0x0;
+ public static final int TB_LOADIMAGES = (WM_USER + 50);
+// public static final int TB_PAGEDOWN = 0x3;
+// public static final int TB_PAGEUP = 0x2;
+// public static final int TB_PRESSBUTTON = 0x403;
+// public static final int TB_REPLACEBITMAP = 0x42E;
+// public static final int TB_SAVERESTORE = 0x41A;
+// public static final int TB_SAVERESTOREA = 0x41A;
+// public static final int TB_SAVERESTOREW = 0x44C;
+ public static final int TB_SETBITMAPSIZE = 0x420;
+ public static final int TB_SETBUTTONINFO = WM_USER + 66;
+// public static final int TB_SETBUTTONINFOW (WM_USER + 64)
+ public static final int TB_SETBUTTONSIZE = 0x41F;
+// public static final int TB_SETBUTTONWIDTH = (WM_USER + 59);
+// public static final int TB_SETCMDID = 0x42A;
+ public static final int TB_SETDISABLEDIMAGELIST = (WM_USER + 54);
+ public static final int TB_SETEXTENDEDSTYLE = (WM_USER + 84);
+ public static final int TB_SETHOTIMAGELIST = (WM_USER + 52);
+ public static final int TB_SETIMAGELIST = (WM_USER + 48);
+// public static final int TB_SETINDENT = (WM_USER + 47);
+// public static final int TB_SETMAXTEXTROWS = (WM_USER + 60);
+// public static final int TB_SETPARENT = 0x425;
+// public static final int TB_SETROWS = 0x427;
+ public static final int TB_SETSTATE = 0x411;
+// public static final int TB_SETSTYLE = (WM_USER + 56);
+// public static final int TB_SETTOOLTIPS = 0x424;
+// public static final int TB_THUMBPOSITION = 0x4;
+// public static final int TB_THUMBTRACK = 0x5;
+// public static final int TB_TOP = 0x6;
+// public static final int TBBF_LARGE = 0x1;
+// public static final int TBDDRET_DEFAULT = 0;
+// public static final int TBDDRET_NODEFAULT = 1;
+// public static final int TBDDRET_TREATPRESSED = 2;
+// public static final int TBIF_COMMAND = 0x00000020;
+ public static final int TBIF_IMAGE = 0x00000001;
+ public static final int TBIF_LPARAM = 0x00000010;
+ public static final int TBIF_SIZE = 0x00000040;
+// public static final int TBIF_STATE = 0x00000004;
+ public static final int TBIF_STYLE = 0x00000008;
+ public static final int TBIF_TEXT = 0x00000002;
+// public static final int TBM_CLEARSEL = 0x413;
+// public static final int TBM_CLEARTICS = 0x409;
+// public static final int TBM_GETCHANNELRECT = 0x41A;
+ public static final int TBM_GETLINESIZE = 0x418;
+// public static final int TBM_GETNUMTICS = 0x410;
+ public static final int TBM_GETPAGESIZE = 0x416;
+ public static final int TBM_GETPOS = 0x400;
+// public static final int TBM_GETPTICS = 0x40E;
+ public static final int TBM_GETRANGEMAX = 0x402;
+ public static final int TBM_GETRANGEMIN = 0x401;
+// public static final int TBM_GETSELEND = 0x412;
+// public static final int TBM_GETSELSTART = 0x411;
+// public static final int TBM_GETTHUMBLENGTH = 0x41C;
+ public static final int TBM_GETTHUMBRECT = 0x419;
+// public static final int TBM_GETTIC = 0x403;
+// public static final int TBM_GETTICPOS = 0x40F;
+ public static final int TBM_SETLINESIZE = 0x417;
+ public static final int TBM_SETPAGESIZE = 0x415;
+ public static final int TBM_SETPOS = 0x405;
+// public static final int TBM_SETRANGE = 0x406;
+ public static final int TBM_SETRANGEMAX = 0x408;
+ public static final int TBM_SETRANGEMIN = 0x407;
+// public static final int TBM_SETSEL = 0x40A;
+// public static final int TBM_SETSELEND = 0x40C;
+// public static final int TBM_SETSELSTART = 0x40B;
+// public static final int TBM_SETTHUMBLENGTH = 0x41B;
+// public static final int TBM_SETTIC = 0x404;
+ public static final int TBM_SETTICFREQ = 0x414;
+// public static final int TBN_BEGINADJUST = 0xFFFFFD41;
+// public static final int TBN_BEGINDRAG = 0xFFFFFD43;
+// public static final int TBN_CUSTHELP = 0xFFFFFD3B;
+ public static final int TBN_DROPDOWN = -710;
+// public static final int TBN_ENDADJUST = 0xFFFFFD40;
+// public static final int TBN_ENDDRAG = 0xFFFFFD42;
+// public static final int TBN_GETBUTTONINFO = 0xFFFFFD44;
+// public static final int TBN_GETBUTTONINFOA = 0xFFFFFD44;
+// public static final int TBN_GETBUTTONINFOW = 0xFFFFFD30;
+// public static final int TBN_LAST = 0xFFFFFD30;
+// public static final int TBN_QUERYDELETE = 0xFFFFFD3D;
+// public static final int TBN_QUERYINSERT = 0xFFFFFD3E;
+// public static final int TBN_RESET = 0xFFFFFD3F;
+// public static final int TBN_TOOLBARCHANGE = 0xFFFFFD3C;
+ public static final int TBS_AUTOTICKS = 0x1;
+ public static final int TBS_BOTH = 0x8;
+// public static final int TBS_BOTTOM = 0x0;
+// public static final int TBS_ENABLESELRANGE = 0x20;
+// public static final int TBS_FIXEDLENGTH = 0x40;
+ public static final int TBS_HORZ = 0x0;
+// public static final int TBS_LEFT = 0x4;
+// public static final int TBS_NOTHUMB = 0x80;
+// public static final int TBS_NOTICKS = 0x10;
+// public static final int TBS_RIGHT = 0x0;
+// public static final int TBS_TOP = 0x4;
+ public static final int TBS_VERT = 0x2;
+ public static final int TBSTATE_CHECKED = 0x1;
+// public static final int TBSTATE_ELLIPSES = 0x40;
+ public static final int TBSTATE_ENABLED = 0x4;
+// public static final int TBSTATE_HIDDEN = 0x8;
+// public static final int TBSTATE_INDETERMINATE = 0x10;
+// public static final int TBSTATE_MARKED = 0x80;
+// public static final int TBSTATE_PRESSED = 0x2;
+// public static final int TBSTATE_WRAP = 0x20;
+// public static final int TBSTYLE_ALTDRAG = 0x400;
+// public static final int TBSTYLE_CUSTOMERASE = 0x2000;
+ public static final int TBSTYLE_EX_DRAWDDARROWS = 0x00000001;
+ public static final int TBSTYLE_FLAT = 0x0800;
+ public static final int TBSTYLE_LIST = 0x1000;
+// public static final int TBSTYLE_REGISTERDROP = 0x4000;
+ public static final int TBSTYLE_TOOLTIPS = 0x100;
+// public static final int TBSTYLE_TRANSPARENT = 0x8000;
+ public static final int TBSTYLE_WRAPABLE = 0x200;
+// public static final int TC_NORMAL = 0x0;
+// public static final int TC_OP_CHARACTER = 0x1;
+// public static final int TC_OP_STROKE = 0x2;
+// public static final int TC_RA_ABLE = 0x2000;
+// public static final int TC_RESERVED = 0x8000;
+// public static final int TC_SA_CONTIN = 0x100;
+// public static final int TC_SA_DOUBLE = 0x40;
+// public static final int TC_SA_INTEGER = 0x80;
+// public static final int TC_SCROLLBLT = 0x10000;
+// public static final int TC_SF_X_YINDEP = 0x20;
+// public static final int TC_SIGNAL = 0x3;
+// public static final int TC_SO_ABLE = 0x1000;
+// public static final int TC_UA_ABLE = 0x800;
+// public static final int TC_VA_ABLE = 0x4000;
+ public static final int TCIF_IMAGE = 0x0002;
+// public static final int TCIF_PARAM = 0x0008;
+// public static final int TCIF_RTLREADING = 0x0004;
+// public static final int TCIF_STATE = 0x0010;
+ public static final int TCIF_TEXT = 0x0001;
+// public static final int TCIS_BUTTONPRESSED = 0x0001;
+// public static final int TCIS_HIGHLIGHTED = 0x0002;
+ public static final int TCM_ADJUSTRECT = 0x1328;
+// public static final int TCM_DELETEALLITEMS = 0x1309;
+ public static final int TCM_DELETEITEM = 0x1308;
+// public static final int TCM_FIRST = 0x1300;
+// public static final int TCM_GETCURFOCUS = 0x132F;
+ public static final int TCM_GETCURSEL = 0x130B;
+// public static final int TCM_GETIMAGELIST = 0x1302;
+// public static final int TCM_GETITEM = 0x1305;
+// public static final int TCM_GETITEMA = 0x1305;
+ public static final int TCM_GETITEMCOUNT = 0x1304;
+ public static final int TCM_GETITEMRECT = 0x130A;
+// public static final int TCM_GETITEMW = 0x133C;
+// public static final int TCM_GETROWCOUNT = 0x132C;
+ public static final int TCM_GETTOOLTIPS = 0x132D;
+// public static final int TCM_HITTEST = 0x130D;
+ public static final int TCM_INSERTITEM = 0x1307;
+// public static final int TCM_INSERTITEMA = 0x1307;
+// public static final int TCM_INSERTITEMW = 0x133E;
+// public static final int TCM_REMOVEIMAGE = 0x132A;
+// public static final int TCM_SETCURFOCUS = 0x1330;
+ public static final int TCM_SETCURSEL = 0x130C;
+ public static final int TCM_SETIMAGELIST = 0x1303;
+ public static final int TCM_SETITEM = 0x1306;
+// public static final int TCM_SETITEMA = 0x1306;
+// public static final int TCM_SETITEMEXTRA = 0x130E;
+// public static final int TCM_SETITEMSIZE = 0x1329;
+// public static final int TCM_SETITEMW = 0x133D;
+// public static final int TCM_SETPADDING = 0x132B;
+// public static final int TCM_SETTOOLTIPS = 0x132E;
+// public static final int TCN_FIRST = 0xFFFFFDDA;
+// public static final int TCN_KEYDOWN = 0xFFFFFDDA;
+// public static final int TCN_LAST = 0xFFFFFDBC;
+ public static final int TCN_SELCHANGE = 0xFFFFFDD9;
+ public static final int TCN_SELCHANGING = 0xFFFFFDD8;
+// public static final int TCP_BSDURGENT = 0x7000;
+// public static final int TCP_NODELAY = 0x1;
+// public static final int TCS_BOTTOM = 0x0002;
+// public static final int TCS_BUTTONS = 0x100;
+// public static final int TCS_EX_FLATSEPARATORS = 0x00000001;
+// public static final int TCS_EX_REGISTERDROP= 0x00000002;
+// public static final int TCS_FIXEDWIDTH = 0x400;
+// public static final int TCS_FLATBUTTONS = 0x0008;
+ public static final int TCS_FOCUSNEVER = 0x8000;
+// public static final int TCS_FOCUSONBUTTONDOWN = 0x1000;
+// public static final int TCS_FORCEICONLEFT = 0x10;
+// public static final int TCS_FORCELABELLEFT = 0x20;
+// public static final int TCS_HOTTRACK = 0x0040;
+ public static final int TCS_MULTILINE = 0x200;
+// public static final int TCS_MULTISELECT = 0x0004;
+// public static final int TCS_OWNERDRAWFIXED = 0x2000;
+// public static final int TCS_RAGGEDRIGHT = 0x800;
+// public static final int TCS_RIGHT = 0x0002;
+// public static final int TCS_RIGHTJUSTIFY = 0x0;
+// public static final int TCS_SCROLLOPPOSITE = 0x0001;
+// public static final int TCS_SINGLELINE = 0x0;
+ public static final int TCS_TABS = 0x0;
+ public static final int TCS_TOOLTIPS = 0x4000;
+// public static final int TM_MULTICODEPAGE = 32;
+// public static final int TM_MULTILEVELUNDO = 8;
+// public static final int TM_PLAINTEXT = 1;
+// public static final int TM_RICHTEXT = 2;
+// public static final int TM_SINGLECODEPAGE = 16;
+// public static final int TM_SINGLELEVELUNDO = 4;
+// public static final int TMPF_DEVICE = 8;
+// public static final int TMPF_FIXED_PITCH = 1;
+// public static final int TMPF_TRUETYPE = 4;
+ public static final int TMPF_VECTOR = 2;
+// public static final int TPM_BOTTOMALIGN = 0x20;
+// public static final int TPM_CENTERALIGN = 0x4;
+// public static final int TPM_HORIZONTAL = 0x0;
+ public static final int TPM_LEFTALIGN = 0x0;
+ public static final int TPM_LEFTBUTTON = 0x0;
+// public static final int TPM_NONOTIFY = 0x80;
+// public static final int TPM_RETURNCMD = 0x100;
+// public static final int TPM_RIGHTALIGN = 0x8;
+ public static final int TPM_RIGHTBUTTON = 0x2;
+// public static final int TPM_TOPALIGN = 0x0;
+// public static final int TPM_VCENTERALIGN = 0x10;
+// public static final int TPM_VERTICAL = 0x40;
+ public static final int TRANSPARENT = 0x1;
+// public static final int TRUETYPE_FONTTYPE = 0x0004;
+// public static final int TTDT_AUTOMATIC = 0;
+// public static final int TTDT_AUTOPOP = 2;
+// public static final int TTDT_INITIAL = 3;
+// public static final int TTDT_RESHOW = 1;
+// public static final int TTF_ABSOLUTE = 0x0080;
+// public static final int TTF_CENTERTIP = 0x0002;
+// public static final int TTF_DI_SETITEM = 0x8000;
+ public static final int TTF_IDISHWND = 0x0001;
+// public static final int TTF_RTLREADING = 0x0004;
+ public static final int TTF_SUBCLASS = 0x0010;
+// public static final int TTF_TRACK = 0x0020;
+// public static final int TTF_TRANSPARENT = 0x0100;
+// public static final int TTM_ACTIVATE = (WM_USER + 1);
+ public static final int TTM_ADDTOOL = (WM_USER + 4);
+ public static final int TTM_DELTOOL = (WM_USER + 5);
+// public static final int TTM_ENUMTOOLS = (WM_USER + 14);
+// public static final int TTM_GETCURRENTTOOL = (WM_USER + 15);
+// public static final int TTM_GETDELAYTIME = (WM_USER + 21);
+// public static final int TTM_GETMARGIN = (WM_USER + 27);
+// public static final int TTM_GETMAXTIPWIDTH = (WM_USER + 25);
+// public static final int TTM_GETTEXT = (WM_USER + 11);
+// public static final int TTM_GETTIPBKCOLOR = (WM_USER + 22);
+// public static final int TTM_GETTIPTEXTCOLOR = (WM_USER + 23);
+// public static final int TTM_GETTOOLCOUNT = (WM_USER + 13);
+// public static final int TTM_GETTOOLINFO = (WM_USER + 8);
+// public static final int TTM_HITTEST = (WM_USER + 10);
+// public static final int TTM_NEWTOOLRECT = (WM_USER + 6);
+// public static final int TTM_POP = (WM_USER + 28);
+// public static final int TTM_RELAYEVENT = (WM_USER + 7);
+// public static final int TTM_SETDELAYTIME = (WM_USER + 3);
+// public static final int TTM_SETMARGIN = (WM_USER + 26);
+// public static final int TTM_SETMAXTIPWIDTH = (WM_USER + 24);
+// public static final int TTM_SETTIPBKCOLOR = (WM_USER + 19);
+// public static final int TTM_SETTIPTEXTCOLOR = (WM_USER + 20);
+// public static final int TTM_SETTOOLINFO = (WM_USER + 9);
+// public static final int TTM_TRACKACTIVATE = (WM_USER + 17);
+// public static final int TTM_TRACKPOSITION = (WM_USER + 18);
+// public static final int TTM_UPDATE = (WM_USER + 29);
+// public static final int TTM_UPDATETIPTEXT = (WM_USER + 12);
+// public static final int TTM_WINDOWFROMPOINT = (WM_USER + 16);
+ public static final int TTN_FIRST = -520;
+ public static final int TTN_GETDISPINFO = (TTN_FIRST - 0);
+// public static final int TTN_GETDISPINFOA = (TTN_FIRST - 0);
+ public static final int TTN_GETDISPINFOW = (TTN_FIRST - 10);
+// public static final int TTN_LAST = -549;
+// public static final int TTN_POP = (TTN_FIRST - 2);
+// public static final int TTN_SHOW = (TTN_FIRST - 1);
+ public static final int TTS_ALWAYSTIP = 0x01;
+// public static final int TTS_NOPREFIX = 0x02;
+ public static final int TV_FIRST = 0x1100;
+// public static final int TVC_BYKEYBOARD = 0x0002;
+// public static final int TVC_BYMOUSE = 0x0001;
+// public static final int TVC_UNKNOWN = 0x0000;
+// public static final int TVCDRF_NOIMAGES = 0x00010000;
+ public static final int TVE_COLLAPSE = 0x0001;
+// public static final int TVE_COLLAPSERESET = 0x8000;
+ public static final int TVE_EXPAND = 0x0002;
+// public static final int TVE_EXPANDPARTIAL = 0x4000;
+// public static final int TVE_TOGGLE = 0x0003;
+ public static final int TVGN_CARET = 0x0009;
+ public static final int TVGN_CHILD = 0x0004;
+// public static final int TVGN_DROPHILITE = 0x0008;
+// public static final int TVGN_FIRSTVISIBLE = 0x0005;
+// public static final int TVGN_LASTVISIBLE = 0x000A;
+ public static final int TVGN_NEXT = 0x0001;
+ public static final int TVGN_NEXTVISIBLE = 0x0006;
+ public static final int TVGN_PARENT = 0x0003;
+// public static final int TVGN_PREVIOUS = 0x0002;
+ public static final int TVGN_PREVIOUSVISIBLE = 0x0007;
+ public static final int TVGN_ROOT = 0x0000;
+// public static final int TVHT_ABOVE = 0x0100;
+// public static final int TVHT_BELOW = 0x0200;
+// public static final int TVHT_NOWHERE = 0x0001;
+ public static final int TVHT_ONITEM = (TVHT_ONITEMICON | TVHT_ONITEMLABEL | TVHT_ONITEMSTATEICON);
+// public static final int TVHT_ONITEMBUTTON = 0x0010;
+// public static final int TVHT_ONITEMINDENT = 0x0008;
+// public static final int TVHT_ONITEMRIGHT = 0x0020;
+// public static final int TVHT_TOLEFT = 0x0800;
+// public static final int TVHT_TORIGHT = 0x0400;
+ public static final int TVI_FIRST = 0xFFFF0001;
+ public static final int TVI_LAST = 0xFFFF0002;
+ public static final int TVI_ROOT = 0xFFFF0000;
+// public static final int TVI_SORT = 0xFFFF0003;
+// public static final int TVIF_CHILDREN = 0x0040;
+// public static final int TVIF_DI_SETITEM = 0x1000;
+ public static final int TVIF_HANDLE = 0x0010;
+ public static final int TVIF_IMAGE = 0x0002;
+// public static final int TVIF_INTEGRAL = 0x0080;
+ public static final int TVIF_PARAM = 0x0004;
+ public static final int TVIF_SELECTEDIMAGE = 0x0020;
+ public static final int TVIF_STATE = 0x0008;
+ public static final int TVIF_TEXT = 0x0001;
+// public static final int TVIS_BOLD = 0x0010;
+// public static final int TVIS_CUT = 0x0004;
+ public static final int TVIS_DROPHILITED = 0x0008;
+ public static final int TVIS_EXPANDED = 0x0020;
+// public static final int TVIS_EXPANDEDONCE = 0x0040;
+// public static final int TVIS_EXPANDPARTIAL = 0x0080;
+// public static final int TVIS_OVERLAYMASK = 0x0F00;
+ public static final int TVIS_SELECTED = 0x0002;
+ public static final int TVIS_STATEIMAGEMASK = 0xF000;
+// public static final int TVIS_USERMASK = 0xF000;
+// public static final int TVM_CREATEDRAGIMAGE = (TV_FIRST + 18);
+ public static final int TVM_DELETEITEM = (TV_FIRST + 1);
+// public static final int TVM_EDITLABEL = (TV_FIRST + 14);
+// public static final int TVM_ENDEDITLABELNOW = (TV_FIRST + 22);
+ public static final int TVM_ENSUREVISIBLE = (TV_FIRST + 20);
+ public static final int TVM_EXPAND = (TV_FIRST + 2);
+ public static final int TVM_GETBKCOLOR = (TV_FIRST + 31);
+ public static final int TVM_GETCOUNT = (TV_FIRST + 5);
+// public static final int TVM_GETEDITCONTROL = (TV_FIRST + 15);
+ public static final int TVM_GETIMAGELIST = (TV_FIRST + 8);
+// public static final int TVM_GETINDENT = (TV_FIRST + 6);
+// public static final int TVM_GETINSERTMARKCOLOR = (TV_FIRST + 38);
+// public static final int TVM_GETISEARCHSTRING = (TV_FIRST + 23);
+ public static final int TVM_GETITEM = (TV_FIRST + 12);
+ public static final int TVM_GETITEMHEIGHT = (TV_FIRST + 28);
+ public static final int TVM_GETITEMRECT = (TV_FIRST + 4);
+ public static final int TVM_GETNEXTITEM = (TV_FIRST + 10);
+// public static final int TVM_GETSCROLLTIME = (TV_FIRST + 34);
+ public static final int TVM_GETTEXTCOLOR = (TV_FIRST + 32);
+// public static final int TVM_GETTOOLTIPS = (TV_FIRST + 25);
+// public static final int TVM_GETUNICODEFORMAT = CCM_GETUNICODEFORMAT;
+// public static final int TVM_GETVISIBLECOUNT = (TV_FIRST + 16);
+ public static final int TVM_HITTEST = (TV_FIRST + 17);
+ public static final int TVM_INSERTITEM = (TV_FIRST + 0);
+ public static final int TVM_SELECTITEM = (TV_FIRST + 11);
+ public static final int TVM_SETBKCOLOR = (TV_FIRST + 29);
+ public static final int TVM_SETIMAGELIST = (TV_FIRST + 9);
+// public static final int TVM_SETINDENT = (TV_FIRST + 7);
+ public static final int TVM_SETINSERTMARK = (TV_FIRST + 26);
+// public static final int TVM_SETINSERTMARKCOLOR = (TV_FIRST + 37);
+ public static final int TVM_SETITEM = (TV_FIRST + 13);
+// public static final int TVM_SETITEMHEIGHT = (TV_FIRST + 27);
+// public static final int TVM_SETSCROLLTIME = (TV_FIRST + 33);
+ public static final int TVM_SETTEXTCOLOR = (TV_FIRST + 30);
+// public static final int TVM_SETTOOLTIPS = (TV_FIRST + 24);
+// public static final int TVM_SETUNICODEFORMAT = CCM_SETUNICODEFORMAT;
+// public static final int TVM_SORTCHILDREN = (TV_FIRST + 19);
+// public static final int TVM_SORTCHILDRENCB = (TV_FIRST + 21);
+ public static final int TVN_BEGINDRAG = (TVN_FIRST-7);
+// public static final int TVN_BEGINLABELEDIT = (TVN_FIRST-10);
+ public static final int TVN_BEGINRDRAG = (TVN_FIRST-8);
+// public static final int TVN_DELETEITEM = (TVN_FIRST-9);
+// public static final int TVN_ENDLABELEDIT = (TVN_FIRST-11);
+// public static final int TVN_GETDISPINFO = (TVN_FIRST-3);
+// public static final int TVN_GETINFOTIP = (TVN_FIRST-13);
+// public static final int TVN_ITEMEXPANDED = (TVN_FIRST-6);
+ public static final int TVN_ITEMEXPANDING = (TVN_FIRST-5);
+// public static final int TVN_KEYDOWN = (TVN_FIRST-12);
+ public static final int TVN_SELCHANGED = (TVN_FIRST-2);
+ public static final int TVN_SELCHANGING = (TVN_FIRST-1);
+// public static final int TVN_SETDISPINFO = (TVN_FIRST-4);
+// public static final int TVN_SINGLEEXPAND = (TVN_FIRST-15);
+// public static final int TVS_CHECKBOXES = 0x0100;
+ public static final int TVS_DISABLEDRAGDROP = 0x0010;
+// public static final int TVS_EDITLABELS = 0x0008;
+ public static final int TVS_FULLROWSELECT= 0x1000;
+ public static final int TVS_HASBUTTONS = 0x0001;
+ public static final int TVS_HASLINES = 0x0002;
+// public static final int TVS_INFOTIP = 0x0800;
+ public static final int TVS_LINESATROOT = 0x0004;
+// public static final int TVS_NONEVENHEIGHT = 0x4000;
+// public static final int TVS_NOSCROLL = 0x2000;
+ public static final int TVS_NOTOOLTIPS = 0x0080;
+// public static final int TVS_RTLREADING = 0x0040;
+ public static final int TVS_SHOWSELALWAYS = 0x0020;
+// public static final int TVS_SINGLEEXPAND = 0x0400;
+// public static final int TVS_TRACKSELECT = 0x0200;
+ public static final int TVSIL_NORMAL = 0;
+ public static final int TVSIL_STATE = 2;
+// public static final int UID_CUT = 4;
+// public static final int UID_DELETE = 2;
+// public static final int UID_DRAGDROP= 3;
+// public static final int UID_PASTE = 5;
+// public static final int UID_TYPING = 1;
+// public static final int UID_UNKNOWN = 0;
+ public static final int VERTRES = 10;
+// public static final int VK_ADD = 0x6B;
+// public static final int VK_APPS = 0x5D;
+// public static final int VK_ATTN = 0xF6;
+ public static final int VK_BACK = 0x8;
+// public static final int VK_CANCEL = 0x3;
+ public static final int VK_CAPITAL = 0x14;
+// public static final int VK_CLEAR = 0xC;
+ public static final int VK_CONTROL = 0x11;
+// public static final int VK_CRSEL = 0xF7;
+// public static final int VK_DECIMAL = 0x6E;
+ public static final int VK_DELETE = 0x2E;
+ public static final int VK_DIVIDE = 0x6F;
+ public static final int VK_DOWN = 0x28;
+ public static final int VK_END = 0x23;
+// public static final int VK_EREOF = 0xF9;
+ public static final int VK_ESCAPE = 0x1B;
+// public static final int VK_EXECUTE = 0x2B;
+// public static final int VK_EXSEL = 0xF8;
+ public static final int VK_F1 = 0x70;
+ public static final int VK_F10 = 0x79;
+ public static final int VK_F11 = 0x7A;
+ public static final int VK_F12 = 0x7B;
+// public static final int VK_F13 = 0x7C;
+// public static final int VK_F14 = 0x7D;
+// public static final int VK_F15 = 0x7E;
+// public static final int VK_F16 = 0x7F;
+// public static final int VK_F17 = 0x80;
+// public static final int VK_F18 = 0x81;
+// public static final int VK_F19 = 0x82;
+ public static final int VK_F2 = 0x71;
+// public static final int VK_F20 = 0x83;
+// public static final int VK_F21 = 0x84;
+// public static final int VK_F22 = 0x85;
+// public static final int VK_F23 = 0x86;
+// public static final int VK_F24 = 0x87;
+ public static final int VK_F3 = 0x72;
+// public static final int VK_F3 = 0x72;
+ public static final int VK_F4 = 0x73;
+// public static final int VK_F4 = 0x73;
+ public static final int VK_F5 = 0x74;
+// public static final int VK_F5 = 0x74;
+ public static final int VK_F6 = 0x75;
+// public static final int VK_F6 = 0x75;
+ public static final int VK_F7 = 0x76;
+// public static final int VK_F7 = 0x76;
+ public static final int VK_F8 = 0x77;
+// public static final int VK_F8 = 0x77;
+ public static final int VK_F9 = 0x78;
+// public static final int VK_F9 = 0x78;
+// public static final int VK_HELP = 0x2F;
+ public static final int VK_HOME = 0x24;
+ public static final int VK_INSERT = 0x2D;
+ public static final int VK_LBUTTON = 0x1;
+// public static final int VK_LCONTROL = 0xA2;
+ public static final int VK_LEFT = 0x25;
+// public static final int VK_LMENU = 0xA4;
+// public static final int VK_LSHIFT = 0xA0;
+// public static final int VK_LWIN = 0x5B;
+ public static final int VK_MBUTTON = 0x4;
+ public static final int VK_MENU = 0x12;
+// public static final int VK_MULTIPLY = 0x6A;
+ public static final int VK_NEXT = 0x22;
+// public static final int VK_NONAME = 0xFC;
+ public static final int VK_NUMLOCK = 0x90;
+ public static final int VK_NUMPAD0 = 0x60;
+// public static final int VK_NUMPAD1 = 0x61;
+// public static final int VK_NUMPAD2 = 0x62;
+// public static final int VK_NUMPAD3 = 0x63;
+// public static final int VK_NUMPAD4 = 0x64;
+// public static final int VK_NUMPAD5 = 0x65;
+// public static final int VK_NUMPAD6 = 0x66;
+// public static final int VK_NUMPAD7 = 0x67;
+// public static final int VK_NUMPAD8 = 0x68;
+// public static final int VK_NUMPAD9 = 0x69;
+// public static final int VK_OEM_CLEAR = 0xFE;
+// public static final int VK_PA1 = 0xFD;
+// public static final int VK_PAUSE = 0x13;
+// public static final int VK_PLAY = 0xFA;
+// public static final int VK_PRINT = 0x2A;
+ public static final int VK_PRIOR = 0x21;
+// public static final int VK_PROCESSKEY = 0xE5;
+ public static final int VK_RBUTTON = 0x2;
+// public static final int VK_RCONTROL = 0xA3;
+ public static final int VK_RETURN = 0xD;
+ public static final int VK_RIGHT = 0x27;
+// public static final int VK_RMENU = 0xA5;
+// public static final int VK_RSHIFT = 0xA1;
+// public static final int VK_RWIN = 0x5C;
+ public static final int VK_SCROLL = 0x91;
+// public static final int VK_SELECT = 0x29;
+// public static final int VK_SEPARATOR = 0x6C;
+ public static final int VK_SHIFT = 0x10;
+// public static final int VK_SNAPSHOT = 0x2C;
+ public static final int VK_SPACE = 0x20;
+// public static final int VK_SUBTRACT = 0x6D;
+ public static final int VK_TAB = 0x9;
+ public static final int VK_UP = 0x26;
+// public static final int VK_ZOOM = 0xFB;
+// public static final int WB_CLASSIFY = 3;
+// public static final int WB_LEFTBREAK = 6;
+// public static final int WB_MOVEWORDLEFT = 4;
+// public static final int WB_MOVEWORDNEXT = 5;
+// public static final int WB_MOVEWORDPREV = 4;
+// public static final int WB_MOVEWORDRIGHT = 5;
+// public static final int WB_NEXTBREAK = 7;
+// public static final int WB_PREVBREAK = 6;
+// public static final int WB_RIGHTBREAK = 7;
+// public static final int WBF_CUSTOM = 0x200;
+// public static final int WBF_LEVEL1 = 0x080;
+// public static final int WBF_LEVEL2 = 0x100;
+// public static final int WBF_OVERFLOW = 0x040;
+// public static final int WBF_WORDBREAK = 0x020;
+// public static final int WBF_WORDWRAP = 0x010;
+// public static final int WCH_EMBEDDING = 0xFFFC;
+// public static final int WHITE_BRUSH = 0x0;
+// public static final int WHITE_PEN = 0x6;
+// public static final int WHITENESS = 0xFF0062;
+ public static final int WM_ACTIVATE = 0x6;
+// public static final int WM_ACTIVATEAPP = 0x1C;
+// public static final int WM_AFXFIRST = 0x360;
+// public static final int WM_AFXLAST = 0x37F;
+// public static final int WM_APP = 0x8000;
+// public static final int WM_ASKCBFORMATNAME = 0x30C;
+// public static final int WM_CANCELJOURNAL = 0x4B;
+ public static final int WM_CANCELMODE = 0x1F;
+// public static final int WM_CANCELMODE = 0x1F;
+// public static final int WM_CAPTURECHANGED = 0x215;
+// public static final int WM_CHANGECBCHAIN = 0x30D;
+ public static final int WM_CHAR = 0x102;
+// public static final int WM_CHARTOITEM = 0x2F;
+// public static final int WM_CHILDACTIVATE = 0x22;
+// public static final int WM_CHOOSEFONT_GETLOGFONT = 0x401;
+// public static final int WM_CHOOSEFONT_SETFLAGS = 0x466;
+// public static final int WM_CHOOSEFONT_SETLOGFONT = 0x465;
+ public static final int WM_CLEAR = 0x303;
+ public static final int WM_CLOSE = 0x10;
+ public static final int WM_COMMAND = 0x111;
+// public static final int WM_COMMNOTIFY = 0x44;
+// public static final int WM_COMPACTING = 0x41;
+// public static final int WM_COMPAREITEM = 0x39;
+ public static final int WM_CONTEXTMENU = 0x7B;
+ public static final int WM_COPY = 0x301;
+// public static final int WM_COPYDATA = 0x4A;
+// public static final int WM_CREATE = 0x1;
+ public static final int WM_CTLCOLORBTN = 0x135;
+ public static final int WM_CTLCOLORDLG = 0x136;
+ public static final int WM_CTLCOLOREDIT = 0x133;
+ public static final int WM_CTLCOLORLISTBOX = 0x134;
+ public static final int WM_CTLCOLORMSGBOX = 0x132;
+ public static final int WM_CTLCOLORSCROLLBAR = 0x137;
+ public static final int WM_CTLCOLORSTATIC = 0x138;
+ public static final int WM_CUT = 0x300;
+// public static final int WM_DDE_ACK = 0x3E4;
+// public static final int WM_DDE_ADVISE = 0x3E2;
+// public static final int WM_DDE_DATA = 0x3E5;
+// public static final int WM_DDE_EXECUTE = 0x3E8;
+// public static final int WM_DDE_FIRST = 0x3E0;
+// public static final int WM_DDE_INITIATE = 0x3E0;
+// public static final int WM_DDE_LAST = 0x3E8;
+// public static final int WM_DDE_POKE = 0x3E7;
+// public static final int WM_DDE_REQUEST = 0x3E6;
+// public static final int WM_DDE_TERMINATE = 0x3E1;
+// public static final int WM_DDE_UNADVISE = 0x3E3;
+// public static final int WM_DEADCHAR = 0x103;
+// public static final int WM_DELETEITEM = 0x2D;
+ public static final int WM_DESTROY = 0x2;
+// public static final int WM_DESTROYCLIPBOARD = 0x307;
+// public static final int WM_DEVICECHANGE = 0x219;
+// public static final int WM_DEVMODECHANGE = 0x1B;
+// public static final int WM_DISPLAYCHANGE = 0x7E;
+// public static final int WM_DRAWCLIPBOARD = 0x308;
+ public static final int WM_DRAWITEM = 0x2B;
+// public static final int WM_DROPFILES = 0x233;
+// public static final int WM_ENABLE = 0xA;
+// public static final int WM_ENDSESSION = 0x16;
+// public static final int WM_ENTERIDLE = 0x121;
+// public static final int WM_ENTERMENULOOP = 0x211;
+// public static final int WM_ENTERSIZEMOVE = 0x231;
+ public static final int WM_ERASEBKGND = 0x14;
+// public static final int WM_EXITMENULOOP = 0x212;
+// public static final int WM_EXITSIZEMOVE = 0x232;
+// public static final int WM_FONTCHANGE = 0x1D;
+ public static final int WM_GETDLGCODE = 0x87;
+ public static final int WM_GETFONT = 0x31;
+// public static final int WM_GETHOTKEY = 0x33;
+ public static final int WM_GETICON = 0x7F;
+// public static final int WM_GETMINMAXINFO = 0x24;
+// public static final int WM_GETTEXT = 0xD;
+// public static final int WM_GETTEXTLENGTH = 0xE;
+// public static final int WM_HANDHELDFIRST = 0x358;
+// public static final int WM_HANDHELDLAST = 0x35F;
+ public static final int WM_HELP = 0x53;
+// public static final int WM_HOTKEY = 0x312;
+ public static final int WM_HSCROLL = 0x114;
+// public static final int WM_HSCROLLCLIPBOARD = 0x30E;
+// public static final int WM_ICONERASEBKGND = 0x27;
+ public static final int WM_IME_CHAR = 0x286;
+ public static final int WM_IME_COMPOSITION = 0x10F;
+// public static final int WM_IME_COMPOSITIONFULL = 0x284;
+// public static final int WM_IME_CONTROL = 0x283;
+// public static final int WM_IME_ENDCOMPOSITION = 0x10E;
+// public static final int WM_IME_KEYDOWN = 0x290;
+// public static final int WM_IME_KEYLAST = 0x10F;
+// public static final int WM_IME_KEYUP = 0x291;
+// public static final int WM_IME_NOTIFY = 0x282;
+// public static final int WM_IME_SELECT = 0x285;
+// public static final int WM_IME_SETCONTEXT = 0x281;
+// public static final int WM_IME_STARTCOMPOSITION = 0x10D;
+ public static final int WM_INITDIALOG = 0x110;
+// public static final int WM_INITMENU = 0x116;
+ public static final int WM_INITMENUPOPUP = 0x117;
+// public static final int WM_INPUTLANGCHANGE = 0x51;
+// public static final int WM_INPUTLANGCHANGEREQUEST = 0x50;
+ public static final int WM_KEYDOWN = 0x100;
+ public static final int WM_KEYFIRST = 0x100;
+ public static final int WM_KEYLAST = 0x108;
+ public static final int WM_KEYUP = 0x101;
+ public static final int WM_KILLFOCUS = 0x8;
+ public static final int WM_LBUTTONDBLCLK = 0x203;
+ public static final int WM_LBUTTONDOWN = 0x201;
+ public static final int WM_LBUTTONUP = 0x202;
+ public static final int WM_MBUTTONDBLCLK = 0x209;
+ public static final int WM_MBUTTONDOWN = 0x207;
+ public static final int WM_MBUTTONUP = 0x208;
+// public static final int WM_MDIACTIVATE = 0x222;
+// public static final int WM_MDICASCADE = 0x227;
+// public static final int WM_MDICREATE = 0x220;
+// public static final int WM_MDIDESTROY = 0x221;
+// public static final int WM_MDIGETACTIVE = 0x229;
+// public static final int WM_MDIICONARRANGE = 0x228;
+// public static final int WM_MDIMAXIMIZE = 0x225;
+// public static final int WM_MDINEXT = 0x224;
+// public static final int WM_MDIREFRESHMENU = 0x234;
+// public static final int WM_MDIRESTORE = 0x223;
+// public static final int WM_MDISETMENU = 0x230;
+// public static final int WM_MDITILE = 0x226;
+ public static final int WM_MEASUREITEM = 0x2C;
+ public static final int WM_MENUCHAR = 0x120;
+ public static final int WM_MENUSELECT = 0x11F;
+ public static final int WM_MOUSEACTIVATE = 0x21;
+// public static final int WM_MOUSEFIRST = 0x200;
+// public static final int WM_MOUSELAST = 0x209;
+ public static final int WM_MOUSEMOVE = 0x200;
+ public static final int WM_MOVE = 0x3;
+// public static final int WM_MOVING = 0x216;
+ public static final int WM_NCACTIVATE = 0x86;
+ public static final int WM_NCCALCSIZE = 0x83;
+// public static final int WM_NCCREATE = 0x81;
+// public static final int WM_NCDESTROY = 0x82;
+ public static final int WM_NCHITTEST = 0x84;
+// public static final int WM_NCLBUTTONDBLCLK = 0xA3;
+// public static final int WM_NCLBUTTONDOWN = 0xA1;
+// public static final int WM_NCLBUTTONUP = 0xA2;
+// public static final int WM_NCMBUTTONDBLCLK = 0xA9;
+// public static final int WM_NCMBUTTONDOWN = 0xA7;
+// public static final int WM_NCMBUTTONUP = 0xA8;
+// public static final int WM_NCMOUSEMOVE = 0xA0;
+// public static final int WM_NCPAINT = 0x85;
+// public static final int WM_NCRBUTTONDBLCLK = 0xA6;
+// public static final int WM_NCRBUTTONDOWN = 0xA4;
+// public static final int WM_NCRBUTTONUP = 0xA5;
+// public static final int WM_NEXTDLGCTL = 0x28;
+// public static final int WM_NEXTMENU = 0x213;
+ public static final int WM_NOTIFY = 0x4E;
+// public static final int WM_NOTIFYFORMAT = 0x55;
+ public static final int WM_NULL = 0x0;
+ public static final int WM_PAINT = 0xF;
+// public static final int WM_PAINTCLIPBOARD = 0x309;
+// public static final int WM_PAINTICON = 0x26;
+ public static final int WM_PALETTECHANGED = 0x311;
+// public static final int WM_PALETTEISCHANGING = 0x310;
+// public static final int WM_PARENTNOTIFY = 0x210;
+ public static final int WM_PASTE = 0x302;
+// public static final int WM_PENWINFIRST = 0x380;
+// public static final int WM_PENWINLAST = 0x38F;
+// public static final int WM_POWER = 0x48;
+// public static final int WM_POWERBROADCAST = 0x218;
+// public static final int WM_PRINT = 0x317;
+// public static final int WM_PRINTCLIENT = 0x318;
+// public static final int WM_PSD_ENVSTAMPRECT = 0x405;
+// public static final int WM_PSD_FULLPAGERECT = 0x401;
+// public static final int WM_PSD_GREEKTEXTRECT = 0x404;
+// public static final int WM_PSD_MARGINRECT = 0x403;
+// public static final int WM_PSD_MINMARGINRECT = 0x402;
+// public static final int WM_PSD_PAGESETUPDLG = 0x400;
+// public static final int WM_PSD_YAFULLPAGERECT = 0x406;
+// public static final int WM_QUERYDRAGICON = 0x37;
+// public static final int WM_QUERYENDSESSION = 0x11;
+ public static final int WM_QUERYNEWPALETTE = 0x30F;
+ public static final int WM_QUERYOPEN = 0x13;
+// public static final int WM_QUEUESYNC = 0x23;
+// public static final int WM_QUIT = 0x12;
+ public static final int WM_RBUTTONDBLCLK = 0x206;
+ public static final int WM_RBUTTONDOWN = 0x204;
+ public static final int WM_RBUTTONUP = 0x205;
+// public static final int WM_RENDERALLFORMATS = 0x306;
+// public static final int WM_RENDERFORMAT = 0x305;
+ public static final int WM_SETCURSOR = 0x20;
+ public static final int WM_SETFOCUS = 0x7;
+ public static final int WM_SETFONT = 0x30;
+// public static final int WM_SETHOTKEY = 0x32;
+ public static final int WM_SETICON = 0x80;
+ public static final int WM_SETREDRAW = 0xB;
+// public static final int WM_SETTEXT = 0xC;
+// public static final int WM_SETTINGCHANGE = 0x1A;
+ public static final int WM_SHOWWINDOW = 0x18;
+ public static final int WM_SIZE = 0x5;
+// public static final int WM_SIZECLIPBOARD = 0x30B;
+// public static final int WM_SIZING = 0x214;
+// public static final int WM_SPOOLERSTATUS = 0x2A;
+// public static final int WM_STYLECHANGED = 0x7D;
+// public static final int WM_STYLECHANGING = 0x7C;
+ public static final int WM_SYSCHAR = 0x106;
+ public static final int WM_SYSCOLORCHANGE = 0x15;
+ public static final int WM_SYSCOMMAND = 0x112;
+// public static final int WM_SYSDEADCHAR = 0x107;
+ public static final int WM_SYSKEYDOWN = 0x104;
+ public static final int WM_SYSKEYUP = 0x105;
+// public static final int WM_TCARD = 0x52;
+// public static final int WM_TIMECHANGE = 0x1E;
+ public static final int WM_TIMER = 0x113;
+ public static final int WM_UNDO = 0x304;
+// public static final int WM_USERCHANGED = 0x54;
+// public static final int WM_VKEYTOITEM = 0x2E;
+ public static final int WM_VSCROLL = 0x115;
+// public static final int WM_VSCROLLCLIPBOARD = 0x30A;
+// public static final int WM_WINDOWPOSCHANGED = 0x47;
+ public static final int WM_WINDOWPOSCHANGING = 0x46;
+// public static final int WM_WININICHANGE = 0x1A;
+// public static final int WMSZ_BOTTOM = 0x6;
+// public static final int WMSZ_BOTTOMLEFT = 0x7;
+// public static final int WMSZ_BOTTOMRIGHT = 0x8;
+// public static final int WMSZ_LEFT = 0x1;
+// public static final int WMSZ_RIGHT = 0x2;
+// public static final int WMSZ_TOP = 0x3;
+// public static final int WMSZ_TOPLEFT = 0x4;
+// public static final int WMSZ_TOPRIGHT = 0x5;
+ public static final int WS_BORDER = 0x800000;
+ public static final int WS_CAPTION = 0xC00000;
+ public static final int WS_CHILD = 0x40000000;
+// public static final int WS_CHILDWINDOW = 0x40000000;
+ public static final int WS_CLIPCHILDREN = 0x2000000;
+ public static final int WS_CLIPSIBLINGS = 0x4000000;
+// public static final int WS_DISABLED = 0x8000000;
+// public static final int WS_DLGFRAME = 0x400000;
+// public static final int WS_EX_ACCEPTFILES = 0x10;
+// public static final int WS_EX_APPWINDOW = 0x40000;
+ public static final int WS_EX_CLIENTEDGE = 0x200;
+// public static final int WS_EX_CONTEXTHELP = 0x400;
+// public static final int WS_EX_CONTROLPARENT = 0x10000;
+ public static final int WS_EX_DLGMODALFRAME = 0x1;
+// public static final int WS_EX_LEFT = 0x0;
+// public static final int WS_EX_LEFTSCROLLBAR = 0x4000;
+// public static final int WS_EX_LTRREADING = 0x0;
+// public static final int WS_EX_MDICHILD = 0x40;
+// public static final int WS_EX_NOPARENTNOTIFY = 0x4;
+// public static final int WS_EX_OVERLAPPEDWINDOW = 0x300;
+// public static final int WS_EX_PALETTEWINDOW = 0x188;
+// public static final int WS_EX_RIGHT = 0x1000;
+// public static final int WS_EX_RIGHTSCROLLBAR = 0x0;
+// public static final int WS_EX_RTLREADING = 0x2000;
+ public static final int WS_EX_STATICEDGE = 0x20000;
+ public static final int WS_EX_TOOLWINDOW = 0x80;
+// public static final int WS_EX_TOPMOST = 0x8;
+// public static final int WS_EX_TRANSPARENT = 0x20;
+// public static final int WS_EX_WINDOWEDGE = 0x100;
+// public static final int WS_GROUP = 0x20000;
+ public static final int WS_HSCROLL = 0x100000;
+// public static final int WS_ICONIC = 0x20000000;
+// public static final int WS_MAXIMIZE = 0x1000000;
+ public static final int WS_MAXIMIZEBOX = 0x10000;
+// public static final int WS_MINIMIZE = 0x20000000;
+ public static final int WS_MINIMIZEBOX = 0x20000;
+ public static final int WS_OVERLAPPED = 0x0;
+ public static final int WS_OVERLAPPEDWINDOW = 0xCF0000;
+ public static final int WS_POPUP = 0x80000000;
+// public static final int WS_POPUPWINDOW = 0x80880000;
+// public static final int WS_SIZEBOX = 0x40000;
+ public static final int WS_SYSMENU = 0x80000;
+ public static final int WS_TABSTOP = 0x10000;
+ public static final int WS_THICKFRAME = 0x40000;
+// public static final int WS_TILED = 0x0;
+// public static final int WS_TILEDWINDOW = 0xCF0000;
+ public static final int WS_VISIBLE = 0x10000000;
+ public static final int WS_VSCROLL = 0x200000;
+// public static final int WSF_VISIBLE = 0x1;
+
+ /* Unused Structs */
+ /*
+ public class CHARFORMAT2 extends CHARFORMAT {
+ public short wWeight;
+ public short sSpacing;
+ public int crBackColor;
+ public int lcid;
+ public int dwReserved;
+ public short sStyle;
+ public short wKerning;
+ public byte bUnderlineType;
+ public byte bAnimation;
+ public byte bRevAuthor;
+ // public byte bReserved1;
+ public static final int sizeof = 84;
+ }
+
+ public class NMTVCUSTOMDRAW extends NMCUSTOMDRAW {
+ public int clrText;
+ public int clrTextBk;
+ public int iLevel;
+ public static final int sizeof = 60;
+ }
+
+ public class NMCUSTOMDRAW extends NMHDR {
+ public int dwDrawStage;
+ public int hdc;
+ // public RECT rc;
+ public int left, top, right, bottom;
+ public int dwItemSpec;
+ public int uItemState;
+ public int lItemlParam;
+ public static final int sizeof = 48;
+ }
+ public class MSGFILTER extends NMHDR {
+ public int msg;
+ public int wParam;
+ public int lParam;
+ public static final int sizeof = 24;
+ }
+ */
+
+ /* Unused Natives */
+ /*
+ public static final native int CopyAcceleratorTable (int hAccelSrc byte [] lpAccelDst, int cAccelEntries);
+ public static final native int ChildWindowFromPoint (int hwndParent, POINT lpPoint);
+ public static final native boolean EnumPrinters(int Flags, byte Name[], int Level, byte pPrinterEnum[], int cbBuf, int pcbNeeded[], int pcReturned[]);
+ public static final native boolean EqualRect (RECT lprc1, RECT lprc2);
+ public static final native int ExtractIcon(int hInst, byte[] lpszFile, int nIconIndex);
+ public static final native int GetCaretBlinkTime ();
+ public static final native int GetCaretBlinkTime ();
+ public static final native int GetClassLong (int hWnd, int nIndex);
+ public static final native int GetDIBits (int hdc, int hbmp, int uStartScan, int cScanLines, byte[] lpvBits, byte[] lpbi, int uUsage);
+ public static final native int GetDlgCtrlID (int hWnd);
+ public static final native boolean GetTextExtentPoint32 (int hWnd, byte lpString[], int cbString, SIZE s);
+ public static final native boolean IntersectRect (RECT lprcDst, RECT lprcSrc1, RECT lprcSrc2);
+ public static final native boolean IsMenu (int hMenu);
+ public static final native boolean IsWindow (int hwnd);
+ public static final native int LoadBitmap (int hInstance, byte [] lpBitmapName);
+ public static final native int LoadCursor (int hInstance, byte [] lpCursorName);
+ public static final native int LoadIcon (int hInstance, byte [] lpIconName);
+ public static final native int LoadImage (int hinst, int lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
+ public static final native void MoveMemory (ACCEL Destination, byte [] Source, int Length);
+ public static final native void MoveMemory (NMTVCUSTOMDRAW Destination, int Source, int Length);
+ public static final native void MoveMemory (RECT Destination, int Source, int Length);
+ public static final native boolean PageSetupDlg (PAGESETUPDLG lppsd);
+ public static final native void PostQuitMessage (int nExitCode);
+ public static final native boolean Rectangle (int hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
+ public static final native int SendMessage (int hWnd, int Msg, int wParam, CHARFORMAT2 lParam);
+ public static final native int SendMessage (int hWnd, int Msg, int wParam, MSG lParam);
+ public static final native boolean SetCaretBlinkTime (int uMSeconds);
+ public static final native boolean TextOut (int hdc, int nXStart, int nYStart, byte[] lpString, int cbString);
+ */
+public static final native int AbortDoc (int hdc);
+public static final native boolean AdjustWindowRectEx (RECT lpRect, int dwStyle, boolean bMenu, int dwExStyle);
+public static final native boolean Arc (int hdc,int nLeftRect,int nTopRect,int nRightRect,int nBottomRect,int nXStartArc,int nYStartArc,int nXEndArc,int nYEndArc);
+public static final native int BeginDeferWindowPos (int nNumWindows);
+public static final native int BeginPaint (int hWnd, PAINTSTRUCT lpPaint);
+public static final native boolean BitBlt (int hdcDest,int nXDest,int nYDest,int nWidth,int nHeight,int hdcSrc,int nXSrc,int nYSrc,int dwRop);
+public static final native boolean BringWindowToTop (int hWnd);
+public static final native int Call (int address, DLLVERSIONINFO arg0);
+public static final native int CallWindowProc (int lpPrevWndFunc, int hWnd, int Msg, int wParam, int lParam);
+public static final native short CharLower (short ch);
+public static final native short CharUpper (short ch);
+public static final native boolean ChooseColor (CHOOSECOLOR lpcc);
+public static final native boolean ChooseFont (CHOOSEFONT chooseFont);
+public static final native boolean ClientToScreen (int hWnd, POINT lpPoint);
+public static final native boolean CloseClipboard ();
+public static final native int CombineRgn (
+ int hrgnDest, // handle to destination region
+ int hrgnSrc1, // handle to source region
+ int hrgnSrc2, // handle to source region
+ int fnCombineMode // region combining mode
+);
+public static final native int CommDlgExtendedError ();
+public static final native int CopyImage (
+ int hImage, // handle to the image to copy
+ int uType, // type of image to copy
+ int cxDesired, // desired width of new image
+ int cyDesired, // desired height of new image
+ int fuFlags // copy flags
+);
+public static final native int CreateAcceleratorTable (
+ byte [] lpaccl, // pointer to structure array with accelerator data
+ int cEntries // number of structures in the array
+);
+public static final native int CreateBitmap (
+ int nWidth, // bitmap width, in pixels
+ int nHeight, // bitmap height, in pixels
+ int cPlanes, // number of color planes used by device
+ int cBitsPerPel, // number of bits required to identify a color
+ byte [] lpvBits // pointer to array containing color data);
+);
+public static final native int CreateBitmapIndirect (BITMAP lpbm);
+public static final native boolean CreateCaret (int hWnd, int hBitmap, int nWidth, int nHeight);
+public static final native int CreateCompatibleBitmap (
+ int hdc, // handle to device context
+ int nWidth, // width of bitmap, in pixels
+ int nHeight // height of bitmap, in pixels
+ );
+public static final native int CreateCompatibleDC (int hdc);
+public static final native int CreateCursor (int hInst, int xHotSpot, int yHotSpot, int nWidth, int nHeight, byte [] pvANDPlane, byte [] pvXORPlane);
+public static final native int CreateDC (byte [] lpszDriver, byte [] lpszDevice, int lpszOutput, int lpInitData);
+public static final native int CreateDIBSection(int hdc, byte[] pbmi, int iUsage, int[] ppvBits, int hSection, int dwOffset);
+public static final native int CreateFontIndirect (int lplf);
+public static final native int CreateFontIndirect (LOGFONT lplf);
+public static final native int CreateIconIndirect (ICONINFO lplf);
+public static final native int CreateMenu ();
+public static final native int CreatePalette (byte[] logPalette);
+public static final native int CreatePatternBrush (int colorRef);
+//public static final native int ExtCreatePen (int fnPenStyle, int nWidth, LOGBRUSH lplb, int dwStyleCount, int lpStyle);
+public static final native int CreatePopupMenu ();
+public static final native int CreateRectRgn (int left, int top, int right, int bottom);
+public static final native int CreateSolidBrush (int colorRef);
+public static final native int CreateWindowEx (int dwExStyle, byte [] lpClassName, byte [] lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight, int hWndParent, int hMenu, int hInstance, CREATESTRUCT lpParam);
+public static final native int DeferWindowPos (int hWinPosInfo, int hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
+public static final native int DefWindowProc (int hWnd, int Msg, int wParam, int lParam);
+public static final native boolean DeleteDC (int hdc);
+public static final native boolean DeleteMenu (int hMenu, int uPosition, int uFlags);
+public static final native boolean DeleteObject (int hGdiObj);
+public static final native boolean DestroyAcceleratorTable (int hAccel);
+public static final native boolean DestroyCaret ();
+public static final native boolean DestroyCursor (int hCursor);
+public static final native boolean DestroyIcon (int hIcon);
+public static final native boolean DestroyMenu (int hMenu);
+public static final native boolean DestroyWindow (int hWnd);
+public static final native int DispatchMessage (MSG lpmsg);
+public static final native boolean DragDetect (int hwnd, POINT pt);
+public static final native boolean DrawEdge (
+ int hdc, // handle to device context
+ RECT qrc, // pointer to rectangle coordinates
+ int edge, // type of inner and outer edge to draw
+ int grfFlags // type of border
+);
+public static final native boolean DrawFocusRect (int hDC, RECT lpRect);
+public static final native boolean DrawFrameControl (int hdc, RECT lprc, int uType, int uState);
+public static final native boolean DrawIconEx (
+ int hdc, // handle to device context
+ int xLeft, // x-coordinate of upper left corner
+ int yTop, // y-coordinate of upper left corner
+ int hIcon, // handle to icon to draw
+ int cxWidth, // width of the icon
+ int cyWidth, // height of the icon
+ int istepIfAniCur, // index of frame in animated cursor
+ int hbrFlickerFreeDraw, // handle to background brush
+ int diFlags // icon-drawing flags
+);
+public static final native boolean DrawMenuBar (int hWnd);
+public static final native int DrawText (int hDC, byte [] lpString, int nCount, RECT lpRect, int uFormat);
+public static final native boolean Ellipse (int hdc,int nLeftRect,int nTopRect,int nRightRect,int nBottomRect);
+public static final native boolean EnableMenuItem (int hMenu, int uIDEnableItem, int uEnable);
+public static final native boolean EnableScrollBar (int hWnd, int wSBflags, int wArrows);
+public static final native boolean EnableWindow (int hWnd, boolean bEnable);
+public static final native boolean EndDeferWindowPos (int hWinPosInfo);
+public static final native int EndDoc (int hdc);
+public static final native int EndPage (int hdc);
+public static final native int EndPaint (int hWnd, PAINTSTRUCT lpPaint);
+public static final native int EnumFontFamilies (int hdc, byte [] lpszFamily, int lpEnumFontFamProc, int lParam);
+public static final native boolean EqualRgn (
+ int hSrcRgn1, // handle to first region
+ int hSrcRgn2 // handle to second region
+);
+public static final native int ExpandEnvironmentStrings (byte [] lpSrc, byte [] lpDest, int nSize);
+public static final native int ExtractIconEx (byte [] lpszFile, int nIconIndex, int [] phiconLarge, int [] phiconSmall, int nIcons);
+public static final native int FillRect(int hDC, RECT lprc, int hbr);
+public static final native boolean FreeLibrary (int hLibModule);
+public static final native int GetACP ();
+public static final native int GetActiveWindow ();
+public static final native int GetBkColor (int hDC);
+public static final native int GetCapture ();
+public static final native boolean GetCaretPos (POINT lpPoint);
+public static final native boolean GetCharABCWidths (int hdc, int iFirstChar, int iLastChar, int [] lpabc);
+public static final native boolean GetCharWidth (int hdc, int iFirstChar, int iLastChar, int [] lpBuffer);
+public static final native boolean GetClassInfoEx (int hInstance, byte [] lpClassName, WNDCLASSEX lpWndClass);
+public static final native boolean GetClientRect (int hWnd, RECT lpRect);
+public static final native int GetClipboardData (int uFormat);
+public static final native int GetClipBox (int hdc, RECT lprc);
+public static final native int GetClipRgn (int hdc, int hrgn);
+public static final native int GetCurrentObject (int hdc, int uObjectType);
+public static final native int GetCurrentProcessId ();
+public static final native int GetCurrentThreadId ();
+public static final native int GetCursor ();
+public static final native boolean GetCursorPos (POINT lpPoint);
+public static final native int GetDC (int hwnd);
+public static final native int GetDCEx (int hWnd, int hrgnClip, int flags);
+public static final native int GetDesktopWindow ();
+public static final native int GetDeviceCaps (int hdc, int nIndex);
+public static final native int GetDialogBaseUnits ();
+public static final native int GetDIBColorTable (int hdc, int uStartIndex, int cEntries, byte[] pColors);
+public static final native int GetDIBits (int hdc, int hbmp, int uStartScan, int cScanLines, int lpvBits, byte[] lpbi, int uUsage);
+public static final native int GetDlgItem (
+ int hDlg, // handle of dialog box
+ int nIDDlgItem // identifier of control
+);
+public static final native int GetDoubleClickTime ();
+public static final native short GetFileTitle (
+ byte [] lpszFile, // pointer to full path and filename for file
+ byte [] lpszTitle, // pointer to buffer that receives filename
+ short cbBuf // length of buffer
+);
+public static final native int GetFocus ();
+public static final native boolean GetIconInfo (int hIcon, ICONINFO piconinfo);
+public static final native boolean GetKeyboardState (byte [] lpKeyState);
+public static final native short GetKeyState (int nVirtKey);
+public static final native int GetLastActivePopup (int hWnd);
+public static final native int GetLastError ();
+public static final native int GetMenu (int hWnd);
+public static final native int GetMenuDefaultItem (int hMenu, int fByPos, int gmdiFlags);
+public static final native boolean GetMenuInfo (int hmenu, MENUINFO lpcmi);
+public static final native int GetMenuItemCount (int hMenu);
+public static final native boolean GetMenuItemInfo (
+ int hMenu,
+ int uItem,
+ boolean fByPosition,
+ MENUITEMINFO lpmii
+);
+public static final native boolean GetMessage (MSG lpMsg, int hWnd, int wMsgFilterMin, int wMsgFilterMax);
+public static final native int GetMessagePos ();
+public static final native int GetMessageTime ();
+public static final native int GetModuleHandle (byte [] lpModuleName);
+public static final native int GetNearestPaletteIndex(int hPal, int crColor);
+public static final native int GetObject (
+ int hgdiobj, // handle to graphics object of interest
+ int cbBuffer, // size of buffer for object information
+ BITMAP lpvObject // pointer to buffer for object information
+);
+public static final native int GetObject (
+ int hgdiobj, // handle to graphics object of interest
+ int cbBuffer, // size of buffer for object information
+ DIBSECTION lpvObject // pointer to buffer for object information
+);
+public static final native int GetObject (
+ int hgdiobj, // handle to graphics object of interest
+ int cbBuffer, // size of buffer for object information
+ LOGBRUSH lpvObject // pointer to buffer for object information
+);
+public static final native int GetObject (
+ int hgdiobj, // handle to graphics object of interest
+ int cbBuffer, // size of buffer for object information
+ LOGFONT lpvObject // pointer to buffer for object information
+);
+//public static final native int GetObject (
+// int hgdiobj, // handle to graphics object of interest
+// int cbBuffer, // size of buffer for object information
+// EXTLOGPEN lpvObject // pointer to buffer for object information
+//);
+public static final native int GetObject (
+ int hgdiobj, // handle to graphics object of interest
+ int cbBuffer, // size of buffer for object information
+ LOGPEN lpvObject // pointer to buffer for object information
+);
+public static final native boolean GetOpenFileName (OPENFILENAME lpofn);
+public static final native int GetPaletteEntries (int hPalette, int iStartIndex, int nEntries, byte[] logPalette);
+public static final native int GetParent (int hWnd);
+public static final native int GetProcAddress (int hModule, byte [] lpProcName);
+public static final native int GetProcessHeap ();
+public static final native int GetProfileString (byte [] lpAppName, byte [] lpKeyName, byte [] lpDefault, byte [] lpReturnedString, int nSize);
+public static final native int GetRegionData (
+ int hRgn, // handle to region
+ int dwCount, // size of buffer containing region data
+ int [] lpRgnData // address of buffer containing region data
+);
+public static final native int GetRgnBox (
+ int hrgn, // handle to a region
+ RECT lprc // address of structure that receives bounding rect.
+);
+public static final native int GetROP2 (int hdc);
+public static final native boolean GetSaveFileName (OPENFILENAME lpofn);
+public static final native boolean GetScrollInfo (int hwnd, int flags, SCROLLINFO info);
+public static final native int GetStockObject (int fnObject);
+public static final native int GetSysColor (int nIndex);
+public static final native int GetSysColorBrush (int nIndex);
+public static final native int GetSystemMenu (int hWnd, boolean bRevert);
+public static final native int GetSystemMetrics (int nIndex);
+public static final native int GetTextColor (int hDC);
+public static final native boolean GetTextExtentPoint32 (int hdc, byte [] lpString, int cbString, SIZE lpSize);
+public static final native boolean GetTextMetrics (int hdc, TEXTMETRIC lptm);
+public static final native int GetUpdateRgn (int hWnd, int hRgn, boolean bErase);
+public static final native int GetVersion ();
+public static final native int GetWindow (int hWnd, int uCmd);
+public static final native int GetWindowLong (int hWnd, int nIndex);
+public static final native boolean GetWindowPlacement (int hWnd, WINDOWPLACEMENT lpwndpl);
+public static final native boolean GetWindowRect (int hWnd, RECT lpRect);
+public static final native int GetWindowText (int hWnd, byte [] lpString, int nMaxCount);
+public static final native int GetWindowTextLength (int hWnd);
+public static final native int GetWindowThreadProcessId (int hWnd, int [] lpdwProcessId);
+public static final native int GlobalAlloc (int uFlags, int dwBytes);
+public static final native int GlobalFree (int hMem);
+public static final native int GlobalLock (int hMem);
+public static final native int GlobalSize (int hMem);
+public static final native boolean GlobalUnlock (int hMem);
+public static final native int HeapAlloc (
+ int hHeap, // handle to the private heap block
+ int dwFlags, // heap allocation control flags
+ int dwBytes // number of bytes to allocate
+);
+public static final native boolean HeapFree (
+ int hHeap, // handle to the heap
+ int dwFlags, // heap freeing flags
+ int lpMem // pointer to the memory to free
+);
+public static final native boolean HideCaret (int hWnd);
+public static final native int ImageList_AddMasked (
+ int himl,
+ int hbmImage,
+ int crMask);
+public static final native int ImageList_Create (
+ int cx,
+ int cy,
+ int flags,
+ int cInitial,
+ int cGrow
+ );
+
+public static final native boolean ImageList_Destroy (int himl);
+
+public static final native int ImageList_GetIcon (int himl, int i, int flags);
+public static final native boolean ImageList_GetIconSize (
+ int himl,
+ int [] cx,
+ int [] cy
+ );
+public static final native int ImageList_GetImageCount (int himl);
+public static final native boolean ImageList_Remove (int himl, int i);
+public static final native boolean ImageList_Replace (int himl, int i, int hbmImage, int hbmMask);
+public static final native int ImageList_ReplaceIcon (
+ int himl,
+ int i,
+ int hicon);
+public static final native boolean ImageList_SetIconSize (
+ int himl,
+ int cx,
+ int cy);
+public static final native int ImmAssociateContext (int hWnd, int hIMC);
+public static final native int ImmCreateContext ();
+public static final native boolean ImmDestroyContext (int hIMC);
+public static final native boolean ImmGetCompositionFont (int hIMC, LOGFONT lplf);
+public static final native int ImmGetCompositionString (int hIMC, int dwIndex, byte [] lpBuf, int dwBufLen);
+public static final native int ImmGetContext (int hWnd);
+public static final native boolean ImmGetConversionStatus (int hIMC, int [] lpfdwConversion, int [] lpfdwSentence);
+public static final native int ImmGetDefaultIMEWnd (int hWnd);
+public static final native boolean ImmGetOpenStatus (int hIMC);
+public static final native boolean ImmReleaseContext (int hWnd, int hIMC);
+public static final native boolean ImmSetCompositionFont (int hIMC, LOGFONT lplf);
+public static final native boolean ImmSetCompositionWindow (int hIMC, COMPOSITIONFORM lpCompForm);
+public static final native boolean ImmSetConversionStatus (int hIMC, int fdwConversion, int dwSentence);
+public static final native boolean ImmSetOpenStatus (int hIMC, boolean fOpen);
+public static final native void InitCommonControls ();
+public static final native boolean InitCommonControlsEx (INITCOMMONCONTROLSEX lpInitCtrls);
+public static final native boolean InsertMenuItem (
+ int hMenu,
+ int uItem,
+ boolean fByPosition,
+ MENUITEMINFO lpmii
+);
+public static final native boolean InvalidateRect(int hWnd, RECT lpRect, boolean bErase);
+public static final native boolean InvalidateRgn (int hWnd, int hRgn, boolean bErase);
+public static final native boolean IsDBCSLeadByte (byte TestChar);
+public static final native boolean IsIconic (int hWnd);
+public static final native boolean IsWindowEnabled (int hWnd);
+public static final native boolean IsWindowVisible (int hWnd);
+public static final native boolean IsZoomed (int hWnd);
+public static final native boolean LineTo (int hdc,int x1, int x2);
+public static final native int LoadBitmap (int hInstance, int lpBitmapName);
+public static final native int LoadCursor (int hInstance, int lpCursorName);
+public static final native int LoadIcon (int hInstance, int lpIconName);
+public static final native int LoadImage (int hinst, byte [] lpszName, int uType, int cxDesired, int cyDesired, int fuLoad);
+public static final native int LoadLibrary (byte [] lpLibFileName);
+public static final native int MapVirtualKey (int uCode, int uMapType);
+public static final native int MapWindowPoints (int hWndFrom, int hWndTo, POINT lpPoints, int cPoints);
+public static final native int MapWindowPoints (int hWndFrom, int hWndTo, RECT lpPoints, int cPoints);
+public static final native boolean MessageBeep (int uType);
+public static final native int MessageBox (
+ int hWnd, // handle of owner window
+ byte [] lpText, // address of text in message box
+ byte [] lpCaption, // address of title of message box
+ int uType // style of message box
+);
+public static final native void MoveMemory (
+ byte [] Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ byte [] Destination, // address of move destination
+ ACCEL Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int [] Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ byte [] Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ char [] Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ int [] Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ LOGFONT Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ MEASUREITEMSTRUCT Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ NMTTDISPINFO Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ int Destination, // address of move destination
+ RECT Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ DRAWITEMSTRUCT Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ HDITEM Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ HELPINFO Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ LOGFONT Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ MEASUREITEMSTRUCT Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ NMHDR Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ NMHEADER Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ NMLISTVIEW Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ NMTOOLBAR Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ NMTTDISPINFO Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ TVITEM Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native void MoveMemory (
+ WINDOWPOS Destination, // address of move destination
+ int Source, // address of block to move
+ int Length // size, in bytes, of block to move
+);
+public static final native boolean MoveToEx (int hdc,int x1, int x2, int lPoint);
+public static final native int MultiByteToWideChar (int CodePage, int dwFlags, byte [] lpMultiByteStr, int cchMultiByte, char [] lpWideCharStr, int cchWideChar);
+public static final native int MultiByteToWideChar (int CodePage, int dwFlags, int lpMultiByteStr, int cchMultiByte, char [] lpWideCharStr, int cchWideChar);
+public static final native int OleInitialize (int pvReserved);
+public static final native void OleUninitialize ();
+public static final native boolean OpenClipboard (int hWndNewOwner);
+public static final native boolean PatBlt (int hdc,int x1, int x2,int w, int h, int rop);
+public static final native boolean PeekMessage (
+ MSG lpMsg, // pointer to structure for message
+ int hWnd, // handle to window
+ int wMsgFilterMin, // first message
+ int wMsgFilterMax, // last message
+ int wRemoveMsg // removal flags
+);
+public static final native boolean Pie (int hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nXStartArc, int nYStartArc, int nXEndArc, int nYEndArc);
+public static final native boolean Polygon (int hdc, int [] points, int nPoints);
+public static final native boolean Polyline (int hdc,int[] points, int nPoints);
+public static final native boolean PostMessage (int hWnd, int Msg, int wParam, int lParam);
+public static final native boolean PostThreadMessage (int idThread, int Msg, int wParam, int lParam);
+public static final native boolean PrintDlg (PRINTDLG lppd);
+public static final native boolean PtInRect (RECT rect, POINT pt);
+public static final native boolean PtInRegion (
+ int hrgn, // handle to region
+ int X, // x-coordinate of point
+ int Y // y-coordinate of point
+);
+public static final native int RealizePalette(int hDC);
+public static final native boolean Rectangle (int hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
+public static final native boolean RectInRegion (
+ int hrgn, // handle to region
+ RECT lprc // address of structure with rectangle
+);
+
+public static final native boolean RedrawWindow (int hWnd, RECT lprcUpdate, int hrgnUpdate, int flags);
+public static final native int RegCloseKey (int hKey);
+public static final native int RegEnumKey (int hKey, int dwIndex, byte [] lpName, int cbName);
+public static final native int RegisterClassEx (WNDCLASSEX lpWndClass);
+public static final native int RegOpenKeyEx (int hKey, byte[] lpSubKey, int ulOptions, int samDesired, int[] phkResult);
+public static final native int RegQueryInfoKey (int hKey, int lpClass, int[] lpcbClass, int lpReserved, int[] lpSubKeys, int[] lpcbMaxSubKeyLen, int[] lpcbMaxClassLen, int[] lpcValues, int[] lpcbMaxValueNameLen, int[] lpcbMaxValueLen, int[] lpcbSecurityDescriptor, int lpftLastWriteTime);
+public static final native int RegQueryValueEx (int hKey, byte[] lpValueName, int lpReserved, int[] lpType, byte [] lpData, int[] lpcbData);
+public static final native boolean ReleaseCapture ();
+public static final native int ReleaseDC (int hWnd, int hDC);
+public static final native boolean RemoveMenu (int hMenu, int uPosition, int uFlags);
+public static final native boolean RoundRect (int hdc, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidth, int nHeight);
+public static final native boolean ScreenToClient (int hWnd, POINT lpPoint);
+public static final native int ScrollWindowEx (int hWnd, int dx, int dy, RECT prcScroll, RECT prcClip, int hrgnUpdate, RECT prcUpdate, int flags);
+public static final native int SelectClipRgn (int hdc, int hrgn);
+public static final native int SelectObject(int hDC, int HGDIObj);
+public static final native int SelectPalette(int hDC, int hpal, boolean bForceBackground);
+public static final native int SendMessage (int hWnd, int Msg, int [] wParam, byte [] lParam);
+public static final native int SendMessage (int hWnd, int Msg, int [] wParam, int [] lParam);
+public static final native int SendMessage (int hWnd, int Msg, int [] wParam, int lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, byte [] lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, int [] lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, short [] lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, int lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, LVCOLUMN lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, LVHITTESTINFO lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, LVITEM lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, REBARBANDINFO lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, RECT lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TBBUTTON lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TBBUTTONINFO lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TCITEM lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TOOLINFO lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TVHITTESTINFO lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TVINSERTSTRUCT lParam);
+public static final native int SendMessage (int hWnd, int Msg, int wParam, TVITEM lParam);
+public static final native int SetActiveWindow (int hWnd);
+public static final native int SetBkColor (int hdc, int colorRef);
+public static final native int SetBkMode (int hdc, int mode);
+public static final native int SetCapture (int hWnd);
+public static final native boolean SetCaretPos (int X, int Y);
+public static final native int SetClipboardData (int uFormat, int hMem);
+public static final native int SetCursor (int hCursor);
+public static final native int SetDIBColorTable (int hdc, int uStartIndex, int cEntries, byte[] pColors);
+public static final native int SetFocus (int hWnd);
+public static final native int SetMapMode (int hdc, int fnMapMode);
+public static final native boolean SetMenu (int hWnd, int hMenu);
+public static final native boolean SetMenuDefaultItem (int hMenu, int uItem, int fByPos);
+public static final native boolean SetMenuInfo (int hmenu, MENUINFO lpcmi);
+public static final native boolean SetMenuItemInfo (
+ int hMenu,
+ int uItem,
+ boolean fByPosition,
+ MENUITEMINFO lpmii
+);
+public static final native int SetPaletteEntries (int hPal, int iStart, int cEntries, byte[] lppe);
+public static final native int SetParent (int hWndChild, int hWndNewParent);
+public static final native int SetPixel (int hdc, int X, int Y, int crColor);
+public static final native boolean SetRect(RECT lprc, int xLeft, int yTop, int xRight, int yBottom);
+public static final native boolean SetRectRgn (int hrgn, int nLeftRect, int nTopRect, int nRightRect, int nBottomRect);
+public static final native int SetROP2 (int hdc, int fnDrawMode);
+public static final native boolean SetScrollInfo (int hwnd, int flags, SCROLLINFO info, boolean fRedraw);
+public static final native int SetTextColor (int hdc, int colorRef);
+public static final native int SetWindowLong (int hWnd, int nIndex, int dwNewLong);
+public static final native boolean SetWindowPlacement (int hWnd, WINDOWPLACEMENT lpwndpl);
+public static final native boolean SetWindowPos(int hWnd, int hWndInsertAfter, int X, int Y, int cx, int cy, int uFlags);
+public static final native boolean SetWindowText (int hWnd, byte [] lpString);
+public static final native int SHBrowseForFolder (BROWSEINFO lpbi);
+public static final native int ShellExecute (int hwnd, byte [] lpOperation, byte [] lpFile, byte [] lpParameters, byte [] lpDirectory, int nShowCmd);
+public static final native int SHGetMalloc (int [] ppMalloc);
+public static final native boolean SHGetPathFromIDList (int pidl, byte [] pszPath);
+public static final native boolean ShowCaret (int hWnd);
+public static final native boolean ShowOwnedPopups (int hWnd, boolean fShow);
+public static final native boolean ShowScrollBar (int hWnd, int wBar, boolean bShow);
+public static final native boolean ShowWindow (int hWnd, int nCmdShow);
+public static final native int StartDoc (int hdc, DOCINFO lpdi);
+public static final native int StartPage (int hdc);
+public static final native boolean StretchBlt (
+ int hdcDest, // handle to destination device context
+ int nXOriginDest, // x-coordinate of upper-left corner of dest.
+ // rect.
+ int nYOriginDest, // y-coordinate of upper-left corner of dest.
+ // rect.
+ int nWidthDest, // width of destination rectangle
+ int nHeightDest, // height of destination rectangle
+ int hdcSrc, // handle to source device context
+ int nXOriginSrc, // x-coordinate of upper-left corner of source
+ // rectangle
+ int nYOriginSrc, // y-coordinate of upper-left corner of source
+ // rectangle
+ int nWidthSrc, // width of source rectangle
+ int nHeightSrc, // height of source rectangle
+ int dwRop // raster operation code
+);
+public static final native boolean TextOut (int hdc, int nXStart, int nYStart, byte [] lpString, int cbString);
+public static final native int ToAscii (
+ int uVirtKey,
+ int uScanCode,
+ byte [] lpKeyState,
+ short [] lpChar,
+ int uFlags
+);
+
+public static final native boolean TrackMouseEvent(TRACKMOUSEEVENT lpEventTrack);
+public static final native boolean TrackPopupMenu (
+ int hMenu, // handle to shortcut menu
+ int uFlags, // screen-position and mouse-button flags
+ int x, // horizontal position, in screen coordinates
+ int y, // vertical position, in screen coordinates
+ int nReserved, // reserved, must be zero
+ int hWnd, // handle to owner window
+ RECT prcRect // pointer to RECT that specifies no-dismissal area
+);
+public static final native int TranslateAccelerator (
+ int hWnd, // handle of destination window
+ int hAccTable, // handle of accelerator table
+ MSG lpMsg // address of structure with message
+);
+public static final native boolean TranslateMessage (MSG lpmsg);
+public static final native boolean UnregisterClass (byte [] lpClassName, int hInstance);
+public static final native boolean UpdateWindow (int hWnd);
+public static final native boolean ValidateRect (int hWnd, RECT lpRect);
+public static final native short VkKeyScan (short ch);
+public static final native int VtblCall (int ppVtbl, int fnNumber, int arg0);
+public static final native boolean WaitMessage ();
+public static final native int WideCharToMultiByte (int CodePage, int dwFlags, char [] lpWideCharStr, int cchWideChar, byte [] lpMultiByteStr, int cchMultiByte, byte [] lpDefaultChar, boolean [] lpUsedDefaultChar);
+public static final native int WindowFromDC (int lpPoint);
+public static final native int WindowFromPoint (POINT lpPoint);
+
+public static final native int SetTimer (int hWnd, int nIDEvent, int Elapse, int lpTimerFunc);
+public static final native boolean KillTimer (int hWnd, int uIDEvent);
+
+public static final native boolean DrawState (int hdc, int hbr, int lpOutputFunc, int lData, int wData, int x, int y, int cx, int cy, int fuFlags);
+
+public static final native int CreatePen (int fnPenStyle, int nWidth, int crColor);
+public static final native int SetStretchBltMode(int hdc, int iStretchMode);
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java
new file mode 100755
index 0000000000..a0e611c5d2
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PAINTSTRUCT.java
@@ -0,0 +1,18 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class PAINTSTRUCT {
+ public int hdc;
+ public boolean fErase;
+// public RECT rcPaint;
+ public int left, top, right, bottom;
+ public boolean fRestore;
+ public boolean fIncUpdate;
+// public byte rgbReserved[32];
+ public int pad0, pad1, pad2, pad3, pad4, pad5, pad6, pad7;
+ public static final int sizeof = 64;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/POINT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/POINT.java
new file mode 100755
index 0000000000..a4fe6d9593
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/POINT.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class POINT {
+ public int x;
+ public int y;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PRINTDLG.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PRINTDLG.java
new file mode 100755
index 0000000000..ecf63a887a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/PRINTDLG.java
@@ -0,0 +1,29 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class PRINTDLG {
+ public int lStructSize; // DWORD
+ public int hwndOwner; // HWND
+ public int hDevMode; // HGLOBAL
+ public int hDevNames; // HGLOBAL
+ public int hDC; // HDC
+ public int Flags; // DWORD
+ public short nFromPage; // WORD
+ public short nToPage; // WORD
+ public short nMinPage; // WORD
+ public short nMaxPage; // WORD
+ public short nCopies; // WORD
+ public int hInstance; // HINSTANCE
+ public int lCustData; // LPARAM
+ public int lpfnPrintHook; // LPPRINTHOOKPROC
+ public int lpfnSetupHook; // LPSETUPHOOKPROC
+ public int lpPrintTemplateName; // LPCTSTR
+ public int lpSetupTemplateName; // LPCTSTR
+ public int hPrintTemplate; // HGLOBAL
+ public int hSetupTemplate; // HGLOBAL
+ public static final int sizeof = 66;
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
new file mode 100755
index 0000000000..187b3c9ba5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/REBARBANDINFO.java
@@ -0,0 +1,30 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class REBARBANDINFO {
+ public int cbSize;
+ public int fMask;
+ public int fStyle;
+ public int clrFore;
+ public int clrBack;
+ public int lpText;
+ public int cch;
+ public int iImage;
+ public int hwndChild;
+ public int cxMinChild;
+ public int cyMinChild;
+ public int cx;
+ public int hbmBack;
+ public int wID;
+ public int cyChild;
+ public int cyMaxChild;
+ public int cyIntegral;
+ public int cxIdeal;
+ public int lParam;
+ public int cxHeader;
+ public static final int sizeof = 80;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/RECT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/RECT.java
new file mode 100755
index 0000000000..36cf0f7e83
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/RECT.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class RECT {
+ public int left;
+ public int top;
+ public int right;
+ public int bottom;
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java
new file mode 100755
index 0000000000..9b6cb17b76
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SCROLLINFO.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class SCROLLINFO {
+ public int cbSize;
+ public int fMask;
+ public int nMin;
+ public int nMax;
+ public int nPage;
+ public int nPos;
+ public int nTrackPos;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SIZE.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SIZE.java
new file mode 100755
index 0000000000..18b415415f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/SIZE.java
@@ -0,0 +1,12 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class SIZE {
+ public int cx;
+ public int cy;
+ public static final int sizeof = 8;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTON.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTON.java
new file mode 100755
index 0000000000..332d1d497c
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTON.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TBBUTTON {
+ public int iBitmap;
+ public int idCommand;
+ public byte fsState;
+ public byte fsStyle;
+ public short ___MISSING_ALIGNMENT__;
+ public int dwData;
+ public int iString;
+ public static final int sizeof = 20;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java
new file mode 100755
index 0000000000..8d168db17b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TBBUTTONINFO.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TBBUTTONINFO {
+ public int cbSize;
+ public int dwMask;
+ public int idCommand;
+ public int iImage;
+ public byte fsState;
+ public byte fsStyle;
+ public short cx;
+ public int lParam;
+ public int pszText;
+ public int cchText;
+ public static final int sizeof = 32;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TCITEM.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TCITEM.java
new file mode 100755
index 0000000000..46685a0770
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TCITEM.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TCITEM {
+ public int mask;
+ public int dwState;
+ public int dwStateMask;
+ public int pszText;
+ public int cchTextMax;
+ public int iImage;
+ public int lParam;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java
new file mode 100755
index 0000000000..2f3d5ef306
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TEXTMETRIC.java
@@ -0,0 +1,32 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TEXTMETRIC {
+ public int tmHeight;
+ public int tmAscent;
+ public int tmDescent;
+ public int tmInternalLeading;
+ public int tmExternalLeading;
+ public int tmAveCharWidth;
+ public int tmMaxCharWidth;
+ public int tmWeight;
+ public int tmOverhang;
+ public int tmDigitizedAspectX;
+ public int tmDigitizedAspectY;
+ public byte tmFirstChar;
+ public byte tmLastChar;
+ public byte tmDefaultChar;
+ public byte tmBreakChar;
+ public byte tmItalic;
+ public byte tmUnderlined;
+ public byte tmStruckOut;
+ public byte tmPitchAndFamily;
+ public byte tmCharSet;
+ public byte ___MISSING_ALIGNMENT__0;
+ public short ___MISSING_ALIGNMENT__1;
+ public static final int sizeof = 56;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TOOLINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TOOLINFO.java
new file mode 100755
index 0000000000..4619f5e943
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TOOLINFO.java
@@ -0,0 +1,19 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TOOLINFO {
+ public int cbSize;
+ public int uFlags;
+ public int hwnd;
+ public int uId;
+// public RECT rect;
+ public int left, top, right, bottom;
+ public int hinst;
+ public int lpszText;
+ public int lParam;
+ public static int sizeof = 44;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java
new file mode 100755
index 0000000000..78fd7044d6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TRACKMOUSEEVENT.java
@@ -0,0 +1,14 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2000 All Rights Reserved
+ */
+
+public class TRACKMOUSEEVENT {
+ public int cbSize;
+ public int dwFlags;
+ public int hwndTrack;
+ public int dwHoverTime;
+ public static final int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java
new file mode 100755
index 0000000000..5d5d04601b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVHITTESTINFO.java
@@ -0,0 +1,15 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TVHITTESTINFO {
+// POINT pt;
+ public int x;
+ public int y;
+ public int flags;
+ public int hItem;
+ public static int sizeof = 16;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java
new file mode 100755
index 0000000000..c51bfc7086
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVINSERTSTRUCT.java
@@ -0,0 +1,23 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TVINSERTSTRUCT {
+ public int hParent;
+ public int hInsertAfter;
+// public TVITEM item;
+ public int mask;
+ public int hItem;
+ public int state;
+ public int stateMask;
+ public int pszText;
+ public int cchTextMax;
+ public int iImage;
+ public int iSelectedImage;
+ public int cChildren;
+ public int lParam;
+ public static final int sizeof = 48;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVITEM.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVITEM.java
new file mode 100755
index 0000000000..81c7caf929
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/TVITEM.java
@@ -0,0 +1,20 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class TVITEM {
+ public int mask;
+ public int hItem;
+ public int state;
+ public int stateMask;
+ public int pszText;
+ public int cchTextMax;
+ public int iImage;
+ public int iSelectedImage;
+ public int cChildren;
+ public int lParam;
+ public static final int sizeof = 40;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java
new file mode 100755
index 0000000000..fb3d1853bb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPLACEMENT.java
@@ -0,0 +1,24 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class WINDOWPLACEMENT {
+ public int length;
+ public int flags;
+ public int showCmd;
+// POINT ptMinPosition;
+ public int ptMinPosition_x;
+ public int ptMinPosition_y;
+// POINT ptMaxPosition;
+ public int ptMaxPosition_x;
+ public int ptMaxPosition_y;
+// RECT rcNormalPosition;
+ public int left;
+ public int top;
+ public int right;
+ public int bottom;
+ public static final int sizeof = 44;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java
new file mode 100755
index 0000000000..eaa9f5b4a7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WINDOWPOS.java
@@ -0,0 +1,17 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class WINDOWPOS {
+ public int hwnd;
+ public int hwndInsertAfter;
+ public int x;
+ public int y;
+ public int cx;
+ public int cy;
+ public int flags;
+ public static final int sizeof = 28;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WNDCLASSEX.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WNDCLASSEX.java
new file mode 100755
index 0000000000..4d3c7aef8e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/WNDCLASSEX.java
@@ -0,0 +1,22 @@
+package org.eclipse.swt.internal.win32;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * WebSphere Studio Workbench
+ * (c) Copyright IBM Corp 2000
+ */
+public class WNDCLASSEX {
+ public int cbSize;
+ public int style;
+ public int lpfnWndProc;
+ public int cbClsExtra;
+ public int cbWndExtra;
+ public int hInstance;
+ public int hIcon;
+ public int hCursor;
+ public int hbrBackground;
+ public int lpszMenuName;
+ public int lpszClassName;
+ public int hIconSm;
+ public static final int sizeof = 48;
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/package.html b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/package.html
new file mode 100755
index 0000000000..049087bd3e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/win32/package.html
@@ -0,0 +1,22 @@
+ <html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+ <meta name="Author" content="IBM">
+ <title>Package-level Javadoc</title>
+</head>
+<body>
+SWT internal Win32 implementation classes.
+<h2>
+Package Specification</h2>
+This package contains the classes which represent the Microsoft
+Win32 platform interface that the win32 variant of SWT is built
+from.
+<p>
+Referencing any of the classes in this package directly guarantees
+that the code is platform specific. Applications should not need to
+reference the classes in this package directly.
+</p>
+
+</p>
+</body>
+</html>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
new file mode 100755
index 0000000000..a57e681714
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java
@@ -0,0 +1,627 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+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 notificiation when pressed and released.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>ARROW, CHECK, PUSH, RADIO, TOGGLE, FLAT</dd>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+
+public class Button extends Control {
+ Image image;
+ static final int ButtonProc;
+ static final byte [] ButtonClass = Converter.wcsToMbcs (0,"BUTTON\0");
+ static final int CheckWidth, CheckHeight;
+ static {
+ int hBitmap = OS.LoadBitmap (0, OS.OBM_CHECKBOXES);
+ if (hBitmap == 0) {
+ CheckWidth = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ CheckHeight = OS.GetSystemMetrics (OS.SM_CYVSCROLL);
+ } else {
+ BITMAP bitmap = new BITMAP ();
+ OS.GetObject (hBitmap, BITMAP.sizeof, bitmap);
+ OS.DeleteObject (hBitmap);
+ CheckWidth = bitmap.bmWidth / 4;
+ CheckHeight = bitmap.bmHeight / 3;
+ }
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ButtonClass, lpWndClass);
+ ButtonProc = lpWndClass.lpfnWndProc;
+ }
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 Button (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 sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ButtonProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ style = checkBits (style, SWT.PUSH, SWT.ARROW, SWT.CHECK, SWT.RADIO, SWT.TOGGLE, 0);
+ if ((style & SWT.PUSH) != 0) {
+ return checkBits (style, SWT.CENTER, SWT.LEFT, SWT.RIGHT, 0, 0, 0);
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO | SWT.TOGGLE)) != 0) {
+ return checkBits (style, SWT.LEFT, SWT.RIGHT, SWT.CENTER, 0, 0, 0);
+ }
+ if ((style & SWT.ARROW) != 0) {
+ return checkBits (style, SWT.UP, SWT.DOWN, SWT.LEFT, SWT.RIGHT, 0, 0);
+ }
+ return style;
+}
+
+void click () {
+ OS.SendMessage (handle, OS.BM_CLICK, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.ARROW) != 0) {
+ if ((style & (SWT.UP | SWT.DOWN)) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ height += OS.GetSystemMetrics (OS.SM_CYVSCROLL);
+ } else {
+ width += OS.GetSystemMetrics (OS.SM_CXHSCROLL);
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+ }
+ int extra = 0;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & (OS.BS_BITMAP | OS.BS_ICON)) == 0) {
+ int oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ TEXTMETRIC lptm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, lptm);
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) {
+ height += lptm.tmHeight;
+ } else {
+ extra = Math.max (8, lptm.tmAveCharWidth);
+ byte [] buffer = new byte [length + 1];
+ OS.GetWindowText (handle, buffer, length + 1);
+ RECT rect = new RECT ();
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
+ OS.DrawText (hDC, buffer, length, rect, flags);
+ width += rect.right - rect.left;
+ height += rect.bottom - rect.top;
+ }
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ } else {
+ if (image != null) {
+ extra = 8;
+ switch (image.type) {
+ case SWT.BITMAP: {
+ BITMAP bm = new BITMAP ();
+ int hImage = image.handle;
+ OS.GetObject (hImage, BITMAP.sizeof, bm);
+ width += bm.bmWidth; height += bm.bmHeight;
+ break;
+ }
+ case SWT.ICON: {
+ BITMAP bm = new BITMAP ();
+ ICONINFO info = new ICONINFO ();
+ int hImage = image.handle;
+ OS.GetIconInfo (hImage, info);
+ int hBitmap = info.hbmColor;
+ if (hBitmap == 0) hBitmap = info.hbmMask;
+ OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+ if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
+ if (info.hbmColor != 0) OS.DeleteObject (info.hbmColor);
+ if (info.hbmMask != 0) OS.DeleteObject (info.hbmMask);
+ width += bm.bmWidth; height += bm.bmHeight;
+ break;
+ }
+ }
+ }
+ }
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ width += CheckWidth + extra;
+ height = Math.max (height, CheckHeight + 3);
+ }
+ if ((style & (SWT.PUSH | SWT.TOGGLE)) != 0) {
+ width += 10; height += 7;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+int defaultForeground () {
+ return OS.GetSysColor (OS.COLOR_BTNTEXT);
+}
+
+/**
+ * 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;
+}
+
+boolean getDefault () {
+ if ((style & SWT.PUSH) == 0) return false;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.BS_DEFPUSHBUTTON) != 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 <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.
+ *
+ * @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;
+ int state = OS.SendMessage (handle, OS.BM_GETCHECK, 0, 0);
+ return (state & OS.BST_CHECKED) != 0;
+}
+
+/**
+ * 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 ();
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, buffer1.length);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+}
+
+boolean mnemonicHit () {
+ if (!setFocus ()) return false;
+ /*
+ * Feature in Windows. When a radio button gets focus,
+ * it selects the button in WM_SETFOCUS. Therefore, it
+ * is not necessary to click the button or send events
+ * because this has already happened in WM_SETFOCUS.
+ */
+ if ((style & SWT.RADIO) == 0) click ();
+ return true;
+}
+
+boolean mnemonicMatch (char key) {
+ char mnemonic = findMnemonic (getText ());
+ if (mnemonic == '\0') return false;
+ return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 #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 () {
+ Control [] children = parent._getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (this != child && child instanceof Button) {
+ Button button = (Button) child;
+ if ((button.style & SWT.RADIO) != 0) {
+ if (button.getSelection ()) {
+ button.setSelection (false);
+ button.postEvent (SWT.Selection);
+ }
+ }
+ }
+ }
+ 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 ();
+ 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);
+ OS.InvalidateRect (handle, null, true);
+ 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);
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT);
+ if ((style & SWT.LEFT) != 0) bits |= OS.BS_LEFT;
+ if ((style & SWT.CENTER) != 0) bits |= OS.BS_CENTER;
+ if ((style & SWT.RIGHT) != 0) bits |= OS.BS_RIGHT;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ OS.InvalidateRect (handle, null, true);
+}
+
+void setDefault (boolean value) {
+ if ((style & SWT.PUSH) == 0) return;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits &= ~OS.BS_DEFPUSHBUTTON;
+ if (value) bits |= OS.BS_DEFPUSHBUTTON;
+ OS.SendMessage (handle, OS.BM_SETSTYLE, bits, 1);
+}
+
+public boolean setFocus () {
+ if ((style & SWT.ARROW) != 0) return false;
+ if (!super.setFocus ()) return false;
+ menuShell ().setDefaultButton (this, false);
+ return true;
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 ();
+ int hImage = 0, imageBits = 0, fImageType = 0;
+ if (image != null) {
+ hImage = image.handle;
+ switch (image.type) {
+ case SWT.BITMAP:
+ imageBits = OS.BS_BITMAP;
+ fImageType = OS.IMAGE_BITMAP;
+ break;
+ case SWT.ICON:
+ imageBits = OS.BS_ICON;
+ fImageType = OS.IMAGE_ICON;
+ break;
+ default:
+ return;
+ }
+ }
+ this.image = image;
+ int newBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int oldBits = newBits;
+ newBits &= ~(OS.BS_BITMAP | OS.BS_ICON);
+ newBits |= imageBits;
+ if (newBits != oldBits) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ }
+ OS.SendMessage (handle, OS.BM_SETIMAGE, fImageType, hImage);
+}
+boolean setRadioFocus () {
+ if ((style & SWT.RADIO) == 0 || !getSelection ()) return false;
+ return setFocus () || !isVisible ();
+}
+
+/**
+ * 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. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @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;
+ int bits = selected ? OS.BST_CHECKED : OS.BST_UNCHECKED;
+ OS.SendMessage (handle, OS.BM_SETCHECK, bits, 0);
+ /*
+ * Feature in Windows. When a radio button gets focus,
+ * it selects the button in WM_SETFOCUS. If the previous
+ * saved focus widget was a radio button, allowing the shell
+ * to automatically restore the focus to the previous radio
+ * button will unexpectedly check that button. The fix is
+ * to set the saved focus widget for the shell to be the
+ * radio button so that when focus is restored, the focus
+ * widget will be the new radio button.
+ */
+ if (!selected) return;
+ if ((style & SWT.RADIO) == 0) return;
+ menuShell ().setSavedFocus (this);
+}
+
+/**
+ * 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);
+ int newBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int oldBits = newBits;
+ newBits &= ~(OS.BS_BITMAP | OS.BS_ICON);
+ if (newBits != oldBits) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ }
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SetWindowText (handle, buffer);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.BS_NOTIFY;
+ if ((style & SWT.FLAT) != 0) bits |= OS.BS_FLAT;
+ if ((style & SWT.ARROW) != 0) return bits | OS.BS_OWNERDRAW;
+ if ((style & SWT.LEFT) != 0) bits |= OS.BS_LEFT;
+ if ((style & SWT.CENTER) != 0) bits |= OS.BS_CENTER;
+ if ((style & SWT.RIGHT) != 0) bits |= OS.BS_RIGHT;
+ if ((style & SWT.PUSH) != 0) return bits | OS.BS_PUSHBUTTON;
+ if ((style & SWT.CHECK) != 0) return bits | OS.BS_CHECKBOX;
+ if ((style & SWT.RADIO) != 0) return bits | OS.BS_RADIOBUTTON;
+ if ((style & SWT.TOGGLE) != 0) return bits | OS.BS_PUSHLIKE | OS.BS_CHECKBOX;
+ return bits | OS.BS_PUSHBUTTON;
+}
+
+byte [] windowClass () {
+ return ButtonClass;
+}
+
+int windowProc () {
+ return ButtonProc;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.ARROW) != 0) {
+ return new LRESULT (OS.DLGC_STATIC);
+ }
+ return result;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.RADIO) == 0) return result;
+ /*
+ * Feature in Windows. When Windows sets focus to
+ * a radio button, it sets the WM_TABSTOP style.
+ * This is undocumented and unwanted. The fix is
+ * to clear this style.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int code = callWindowProc (OS.WM_SETFOCUS, wParam, lParam);
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ return new LRESULT (code);
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ int code = wParam >> 16;
+ switch (code) {
+ case OS.BN_CLICKED:
+ case OS.BN_DOUBLECLICKED:
+ if ((style & (SWT.CHECK | SWT.TOGGLE)) != 0) {
+ setSelection (!getSelection ());
+ } else {
+ if ((style & SWT.RADIO) != 0) {
+ if ((parent.getStyle () & SWT.NO_RADIO_GROUP) == 0) {
+ selectRadio ();
+ } else {
+ setSelection (!getSelection ());
+ }
+ }
+ }
+ postEvent (SWT.Selection);
+ }
+ return super.wmCommandChild (wParam, lParam);
+}
+
+LRESULT wmDrawChild (int wParam, int lParam) {
+ if ((style & SWT.ARROW) == 0) return super.wmDrawChild (wParam, lParam);
+ DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+ int uState = OS.DFCS_SCROLLLEFT;
+ switch (style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) {
+ case SWT.UP: uState = OS.DFCS_SCROLLUP; break;
+ case SWT.DOWN: uState = OS.DFCS_SCROLLDOWN; break;
+ case SWT.LEFT: uState = OS.DFCS_SCROLLLEFT; break;
+ case SWT.RIGHT: uState = OS.DFCS_SCROLLRIGHT; break;
+ }
+ if ((style & SWT.FLAT) == SWT.FLAT) uState |= OS.DFCS_FLAT;
+ if (!OS.IsWindowEnabled (handle)) uState |= OS.DFCS_INACTIVE;
+ if ((struct.itemState & OS.ODS_SELECTED) != 0) uState |= OS.DFCS_PUSHED;
+ RECT rect = new RECT ();
+ OS.SetRect (rect, struct.left, struct.top, struct.right, struct.bottom);
+ OS.DrawFrameControl (struct.hDC, rect, OS.DFC_SCROLL, uState);
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
new file mode 100755
index 0000000000..a1439d888b
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java
@@ -0,0 +1,205 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * 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 agregates of other controls. That is, they are either
+ * painted using SWT graphics calls or are handled by native
+ * methods.
+ * </p>
+ *
+ * @see Composite
+ */
+
+public class Canvas extends Composite {
+ Caret caret;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 Canvas (Composite parent, int style) {
+ super (parent, style);
+}
+
+/*
+* Not currently used.
+*/
+void clearArea (int x, int y, int width, int height) {
+ checkWidget ();
+ if (OS.IsWindowVisible (handle)) return;
+ RECT rect = new RECT ();
+ OS.SetRect (rect, x, y, x + width, y + height);
+ int hDC = OS.GetDCEx (handle, 0, OS.DCX_CACHE | OS.DCX_CLIPCHILDREN | OS.DCX_CLIPSIBLINGS);
+ drawBackground (hDC, rect);
+ OS.ReleaseDC (handle, hDC);
+}
+
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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;
+}
+
+void releaseWidget () {
+ if (caret != null) caret.releaseWidget ();
+ caret = null;
+ super.releaseWidget ();
+}
+
+/**
+ * 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 ();
+
+ /* Remove the caret so it won't get scrolled */
+ boolean isFocus = caret != null && caret.isFocusCaret ();
+ if (isFocus) caret.killFocus ();
+
+ /* Flush outstanding WM_PAINT's and scroll the window */
+ OS.RedrawWindow (handle, null, 0, OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN);
+ RECT rect = new RECT ();
+ OS.SetRect (rect, x, y, x + width, y + height);
+ int deltaX = destX - x, deltaY = destY - y;
+ int flags = OS.SW_INVALIDATE | OS.SW_ERASE;
+ if (all) flags |= OS.SW_SCROLLCHILDREN;
+ OS.ScrollWindowEx (handle, deltaX, deltaY, rect, null, 0, null, flags);
+
+ /* Restore the caret */
+ if (isFocus) caret.setFocus ();
+}
+
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 (isFocusControl ()) {
+ if (oldCaret != null) oldCaret.killFocus ();
+ if (newCaret != null) newCaret.setFocus ();
+ }
+}
+
+public void setFont (Font font) {
+ checkWidget ();
+ super.setFont (font);
+ if (caret != null) caret.setFont (font);
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
+ if (result != null) return result;
+ if (caret != null) caret.killFocus ();
+ return result;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if (result != null) return result;
+ if (caret != null) caret.setFocus ();
+ return result;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
new file mode 100755
index 0000000000..695b05a59a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Caret.java
@@ -0,0 +1,488 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ */
+
+public class Caret extends Widget {
+ Canvas parent;
+ int x, y, width, height;
+ boolean moved, resized;
+ boolean isVisible;
+ Font font;
+ LOGFONT oldFont;
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 ();
+}
+
+void createWidget () {
+ isVisible = true;
+ if (parent.getCaret () == null) {
+ parent.setCaret (this);
+ }
+}
+
+int defaultFont () {
+ int hwnd = parent.handle;
+ int hwndIME = OS.ImmGetDefaultIMEWnd (hwnd);
+ int hFont = OS.SendMessage (hwndIME, OS.WM_GETFONT, 0, 0);
+ return hFont;
+}
+
+/**
+ * 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();
+ return new Rectangle (x, y, width, height);
+}
+
+public Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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.win32_new (getDisplay (), defaultFont ());
+ return font;
+}
+
+/**
+ * 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();
+ 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 isFocusCaret () {
+ return parent.caret == this && parent.isFocusControl ();
+}
+
+/**
+ * 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 isVisible () {
+ checkWidget();
+ return isVisible && parent.isVisible () && parent.hasFocus ();
+}
+
+void killFocus () {
+ OS.DestroyCaret ();
+ if (font != null) restoreIMEFont ();
+}
+
+void move () {
+ moved = false;
+ if (!OS.SetCaretPos (x, y)) return;
+ if (IsDBLocale) {
+ POINT ptCurrentPos = new POINT ();
+ if (!OS.GetCaretPos (ptCurrentPos)) return;
+ COMPOSITIONFORM lpCompForm = new COMPOSITIONFORM ();
+ lpCompForm.dwStyle = OS.CFS_POINT;
+ lpCompForm.x = ptCurrentPos.x;
+ lpCompForm.y = ptCurrentPos.y;
+ int hwnd = parent.handle;
+ int hIMC = OS.ImmGetContext (hwnd);
+ OS.ImmSetCompositionWindow (hIMC, lpCompForm);
+ OS.ImmReleaseContext (hwnd, hIMC);
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (this == parent.getCaret ()) parent.setCaret (null);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ font = null;
+ oldFont = null;
+}
+
+void resize () {
+ resized = false;
+ int hwnd = parent.handle;
+ OS.DestroyCaret ();
+ OS.CreateCaret (hwnd, 0, width, height);
+ OS.SetCaretPos (x, y);
+ OS.ShowCaret (hwnd);
+ move ();
+}
+
+void restoreIMEFont () {
+ if (!IsDBLocale) return;
+ if (oldFont == null) return;
+ int hwnd = parent.handle;
+ int hIMC = OS.ImmGetContext (hwnd);
+ OS.ImmSetCompositionFont (hIMC, oldFont);
+ OS.ImmReleaseContext (hwnd, hIMC);
+ oldFont = null;
+}
+
+void saveIMEFont () {
+ if (!IsDBLocale) return;
+ if (oldFont != null) return;
+ int hwnd = parent.handle;
+ int hIMC = OS.ImmGetContext (hwnd);
+ oldFont = new LOGFONT ();
+ if (OS.ImmGetCompositionFont (hIMC, oldFont)) oldFont = null;
+ OS.ImmReleaseContext (hwnd, hIMC);
+}
+
+/**
+ * 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();
+ boolean samePosition = this.x == x && this.y == y;
+ boolean sameExtent = this.width == width && this.height == height;
+ if (samePosition && sameExtent) return;
+ this.x = x; this.y = y;
+ this.width = width; this.height = height;
+ if (sameExtent) {
+ moved = true;
+ if (isVisible && parent.hasFocus ()) move ();
+ } else {
+ resized = true;
+ if (isVisible && parent.hasFocus ()) resize ();
+ }
+}
+
+/**
+ * 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) {
+ if (rect == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setBounds (rect.x, rect.y, rect.width, rect.height);
+}
+
+void setFocus () {
+ int hwnd = parent.handle;
+ OS.CreateCaret (hwnd, 0, width, height);
+ move ();
+ if (font != null) {
+ int hFont = font.handle;
+ saveIMEFont ();
+ setIMEFont (hFont);
+ }
+ if (isVisible) OS.ShowCaret (hwnd);
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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();
+ this.font = font;
+ if (isVisible && parent.hasFocus ()) {
+ int hFont = 0;
+ if (font != null) hFont = font.handle;
+ if (hFont == 0) hFont = defaultFont ();
+ saveIMEFont ();
+ setIMEFont (hFont);
+ }
+}
+
+void setIMEFont (int hFont) {
+ if (!IsDBLocale) return;
+ LOGFONT logFont = new LOGFONT ();
+ if (OS.GetObject (hFont, LOGFONT.sizeof, logFont) != 0) {
+ int hwnd = parent.handle;
+ int hIMC = OS.ImmGetContext (hwnd);
+ OS.ImmSetCompositionFont (hIMC, logFont);
+ OS.ImmReleaseContext (hwnd, hIMC);
+ }
+}
+
+/**
+ * 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();
+ if (this.x == x && this.y == y) return;
+ this.x = x; this.y = y;
+ moved = true;
+ if (isVisible && parent.hasFocus ()) move ();
+}
+
+/**
+ * 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();
+ if (this.width == width && this.height == height) return;
+ this.width = width; this.height = height;
+ resized = true;
+ if (isVisible && parent.hasFocus ()) resize ();
+}
+
+/**
+ * Sets the receiver's size to the point specified by the argument.
+ *
+ * @param size the new extent for the receiver
+ * @param height the new height 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;
+ int hwnd = parent.handle;
+ if (OS.GetFocus () != hwnd) return;
+ if (!isVisible) {
+ OS.HideCaret (hwnd);
+ } else {
+ if (resized) {
+ resize ();
+ } else {
+ if (moved) move ();
+ }
+ OS.ShowCaret (hwnd);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
new file mode 100755
index 0000000000..1e697ca4a7
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ColorDialog.java
@@ -0,0 +1,181 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ */
+
+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 (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 ColorDialog (Shell parent) {
+ this (parent, SWT.NULL);
+}
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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, style);
+}
+
+int CCHookProc (int hdlg, int uiMsg, int lParam, int lpData) {
+ switch (uiMsg) {
+ case OS.WM_INITDIALOG:
+ if (title != null && title.length () != 0) {
+ byte [] buffer = Converter.wcsToMbcs (0, title, true);
+ OS.SetWindowText (hdlg, buffer);
+ }
+ break;
+ }
+ return 0;
+}
+
+/**
+ * Returns the currently selected color in the receiver.
+ *
+ * @return the RGB value for the selected color
+ *
+ * @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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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 () {
+
+ /* Get the owner HWND for the dialog */
+ int hwndOwner = 0;
+ if (parent != null) hwndOwner = parent.handle;
+
+ /* Create the CCHookProc */
+ Callback callback = new Callback (this, "CCHookProc", 4);
+ int lpfnHook = callback.getAddress ();
+
+ /* Open the dialog */
+ int hHeap = OS.GetProcessHeap ();
+ int lpCustColors = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 16 * 4);
+ CHOOSECOLOR lpcc = new CHOOSECOLOR ();
+ lpcc.lStructSize = CHOOSECOLOR.sizeof;
+ lpcc.Flags = OS.CC_ANYCOLOR | OS.CC_ENABLEHOOK;
+ lpcc.lpfnHook = lpfnHook;
+ lpcc.hwndOwner = hwndOwner;
+ lpcc.lpCustColors = lpCustColors;
+ if (rgb != null) {
+ lpcc.Flags |= OS.CC_RGBINIT;
+ int red = rgb.red & 0xFF;
+ int green = (rgb.green << 8) & 0xFF00;
+ int blue = (rgb.blue << 16) & 0xFF0000;
+ lpcc.rgbResult = red | green | blue;
+ }
+ rgb = null;
+ if (OS.ChooseColor (lpcc)) {
+ int red = lpcc.rgbResult & 0xFF;
+ int green = (lpcc.rgbResult >> 8) & 0xFF;
+ int blue = (lpcc.rgbResult >> 16) & 0xFF;
+ rgb = new RGB (red, green, blue);
+ }
+
+ /* Free the CCHookProc */
+ callback.dispose ();
+
+ /* Free the OS memory */
+ if (lpCustColors != 0) OS.HeapFree (hHeap, 0, lpCustColors);
+
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when a dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
+
+ return rgb;
+}
+
+/**
+ * Returns the receiver's selected color to be the argument.
+ *
+ * @param rgb the new RGB value for the selected color
+ *
+ * @see PaletteData#getRGBs
+ */
+public void setRGB (RGB rgb) {
+ this.rgb = rgb;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
new file mode 100755
index 0000000000..04ac440502
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Combo.java
@@ -0,0 +1,1247 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>DROP_DOWN, READ_ONLY, SIMPLE</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ *
+ * @see List
+ */
+
+public class Combo extends Composite {
+ boolean noSelection;
+
+ /**
+ * the operating system limit for the number of characters
+ * that the text field in an instance of this class can hold
+ */
+ public static final 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 = IsWinNT ? 0x7FFFFFFF : 0x7FFF;
+ }
+
+ static final int ComboProc;
+ static final byte [] ComboClass = Converter.wcsToMbcs (0,"COMBOBOX\0", false);
+ /*
+ * These are the undocumented control id's for the children of
+ * a combo box. Since there are no constants for these values,
+ * they may change with different versions of Windows (but have
+ * been the same since Windows 3.0).
+ */
+ static final int CBID_LIST = 1000;
+ static final int CBID_EDIT = 1001;
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ComboClass, lpWndClass);
+ ComboProc = lpWndClass.lpfnWndProc;
+ }
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int result = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
+ if (result == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (result == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int result = OS.SendMessage (handle, OS.CB_INSERTSTRING, index, buffer);
+ if (result == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (result == OS.CB_ERR) {
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (0 <= index && index <= count) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ } else {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+}
+
+/**
+ * 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 receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ComboProc, handle, msg, wParam, lParam);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+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;
+}
+
+/**
+ * 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 ();
+ OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, -1);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ int itemHeight = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
+ int width = 0, height = 0;
+ if ((style & SWT.SIMPLE) != 0) height = count * itemHeight;
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ RECT rect = new RECT ();
+ int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX;
+ int length = OS.GetWindowTextLength (handle);
+ byte [] buffer = new byte [length + 1];
+ OS.GetWindowText (handle, buffer, buffer.length);
+ OS.DrawText (hDC, buffer, length, rect, flags);
+ width = Math.max (width, rect.right - rect.left);
+ for (int i=0; i<count; i++) {
+ length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, i, 0);
+ if (length != OS.CB_ERR) {
+ if (length + 1 > buffer.length) buffer = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, i, buffer);
+ if (result != OS.CB_ERR) {
+ OS.DrawText (hDC, buffer, length, rect, flags);
+ width = Math.max (width, rect.right - rect.left);
+ }
+ }
+ }
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ 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 textHeight = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL) + 8;
+ if ((style & SWT.DROP_DOWN) != 0) {
+ height = textHeight + 6;
+ } else {
+ height += textHeight + 10;
+ }
+ return new Point (width, height);
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_WINDOW);
+}
+
+/**
+ * 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 ();
+ int selection = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ if (index != selection) return;
+ OS.SendMessage (handle, OS.CB_SETCURSEL, -1, 0);
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+}
+
+/**
+ * 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 ();
+ OS.SendMessage (handle, OS.CB_SETCURSEL, -1, 0);
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+}
+
+boolean getEditable () {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & 0x0F) == OS.CBS_DROPDOWNLIST;
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public String getItem (int index) {
+ checkWidget ();
+ int length = OS.SendMessage (handle, OS.CB_GETLBTEXTLEN, index, 0);
+ if (length != OS.CB_ERR) {
+ byte [] buffer1 = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.CB_GETLBTEXT, index, buffer1);
+ if (result != OS.CB_ERR) {
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+ }
+ }
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (0 <= index && index < count) error (SWT.ERROR_CANNOT_GET_ITEM);
+ error (SWT.ERROR_INVALID_RANGE);
+ return null;
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int getItemCount () {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (count == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_COUNT);
+ return count;
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int getItemHeight () {
+ checkWidget ();
+ int result = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
+ if (result == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
+ return result;
+}
+
+/**
+ * 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 effect 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public String [] getItems () {
+ checkWidget ();
+ int count = getItemCount ();
+ String [] result = new String [count];
+ for (int i=0; i<count; i++) result [i] = getItem (i);
+ return result;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+/**
+ * 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 ();
+ if ((style & SWT.DROP_DOWN) != 0 && (style & SWT.READ_ONLY) != 0) {
+ return new Point (0, OS.GetWindowTextLength (handle));
+ }
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.CB_GETEDITSEL, 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 (noSelection) return -1;
+ return OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+}
+
+/**
+ * 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 ();
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, buffer1.length);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+}
+
+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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM_HEIGHT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int getTextHeight () {
+ checkWidget ();
+ int result = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
+ if (result == OS.CB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
+ return result + 6;
+}
+
+/**
+ * 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 ();
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndText == 0) return LIMIT;
+ return OS.SendMessage (hwndText, OS.EM_GETLIMITTEXT, 0, 0);
+}
+
+protected boolean hasFocus () {
+ int hwndFocus = OS.GetFocus ();
+ if (hwndFocus == handle) return true;
+ if (hwndFocus == 0) return false;
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (hwndFocus == hwndText) return true;
+ int hwndList = OS.GetDlgItem (handle, CBID_LIST);
+ if (hwndFocus == hwndList) return true;
+ return 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 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
+ * @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);
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (!((0 <= start) && (start < count))) return -1;
+ int index = start - 1, last;
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ do {
+ index = OS.SendMessage (handle, OS.CB_FINDSTRINGEXACT, last = index, buffer);
+ if ((index == OS.CB_ERR) || (index <= last)) return -1;
+ } while (!string.equals (getItem (index)));
+ return index;
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int index) {
+ checkWidget ();
+ int length = OS.GetWindowTextLength (handle);
+ int code = OS.SendMessage (handle, OS.CB_DELETESTRING, index, 0);
+ if (code == OS.CB_ERR) {
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ if (length != OS.GetWindowTextLength (handle)) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the modify
+ * event. If this happens, just return.
+ */
+ sendEvent (SWT.Modify);
+ if (isDisposed ()) return;
+ }
+ /*
+ * Bug in Windows. When the combo box is read only
+ * with exactly one item that is currently selected
+ * and that item is removed, the combo box does not
+ * redraw to clear the text area. The fix is to
+ * force a redraw.
+ */
+ if ((style & SWT.READ_ONLY) != 0) {
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (count == 0) OS.InvalidateRect (handle, null, 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+ checkWidget ();
+ if (start > end) return;
+ int length = OS.GetWindowTextLength (handle);
+ for (int i=start; i<=end; i++) {
+ int result = OS.SendMessage (handle, OS.CB_DELETESTRING, start, 0);
+ if (result == OS.CB_ERR) {
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (0 <= i && i < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+ if (length != OS.GetWindowTextLength (handle)) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the modify
+ * event. If this happens, just return.
+ */
+ sendEvent (SWT.Modify);
+ if (isDisposed ()) return;
+ }
+ /*
+ * Bug in Windows. When the combo box is read only
+ * with exactly one item that is currently selected
+ * and that item is removed, the combo box does not
+ * redraw to clear the text area. The fix is to
+ * force a redraw.
+ */
+ if ((style & SWT.READ_ONLY) != 0) {
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (count == 0) OS.InvalidateRect (handle, null, 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (String string) {
+ checkWidget ();
+ 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.
+ * <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 ();
+ OS.SendMessage (handle, OS.CB_RESETCONTENT, 0, 0);
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+}
+
+/**
+ * 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 receiver's selection changes.
+ *
+ * @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 ();
+ int count = OS.SendMessage (handle, OS.CB_GETCOUNT, 0, 0);
+ if (0 <= index && index < count) {
+ int code = OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
+ if (code != OS.CB_ERR) {
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+ }
+ }
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ /*
+ * Feature in Windows. If the combo box has the CBS_DROPDOWN
+ * or CBS_DROPDOWNLIST style, Windows uses the height that the
+ * programmer sets in SetWindowPos () to control height of the
+ * drop down list. When the width is non-zero, Windows remembers
+ * this value and sets the height to be the height of the text
+ * field part of the combo box. If the width is zero, Windows
+ * allows the height to have any value. Therefore, when the
+ * programmer sets and then queries the height, the values can
+ * be different depending on the width. The problem occurs when
+ * the programmer uses computeSize () to determine the preferred
+ * height (always the height of the text field) and then uses
+ * this value to set the height of the combo box. The result
+ * is a combo box with a zero size drop down list. The fix, is
+ * to always set the height to show a fixed number of combo box
+ * items and ignore the height value that the programmer supplies.
+ */
+ if ((style & SWT.DROP_DOWN) != 0) {
+ int textHeight = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, -1, 0);
+ int itemHeight = OS.SendMessage (handle, OS.CB_GETITEMHEIGHT, 0, 0);
+ super.setBounds (x, y, width, textHeight + 6 + (itemHeight * 5) + 2, flags);
+ return;
+ }
+
+ /*
+ * Bug in Windows. If the combo box has the CBS_SIMPLE style,
+ * the list portion of the combo box is not redrawn when the
+ * combo box is resized. The fix is to force a redraw when
+ * the size has changed.
+ */
+ if (parent.hdwp != 0 || (flags & OS.SWP_NOSIZE) != 0 || !OS.IsWindowVisible (handle)) {
+ super.setBounds (x, y, width, height, flags);
+ return;
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ super.setBounds (x, y, width, height, flags);
+ if (((rect.right - rect.left) != width) || ((rect.bottom - rect.top) != height)) {
+ OS.RedrawWindow (handle, null, 0, OS.RDW_ERASE | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN);
+ }
+}
+
+void setEditable (boolean editable) {
+ error (SWT.ERROR_NOT_IMPLEMENTED);
+}
+
+/**
+ * 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>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li>
+ * <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ remove (index);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the modify
+ * event that might be sent when the index is removed.
+ * If this happens, just exit.
+ */
+ if (isDisposed ()) return;
+ add (string, index);
+}
+
+/**
+ * Sets the receiver's list to be the given array of items.
+ *
+ * @param items the array 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void setItems (String [] items) {
+ checkWidget ();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.SendMessage (handle, OS.CB_RESETCONTENT, 0, 0);
+ for (int i=0; i<items.length; i++) {
+ String string = items [i];
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int code = OS.SendMessage (handle, OS.CB_ADDSTRING, 0, buffer);
+ if (code == OS.CB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (code == OS.CB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+}
+
+/**
+ * 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 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);
+ int bits = selection.x | (selection.y << 16);
+ OS.SendMessage (handle, OS.CB_SETEDITSEL, 0, bits);
+}
+protected boolean setTabGroupFocus () {
+ return setFocus ();
+}
+
+/**
+ * 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 text 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);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ if ((style & SWT.READ_ONLY) != 0) {
+ int code = OS.SendMessage (handle, OS.CB_SELECTSTRING, -1, buffer);
+ if (code != OS.CB_ERR) {
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+ }
+ return;
+ }
+ if (OS.SetWindowText (handle, buffer)) {
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+ }
+}
+
+/**
+ * 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 ();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.SendMessage (handle, OS.CB_LIMITTEXT, limit, 0);
+}
+
+boolean translateAccelerator (MSG msg) {
+ /*
+ * In order to see key events for the text widget in a combo box,
+ * filter the key events before they are dispatched to the text
+ * widget and invoke the cooresponding key handler for the combo
+ * box as if the key was sent directly to the combo box, not the
+ * text field. The key is still dispatched to the text widget,
+ * in the normal fashion.
+ */
+ int hwndText = OS.GetDlgItem (handle, CBID_EDIT);
+ if (msg.hwnd == hwndText) {
+ switch (msg.message) {
+ case OS.WM_CHAR: WM_CHAR (msg.wParam, msg.lParam); break;
+ case OS.WM_KEYDOWN: WM_KEYDOWN (msg.wParam, msg.lParam); break;
+ case OS.WM_KEYUP: WM_KEYUP (msg.wParam, msg.lParam); break;
+ case OS.WM_SYSCHAR: WM_SYSCHAR (msg.wParam, msg.lParam); break;
+ case OS.WM_SYSKEYDOWN: WM_SYSKEYDOWN (msg.wParam, msg.lParam); break;
+ case OS.WM_SYSKEYUP: WM_SYSKEYUP (msg.wParam, msg.lParam); break;
+ }
+ }
+ return super.translateAccelerator (msg);
+}
+
+boolean translateTraversal (MSG msg) {
+ /*
+ * Feature in Windows. For some reason, when the
+ * user presses tab, return or escape, Windows beeps.
+ * The fix is to look for these keys and not call
+ * the window proc.
+ */
+ switch (msg.wParam) {
+ case OS.VK_ESCAPE:
+ /* Allow the escape key to close the combo box */
+ if (OS.SendMessage (handle, OS.CB_GETDROPPEDSTATE, 0, 0) != 0) {
+ return false;
+ }
+ // FALL THROUGH
+ case OS.VK_TAB:
+ case OS.VK_RETURN:
+ boolean translated = super.translateTraversal (msg);
+ if (!translated && msg.wParam == OS.VK_RETURN) {
+ sendEvent (SWT.DefaultSelection);
+ // widget could be disposed at this point
+ }
+ return true;
+ }
+ return super.translateTraversal (msg);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.CBS_AUTOHSCROLL | OS.CBS_NOINTEGRALHEIGHT | OS.WS_VSCROLL;
+ if ((style & SWT.SIMPLE) != 0) return bits | OS.CBS_SIMPLE;
+ if ((style & SWT.READ_ONLY) != 0) return bits | OS.CBS_DROPDOWNLIST;
+ return bits | OS.CBS_DROPDOWN;
+}
+
+byte [] windowClass () {
+ return ComboClass;
+}
+
+int windowProc () {
+ return ComboProc;
+}
+
+LRESULT WM_CHAR (int wParam, int lParam) {
+ LRESULT result = super.WM_CHAR (wParam, lParam);
+ if (result != null) return result;
+ if (wParam == OS.VK_RETURN) {
+ postEvent (SWT.DefaultSelection);
+ }
+ return result;
+}
+
+LRESULT WM_CTLCOLOR (int wParam, int lParam) {
+ return wmColorChild (wParam, lParam);
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ int code = callWindowProc (OS.WM_GETDLGCODE, wParam, lParam);
+ return new LRESULT (code | OS.DLGC_WANTARROWS);
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ /*
+ * Return NULL - Focus notification is
+ * done in WM_COMMAND by CBN_KILLFOCUS.
+ */
+ return null;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ /*
+ * Return NULL - Focus notification is
+ * done by WM_COMMAND with CBN_SETFOCUS.
+ */
+ return null;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ int code = wParam >> 16;
+ switch (code) {
+ case OS.CBN_EDITCHANGE:
+ /*
+ * Feature in Windows. If the combo box list selection is
+ * queried using CB_GETCURSEL before the WM_COMMAND (with
+ * CBM_EDITCHANGE) returns, CB_GETCURSEL returns the previous
+ * selection in the list. It seems that the combo box sends
+ * the WM_COMMAND before it makes the selection in the list box
+ * match the entry field. The fix is remember that no selection
+ * in the list should exist in this case.
+ */
+ noSelection = true;
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the modify
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Modify);
+ if (isDisposed ()) return LRESULT.ZERO;
+ noSelection = false;
+ break;
+ case OS.CBN_SELCHANGE:
+ /*
+ * Feature in Windows. If the text in and editable combo box
+ * is queried using GetWindowText () before the WM_COMMAND
+ * (with CBM_SELCHANGE) returns, GetWindowText () returns is
+ * the previous text in the combo box. It seems that the combo
+ * box sends the WM_COMMAND before it updates the text field to
+ * match the list selection. The fix is to force the text field
+ * to match the list selection by re-selecting the list item.
+ */
+ int index = OS.SendMessage (handle, OS.CB_GETCURSEL, 0, 0);
+ if (index != OS.CB_ERR) OS.SendMessage (handle, OS.CB_SETCURSEL, index, 0);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the modify
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Modify);
+ if (isDisposed ()) return LRESULT.ZERO;
+ postEvent (SWT.Selection);
+ break;
+ case OS.CBN_SETFOCUS:
+ case OS.CBN_KILLFOCUS:
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the focus
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (code == OS.CBN_SETFOCUS ? SWT.FocusIn : SWT.FocusOut);
+ if (isDisposed ()) return LRESULT.ZERO;
+ break;
+ }
+ return super.wmCommandChild (wParam, lParam);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
new file mode 100755
index 0000000000..e8b6b796c6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java
@@ -0,0 +1,608 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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</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 constructed from agregates
+ * of other controls.
+ * </p>
+ *
+ * @see Canvas
+ */
+
+public class Composite extends Scrollable {
+
+ Layout layout;
+ int font, hdwp;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Composite () {
+}
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public Composite (Composite parent, int style) {
+ super (parent, style);
+}
+Control [] _getChildren () {
+ int count = 0;
+ int hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ if (hwndChild == 0) return new Control [0];
+ while (hwndChild != 0) {
+ count++;
+ hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
+ }
+ Control [] children = new Control [count];
+ int index = 0;
+ hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ while (hwndChild != 0) {
+ Control control = WidgetTable.get (hwndChild);
+ if (control != null && control != this) {
+ children [index++] = control;
+ }
+ hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
+ }
+ if (count == index) return children;
+ Control [] newChildren = new Control [index];
+ System.arraycopy (children, 0, newChildren, 0, index);
+ return newChildren;
+}
+
+protected void checkSubclass () {
+ /* Do nothing - Subclassing is allowed */
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ Point size;
+ if (layout != null) {
+ if (wHint == SWT.DEFAULT || hHint == SWT.DEFAULT) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = new Point (wHint, hHint);
+ }
+ } else {
+ size = minimumSize ();
+ }
+ 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);
+}
+
+void createHandle () {
+ super.createHandle ();
+ state |= CANVAS;
+}
+void drawBackground (int hdc, RECT rect) {
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_BACKGROUND) != 0) return;
+ }
+ int pixel = getBackgroundPixel ();
+ int hBrush = findBrush (pixel);
+ OS.FillRect (hdc, rect, hBrush);
+}
+
+/**
+ * Returns an array containing the receiver's children.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of children, so modifying the array will
+ * not effect the receiver.
+ * </p>
+ *
+ * @return an array of children
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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 count = 0;
+ int hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
+ while (hwndChild != 0) {
+ count++;
+ hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
+ }
+ return count;
+}
+
+/**
+ * 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;
+}
+
+Control [] getTabList () {
+ Control result [] = super.getTabList ();
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ Control [] list = child.getTabList ();
+ if (list.length != 0) {
+ Control [] newResult = new Control [result.length + list.length];
+ System.arraycopy (result, 0, newResult, 0, result.length);
+ System.arraycopy (list, 0, newResult, result.length, list.length);
+ result = newResult;
+ }
+ }
+ return result;
+}
+
+/**
+ * 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>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 the argument is <code>true</code> the layout must not rely
+ * on any cached information it is keeping about the children. If it
+ * is <code>false</code> the layout may (potentially) simplify the
+ * work it is doing by assuming that the state of the none of the
+ * receiver's children has changed since the last layout.
+ * If the receiver does not have a layout, do nothing.
+ *
+ * @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;
+ int count = getChildrenCount ();
+ if (count == 0) return;
+ if (count > 1 && hdwp == 0) {
+ hdwp = OS.BeginDeferWindowPos (count);
+ }
+ layout.layout (this, changed);
+ int oldHdwp = hdwp;
+ hdwp = 0;
+ if (oldHdwp != 0) OS.EndDeferWindowPos (oldHdwp);
+}
+
+Point minimumSize () {
+ 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);
+}
+
+void releaseChildren () {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (!child.isDisposed ()) {
+ child.releaseWidget ();
+ child.releaseHandle ();
+ }
+ }
+}
+
+void releaseWidget () {
+ releaseChildren ();
+ super.releaseWidget ();
+ layout = null;
+ int oldHdwp = hdwp;
+ hdwp = 0;
+ if (oldHdwp != 0) OS.EndDeferWindowPos (oldHdwp);
+}
+
+public boolean setFocus () {
+ checkWidget ();
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return false;
+ }
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.setRadioFocus ()) return true;
+ }
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (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 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;
+}
+
+boolean setTabGroupFocus () {
+ if (!isVisible ()) return false;
+ if (isTabItem ()) return setTabItemFocus ();
+ Control [] children = _getChildren ();
+ if (children.length == 0) return setTabItemFocus ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isVisible () && child.setRadioFocus ()) return true;
+ }
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.isTabGroup () && child.setTabGroupFocus ()) return true;
+ }
+ return false;
+}
+
+String toolTipText (NMTTDISPINFO hdr) {
+ if ((hdr.uFlags & OS.TTF_IDISHWND) == 0) {
+ return null;
+ }
+ int hwnd = hdr.idFrom;
+ if (hwnd == 0) return null;
+ Control control = WidgetTable.get (hwnd);
+ if (control == null) return null;
+ return control.toolTipText;
+}
+
+boolean traverseMnemonic (char key) {
+ if (super.traverseMnemonic (key)) return true;
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ Control child = children [i];
+ if (child.traverseMnemonic (key)) return true;
+ }
+ return false;
+}
+
+int widgetStyle () {
+ /* Temporary code to force SWT.CLIP_SIBLINGS */
+ return super.widgetStyle () | OS.WS_CLIPCHILDREN;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ if ((state & CANVAS) != 0) {
+ return super.WM_ERASEBKGND (wParam, lParam);
+ }
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ drawBackground (wParam, rect);
+ return LRESULT.ONE;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ LRESULT result = super.WM_GETDLGCODE (wParam, lParam);
+ if (result != null) return result;
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return new LRESULT (OS.DLGC_STATIC);
+ if (hooks (SWT.KeyDown)) {
+ int flags = OS.DLGC_WANTALLKEYS | OS.DLGC_WANTARROWS | OS.DLGC_WANTTAB;
+ return new LRESULT (flags);
+ }
+ int count = getChildrenCount ();
+ if (count != 0) return new LRESULT (OS.DLGC_STATIC);
+ }
+ return result;
+}
+
+LRESULT WM_GETFONT (int wParam, int lParam) {
+ LRESULT result = super.WM_GETFONT (wParam, lParam);
+ if (result != null) return result;
+ int code = callWindowProc (OS.WM_GETFONT, wParam, lParam);
+ if (code != 0) return new LRESULT (code);
+ if (font == 0) font = defaultFont ();
+ return new LRESULT (font);
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
+
+ /* Set focus for a canvas with no children */
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_FOCUS) != 0) return result;
+ if (OS.GetWindow (handle, OS.GW_CHILD) == 0) setFocus ();
+ }
+ return result;
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ case OS.TTN_GETDISPINFO:
+ NMTTDISPINFO lpnmtdi = new NMTTDISPINFO ();
+ OS.MoveMemory (lpnmtdi, lParam, NMTTDISPINFO.sizeof);
+ String string = toolTipText (lpnmtdi);
+ if (string != null && string.length () != 0) {
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ getShell ().setToolTipText (lpnmtdi, buffer);
+ OS.MoveMemory (lParam, lpnmtdi, NMTTDISPINFO.sizeof);
+ }
+ return LRESULT.ZERO;
+ }
+ return super.WM_NOTIFY (wParam, lParam);
+}
+
+LRESULT WM_PAINT (int wParam, int lParam) {
+ if ((state & CANVAS) == 0) {
+ return super.WM_PAINT (wParam, lParam);
+ }
+
+ /*
+ * This code is intentionally commented. Don't exit
+ * early because the background must still be painted,
+ * even though no application code will be painting
+ * the widget.
+ *
+ * Do not uncomment this code.
+ */
+// if (!hooks (SWT.Paint)) return null;
+
+ /* Get the damage */
+ int [] lpRgnData = null;
+ boolean isComplex = false;
+ boolean exposeRegion = false;
+ if ((style & SWT.NO_MERGE_PAINTS) != 0) {
+ int rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ isComplex = OS.GetUpdateRgn (handle, rgn, false) == OS.COMPLEXREGION;
+ if (isComplex) {
+ int nBytes = OS.GetRegionData (rgn, 0, null);
+ lpRgnData = new int [nBytes / 4];
+ exposeRegion = OS.GetRegionData (rgn, nBytes, lpRgnData) != 0;
+ }
+ OS.DeleteObject (rgn);
+ }
+
+ /* Set the clipping bits */
+ int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int newBits = oldBits | OS.WS_CLIPSIBLINGS | OS.WS_CLIPCHILDREN;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+
+ /* Create the paint GC */
+ PAINTSTRUCT ps = new PAINTSTRUCT ();
+ GCData data = new GCData ();
+ data.ps = ps;
+ GC gc = GC.win32_new (this, data);
+ int hDC = gc.handle;
+
+ /* Send the paint event */
+ Event event = new Event ();
+ event.gc = gc;
+ if (isComplex && exposeRegion) {
+ RECT rect = new RECT ();
+ int nCount = lpRgnData [2];
+ for (int i=0; i<nCount; i++) {
+ OS.SetRect (rect,
+ lpRgnData [8 + (i << 2)],
+ lpRgnData [8 + (i << 2) + 1],
+ lpRgnData [8 + (i << 2) + 2],
+ lpRgnData [8 + (i << 2) + 3]);
+ drawBackground (hDC, rect);
+ event.x = rect.left;
+ event.y = rect.top;
+ event.width = rect.right - rect.left;
+ event.height = rect.bottom - rect.top;
+ event.count = nCount - 1 - i;
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the paint
+ * event. If this happens, attempt to give back the
+ * paint GC anyways because this is a scarce Windows
+ * resource.
+ */
+ sendEvent (SWT.Paint, event);
+ if (isDisposed ()) break;
+ }
+ } else {
+ RECT rect = new RECT ();
+ OS.SetRect (rect, ps.left, ps.top, ps.right, ps.bottom);
+ drawBackground (hDC, rect);
+ event.x = ps.left;
+ event.y = ps.top;
+ event.width = ps.right - ps.left;
+ event.height = ps.bottom - ps.top;
+ sendEvent (SWT.Paint, event);
+ }
+ // widget could be disposed at this point
+
+ /* Dispose the paint GC */
+ event.gc = null;
+ gc.dispose ();
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the paint
+ * event. If this happens, don't attempt to restore
+ * the style.
+ */
+ if (!isDisposed ()) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, oldBits);
+ }
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_SETFONT (int wParam, int lParam) {
+ return super.WM_SETFONT (font = wParam, lParam);
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ /*
+ * Begin deferred window positioning
+ */
+ int count = getChildrenCount ();
+ if (count > 1 && hdwp == 0) {
+ hdwp = OS.BeginDeferWindowPos (count);
+ }
+
+ /* Layout and resize */
+ if (layout != null) layout.layout (this, false);
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the resize
+ * event. If this happens, end the processing of the
+ * Windows message by returning the result of the
+ * WM_SIZE message.
+ */
+ if (isDisposed ()) return result;
+
+ /* End deferred window positioning */
+ int oldHdwp = hdwp;
+ hdwp = 0;
+ if (oldHdwp != 0) OS.EndDeferWindowPos (oldHdwp);
+
+ /* Damage the widget to cause a repaint */
+ if ((state & CANVAS) != 0) {
+ if ((style & SWT.NO_REDRAW_RESIZE) == 0) {
+ if (hooks (SWT.Paint)) {
+ OS.InvalidateRect (handle, null, true);
+ }
+ }
+ }
+ return result;
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ Control [] children = _getChildren ();
+ for (int i=0; i<children.length; i++) {
+ int hwndChild = children [i].handle;
+ OS.SendMessage (hwndChild, OS.WM_SYSCOLORCHANGE, 0, 0);
+ }
+ return null;
+}
+
+LRESULT WM_SYSCOMMAND (int wParam, int lParam) {
+ LRESULT result = super.WM_SYSCOMMAND (wParam, lParam);
+ if (result != null) return result;
+
+ /*
+ * Check to see if the command is a system command or
+ * a user menu item that was added to the system menu.
+ */
+ if ((wParam & 0xF000) == 0) return result;
+
+ /*
+ * Bug in Windows. When a vertical or horizontal scroll bar is
+ * hidden or shown while the opposite scroll bar is being scrolled
+ * by the user (with WM_HSCROLL code SB_LINEDOWN), the scroll bar
+ * does not redraw properly. The fix is to detect this case and
+ * redraw the non-client area.
+ */
+ int cmd = wParam & 0xFFF0;
+ switch (cmd) {
+ case OS.SC_HSCROLL:
+ case OS.SC_VSCROLL:
+ boolean showHBar = horizontalBar != null && horizontalBar.getVisible ();
+ boolean showVBar = verticalBar != null && verticalBar.getVisible ();
+ int code = callWindowProc (OS.WM_SYSCOMMAND, wParam, lParam);
+ if ((showHBar != (horizontalBar != null && horizontalBar.getVisible ())) ||
+ (showVBar != (verticalBar != null && verticalBar.getVisible ()))) {
+ int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_UPDATENOW;
+ OS.RedrawWindow (handle, null, 0, flags);
+ }
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+ }
+
+ /* Return the result */
+ return result;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
new file mode 100755
index 0000000000..f6caed8759
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -0,0 +1,3556 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Control is the abstract superclass of all windowed user interface classes.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b>
+ * <dd>BORDER</dd>
+ * <dt><b>Events:</b>
+ * <dd>DoubleClick, FocusIn, FocusOut, Help, KeyDown, KeyUp, MouseDown, MouseEnter,
+ * MouseExit, MouseHover, MouseUp, MouseMove, Move, Paint, Resize</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+
+public abstract class Control extends Widget implements Drawable {
+
+ /**
+ * the handle to the OS resource
+ * (Warning: This field is platform dependent)
+ */
+ public int handle;
+
+ Composite parent;
+ int drawCount, hCursor;
+ int foreground, background;
+ Menu menu;
+ String toolTipText;
+ Object layoutData;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 Control (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ createWidget ();
+}
+
+/**
+ * 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 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 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 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);
+}
+
+/**
+ * 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 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 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 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);
+}
+
+/**
+ * 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);
+}
+
+abstract int callWindowProc (int msg, int wParam, int lParam);
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>prefered 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
+ */
+public Point computeSize (int wHint, int hHint) {
+ return computeSize (wHint, hHint, true);
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>prefered 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
+ */
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = DEFAULT_WIDTH;
+ int 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 hwndParent = 0;
+ if (handle != 0) {
+ hwndParent = handle;
+ } else {
+ if (parent != null) hwndParent = parent.handle;
+ }
+ handle = OS.CreateWindowEx (
+ widgetExtStyle (),
+ windowClass (),
+ null,
+ widgetStyle (),
+ OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
+ hwndParent,
+ 0,
+ OS.GetModuleHandle (null),
+ null);
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+ if (IsDBLocale && parent != null) {
+ int hIMC = OS.ImmGetContext (hwndParent);
+ OS.ImmAssociateContext (handle, hIMC);
+ OS.ImmReleaseContext (hwndParent, hIMC);
+ }
+}
+
+void createWidget () {
+ foreground = background = -1;
+ createHandle ();
+ register ();
+ subclass ();
+ setDefaultFont ();
+}
+
+Control currentTabGroup () {
+ if (isTabGroup ()) return this;
+ return parent.currentTabGroup ();
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_BTNFACE);
+}
+
+int defaultFont () {
+ int hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (hFont == 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ return hFont;
+}
+
+int defaultForeground () {
+ return OS.GetSysColor (OS.COLOR_WINDOWTEXT);
+}
+
+void deregister () {
+ WidgetTable.remove (handle);
+}
+
+void destroyWidget () {
+ int hwnd = handle;
+ releaseHandle ();
+ if (hwnd != 0) {
+ OS.DestroyWindow (hwnd);
+ }
+}
+
+int findBrush (int pixel) {
+ return parent.findBrush (pixel);
+}
+
+int findCursor () {
+ if (hCursor != 0) return hCursor;
+ return parent.findCursor ();
+}
+
+char findMnemonic (String string) {
+ int index = 0;
+ int length = string.length ();
+ do {
+ while ((index < length) && (string.charAt (index) != Mnemonic)) index++;
+ if (++index >= length) return '\0';
+ if (string.charAt (index) != Mnemonic) return string.charAt (index);
+ index++;
+ } while (index < length);
+ return '\0';
+}
+
+/**
+ * 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 ();
+ Decorations shell = menuShell ();
+ shell.setSavedFocus (this);
+ if (!isEnabled () || !isVisible () || !isActive ()) return false;
+ if (isFocusControl ()) return true;
+ shell.bringToTop ();
+ OS.SetFocus (handle);
+ if (!isFocusControl ()) return false;
+ shell.setDefaultButton (null, false);
+ return 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>
+ */
+public Color getBackground () {
+ checkWidget ();
+ return Color.win32_new (getDisplay (), getBackgroundPixel ());
+}
+
+int getBackgroundPixel () {
+ if (background == -1) return defaultBackground ();
+ return background;
+}
+
+/**
+ * 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 ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ if ((bits & OS.WS_EX_CLIENTEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXEDGE);
+ if ((bits & OS.WS_EX_STATICEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
+ return 0;
+}
+
+/**
+ * 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 ();
+ int hwndParent = 0;
+ if (parent != null) {
+ hwndParent = parent.handle;
+ if (parent.hdwp != 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ int count = parent.getChildrenCount ();
+ parent.hdwp = OS.BeginDeferWindowPos (count);
+ }
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ OS.MapWindowPoints (0, hwndParent, rect, 2);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+}
+
+/**
+ * Returns the display that the receiver was created on.
+ *
+ * @return the receiver's 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 Display getDisplay () {
+ Composite parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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>
+ */
+public boolean getEnabled () {
+ checkWidget ();
+ return OS.IsWindowEnabled (handle);
+}
+
+/**
+ * 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 ();
+ int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (hFont == 0) hFont = defaultFont ();
+ return Font.win32_new (getDisplay (), hFont);
+}
+
+/**
+ * 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.win32_new (getDisplay (), getForegroundPixel ());
+}
+
+int getForegroundPixel () {
+ if (foreground == -1) return defaultForeground ();
+ return foreground;
+}
+
+/**
+ * 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 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 ();
+ int hwndParent = 0;
+ if (parent != null) {
+ hwndParent = parent.handle;
+ if (parent.hdwp != 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ int count = parent.getChildrenCount ();
+ parent.hdwp = OS.BeginDeferWindowPos (count);
+ }
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ OS.MapWindowPoints (0, hwndParent, rect, 2);
+ return new Point (rect.left, rect.top);
+}
+
+/**
+ * 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 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 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 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 (parent != null && parent.hdwp != 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ int count = parent.getChildrenCount ();
+ parent.hdwp = OS.BeginDeferWindowPos (count);
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Point (width, height);
+}
+
+Control [] getTabList () {
+ if (isTabGroup ()) {
+ if (getVisible () && getEnabled ()) {
+ return new Control [] {this};
+ }
+ }
+ return new Control [0];
+}
+
+/**
+ * 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 ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.WS_VISIBLE) != 0;
+}
+
+boolean hasCursor () {
+ RECT rect = new RECT ();
+ if (!OS.GetClientRect (handle, rect)) return false;
+ if (OS.MapWindowPoints (handle, 0, rect, 2) == 0) return false;
+ POINT pt = new POINT ();
+ return (OS.GetCursorPos (pt) && OS.PtInRect (rect, pt));
+}
+
+boolean hasFocus () {
+ int hwndFocus = OS.GetFocus ();
+ while (hwndFocus != 0) {
+ if (hwndFocus == handle) return true;
+ hwndFocus = OS.GetParent (hwndFocus);
+ }
+ return false;
+}
+
+/**
+ * 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
+ *
+ * @private
+ */
+public int internal_new_GC (GCData data) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ int hDC;
+ if (data == null || data.ps == null) {
+ hDC = OS.GetDC (handle);
+ } else {
+ hDC = OS.BeginPaint (handle, data.ps);
+ }
+ if (hDC == 0) SWT.error(SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ data.device = getDisplay ();
+ data.foreground = getForegroundPixel ();
+ data.background = getBackgroundPixel ();
+ data.hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ }
+ return hDC;
+}
+
+/**
+ * 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 handle the platform specific GC handle
+ * @param data the platform specific GC data
+ *
+ * @private
+ */
+public void internal_dispose_GC (int hDC, GCData data) {
+ //if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (data == null || data.ps == null) {
+ OS.ReleaseDC (handle, hDC);
+ } else {
+ OS.EndPaint (handle, data.ps);
+ }
+}
+
+boolean isActive () {
+ Display display = getDisplay ();
+ Shell modal = display.getModalShell ();
+ if (modal != null && modal != this) {
+ if ((modal.style & SWT.PRIMARY_MODAL) != 0) {
+ Shell shell = getShell ();
+ if (modal.parent == shell) {
+ return false;
+ }
+ }
+ int bits = SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+ if ((modal.style & bits) != 0) {
+ Control control = this;
+ while (control != null) {
+ if (control == modal) break;
+ control = control.parent;
+ }
+ if (control != modal) return false;
+ }
+ }
+ return getShell ().getEnabled ();
+}
+
+public boolean isDisposed () {
+ return handle == 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>
+ */
+public boolean isEnabled () {
+ checkWidget ();
+ return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * 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 ();
+ return hasFocus ();
+}
+
+/**
+ * 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 isTabGroup () {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.WS_TABSTOP) != 0;
+}
+
+boolean isTabItem () {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.WS_TABSTOP) != 0) return false;
+ int code = OS.SendMessage (handle, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & OS.DLGC_STATIC) != 0) return false;
+ if ((code & OS.DLGC_WANTALLKEYS) != 0) return false;
+ if ((code & OS.DLGC_WANTARROWS) != 0) return false;
+ if ((code & OS.DLGC_WANTTAB) != 0) return false;
+ return true;
+}
+
+boolean isValidWidget () {
+ return handle != 0;
+}
+
+/**
+ * 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 isVisible () {
+ checkWidget ();
+ return OS.IsWindowVisible (handle);
+}
+
+Decorations menuShell () {
+ return parent.menuShell ();
+}
+
+boolean mnemonicHit () {
+ return false;
+}
+
+boolean mnemonicMatch (char key) {
+ return false;
+}
+
+/**
+ * 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 the sibling control (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 moveAbove (Control control) {
+ checkWidget ();
+ int hwndAfter = OS.HWND_TOP;
+ if (control != null) {
+ int hwnd = control.handle;
+ if ((hwnd == 0) || (hwnd == handle)) return;
+ hwndAfter = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
+ if (hwndAfter == 0) hwndAfter = OS.HWND_TOP;
+ }
+ int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (handle, hwndAfter, 0, 0, 0, 0, flags);
+}
+
+/**
+ * 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 the sibling control (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 moveBelow (Control control) {
+ checkWidget ();
+ int hwndAfter = OS.HWND_BOTTOM;
+ if (control != null) hwndAfter = control.handle;
+ if (hwndAfter == 0) return;
+ int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (handle, hwndAfter, 0, 0, 0, 0, flags);
+}
+
+/**
+ * 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
+ */
+public void pack () {
+ checkWidget ();
+ 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>
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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
+ */
+public void pack (boolean changed) {
+ checkWidget ();
+ setSize (computeSize (SWT.DEFAULT, SWT.DEFAULT, changed));
+}
+
+/**
+ * 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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
+ */
+public void redraw () {
+ checkWidget ();
+ if (!OS.IsWindowVisible (handle)) return;
+ int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, null, 0, flags);
+}
+
+/**
+ * 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.
+ *
+ * @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
+ */
+public void redraw (int x, int y, int width, int height, boolean all) {
+ checkWidget ();
+ if (!OS.IsWindowVisible (handle)) return;
+ RECT rect = new RECT ();
+ int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
+ if (all) flags |= OS.RDW_ALLCHILDREN;
+ OS.SetRect (rect, x, y, x + width, y + height);
+ OS.RedrawWindow (handle, rect, 0, flags);
+}
+
+void register () {
+ WidgetTable.put (handle, this);
+}
+
+void releaseHandle () {
+ handle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ if (IsDBLocale) {
+ OS.ImmAssociateContext (handle, 0);
+ }
+ if (toolTipText != null) {
+ Shell shell = getShell ();
+ shell.setToolTipText (handle, null);
+ }
+ toolTipText = null;
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ menu = null;
+ deregister ();
+ unsubclass ();
+ parent = null;
+ layoutData = 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 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 gains or loses focus.
+ *
+ * @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 #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 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 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 mouse passes or hovers over controls.
+ *
+ * @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 #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 mouse buttons are pressed and released.
+ *
+ * @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 #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 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 receiver needs to be painted.
+ *
+ * @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 #addPaintListener
+ */
+public void removePaintListener(PaintListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook(SWT.Paint, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when traversal events occur.
+ *
+ * @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 #addTraverseListener
+ */
+public void removeTraverseListener(TraverseListener listener) {
+ checkWidget ();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Traverse, listener);
+}
+
+boolean sendKeyEvent (int type, int msg, int wParam, int lParam) {
+ Event event = new Event ();
+ if (!setKeyState (event, type)) return true;
+ return sendKeyEvent (type, msg, wParam, lParam, event);
+}
+
+boolean sendKeyEvent (int type, int msg, int wParam, int lParam, Event event) {
+ postEvent (type, event);
+ return true;
+}
+
+boolean sendMouseEvent (int type, int button, int msg, int wParam, int lParam) {
+ Event event = new Event ();
+ event.button = button;
+ event.x = (short) (lParam & 0xFFFF);
+ event.y = (short) (lParam >> 16);
+ if (OS.GetKeyState (OS.VK_MENU) < 0) event.stateMask |= SWT.ALT;
+ if ((wParam & OS.MK_SHIFT) != 0) event.stateMask |= SWT.SHIFT;
+ if ((wParam & OS.MK_CONTROL) != 0) event.stateMask |= SWT.CONTROL;
+ if (button != 1 || (type != SWT.MouseDown && type != SWT.MouseDoubleClick)) {
+ if (type == SWT.MouseUp || (wParam & OS.MK_LBUTTON) != 0) {
+ event.stateMask |= SWT.BUTTON1;
+ }
+ }
+ if (button != 2 || (type != SWT.MouseDown && type != SWT.MouseDoubleClick)) {
+ if (type == SWT.MouseUp || (wParam & OS.MK_MBUTTON) != 0) {
+ event.stateMask |= SWT.BUTTON2;
+ }
+ }
+ if (button != 3 || (type != SWT.MouseDown && type != SWT.MouseDoubleClick)) {
+ if (type == SWT.MouseUp || (wParam & OS.MK_RBUTTON) != 0) {
+ event.stateMask |= SWT.BUTTON3;
+ }
+ }
+ return sendMouseEvent (type, msg, wParam, lParam, event);
+}
+
+boolean sendMouseEvent (int type, int msg, int wParam, int lParam, Event event) {
+ postEvent (type, event);
+ return true;
+}
+
+/**
+ * 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.
+ *
+ * @param color the new color (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 setBackground (Color color) {
+ checkWidget ();
+ int pixel = -1;
+ if (color != null) {
+ pixel = color.handle;
+ }
+ setBackgroundPixel (pixel);
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ background = pixel;
+ OS.InvalidateRect (handle, null, 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).
+ * <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), 0);
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ flags |= OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
+ if (parent == null) {
+ OS.SetWindowPos (handle, 0, x, y, width, height, flags);
+ return;
+ }
+ int count = parent.getChildrenCount ();
+ if (parent.hdwp == 0) {
+ if (count > 1) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.WS_CLIPSIBLINGS) == 0) flags |= OS.SWP_NOCOPYBITS;
+ }
+ OS.SetWindowPos (handle, 0, x, y, width, height, flags);
+ return;
+ }
+ int hdwp = OS.DeferWindowPos (parent.hdwp, handle, 0, x, y, width, height, flags);
+ if (hdwp == 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ if (count > 1) hdwp = OS.BeginDeferWindowPos (count);
+ }
+ parent.hdwp = hdwp;
+}
+
+/**
+ * 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, rect.width, rect.height);
+}
+
+/**
+ * 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.
+ *
+ * @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 ();
+ if (capture) {
+ OS.SetCapture (handle);
+ } else {
+ if (OS.GetCapture () == handle) {
+ OS.ReleaseCapture ();
+ }
+ }
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 ();
+ hCursor = 0;
+ if (cursor != null) hCursor = cursor.handle;
+ int hwndCursor = OS.GetCapture ();
+ if (hwndCursor == 0) {
+ POINT pt = new POINT ();
+ if (!OS.GetCursorPos (pt)) return;
+ int hwnd = hwndCursor = OS.WindowFromPoint (pt);
+ while (hwnd != 0 && hwnd != handle) {
+ hwnd = OS.GetParent (hwnd);
+ }
+ if (hwnd == 0) return;
+ }
+ int lParam = OS.HTCLIENT | (OS.WM_MOUSEMOVE << 16);
+ OS.SendMessage (hwndCursor, OS.WM_SETCURSOR, hwndCursor, lParam);
+}
+
+void setDefaultFont () {
+ int hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (hFont == 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
+}
+
+/**
+ * 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 ();
+
+ /* Enable or disable the window */
+ boolean fixFocus = false;
+ if (!enabled) {
+ Display display = getDisplay ();
+ Control control = display.getFocusControl ();
+ while (control != null && control != this) {
+ control = control.parent;
+ }
+ fixFocus = control == this;
+ }
+ OS.EnableWindow (handle, enabled);
+
+ /*
+ * Feature in Windows. If the receiver has focus, disabling
+ * the receiver causes no window to have focus. The fix is
+ * to assign focus to the first ancestor window that takes
+ * focus. If no window will take focus, set focus to the
+ * desktop.
+ */
+ if (!fixFocus) return;
+ Control control = this;
+ while ((control = control.parent) != null) {
+ if (control.setFocus () || control instanceof Shell) return;
+ }
+ OS.SetFocus (0);
+}
+
+/**
+ * Causes the receiver to have the <em>keyboard focus</em>,
+ * such that all keyboard events will 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 #forceFocus
+ */
+public boolean setFocus () {
+ checkWidget ();
+ 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 hFont = 0;
+ if (font != null) hFont = font.handle;
+ if (hFont == 0) hFont = defaultFont ();
+ OS.SendMessage (handle, OS.WM_SETFONT, hFont, 1);
+}
+
+/**
+ * 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.
+ *
+ * @param color the new color (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 setForeground (Color color) {
+ checkWidget ();
+ int pixel = -1;
+ if (color != null) {
+ pixel = color.handle;
+ }
+ setForegroundPixel (pixel);
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+ OS.InvalidateRect (handle, null, true);
+}
+
+boolean setKeyState (Event event, int type) {
+ Display display = getDisplay ();
+ if (display.lastAscii != 0) {
+ event.character = mbcsToWcs ((char) display.lastAscii);
+ }
+ if (display.lastVirtual) {
+ event.keyCode = Display.translateKey (display.lastKey);
+ }
+ if (event.keyCode == 0 && event.character == 0) {
+ return false;
+ }
+ if (OS.GetKeyState (OS.VK_MENU) < 0) {
+ if (type != SWT.KeyDown || event.keyCode != SWT.ALT) {
+ event.stateMask |= SWT.ALT;
+ }
+ }
+ if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
+ if (type != SWT.KeyDown || event.keyCode != SWT.SHIFT) {
+ event.stateMask |= SWT.SHIFT;
+ }
+ }
+ if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
+ if (type != SWT.KeyDown || event.keyCode != SWT.CONTROL) {
+ event.stateMask |= SWT.CONTROL;
+ }
+ }
+ if (type == SWT.KeyUp) {
+ if (event.keyCode == SWT.ALT) event.stateMask |= SWT.ALT;
+ if (event.keyCode == SWT.SHIFT) event.stateMask |= SWT.SHIFT;
+ if (event.keyCode == SWT.CONTROL) event.stateMask |= SWT.CONTROL;
+ }
+ if (OS.GetKeyState (OS.VK_LBUTTON) < 0) event.stateMask |= SWT.BUTTON1;
+ if (OS.GetKeyState (OS.VK_MBUTTON) < 0) event.stateMask |= SWT.BUTTON2;
+ if (OS.GetKeyState (OS.VK_RBUTTON) < 0) event.stateMask |= SWT.BUTTON3;
+ return true;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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, 0, 0, OS.SWP_NOSIZE);
+}
+
+/**
+ * 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 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.
+ *
+ * @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>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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;
+}
+
+boolean setRadioFocus () {
+ 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.
+ * <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
+ * @see #update
+ */
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+
+ /*
+ * This code is intentionally commented.
+ *
+ * Feature in Windows. When WM_SETREDRAW is used to turn
+ * off drawing in a widget, it clears the WS_VISIBLE bits
+ * and then sets them when redraw is turned back on. This
+ * means that WM_SETREDRAW will make a widget unexpectedly
+ * visible.
+ *
+ * There is no fix at this time.
+ */
+// if (drawCount == 0) {
+// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+// if ((bits & OS.WS_VISIBLE) == 0) return;
+// }
+
+ if (redraw) {
+ if (--drawCount == 0) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, null, 0, flags);
+ }
+ } else {
+ if (drawCount++ == 0) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ }
+}
+
+/**
+ * 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), OS.SWP_NOMOVE);
+}
+
+/**
+ * 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
+ * @param height the new height 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);
+}
+
+boolean setTabGroupFocus () {
+ return setTabItemFocus ();
+}
+
+boolean setTabItemFocus () {
+ return setFocus ();
+}
+
+/**
+ * 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 ();
+ Shell shell = getShell ();
+ shell.setToolTipText (handle, toolTipText = string);
+}
+
+/**
+ * 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 ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if (((bits & OS.WS_VISIBLE) != 0) == 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.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
+ if (!visible) sendEvent (SWT.Hide);
+}
+
+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;
+ }
+ }
+ }
+ }
+}
+
+void subclass () {
+ int oldProc = windowProc ();
+ int newProc = getDisplay ().windowProc;
+ if (oldProc == newProc) return;
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc);
+}
+
+/**
+ * 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)
+ *
+ * @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);
+ POINT pt = new POINT ();
+ pt.x = point.x; pt.y = point.y;
+ OS.ScreenToClient (handle, pt);
+ return new Point (pt.x, pt.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)
+ *
+ * @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);
+ POINT pt = new POINT ();
+ pt.x = point.x; pt.y = point.y;
+ OS.ClientToScreen (handle, pt);
+ return new Point (pt.x, pt.y);
+}
+
+boolean translateAccelerator (MSG msg) {
+ return menuShell ().translateAccelerator (msg);
+}
+
+boolean translateMnemonic (MSG msg) {
+ int hwnd = msg.hwnd;
+ if (OS.GetKeyState (OS.VK_MENU) >= 0) {
+ int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & OS.DLGC_WANTALLKEYS) != 0) return false;
+ if ((code & OS.DLGC_BUTTON) == 0) return false;
+ }
+ Decorations shell = menuShell ();
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ char ch = mbcsToWcs ((char) msg.wParam);
+ return ch != 0 && shell.traverseMnemonic (ch);
+}
+
+boolean translateTraversal (MSG msg) {
+ int hwnd = msg.hwnd;
+ int detail = 0;
+ int key = msg.wParam;
+ boolean doit = true;
+ boolean lastVirtual = false;
+ int lastKey = key, lastAscii = 0;
+ switch (key) {
+ case OS.VK_ESCAPE: {
+ lastAscii = 27;
+ Shell shell = getShell ();
+ if (shell.parent == null) return false;
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ detail = SWT.TRAVERSE_ESCAPE;
+ break;
+ }
+ case OS.VK_RETURN: {
+ lastAscii = '\r';
+ Button button = menuShell ().getDefaultButton ();
+ if (button == null || button.isDisposed ()) return false;
+ if (!button.isVisible () || !button.isEnabled ()) return false;
+ int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & OS.DLGC_WANTALLKEYS) != 0) doit = false;
+ detail = SWT.TRAVERSE_RETURN;
+ break;
+ }
+ case OS.VK_TAB: {
+ lastAscii = '\t';
+ boolean next = OS.GetKeyState (OS.VK_SHIFT) >= 0;
+ int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & (OS.DLGC_WANTTAB | OS.DLGC_WANTALLKEYS)) != 0) {
+ if (next && OS.GetKeyState (OS.VK_CONTROL) >= 0) doit = false;
+ }
+ detail = SWT.TRAVERSE_TAB_PREVIOUS;
+ if (next) detail = SWT.TRAVERSE_TAB_NEXT;
+ break;
+ }
+ case OS.VK_UP:
+ case OS.VK_LEFT:
+ case OS.VK_DOWN:
+ case OS.VK_RIGHT: {
+ lastVirtual = true;
+ int code = OS.SendMessage (hwnd, OS.WM_GETDLGCODE, 0, 0);
+ if ((code & OS.DLGC_WANTARROWS) != 0) doit = false;
+ detail = SWT.TRAVERSE_ARROW_PREVIOUS;
+ if (key == OS.VK_DOWN || key == OS.VK_RIGHT) {
+ detail = SWT.TRAVERSE_ARROW_NEXT;
+ }
+ break;
+ }
+ default:
+ return false;
+ }
+ if (hooks (SWT.Traverse)) {
+ Event event = new Event ();
+ event.doit = doit;
+ event.detail = detail;
+ Display display = getDisplay ();
+ display.lastKey = lastKey;
+ display.lastAscii = lastAscii;
+ display.lastVirtual = lastVirtual;
+ if (!setKeyState (event, SWT.Traverse)) {
+ return false;
+ }
+ /*
+ * 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;
+ doit = event.doit;
+ detail = event.detail;
+ }
+ if (doit) return traverse (detail);
+ return false;
+}
+
+/**
+ * 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 ();
+ if (!isFocusControl () && !setFocus ()) return false;
+ switch (traversal) {
+ 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);
+ }
+ return false;
+}
+
+boolean traverseEscape () {
+ Shell shell = getShell ();
+ if (shell.parent == null) return false;
+ if (!shell.isVisible () || !shell.isEnabled ()) return false;
+ shell.close ();
+ return true;
+}
+
+boolean traverseGroup (boolean next) {
+ Control group = currentTabGroup ();
+ Control [] list = menuShell ().getTabList ();
+ int length = list.length;
+ int index = 0;
+ while (index < length) {
+ if (list [index] == group) break;
+ index++;
+ }
+ if (index == length) return false;
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset + length) % length)) != start) {
+ if (list [index].setTabGroupFocus () && !isFocusControl ()) return true;
+ }
+ return group.setTabGroupFocus ();
+}
+
+boolean traverseItem (boolean next) {
+ Control [] children = parent._getChildren ();
+ int length = children.length;
+ int index = 0;
+ while (index < length) {
+ if (children [index] == this) break;
+ index++;
+ }
+ int start = index, offset = (next) ? 1 : -1;
+ while ((index = ((index + offset) + length) % length) != start) {
+ Control child = children [index];
+ if (child.isTabItem () && child.setTabItemFocus ()) return true;
+ }
+ return false;
+}
+
+boolean traverseMnemonic (char key) {
+ if (!isVisible () || !isEnabled ()) return false;
+ return mnemonicMatch (key) && mnemonicHit ();
+}
+
+boolean traverseReturn () {
+ Button button = menuShell ().getDefaultButton ();
+ if (button == null || button.isDisposed ()) return false;
+ if (!button.isVisible () || !button.isEnabled ()) return false;
+ button.click ();
+ return true;
+}
+
+void unsubclass () {
+ int newProc = windowProc ();
+ int oldProc = getDisplay ().windowProc;
+ if (oldProc == newProc) return;
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, newProc);
+}
+
+/**
+ * Forces all outstanding paint requests for the widget tree
+ * to be processed before this method returns.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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
+ */
+public void update () {
+ checkWidget ();
+ int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (handle, null, 0, flags);
+}
+
+int widgetExtStyle () {
+ if ((style & SWT.BORDER) != 0) return OS.WS_EX_CLIENTEDGE;
+ return 0;
+}
+
+int widgetStyle () {
+ /* Force strict clipping by setting WS_CLIPSIBLINGS */
+ return OS.WS_CHILD | OS.WS_VISIBLE | OS.WS_CLIPSIBLINGS;
+
+ /*
+ * This code is intentionally commented. When strict
+ * clipping (clipping of both siblings and children)
+ * was not enforced on all widgets, poorly written
+ * application code could draw outside of the control.
+ */
+// int bits = OS.WS_CHILD | OS.WS_VISIBLE;
+// if ((style & SWT.CLIP_SIBLINGS) != 0) bits |= OS.WS_CLIPSIBLINGS;
+// if ((style & SWT.CLIP_CHILDREN) != 0) bits |= OS.WS_CLIPCHILDREN;
+// return bits;
+}
+
+/**
+ * Changes the parent of the widget to be the one provided if
+ * the underlying operating system supports this feature.
+ * Answers <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 SWTError <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 boolean setParent (Composite parent) {
+ checkWidget ();
+ if (parent == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (OS.SetParent (handle, parent.handle) == 0) {
+ return false;
+ }
+ this.parent = parent;
+ return true;
+}
+
+abstract byte [] windowClass ();
+
+abstract int windowProc ();
+
+int windowProc (int msg, int wParam, int lParam) {
+ LRESULT result = null;
+ switch (msg) {
+ case OS.WM_ACTIVATE: result = WM_ACTIVATE (wParam, lParam); break;
+ case OS.WM_CHAR: result = WM_CHAR (wParam, lParam); break;
+ case OS.WM_CLEAR: result = WM_CLEAR (wParam, lParam); break;
+ case OS.WM_CLOSE: result = WM_CLOSE (wParam, lParam); break;
+ case OS.WM_COMMAND: result = WM_COMMAND (wParam, lParam); break;
+ case OS.WM_CONTEXTMENU: result = WM_CONTEXTMENU (wParam, lParam); break;
+ case OS.WM_CTLCOLORBTN:
+ case OS.WM_CTLCOLORDLG:
+ case OS.WM_CTLCOLOREDIT:
+ case OS.WM_CTLCOLORLISTBOX:
+ case OS.WM_CTLCOLORMSGBOX:
+ case OS.WM_CTLCOLORSCROLLBAR:
+ case OS.WM_CTLCOLORSTATIC: result = WM_CTLCOLOR (wParam, lParam); break;
+ case OS.WM_CUT: result = WM_CUT (wParam, lParam); break;
+ case OS.WM_DESTROY: result = WM_DESTROY (wParam, lParam); break;
+ case OS.WM_DRAWITEM: result = WM_DRAWITEM (wParam, lParam); break;
+ case OS.WM_ERASEBKGND: result = WM_ERASEBKGND (wParam, lParam); break;
+ case OS.WM_GETDLGCODE: result = WM_GETDLGCODE (wParam, lParam); break;
+ case OS.WM_HELP: result = WM_HELP (wParam, lParam); break;
+ case OS.WM_HSCROLL: result = WM_HSCROLL (wParam, lParam); break;
+ case OS.WM_IME_CHAR: result = WM_IME_CHAR (wParam, lParam); break;
+ case OS.WM_IME_COMPOSITION: result = WM_IME_COMPOSITION (wParam, lParam); break;
+ case OS.WM_INITMENUPOPUP: result = WM_INITMENUPOPUP (wParam, lParam); break;
+ case OS.WM_GETFONT: result = WM_GETFONT (wParam, lParam); break;
+ case OS.WM_KEYDOWN: result = WM_KEYDOWN (wParam, lParam); break;
+ case OS.WM_KEYUP: result = WM_KEYUP (wParam, lParam); break;
+ case OS.WM_KILLFOCUS: result = WM_KILLFOCUS (wParam, lParam); break;
+ case OS.WM_LBUTTONDBLCLK: result = WM_LBUTTONDBLCLK (wParam, lParam); break;
+ case OS.WM_LBUTTONDOWN: result = WM_LBUTTONDOWN (wParam, lParam); break;
+ case OS.WM_LBUTTONUP: result = WM_LBUTTONUP (wParam, lParam); break;
+ case OS.WM_MBUTTONDBLCLK: result = WM_MBUTTONDBLCLK (wParam, lParam); break;
+ case OS.WM_MBUTTONDOWN: result = WM_MBUTTONDOWN (wParam, lParam); break;
+ case OS.WM_MBUTTONUP: result = WM_MBUTTONUP (wParam, lParam); break;
+ case OS.WM_MEASUREITEM: result = WM_MEASUREITEM (wParam, lParam); break;
+ case OS.WM_MENUCHAR: result = WM_MENUCHAR (wParam, lParam); break;
+ case OS.WM_MENUSELECT: result = WM_MENUSELECT (wParam, lParam); break;
+ case OS.WM_MOUSEACTIVATE: result = WM_MOUSEACTIVATE (wParam, lParam); break;
+ case OS.WM_MOUSEHOVER: result = WM_MOUSEHOVER (wParam, lParam); break;
+ case OS.WM_MOUSELEAVE: result = WM_MOUSELEAVE (wParam, lParam); break;
+ case OS.WM_MOUSEMOVE: result = WM_MOUSEMOVE (wParam, lParam); break;
+ case OS.WM_MOVE: result = WM_MOVE (wParam, lParam); break;
+ case OS.WM_NCACTIVATE: result = WM_NCACTIVATE (wParam, lParam); break;
+ case OS.WM_NCCALCSIZE: result = WM_NCCALCSIZE (wParam, lParam); break;
+ case OS.WM_NCHITTEST: result = WM_NCHITTEST (wParam, lParam); break;
+ case OS.WM_NOTIFY: result = WM_NOTIFY (wParam, lParam); break;
+ case OS.WM_PAINT: result = WM_PAINT (wParam, lParam); break;
+ case OS.WM_PALETTECHANGED: result = WM_PALETTECHANGED (wParam, lParam); break;
+ case OS.WM_PASTE: result = WM_PASTE (wParam, lParam); break;
+ case OS.WM_QUERYNEWPALETTE: result = WM_QUERYNEWPALETTE (wParam, lParam); break;
+ case OS.WM_QUERYOPEN: result = WM_QUERYOPEN (wParam, lParam); break;
+ case OS.WM_RBUTTONDBLCLK: result = WM_RBUTTONDBLCLK (wParam, lParam); break;
+ case OS.WM_RBUTTONDOWN: result = WM_RBUTTONDOWN (wParam, lParam); break;
+ case OS.WM_RBUTTONUP: result = WM_RBUTTONUP (wParam, lParam); break;
+ case OS.WM_SETCURSOR: result = WM_SETCURSOR (wParam, lParam); break;
+ case OS.WM_SETFOCUS: result = WM_SETFOCUS (wParam, lParam); break;
+ case OS.WM_SETFONT: result = WM_SETFONT (wParam, lParam); break;
+ case OS.WM_SHOWWINDOW: result = WM_SHOWWINDOW (wParam, lParam); break;
+ case OS.WM_SIZE: result = WM_SIZE (wParam, lParam); break;
+ case OS.WM_SYSCHAR: result = WM_SYSCHAR (wParam, lParam); break;
+ case OS.WM_SYSCOLORCHANGE: result = WM_SYSCOLORCHANGE (wParam, lParam); break;
+ case OS.WM_SYSCOMMAND: result = WM_SYSCOMMAND (wParam, lParam); break;
+ case OS.WM_SYSKEYDOWN: result = WM_SYSKEYDOWN (wParam, lParam); break;
+ case OS.WM_SYSKEYUP: result = WM_SYSKEYUP (wParam, lParam); break;
+ case OS.WM_TIMER: result = WM_TIMER (wParam, lParam); break;
+ case OS.WM_UNDO: result = WM_UNDO (wParam, lParam); break;
+ case OS.WM_VSCROLL: result = WM_VSCROLL (wParam, lParam); break;
+ case OS.WM_WINDOWPOSCHANGING: result = WM_WINDOWPOSCHANGING (wParam, lParam); break;
+ }
+ if (result != null) return result.value;
+ return callWindowProc (msg, wParam, lParam);
+}
+
+LRESULT WM_ACTIVATE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_CHAR (int wParam, int lParam) {
+
+ /*
+ * Do not report a lead byte as a key pressed.
+ */
+ Display display = getDisplay ();
+ if (IsDBLocale) {
+ byte lead = (byte) (wParam & 0xFF);
+ if (OS.IsDBCSLeadByte (lead)) return null;
+ }
+
+ /*
+ * Use VkKeyScan () to tell us if the character is a control
+ * or a numeric key pad character with Num Lock down. On
+ * international keyboards, the control key may be down when
+ * the character is not a control character. In this case
+ * use the last key (computed in WM_KEYDOWN) instead of wParam
+ * as the keycode because there is not enough information to
+ * compute the keycode in WPARAM.
+ */
+ display.lastAscii = wParam;
+ if (display.lastKey == 0) {
+ display.lastKey = wParam;
+ display.lastVirtual = display.isVirtualKey (wParam);
+ } else {
+ int result = OS.VkKeyScan ((short) wParam);
+ if (result == -1 || (result >> 8) <= 2) {
+ if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
+ display.lastVirtual = display.isVirtualKey (display.lastKey);
+ }
+ } else {
+ display.lastKey = wParam;
+ display.lastVirtual = false;
+ }
+ }
+ if (!sendKeyEvent (SWT.KeyDown, OS.WM_CHAR, wParam, lParam)) {
+ return LRESULT.ZERO;
+ }
+ return null;
+}
+
+LRESULT WM_CLEAR (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_CLOSE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_COMMAND (int wParam, int lParam) {
+ /*
+ * When the WM_COMMAND message is sent from a
+ * menu, the HWND parameter in LPARAM is zero.
+ */
+ if (lParam == 0) {
+ Decorations shell = menuShell ();
+ if (shell.isEnabled ()) {
+ MenuItem item = shell.findMenuItem (wParam & 0xFFFF);
+ if (item != null && item.isEnabled ()) {
+ return item.wmCommandChild (wParam, lParam);
+ }
+ }
+ return null;
+ }
+ Control control = WidgetTable.get (lParam);
+ if (control == null) return null;
+ return control.wmCommandChild (wParam, lParam);
+}
+
+LRESULT WM_CONTEXTMENU (int wParam, int lParam) {
+ /*
+ * Because context menus can be shared between controls
+ * and the parent of all menus is the shell, the menu may
+ * have been destroyed but not removed from the control.
+ */
+ if (menu == null || menu.isDisposed ()) return null;
+ menu.setVisible (true);
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_CTLCOLOR (int wParam, int lParam) {
+ Display display = getDisplay ();
+ int hPalette = display.hPalette;
+ if (hPalette != 0) {
+ OS.SelectPalette (wParam, hPalette, false);
+ OS.RealizePalette (wParam);
+ }
+ Control control = WidgetTable.get (lParam);
+ if (control == null) return null;
+ return control.wmColorChild (wParam, lParam);
+}
+
+LRESULT WM_CUT (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_DESTROY (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_DRAWITEM (int wParam, int lParam) {
+ DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+ if (struct.CtlType == OS.ODT_MENU) {
+ Decorations shell = menuShell ();
+ MenuItem item = shell.findMenuItem (struct.itemID);
+ if (item == null) return null;
+ return item.wmDrawChild (wParam, lParam);
+ }
+ Control control = WidgetTable.get (struct.hwndItem);
+ if (control == null) return null;
+ return control.wmDrawChild (wParam, lParam);
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_GETFONT (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_HELP (int wParam, int lParam) {
+ HELPINFO lphi = new HELPINFO ();
+ OS.MoveMemory (lphi, lParam, HELPINFO.sizeof);
+ Decorations shell = menuShell ();
+ if (!shell.isEnabled ()) return null;
+ if (lphi.iContextType == OS.HELPINFO_MENUITEM) {
+ MenuItem item = shell.findMenuItem (lphi.iCtrlId);
+ if (item != null && item.isEnabled ()) {
+ Widget widget = null;
+ if (item.hooks (SWT.Help)) {
+ widget = item;
+ } else {
+ Menu menu = item.parent;
+ if (menu.hooks (SWT.Help)) widget = menu;
+ }
+ if (widget != null) {
+ int hwndShell = shell.handle;
+ OS.SendMessage (hwndShell, OS.WM_CANCELMODE, 0, 0);
+ widget.postEvent (SWT.Help);
+ return LRESULT.ONE;
+ }
+ }
+ return null;
+ }
+ if (hooks (SWT.Help)) {
+ postEvent (SWT.Help);
+ return LRESULT.ONE;
+ }
+ return null;
+}
+
+LRESULT WM_HSCROLL (int wParam, int lParam) {
+ if (lParam == 0) return null;
+ Control control = WidgetTable.get (lParam);
+ if (control == null) return null;
+ return control.wmScrollChild (wParam, lParam);
+}
+
+LRESULT WM_IME_CHAR (int wParam, int lParam) {
+ Display display = getDisplay ();
+ display.lastKey = 0;
+ display.lastAscii = wParam;
+ display.lastVirtual = false;
+ sendKeyEvent (SWT.KeyDown, OS.WM_IME_CHAR, wParam, lParam);
+ sendKeyEvent (SWT.KeyUp, OS.WM_IME_CHAR, wParam, lParam);
+ display.lastKey = display.lastAscii = 0;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_IME_COMPOSITION (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_INITMENUPOPUP (int wParam, int lParam) {
+
+ /* Ignore WM_INITMENUPOPUP for an accelerator */
+ Display display = getDisplay ();
+ if (display.accelKeyHit) return null;
+
+ /*
+ * If the high order word of LPARAM is non-zero,
+ * the menu is the system menu and we can ignore
+ * WPARAM. Otherwise, use WPARAM to find the menu.
+ */
+ Shell shell = getShell ();
+ Menu oldMenu = shell.activeMenu, newMenu = null;
+ if ((lParam >> 16) == 0) {
+ newMenu = menuShell ().findMenu (wParam);
+ }
+ Menu menu = newMenu;
+ while (menu != null && menu != oldMenu) {
+ menu = menu.getParentMenu ();
+ }
+ if (menu == null) {
+ menu = shell.activeMenu;
+ while (menu != null) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the hide
+ * event. If this happens, stop searching up the
+ * ancestor list because there is no longer a link
+ * to follow.
+ */
+ menu.sendEvent (SWT.Hide);
+ if (menu.isDisposed ()) break;
+ menu = menu.getParentMenu ();
+ Menu ancestor = newMenu;
+ while (ancestor != null && ancestor != menu) {
+ ancestor = ancestor.getParentMenu ();
+ }
+ if (ancestor != null) break;
+ }
+ }
+
+ /*
+ * The shell and the new menu may be disposed because of
+ * sending the hide event to the ancestor menus but setting
+ * a field to null in a disposed shell is not harmful.
+ */
+ if (newMenu != null && newMenu.isDisposed ()) newMenu = null;
+ shell.activeMenu = newMenu;
+
+ /*
+ * Send the show event
+ */
+ if (newMenu != null && newMenu != oldMenu) {
+ /*
+ * SWT.Selection events are posted to allow stepping
+ * in the VA/Java debugger. SWT.Show events are
+ * sent to ensure that application event handler
+ * code runs before the menu is displayed. This
+ * means that SWT.Show events would normally occur
+ * before SWT.Selection events. While this is not
+ * strictly incorrect, applications often use the
+ * SWT.Selection event to update the state of menu
+ * items and would like the ordering of events to
+ * be the other way around.
+ *
+ * The fix is to run the deferred events before
+ * the menu is shown. This means that stepping
+ * through a selection event that was caused by
+ * a popup menu will fail in VA/Java.
+ */
+ display.runDeferredEvents ();
+ newMenu.sendEvent (SWT.Show);
+ // widget could be disposed at this point
+ }
+ return null;
+}
+
+LRESULT WM_KEYDOWN (int wParam, int lParam) {
+
+ /*
+ * Do not report a lead byte as a key pressed.
+ */
+ Display display = getDisplay ();
+ if (IsDBLocale) {
+ byte lead = (byte) (wParam & 0xFF);
+ if (OS.IsDBCSLeadByte (lead)) {
+ display.lastAscii = display.lastKey = 0;
+ display.lastVirtual = false;
+ return null;
+ }
+ }
+
+ /* Ignore repeating modifier keys by testing key down state */
+ if ((wParam == OS.VK_SHIFT) || (wParam == OS.VK_MENU) ||
+ (wParam == OS.VK_CONTROL) || (wParam == OS.VK_CAPITAL) ||
+ (wParam == OS.VK_NUMLOCK) || (wParam == OS.VK_SCROLL)) {
+ if ((lParam & 0x40000000) != 0) return null;
+ }
+
+ /* Set last key and clear last ascii because a new key has been typed */
+ display.lastAscii = 0;
+ display.lastKey = wParam;
+
+ /* Map the virtual key */
+ int mapKey = OS.MapVirtualKey (display.lastKey, 2);
+
+ /*
+ * Bug in Windows 95 and NT. When the user types an accent key such
+ * as ^ to get an accented character on a German keyboard, the accent
+ * key should be ignored and the next key that the user types is the
+ * accented key. On Windows 95 and NT, a call to ToAscii (), clears the
+ * accented state such that the next WM_CHAR loses the accent. The fix
+ * is to detect the accent key stroke (called a dead key) by testing the
+ * high bit of the value returned by MapVirtualKey (). A further problem
+ * is that the high bit on Windows NT is bit 32 while the high bit on
+ * Windows 95 is bit 16. They should both be bit 32.
+ */
+ if (IsWinNT) {
+ if ((mapKey & 0x80000000) != 0) return null;
+ } else {
+ if ((mapKey & 0x8000) != 0) return null;
+ }
+
+ /*
+ * If are going to get a WM_CHAR, ensure that last key has
+ * the correct character value for the key down and key up
+ * events. It is not sufficient to ignore the WM_KEYDOWN
+ * (when we know we are going to get a WM_CHAR) and compute
+ * the key in WM_CHAR because there is not enough information
+ * by the time we get the WM_CHAR. For example, when the user
+ * types Ctrl+Shift+6 on a US keyboard, we get a WM_CHAR with
+ * wParam=30. When the user types Ctrl+Shift+6 on a German
+ * keyboard, we also get a WM_CHAR with wParam=30. On the US
+ * keyboard Shift+6 is ^, on the German keyboard Shift+6 is &.
+ * There is no way to map wParam=30 in WM_CHAR to the correct
+ * value. Also, on international keyboards, the control key
+ * may be down when the user has not entered a control character.
+ */
+ display.lastVirtual = (mapKey == 0);
+ if (display.lastVirtual) {
+ /*
+ * Feature in Windows. The virtual key VK_DELETE is not
+ * treated as both a virtual key and an ASCII key by Windows.
+ * Therefore, we will not receive a WM_CHAR for this key.
+ * The fix is to treat VK_DELETE as a special case and map
+ * the ASCII value explictly (Delete is 127).
+ */
+ if (display.lastKey == OS.VK_DELETE) display.lastAscii = 127;
+ /*
+ * It is possible to get a WM_CHAR for a virtual key when
+ * Num Lock is on. If the user types Home while Num Lock
+ * is down, a WM_CHAR is issued with WPARM=55 (for the
+ * character 7). If we are going to get a WM_CHAR we need
+ * to ensure that the last key has the correct value. Note
+ * that Ctrl+Home does not issue a WM_CHAR when Num Lock is
+ * down.
+ */
+ if ((OS.VK_NUMPAD0 <= display.lastKey) && (display.lastKey <= OS.VK_DIVIDE)) {
+ if (display.asciiKey (display.lastKey) != 0) return null;
+ }
+ } else {
+ /*
+ * Get the shifted state or convert to lower case if necessary.
+ * If the user types Ctrl+A, LastKey should be $a, not $A. If
+ * the user types Ctrl+Shift+A, LastKey should be $A. If the user
+ * types Ctrl+Shift+6, the value of LastKey will depend on the
+ * international keyboard.
+ */
+ if (OS.GetKeyState (OS.VK_SHIFT) < 0) {
+ display.lastKey = display.shiftedKey (display.lastKey);
+ if (display.lastKey == 0) display.lastKey = wParam;
+ } else {
+ display.lastKey = OS.CharLower ((short) mapKey);
+ }
+ /*
+ * Some key combinations map to Windows ASCII keys depending
+ * on the keyboard. For example, Ctrl+Alt+Q maps to @ on a
+ * German keyboard. If the current key combination is special,
+ * the correct character is placed in wParam for processing in
+ * WM_CHAR. If this is the case, issue the key down event from
+ * inside WM_CHAR.
+ */
+ int newKey = display.asciiKey (wParam);
+ if (newKey != 0) {
+ /*
+ * When the user types Ctrl+Space, ToAscii () maps this to
+ * Space. Normally, ToAscii () maps a key to a different
+ * key if both a WM_KEYDOWN and a WM_CHAR will be issued.
+ * To avoid the extra OSxKeyDown, look for VK_SPACE and
+ * issue the event from WM_CHAR.
+ */
+ if (newKey == OS.VK_SPACE) {
+ display.lastVirtual = true;
+ return null;
+ }
+ if (newKey != wParam) return null;
+ }
+
+ /*
+ * If the control key is not down at this point, then
+ * the key that was pressed was an accent key. In that
+ * case, do not issue the key down event.
+ */
+ if (OS.GetKeyState (OS.VK_CONTROL) >= 0) {
+ display.lastKey = 0;
+ return null;
+ }
+
+ /*
+ * Virtual keys such as VK_RETURN are both virtual and ASCII keys.
+ * Normally, these are marked virtual in WM_CHAR. Since we will not
+ * be getting a WM_CHAR for the key at this point, we need to test LastKey
+ * to see if it is virtual. This happens when the user types Ctrl+Tab.
+ */
+ display.lastVirtual = display.isVirtualKey (display.lastKey);
+ display.lastAscii = display.controlKey (display.lastKey);
+ }
+ if (!sendKeyEvent (SWT.KeyDown, OS.WM_KEYDOWN, wParam, lParam)) {
+ return LRESULT.ZERO;
+ }
+ return null;
+}
+
+LRESULT WM_KEYUP (int wParam, int lParam) {
+
+ /*
+ * If the key up is not hooked, reset last key
+ * and last ascii in case the key down is hooked.
+ */
+ Display display = getDisplay ();
+ if (!hooks (SWT.KeyUp)) {
+ display.lastVirtual = false;
+ display.lastKey = display.lastAscii = 0;
+ }
+
+ /* Map the virtual key. */
+ int mapKey = OS.MapVirtualKey (wParam, 2);
+
+ /*
+ * Bug in Windows 95 and NT. When the user types an accent key such
+ * as ^ to get an accented character on a German keyboard, the accent
+ * key should be ignored and the next key that the user types is the
+ * accented key. On Windows 95 and NT, a call to ToAscii(), clears the
+ * accented state such that the next WM_CHAR loses the accent. The fix
+ * is to detect the accent key stroke (called a dead key) by testing the
+ * high bit of the value returned by MapVirtualKey(). A further problem
+ * is that the high bit on Windows NT is bit 32 while the high bit on
+ * Windows 95 is bit 16. They should both be bit 32.
+ */
+ if (IsWinNT) {
+ if ((mapKey & 0x80000000) != 0) return null;
+ } else {
+ if ((mapKey & 0x8000) != 0) return null;
+ }
+
+ display.lastVirtual = (mapKey == 0);
+ if (display.lastVirtual) {
+ display.lastKey = wParam;
+ } else {
+ if (display.lastKey == 0) {
+ display.lastAscii = 0;
+ return null;
+ }
+ display.lastVirtual = display.isVirtualKey (display.lastKey);
+ }
+ if (!sendKeyEvent (SWT.KeyUp, OS.WM_KEYUP, wParam, lParam)) {
+ return LRESULT.ZERO;
+ }
+ return null;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+
+ /* Build the focus out list */
+ int index = 0;
+ Control [] focusOut = getPath ();
+ Display display = getDisplay ();
+ Control control = display.findControl (wParam);
+ if (control != null) {
+ Control [] focusIn = control.getPath ();
+ int length = Math.min (focusIn.length, focusOut.length);
+ while (index < length) {
+ if (focusIn [index] != focusOut [index]) break;
+ index++;
+ }
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the focus
+ * out event. If this happens keep going to send
+ * the deactivate events.
+ */
+ sendEvent (SWT.FocusOut);
+ // widget could be disposed at this point
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets in
+ * the focus out event or the deactivate event. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=focusOut.length-1; i>=index; --i) {
+ if (!focusOut [i].isDisposed ()) {
+ focusOut [i].sendEvent (SWT.Deactivate);
+ }
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the focus
+ * or deactivate events. If this happens, end the
+ * processing of the Windows message by returning
+ * zero as the result of the window proc.
+ */
+ if (isDisposed ()) return LRESULT.ZERO;
+ return null;
+}
+
+LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Feature in Windows. Windows sends the following
+ * messages when the user double clicks the mouse:
+ *
+ * WM_LBUTTONDOWN - mouse down
+ * WM_LBUTTONUP - mouse up
+ * WM_LBUTTONDBLCLK - double click
+ * WM_LBUTTONUP - mouse up
+ *
+ * Applications that expect matching mouse down/up
+ * pairs will not see the second mouse down. The
+ * fix is to send a mouse down event.
+ */
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 1, OS.WM_LBUTTONDBLCLK, wParam, lParam);
+ int result = callWindowProc (OS.WM_LBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return new LRESULT (result);
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ int result = callWindowProc (OS.WM_LBUTTONDOWN, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ if (hooks (SWT.DragDetect)) {
+ POINT pt = new POINT ();
+ pt.x = (short) (lParam & 0xFFFF);
+ pt.y = (short) (lParam >> 16);
+ if (OS.DragDetect (handle, pt)) {
+ sendEvent (SWT.DragDetect);
+ // widget could be disposed at this point
+ }
+ }
+ return new LRESULT (result);
+}
+
+LRESULT WM_LBUTTONUP (int wParam, int lParam) {
+ sendMouseEvent (SWT.MouseUp, 1, OS.WM_LBUTTONUP, wParam, lParam);
+ int result = callWindowProc (OS.WM_LBUTTONUP, wParam, lParam);
+ if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ if (OS.GetCapture () == handle) OS.ReleaseCapture ();
+ return new LRESULT (result);
+}
+
+LRESULT WM_MBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Feature in Windows. Windows sends the following
+ * messages when the user double clicks the mouse:
+ *
+ * WM_MBUTTONDOWN - mouse down
+ * WM_MBUTTONUP - mouse up
+ * WM_MLBUTTONDBLCLK - double click
+ * WM_MBUTTONUP - mouse up
+ *
+ * Applications that expect matching mouse down/up
+ * pairs will not see the second mouse down. The
+ * fix is to send a mouse down event.
+ */
+ sendMouseEvent (SWT.MouseDown, 2, OS.WM_MBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 2, OS.WM_MBUTTONDBLCLK, wParam, lParam);
+ int result = callWindowProc (OS.WM_MBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return new LRESULT (result);
+}
+
+LRESULT WM_MBUTTONDOWN (int wParam, int lParam) {
+ sendMouseEvent (SWT.MouseDown, 2, OS.WM_MBUTTONDOWN, wParam, lParam);
+ int result = callWindowProc (OS.WM_MBUTTONDOWN, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture(handle);
+ return new LRESULT (result);
+}
+
+LRESULT WM_MBUTTONUP (int wParam, int lParam) {
+ sendMouseEvent (SWT.MouseUp, 2, OS.WM_MBUTTONUP, wParam, lParam);
+ int result = callWindowProc (OS.WM_MBUTTONUP, wParam, lParam);
+ if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ if (OS.GetCapture () == handle) OS.ReleaseCapture ();
+ return new LRESULT (result);
+}
+
+LRESULT WM_MEASUREITEM (int wParam, int lParam) {
+ MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
+ if (struct.CtlType == OS.ODT_MENU) {
+ Decorations shell = menuShell ();
+ MenuItem item = shell.findMenuItem (struct.itemID);
+ if (item == null) return null;
+ return item.wmMeasureChild (wParam, lParam);
+ }
+ int hwnd = OS.GetDlgItem (handle, struct.CtlID);
+ Control control = WidgetTable.get (hwnd);
+ if (control == null) return null;
+ return control.wmMeasureChild (wParam, lParam);
+}
+
+LRESULT WM_MENUCHAR (int wParam, int lParam) {
+ Display display = getDisplay ();
+ display.mnemonicKeyHit = false;
+ /*
+ * Feature in Windows. When the user types Alt+<key>
+ * and <key> does not match a mnemonic in the System
+ * menu or the menu bar, Windows beeps. This beep is
+ * unexpected and unwanted by applications that look
+ * for Alt+<key>. The fix is to detect the case and
+ * stop Windows from beeping by closing the menu.
+ */
+ int type = wParam >> 16;
+ if (type == 0 || type == OS.MF_SYSMENU) {
+ return new LRESULT (OS.MNC_CLOSE << 16);
+ }
+ return null;
+}
+
+LRESULT WM_MENUSELECT (int wParam, int lParam) {
+ int code = wParam >> 16;
+ Shell shell = getShell ();
+ if (code == -1 && lParam == 0) {
+ Menu menu = shell.activeMenu;
+ while (menu != null) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the hide
+ * event. If this happens, stop searching up the
+ * parent list because there is no longer a link
+ * to follow.
+ */
+ menu.sendEvent (SWT.Hide);
+ if (menu.isDisposed ()) break;
+ menu = menu.getParentMenu ();
+ }
+ /*
+ * The shell may be disposed because of sending the hide
+ * event to the last active menu menu but setting a field
+ * to null in a destroyed widget is not harmful.
+ */
+ shell.activeMenu = null;
+ return null;
+ }
+ if ((code & OS.MF_SYSMENU) != 0) return null;
+ if ((code & OS.MF_HILITE) != 0) {
+ MenuItem item = null;
+ Decorations menuShell = menuShell ();
+ if ((code & OS.MF_POPUP) != 0) {
+ int index = wParam & 0xFFFF;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_SUBMENU;
+ if (OS.GetMenuItemInfo (lParam, index, true, info)) {
+ Menu newMenu = menuShell.findMenu (info.hSubMenu);
+ if (newMenu != null) item = newMenu.cascade;
+ }
+ } else {
+ Menu newMenu = menuShell.findMenu (lParam);
+ if (newMenu != null) {
+ int id = wParam & 0xFFFF;
+ item = menuShell.findMenuItem (id);
+ }
+ Menu oldMenu = shell.activeMenu;
+ if (oldMenu != null) {
+ Menu ancestor = oldMenu;
+ while (ancestor != null && ancestor != newMenu) {
+ ancestor = ancestor.getParentMenu ();
+ }
+ if (ancestor == newMenu) {
+ ancestor = oldMenu;
+ while (ancestor != newMenu) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the hide
+ * event or the item about to be armed. If this
+ * happens, stop searching up the ancestor list
+ * because there is no longer a link to follow.
+ */
+ ancestor.sendEvent (SWT.Hide);
+ if (ancestor.isDisposed ()) break;
+ ancestor = ancestor.getParentMenu ();
+ }
+ /*
+ * The shell and/or the item could be disposed when
+ * processing hide events from above. If this happens,
+ * ensure that the shell is not accessed and that no
+ * arm event is sent to the item.
+ */
+ if (!shell.isDisposed ()) {
+ if (newMenu != null && newMenu.isDisposed ()) {
+ newMenu = null;
+ }
+ shell.activeMenu = newMenu;
+ }
+ if (item != null && item.isDisposed ()) item = null;
+ }
+ }
+ }
+ if (item != null) item.sendEvent (SWT.Arm);
+ }
+ return null;
+}
+
+LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_MOUSEHOVER (int wParam, int lParam) {
+ int pos = OS.GetMessagePos ();
+ Event event = new Event ();
+ event.time = OS.GetMessageTime ();
+ POINT pt = new POINT ();
+ pt.x = (short) (pos & 0xFFFF);
+ pt.y = (short) (pos >> 16);
+ OS.ScreenToClient (handle, pt);
+ event.x = pt.x;
+ event.y = pt.y;
+ postEvent (SWT.MouseHover, event);
+ return null;
+}
+
+LRESULT WM_MOUSELEAVE (int wParam, int lParam) {
+ int pos = OS.GetMessagePos ();
+ Event event = new Event ();
+ event.time = OS.GetMessageTime ();
+ POINT pt = new POINT ();
+ pt.x = (short) (pos & 0xFFFF);
+ pt.y = (short) (pos >> 16);
+ OS.ScreenToClient (handle, pt);
+ event.x = pt.x;
+ event.y = pt.y;
+ postEvent (SWT.MouseExit, event);
+ return null;
+}
+
+LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
+ boolean hooksMouseEnter = hooks (SWT.MouseEnter);
+ if (hooksMouseEnter || hooks (SWT.MouseExit) || hooks (SWT.MouseHover)) {
+ TRACKMOUSEEVENT lpEventTrack = new TRACKMOUSEEVENT ();
+ lpEventTrack.cbSize = TRACKMOUSEEVENT.sizeof;
+ lpEventTrack.dwFlags = OS.TME_QUERY;
+ lpEventTrack.hwndTrack = handle;
+ OS.TrackMouseEvent (lpEventTrack);
+ if (lpEventTrack.dwFlags == 0) {
+ lpEventTrack.dwFlags = OS.TME_LEAVE | OS.TME_HOVER;
+ lpEventTrack.hwndTrack = handle;
+ OS.TrackMouseEvent (lpEventTrack);
+ if (hooksMouseEnter) {
+ Event event = new Event ();
+ event.time = OS.GetMessageTime ();
+ event.x = (short) (lParam & 0xFFFF);
+ event.y = (short) (lParam >> 16);
+ postEvent (SWT.MouseEnter, event);
+ }
+ } else {
+ lpEventTrack.dwFlags = OS.TME_HOVER;
+ OS.TrackMouseEvent (lpEventTrack);
+ }
+ }
+ Display display = getDisplay ();
+ int pos = OS.GetMessagePos ();
+ if (pos != display.lastMouse) {
+ display.lastMouse = pos;
+ sendMouseEvent (SWT.MouseMove, 0, OS.WM_MOUSEMOVE, wParam, lParam);
+ }
+ return null;
+}
+
+LRESULT WM_MOVE (int wParam, int lParam) {
+ sendEvent (SWT.Move);
+ // widget could be disposed at this point
+ return null;
+}
+
+LRESULT WM_NCACTIVATE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_NCCALCSIZE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_NCHITTEST (int wParam, int lParam) {
+ if (!isActive ()) return new LRESULT (OS.HTTRANSPARENT);
+ return null;
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ int hwnd = hdr.hwndFrom;
+ if (hwnd == 0) return null;
+ Control control = WidgetTable.get (hwnd);
+ if (control == null) return null;
+ return control.wmNotifyChild (wParam, lParam);
+}
+
+LRESULT WM_PAINT (int wParam, int lParam) {
+
+ /* Exit early - don't draw the background */
+ if (!hooks (SWT.Paint)) return null;
+
+ /* Get the damage */
+ int rgn = 0;
+ rgn = OS.CreateRectRgn (0, 0, 0, 0);
+ OS.GetUpdateRgn (handle, rgn, false);
+ int result = callWindowProc (OS.WM_PAINT, wParam, lParam);
+ OS.InvalidateRgn (handle, rgn, false);
+ OS.DeleteObject (rgn);
+
+ /* Create the paint GC */
+ PAINTSTRUCT ps = new PAINTSTRUCT ();
+ GCData data = new GCData ();
+ data.ps = ps;
+ GC gc = GC.win32_new (this, data);
+
+ /* Send the paint event */
+ Event event = new Event ();
+ event.gc = gc;
+ event.x = ps.left;
+ event.y = ps.top;
+ event.width = ps.right - ps.left;
+ event.height = ps.bottom - ps.top;
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the paint
+ * event. If this happens, attempt to give back the
+ * paint GC anyways because this is a scarce Windows
+ * resource.
+ */
+ sendEvent (SWT.Paint, event);
+ // widget could be disposed at this point
+
+ /* Dispose the paint GC */
+ event.gc = null;
+ gc.dispose ();
+
+ if (result == 0) return LRESULT.ZERO;
+ return new LRESULT (result);
+}
+
+LRESULT WM_PALETTECHANGED (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_PASTE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_QUERYOPEN (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Feature in Windows. Windows sends the following
+ * messages when the user double clicks the mouse:
+ *
+ * WM_RBUTTONDOWN - mouse down
+ * WM_RBUTTONUP - mouse up
+ * WM_RBUTTONDBLCLK - double click
+ * WM_LBUTTONUP - mouse up
+ *
+ * Applications that expect matching mouse down/up
+ * pairs will not see the second mouse down. The
+ * fix is to send a mouse down event.
+ */
+ sendMouseEvent (SWT.MouseDown, 3, OS.WM_RBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 3, OS.WM_RBUTTONDBLCLK, wParam, lParam);
+ int result = callWindowProc (OS.WM_RBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return new LRESULT (result);
+}
+
+LRESULT WM_RBUTTONDOWN (int wParam, int lParam) {
+ sendMouseEvent (SWT.MouseDown, 3, OS.WM_RBUTTONDOWN, wParam, lParam);
+ int result = callWindowProc (OS.WM_RBUTTONDOWN, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return new LRESULT (result);
+}
+
+LRESULT WM_RBUTTONUP (int wParam, int lParam) {
+ sendMouseEvent (SWT.MouseUp, 3, OS.WM_RBUTTONUP, wParam, lParam);
+ int result = callWindowProc (OS.WM_RBUTTONUP, wParam, lParam);
+ if ((wParam & (OS.MK_LBUTTON | OS.MK_MBUTTON | OS.MK_RBUTTON)) == 0)
+ if (OS.GetCapture () == handle) OS.ReleaseCapture ();
+ return new LRESULT (result);
+}
+
+LRESULT WM_SETCURSOR (int wParam, int lParam) {
+ int hitTest = lParam & 0xFFFF;
+ if (hitTest == OS.HTCLIENT) {
+ Control control = WidgetTable.get (wParam);
+ if (control == null) return null;
+ int hCursor = control.findCursor ();
+ if (hCursor != 0) {
+ OS.SetCursor (hCursor);
+ return LRESULT.ONE;
+ }
+ }
+ return null;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+
+ /* Build the focus in list */
+ int index = 0;
+ Control [] focusIn = getPath ();
+ Display display = getDisplay ();
+ Control control = display.findControl (wParam);
+ if (control != null) {
+ Control [] focusOut = control.getPath ();
+ int length = Math.min (focusIn.length, focusOut.length);
+ while (index < length) {
+ if (focusIn [index] != focusOut [index]) break;
+ index++;
+ }
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the focus
+ * in event. If this happens keep going to send
+ * the activate events.
+ */
+ sendEvent (SWT.FocusIn);
+ // widget could be disposed at this point
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have destroyed some of the widgets in
+ * the focus in event or the activate event. If
+ * this happens, keep processing those widgets that
+ * are not disposed.
+ */
+ for (int i=focusIn.length-1; i>=index; --i) {
+ if (!focusIn [i].isDisposed ()) {
+ focusIn [i].sendEvent (SWT.Activate);
+ }
+ }
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the focus
+ * or activate events. If this happens, end the
+ * processing of the Windows message by returning
+ * zero as the result of the window proc.
+ */
+ if (isDisposed ()) return LRESULT.ZERO;
+ return null;
+}
+
+LRESULT WM_SETFONT (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_SHOWWINDOW (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ sendEvent (SWT.Resize);
+ // widget could be disposed at this point
+ return null;
+}
+
+LRESULT WM_SYSCHAR (int wParam, int lParam) {
+ Display display = getDisplay ();
+
+ /* Set last key and last ascii because a new key has been typed */
+ display.lastAscii = display.lastKey = wParam;
+ display.lastVirtual = display.isVirtualKey (display.lastKey);
+
+ /* Do not issue a key down if a menu bar mnemonic was invoked */
+ if (!hooks (SWT.KeyDown)) return null;
+ display.mnemonicKeyHit = true;
+ int result = callWindowProc (OS.WM_SYSCHAR, wParam, lParam);
+ if (!display.mnemonicKeyHit) {
+ sendKeyEvent (SWT.KeyDown, OS.WM_SYSCHAR, wParam, lParam);
+ }
+ display.mnemonicKeyHit = false;
+ return new LRESULT (result);
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_SYSCOMMAND (int wParam, int lParam) {
+ /*
+ * Check to see if the command is a system command or
+ * a user menu item that was added to the System menu.
+ * When a user item is added to the System menu,
+ * WM_SYSCOMMAND must always return zero.
+ */
+ if ((wParam & 0xF000) == 0) {
+ Decorations shell = menuShell ();
+ if (shell.isEnabled ()) {
+ MenuItem item = shell.findMenuItem (wParam & 0xFFFF);
+ if (item != null) item.wmCommandChild (wParam, lParam);
+ }
+ return LRESULT.ZERO;
+ }
+
+ /* Process the System Command */
+ int cmd = wParam & 0xFFF0;
+ switch (cmd) {
+ case OS.SC_CLOSE:
+ int hwndShell = menuShell ().handle;
+ int bits = OS.GetWindowLong (hwndShell, OS.GWL_STYLE);
+ if ((bits & OS.WS_SYSMENU) == 0) return LRESULT.ZERO;
+ break;
+ case OS.SC_KEYMENU:
+ case OS.SC_HSCROLL:
+ case OS.SC_VSCROLL:
+ /*
+ * Do not allow keyboard traversal of the menu bar
+ * or scrolling when the shell is not enabled.
+ */
+ if (!menuShell ().isEnabled ()) return LRESULT.ZERO;
+ break;
+ case OS.SC_MINIMIZE:
+ /* Save the focus widget when the shell is minimized */
+ menuShell ().saveFocus ();
+ break;
+ }
+ return null;
+}
+
+LRESULT WM_SYSKEYDOWN (int wParam, int lParam) {
+ Display display = getDisplay ();
+
+ /*
+ * Feature in Windows. WM_SYSKEYDOWN is sent when
+ * the user presses ALT-<aKey> or F10 without the ALT key.
+ * In order to issue events for F10 (without the ALT key)
+ * but ignore all other key presses without the ALT key,
+ * make F10 a special case.
+ */
+ if (wParam != OS.VK_F10) {
+ /* Make sure WM_SYSKEYDOWN was sent by ALT-<aKey>. */
+ if ((lParam & 0x20000000) == 0) return null;
+ }
+
+ /* If are going to get a WM_SYSCHAR, ignore this message. */
+ if (OS.MapVirtualKey (wParam, 2) != 0) return null;
+
+ /* Ignore repeating keys for modifiers by testing key down state. */
+ if ((wParam == OS.VK_SHIFT) || (wParam == OS.VK_MENU) ||
+ (wParam == OS.VK_CONTROL) || (wParam == OS.VK_CAPITAL) ||
+ (wParam == OS.VK_NUMLOCK) || (wParam == OS.VK_SCROLL))
+ if ((lParam & 0x40000000) != 0) return null;
+
+ /* Set last key and clear last ascii because a new key has been typed. */
+ display.lastAscii = 0;
+ display.lastKey = wParam;
+ display.lastVirtual = true;
+
+ if (!sendKeyEvent (SWT.KeyDown, OS.WM_SYSKEYDOWN, wParam, lParam)) {
+ return LRESULT.ZERO;
+ }
+ return null;
+}
+
+LRESULT WM_SYSKEYUP (int wParam, int lParam) {
+ return WM_KEYUP (wParam, lParam);
+}
+
+LRESULT WM_TIMER (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_UNDO (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT WM_VSCROLL (int wParam, int lParam) {
+ if (lParam == 0) return null;
+ Control control = WidgetTable.get (lParam);
+ if (control == null) return null;
+ return control.wmScrollChild (wParam, lParam);
+}
+
+LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT wmColorChild (int wParam, int lParam) {
+ if (background == -1 && foreground == -1) return null;
+ int forePixel = foreground, backPixel = background;
+ if (forePixel == -1) forePixel = defaultForeground ();
+ if (backPixel == -1) backPixel = defaultBackground ();
+ OS.SetTextColor (wParam, forePixel);
+ OS.SetBkColor (wParam, backPixel);
+ return new LRESULT (findBrush (backPixel));
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT wmDrawChild (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT wmMeasureChild (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ return null;
+}
+
+LRESULT wmScrollChild (int wParam, int lParam) {
+ return null;
+}
+
+}
+
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
new file mode 100755
index 0000000000..2fe5c21f74
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java
@@ -0,0 +1,567 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide an area for dynamically
+ * positioning the items they contain.
+ * <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>
+ */
+
+public class CoolBar extends Composite {
+
+ CoolItem [] items;
+ static final int ReBarProc;
+ static final byte [] ReBarClass = OS.REBARCLASSNAME;
+ static {
+ INITCOMMONCONTROLSEX icex = new INITCOMMONCONTROLSEX ();
+ icex.dwSize = INITCOMMONCONTROLSEX.sizeof;
+ icex.dwICC = OS.ICC_COOL_CLASSES;
+ OS.InitCommonControlsEx (icex);
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ReBarClass, lpWndClass);
+ ReBarProc = lpWndClass.lpfnWndProc;
+ }
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ReBarProc, handle, msg, wParam, lParam);
+}
+
+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 ();
+ int height = 0, width = 0;
+ RECT rect = new RECT ();
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_IDEALSIZE;
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_GETRECT, i, rect);
+ height = Math.max (height, rect.bottom - rect.top);
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ width += rbBand.cxIdeal;
+ }
+ if (count != 0) width += 4;
+ 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 () {
+ super.createHandle ();
+ state &= ~CANVAS;
+
+ /*
+ * Feature in Windows. When the control is created,
+ * it does not use the default system font. A new HFONT
+ * is created and destroyed when the control is destroyed.
+ * This means that a program that queries the font from
+ * this control, uses the font in another control and then
+ * destroys this control will have the font unexpectedly
+ * destroyed in the other control. The fix is to assign
+ * the font ourselves each time the control is created.
+ * The control will not destroy a font that it did not
+ * create.
+ */
+ int hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
+}
+
+void createItem (CoolItem item, int index) {
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int id = 0;
+ while (id < items.length && items [id] != null) id++;
+ if (id == items.length) {
+ CoolItem [] newItems = new CoolItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ int hHeap = OS.GetProcessHeap ();
+ int lpText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 1);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_TEXT | OS.RBBIM_STYLE | OS.RBBIM_ID;
+ rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS;
+ rbBand.lpText = lpText;
+ rbBand.wID = id;
+ if (OS.SendMessage (handle, OS.RB_INSERTBAND, index, rbBand) == 0) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+ OS.HeapFree (hHeap, 0, lpText);
+ items [item.id = id] = item;
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new CoolItem [4];
+}
+
+void destroyItem (CoolItem item) {
+ int index = OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
+ /*
+ * Feature in Windows. When Windows removed a rebar
+ * band, it makes the band child invisible. The fix
+ * is to show the child.
+ */
+ Control control = item.control;
+ boolean wasVisible = control != null && control.getVisible ();
+ if (OS.SendMessage (handle, OS.RB_DELETEBAND, index, 0) == 0) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ items [item.id] = null;
+ item.id = -1;
+ if (wasVisible) control.setVisible (true);
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public CoolItem getItem (int index) {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_ID;
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, index, rbBand);
+ return items [rbBand.wID];
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int getItemCount () {
+ checkWidget ();
+ return OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+}
+
+/**
+ * Returns an array of <code>CoolItems</code>s which are the
+ * items in the receiver in the order those items were added.
+ * <p>
+ * Note: This is not the actual structure used by the receiver
+ * to maintain its list of items, so modifying the array will
+ * not effect 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public CoolItem [] getItems () {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ CoolItem [] result = new CoolItem [count];
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_ID;
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_GETBANDINFO, i, rbBand);
+ result [i] = items [rbBand.wID];
+ }
+ return result;
+}
+
+/**
+ * Searches the receiver's items, in the order they were
+ * added, 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 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 (CoolItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return OS.SendMessage (handle, OS.RB_IDTOINDEX, item.id, 0);
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ CoolItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseWidget ();
+ }
+ }
+ items = null;
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ background = pixel;
+ if (pixel == -1) pixel = defaultBackground ();
+ OS.SendMessage (handle, OS.RB_SETBKCOLOR, 0, pixel);
+ setItemColors (OS.SendMessage (handle, OS.RB_GETTEXTCOLOR, 0, 0), pixel);
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+ if (pixel == -1) pixel = defaultForeground ();
+ OS.SendMessage (handle, OS.RB_SETTEXTCOLOR, 0, pixel);
+ setItemColors (pixel, OS.SendMessage (handle, OS.RB_GETBKCOLOR, 0, 0));
+}
+
+void setItemColors (int foreColor, int backColor) {
+ int count = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_COLORS;
+ rbBand.clrFore = foreColor;
+ rbBand.clrBack = backColor;
+ for (int i=0; i<count; i++) {
+ OS.SendMessage (handle, OS.RB_SETBANDINFO, i, rbBand);
+ }
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.CCS_NODIVIDER | OS.CCS_NORESIZE;
+ bits |= OS.RBS_VARHEIGHT | OS.RBS_BANDBORDERS;
+ return bits;
+}
+
+byte [] windowClass () {
+ return ReBarClass;
+}
+
+int windowProc () {
+ return ReBarProc;
+}
+
+LRESULT WM_COMMAND (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the coolbar window
+ * proc processes WM_COMMAND, it forwards this
+ * message to the parent. This is done so that
+ * children of the coolbar that send WM_COMMAND
+ * messages to their parents will notify not only
+ * the coolbar but also the parent of the coolbar,
+ * which is typically the application window and
+ * the window that is looking for this message.
+ * If the coolbar did not do this, applications
+ * would have to subclass the coolbar window to
+ * see WM_COMMAND messages. Because the coolbar
+ * window is subclassed, the WM_COMMAND message
+ * is delivered twice. The fix is to avoid
+ * calling the coolbar window proc.
+ */
+ LRESULT result = super.WM_COMMAND (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ /*
+ * Feature in Windows. For some reason, Windows
+ * does not fully erase the area that the cool bar
+ * occupies when the size of the cool bar grows.
+ * The fix is to erase the cool bar background.
+ */
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ drawBackground (wParam, rect);
+ return null;
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ case OS.RBN_HEIGHTCHANGE:
+ Point size = getSize ();
+ int border = getBorderWidth ();
+ int height = OS.SendMessage (handle, OS.RB_GETBARHEIGHT, 0, 0);
+ setSize (size.x, height + (border * 2));
+ break;
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+
+/**
+ * Returns an array of zero-relative indices which map the order
+ * that the items in the receiver were added in (which is the
+ * order that they are returned by <code>getItems()</code>) to
+ * the order 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 effect the receiver.
+ * </p>
+ *
+ * @return the receiver's item 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 SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int [] getItemOrder () {
+ checkWidget ();
+ CoolItem [] items = getItems ();
+ int [] indices = new int [items.length];
+ for (int i = 0; i < items.length; i++) {
+ indices [i] = items [i].id;
+ }
+ return indices;
+}
+
+/**
+ * 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 the items were added.
+ *
+ * @return the receiver's item sizes
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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;
+}
+
+/**
+ * Returns an array of ints which describe the zero-relative
+ * row number of the row which each of the items in the
+ * receiver occurs in, in the order the items were added.
+ *
+ * @return the receiver's wrap indices
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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 ();
+ CoolItem [] items = getItems ();
+ int [] indices = new int [items.length];
+ int count = 0;
+ for (int i = 0; i < items.length; i++) {
+ if (items [i].getWrap ()) {
+ indices [count] = i;
+ count++;
+ }
+ }
+ int [] answer = new int [count];
+ System.arraycopy(indices, 0, answer, 0, count);
+ return answer;
+}
+
+/**
+ * Sets the 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 itemOrder the new item 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 SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+void setItemOrder (int [] itemOrder) {
+ if (itemOrder == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int itemCount = OS.SendMessage (handle, OS.RB_GETBANDCOUNT, 0, 0);
+ if (itemOrder.length != itemCount) error (SWT.ERROR_INVALID_ARGUMENT);
+ for (int i = 0; i < itemCount; i++) {
+ int currentIndex = OS.SendMessage (handle, OS.RB_IDTOINDEX, itemOrder [i], 0);
+ OS.SendMessage (handle, OS.RB_MOVEBAND, currentIndex, i);
+ }
+}
+
+/**
+ * Sets the width and height of the areas in the receiver which
+ * are used to display its items to the ones specified by the
+ * argument, which is an array of points whose x and y coordinates
+ * describe the widths and heights (respectively) in the order the
+ * items were added.
+ *
+ * @param sizes the new sizes for each 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>
+ */
+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]);
+ }
+}
+
+/**
+ * Sets the row that each of the receiver's items will be
+ * displayed in to the given array of ints which describe
+ * the zero-relative row number of the row for each item
+ * in the order the items were added.
+ *
+ * @param indices the new wrap indices
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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) error (SWT.ERROR_NULL_ARGUMENT);
+ CoolItem [] items = getItems ();
+ for (int i = 0; i < items.length; i++) {
+ items [i].setWrap (false);
+ }
+ for (int i = 0; i < indices.length; i++) {
+ int index = indices [i];
+ items [index].setWrap (true);
+ }
+}
+
+/**
+ * Sets the receiver's item order, wrap indices, and item
+ * sizes at once. This equivalent to calling the setter
+ * methods for each of these values individually.
+ *
+ * @param itemOrder the new item order
+ * @param wrapIndices the new wrap indices
+ * @param size the new item sizes
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public void setItemLayout (int [] itemOrder, int [] wrapIndices, Point [] sizes) {
+ checkWidget ();
+ setItemOrder (itemOrder);
+ setItemSizes (sizes);
+ setWrapIndices(wrapIndices);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
new file mode 100755
index 0000000000..d23653a8c4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -0,0 +1,381 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * 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>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class CoolItem extends Item {
+ CoolBar parent;
+ Control control;
+ int id;
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 CoolItem (CoolBar parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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>
+ * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
+ * </ul>
+ *
+ * @see SWT
+ * @see Widget#checkSubclass
+ * @see Widget#getStyle
+ */
+public CoolItem (CoolBar parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * Returns the preferred size of the receiver.
+ * <p>
+ * The <em>prefered 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
+ */
+public Point computeSize (int wHint, int hHint) {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return new Point (0, 0);
+ int width = wHint, height = hHint;
+ if (wHint == SWT.DEFAULT) width = 32;
+ if (hHint == SWT.DEFAULT) height = 32;
+ int hwnd = parent.handle;
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, rect);
+ width += rect.left + rect.right;
+ height += rect.top + rect.bottom;
+ if (index == 0) {
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_HEADERSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ width = width - rbBand.cxHeader + 1;
+ }
+ return new Point (width, height);
+}
+
+/**
+ * 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 ();
+ int index = parent.indexOf (this);
+ if (index == -1) return new Rectangle (0, 0, 0, 0);
+ int hwnd = parent.handle;
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+}
+
+/*
+* Not currently used.
+*/
+Rectangle getClientArea () {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return new Rectangle (0, 0, 0, 0);
+ int hwnd = parent.handle;
+ RECT insetRect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, insetRect);
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
+ int x = rect.left + insetRect.left;
+ int y = rect.top + insetRect.top;
+ int width = rect.right - rect.left - (insetRect.left + insetRect.right);
+ int height = rect.bottom - rect.top - (insetRect.top + insetRect.bottom);
+ if (index == 0) {
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_HEADERSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ width = width - rbBand.cxHeader + 1;
+ }
+ return new Rectangle (x, y, width, height);
+}
+
+/**
+ * Gets the control which is associated with the receiver.
+ *
+ * @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;
+}
+
+public Display getDisplay () {
+ CoolBar parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ control = null;
+ parent = null;
+}
+
+/**
+ * Sets the control which is associated with the receiver
+ * to the argument.
+ *
+ * @param control the new 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 void setControl (Control control) {
+ checkWidget ();
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ Control newControl = control;
+ Control oldControl = this.control;
+ int hwnd = parent.handle;
+ int hwndChild = 0;
+ if (newControl != null) hwndChild = control.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILD;
+ rbBand.hwndChild = hwndChild;
+ this.control = newControl;
+
+ /*
+ * Feature in Windows. When Windows sets the rebar band child,
+ * it makes the new child visible and hides the old child. The
+ * fix is to save and restore the visibility of the controls.
+ */
+ boolean hideNew = newControl != null && !newControl.getVisible ();
+ boolean showOld = oldControl != null && oldControl.getVisible ();
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+ if (hideNew) newControl.setVisible (false);
+ if (showOld) oldControl.setVisible (true);
+}
+
+public Point getPreferredSize () {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return null;
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ return new Point (rbBand.cxIdeal, rbBand.cyMinChild);
+}
+
+public void setPreferredSize (int width, int height) {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE | OS.RBBIM_SIZE;
+ rbBand.cx = rbBand.cxIdeal = width;
+ rbBand.cyMinChild = rbBand.cyMaxChild = height;
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+public void setPreferredSize (Point size) {
+ checkWidget ();
+ setPreferredSize (size.x, size.y);
+}
+
+public Point getSize() {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return null;
+ int hwnd = parent.handle;
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Point (width, height);
+}
+
+public void setSize (int width, int height) {
+ checkWidget ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_SIZE;
+ rbBand.cx = width;
+ rbBand.cyChild = height;
+ Point preferred = getPreferredSize();
+ if (preferred != null) {
+ rbBand.cyMinChild = rbBand.cyMaxChild = preferred.y;
+ } else {
+ rbBand.cyMinChild = rbBand.cyMaxChild = height;
+ }
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+public void setSize (Point size) {
+ checkWidget ();
+ setSize (size.x, size.y);
+}
+
+boolean getWrap() {
+ int index = parent.indexOf (this);
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_STYLE;
+ OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
+ return (rbBand.fStyle & OS.RBBS_BREAK) != 0;
+}
+
+void setWrap(boolean wrap) {
+ int index = parent.indexOf (this);
+ int hwnd = parent.handle;
+ REBARBANDINFO rbBand = new REBARBANDINFO ();
+ rbBand.cbSize = REBARBANDINFO.sizeof;
+ rbBand.fMask = OS.RBBIM_STYLE;
+ if (wrap) {
+ rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS | OS.RBBS_BREAK;
+ } else {
+ rbBand.fStyle = OS.RBBS_VARIABLEHEIGHT | OS.RBBS_GRIPPERALWAYS;
+ }
+ OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
new file mode 100755
index 0000000000..938e00b119
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java
@@ -0,0 +1,1000 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ * 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), it's 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</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
+ */
+
+public class Decorations extends Canvas {
+
+ Image image;
+ Menu menuBar;
+ Menu [] menus;
+ MenuItem [] items;
+ Control savedFocus;
+ Button defaultButton, saveDefault;
+ int swFlags, hAccel;
+
+/**
+ * Prevents uninitialized instances from being created outside the package.
+ */
+Decorations () {
+}
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 Decorations (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+void add (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;
+}
+
+void add (MenuItem item) {
+ if (items == null) items = new MenuItem [12];
+ for (int i=0; i<items.length; i++) {
+ if (items [i] == null) {
+ items [item.id = i] = item;
+ return;
+ }
+ }
+ MenuItem [] newItems = new MenuItem [items.length + 12];
+ newItems [item.id = items.length] = item;
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+}
+
+void bringToTop () {
+ /*
+ * This code is intentionally commented. On some platforms,
+ * the NO_TRIM style creates a shell that will stay on top
+ * of every other shell on the desktop. Using SetWindowPos ()
+ * with HWND_TOP caused problems on Windows so this code is
+ * commented out until this functionality is specified and
+ * the problems are fixed.
+ */
+// if ((style & SWT.NO_TRIM) != 0) {
+// int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
+// OS.SetWindowPos (handle, OS.HWND_TOP, 0, 0, 0, 0, flags);
+// } else {
+ OS.BringWindowToTop (handle);
+// }
+}
+
+static int checkStyle (int style) {
+ 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 createAcceleratorTable () {
+ hAccel = 0;
+ if ((menuBar == null) || (items == null)) return;
+ int nAccel = 0;
+ int size = ACCEL.sizeof;
+ ACCEL accel = new ACCEL ();
+ byte [] buffer1 = new byte [size];
+ byte [] buffer2 = new byte [items.length * size];
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (item != null && item.accelerator != 0) {
+ Menu parent = item.parent;
+ while (parent != null && parent != menuBar) {
+ parent = parent.getParentMenu ();
+ }
+ if (parent == menuBar) {
+ item.fillAccel (accel);
+ OS.MoveMemory (buffer1, accel, size);
+ System.arraycopy (buffer1, 0, buffer2, nAccel * size, size);
+ nAccel++;
+ }
+ }
+ }
+ if (nAccel != 0) hAccel = OS.CreateAcceleratorTable (buffer2, nAccel);
+}
+
+void createHandle () {
+ super.createHandle ();
+ if (parent == null) return;
+ setParent ();
+ setSystemMenu ();
+}
+
+void createWidget () {
+ /*
+ * Bug in Windows. If WS_MINIMIZEBOX or WS_MAXIMIZEBOX
+ * are set, we must also set WS_SYSMENU or the buttons
+ * will not appear.
+ */
+ if ((style & (SWT.MIN | SWT.MAX)) != 0) style |= SWT.CLOSE;
+ super.createWidget ();
+ swFlags = OS.SW_SHOWNOACTIVATE;
+ hAccel = -1;
+}
+
+Control currentTabGroup () {
+ return this;
+}
+
+void destroyAcceleratorTable () {
+ if ((hAccel != 0) && (hAccel != -1)) OS.DestroyAcceleratorTable (hAccel);
+ hAccel = -1;
+}
+
+Menu findMenu (int hMenu) {
+ if (menus == null) return null;
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if ((menu != null) && (hMenu == menu.handle)) return menu;
+ }
+ return null;
+}
+
+MenuItem findMenuItem (int id) {
+ if (items == null) return null;
+ if ((0 <= id) && (id < items.length)) return items [id];
+ return null;
+}
+
+public Rectangle getBounds () {
+ checkWidget ();
+ if (OS.IsIconic (handle)) {
+ WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
+ lpwndpl.length = WINDOWPLACEMENT.sizeof;
+ OS.GetWindowPlacement (handle, lpwndpl);
+ int width = lpwndpl.right - lpwndpl.left;
+ int height = lpwndpl.bottom - lpwndpl.top;
+ return new Rectangle (lpwndpl.left, lpwndpl.top, width, height);
+ }
+ return super.getBounds ();
+}
+
+public Rectangle getClientArea () {
+ checkWidget ();
+ RECT rect = new RECT ();
+ if (OS.IsIconic (handle)) {
+ WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
+ lpwndpl.length = WINDOWPLACEMENT.sizeof;
+ OS.GetWindowPlacement (handle, lpwndpl);
+ int width = lpwndpl.right - lpwndpl.left;
+ int height = lpwndpl.bottom - lpwndpl.top;
+ OS.SetRect (rect, 0, 0, width, height);
+ OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, rect);
+ return new Rectangle (0, 0, rect.right, rect.bottom);
+ }
+ return super.getClientArea ();
+}
+
+/**
+ * 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
+ */
+public Button getDefaultButton () {
+ checkWidget ();
+ return defaultButton;
+}
+
+/**
+ * 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;
+}
+
+public Point getLocation () {
+ checkWidget ();
+ if (OS.IsIconic (handle)) {
+ WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
+ lpwndpl.length = WINDOWPLACEMENT.sizeof;
+ OS.GetWindowPlacement (handle, lpwndpl);
+ return new Point (lpwndpl.left, lpwndpl.top);
+ }
+ return super.getLocation ();
+}
+
+/**
+ * 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 ();
+ if (OS.IsWindowVisible (handle)) return OS.IsZoomed (handle);
+ return swFlags == OS.SW_SHOWMAXIMIZED;
+}
+
+/**
+ * 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 ();
+ if (OS.IsWindowVisible (handle)) return OS.IsIconic (handle);
+ return swFlags == OS.SW_SHOWMINNOACTIVE;
+}
+
+String getNameText () {
+ return getText ();
+}
+
+public Point getSize () {
+ checkWidget ();
+ if (OS.IsIconic (handle)) {
+ WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
+ lpwndpl.length = WINDOWPLACEMENT.sizeof;
+ OS.GetWindowPlacement (handle, lpwndpl);
+ int width = lpwndpl.right - lpwndpl.left;
+ int height = lpwndpl.bottom - lpwndpl.top;
+ return new Point (width, height);
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Point (width, height);
+}
+
+/**
+ * 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 ();
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, buffer1.length);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+}
+
+Decorations menuShell () {
+ return this;
+}
+
+void releaseWidget () {
+ if (menuBar != null) {
+ menuBar.releaseWidget ();
+ menuBar.releaseHandle ();
+ }
+ menuBar = null;
+ if (menus != null) {
+ for (int i=0; i<menus.length; i++) {
+ Menu menu = menus [i];
+ if (menu != null && !menu.isDisposed ()) {
+ menu.dispose ();
+ }
+ }
+ }
+ menus = null;
+ super.releaseWidget ();
+ if (image != null) {
+ int hOld = OS.SendMessage (handle, OS.WM_GETICON, OS.ICON_BIG, 0);
+ if (hOld != 0 && image.handle != hOld) OS.DestroyIcon (hOld);
+ }
+ items = null;
+ image = null;
+ savedFocus = null;
+ defaultButton = saveDefault = null;
+ if (hAccel != 0 && hAccel != -1) OS.DestroyAcceleratorTable (hAccel);
+ hAccel = -1;
+}
+
+void remove (Menu menu) {
+ if (menus == null) return;
+ for (int i=0; i<menus.length; i++) {
+ if (menus [i] == menu) {
+ menus [i] = null;
+ return;
+ }
+ }
+}
+
+void remove (MenuItem item) {
+ if (items == null) return;
+ items [item.id] = null;
+ item.id = -1;
+}
+
+boolean restoreFocus () {
+ if (savedFocus != null && savedFocus.isDisposed ()) savedFocus = null;
+ if (savedFocus == null) return false;
+ return savedFocus.forceFocus ();
+}
+
+void saveFocus () {
+ Control control = getDisplay ().getFocusControl ();
+ if (control != null) setSavedFocus (control);
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ if (OS.IsIconic (handle)) {
+ WINDOWPLACEMENT lpwndpl = new WINDOWPLACEMENT ();
+ lpwndpl.length = WINDOWPLACEMENT.sizeof;
+ OS.GetWindowPlacement (handle, lpwndpl);
+ lpwndpl.showCmd = 0;
+ if ((flags & OS.SWP_NOMOVE) == 0) {
+ lpwndpl.left = x;
+ lpwndpl.top = y;
+ }
+ if ((flags & OS.SWP_NOSIZE) == 0) {
+ lpwndpl.right = x + width;
+ lpwndpl.bottom = y + height;
+ }
+ OS.SetWindowPlacement (handle, lpwndpl);
+ return;
+ }
+ super.setBounds (x, y, width, height, flags);
+}
+
+/**
+ * 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.
+ *
+ * @param the new default 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>
+ */
+public void setDefaultButton (Button button) {
+ checkWidget ();
+ setDefaultButton (button, true);
+}
+
+void setDefaultButton (Button button, boolean save) {
+ if (button == null) {
+ if (defaultButton == saveDefault) return;
+ } else {
+ if ((button.style & SWT.PUSH) == 0) return;
+ if (button == defaultButton) return;
+ }
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (false);
+ }
+ if ((defaultButton = button) == null) defaultButton = saveDefault;
+ if (defaultButton != null) {
+ if (!defaultButton.isDisposed ()) defaultButton.setDefault (true);
+ }
+ if (save || saveDefault == null) saveDefault = defaultButton;
+ if (saveDefault != null && saveDefault.isDisposed ()) saveDefault = null;
+}
+
+public boolean setFocus () {
+ checkWidget ();
+ if (this instanceof Shell) return super.setFocus ();
+ /*
+ * Bug in Windows. Setting the focus to a child of the
+ * receiver interferes with moving and resizing of the
+ * parent shell. The fix (for now) is to always set the
+ * focus to the shell.
+ */
+ int hwndFocus = OS.SetFocus (getShell ().handle);
+ return hwndFocus == OS.GetFocus ();
+}
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 ();
+ int hIcon = 0;
+ if (image != null) {
+ switch (image.type) {
+ case SWT.BITMAP:
+ int hOld = OS.SendMessage (handle, OS.WM_GETICON, OS.ICON_BIG, 0);
+ if (hOld != 0 && image != null) {
+ int hImage = this.image.handle;
+ if (hImage != hOld) OS.DestroyIcon (hOld);
+ }
+ /* Copy the bitmap in case it's a DIB */
+ int hBitmap = image.handle;
+ BITMAP bm = new BITMAP ();
+ OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+ byte [] lpvBits = new byte [(bm.bmWidth + 15) / 16 * 2 * bm.bmHeight];
+ int hMask = OS.CreateBitmap (bm.bmWidth, bm.bmHeight, 1, 1, lpvBits);
+ int hDC = OS.GetDC (handle);
+ int hdcMem = OS.CreateCompatibleDC (hDC);
+ int hColor = OS.CreateCompatibleBitmap (hDC, bm.bmWidth, bm.bmHeight);
+ OS.SelectObject (hdcMem, hColor);
+ int hdcBmp = OS.CreateCompatibleDC (hDC);
+ OS.SelectObject (hdcBmp, hBitmap);
+ OS.BitBlt (hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcBmp, 0, 0, OS.SRCCOPY);
+ ICONINFO info = new ICONINFO ();
+ info.fIcon = true;
+ info.hbmMask = hMask;
+ info.hbmColor = hColor;
+ hIcon = OS.CreateIconIndirect (info);
+ OS.DeleteObject (hMask);
+ OS.DeleteObject(hColor);
+ OS.DeleteDC (hdcBmp);
+ OS.DeleteDC (hdcMem);
+ OS.ReleaseDC (handle, hDC);
+ break;
+ case SWT.ICON:
+ hIcon = image.handle;
+ break;
+ default:
+ return;
+ }
+ }
+ this.image = image;
+ OS.SendMessage (handle, OS.WM_SETICON, OS.ICON_BIG, hIcon);
+
+ /*
+ * Bug in Windows. When WM_SETICON is used to remove an
+ * icon from the window trimmings for a window with the
+ * extended style bits WS_EX_DLGMODALFRAME, the window
+ * trimmings do not redraw to hide the previous icon.
+ * The fix is to force a redraw.
+ */
+ if (hIcon == 0 && ((style & SWT.BORDER) != 0)) {
+ OS.RedrawWindow (handle, null, 0, OS.RDW_FRAME | OS.RDW_INVALIDATE);
+ }
+}
+
+/**
+ * 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 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 ();
+ swFlags = OS.SW_RESTORE;
+ if (maximized) swFlags = OS.SW_SHOWMAXIMIZED;
+ if (!OS.IsWindowVisible (handle)) return;
+ if (maximized == OS.IsZoomed (handle)) return;
+ OS.ShowWindow (handle, swFlags);
+ OS.UpdateWindow (handle);
+}
+
+/**
+ * Sets the receiver's menu bar to the argument, which
+ * may be null.
+ *
+ * @param menu the new menu bar
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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;
+ int hMenu = 0;
+ if (menuBar != null) hMenu = menuBar.handle;
+ OS.SetMenu (handle, hMenu);
+ destroyAcceleratorTable ();
+}
+
+/**
+ * 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 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 ();
+ swFlags = OS.SW_RESTORE;
+ if (minimized) swFlags = OS.SW_SHOWMINNOACTIVE;
+ if (!OS.IsWindowVisible (handle)) return;
+ if (minimized == OS.IsIconic (handle)) return;
+ OS.ShowWindow (handle, swFlags);
+ OS.UpdateWindow (handle);
+}
+
+void setParent () {
+ /*
+ * In order for an MDI child window to support
+ * a menu bar, setParent () is needed to reset
+ * the parent. Otherwise, the MDI child window
+ * will appear as a separate shell. This is an
+ * undocumented and dangerous Windows feature.
+ */
+ Display display = getDisplay ();
+ int hwndParent = parent.handle;
+ display.lockActiveWindow = true;
+ OS.SetParent (handle, hwndParent);
+ if (!OS.IsWindowVisible (hwndParent)) {
+ OS.ShowWindow (handle, OS.SW_SHOWNA);
+ }
+ display.lockActiveWindow = false;
+}
+
+void setSavedFocus (Control control) {
+ if (this == control) {
+ savedFocus = null;
+ return;
+ }
+ if (this != control.menuShell ()) return;
+ savedFocus = control;
+}
+
+void setSystemMenu () {
+ int hMenu = OS.GetSystemMenu (handle, false);
+ if (hMenu == 0) return;
+ int oldCount = OS.GetMenuItemCount (hMenu);
+ if ((style & SWT.RESIZE) == 0) {
+ OS.DeleteMenu (hMenu, OS.SC_SIZE, OS.MF_BYCOMMAND);
+ }
+ if ((style & SWT.MIN) == 0) {
+ OS.DeleteMenu (hMenu, OS.SC_MINIMIZE, OS.MF_BYCOMMAND);
+ }
+ if ((style & SWT.MAX) == 0) {
+ OS.DeleteMenu (hMenu, OS.SC_MAXIMIZE, OS.MF_BYCOMMAND);
+ }
+ if ((style & (SWT.MIN | SWT.MAX)) == 0) {
+ OS.DeleteMenu (hMenu, OS.SC_RESTORE, OS.MF_BYCOMMAND);
+ }
+ int newCount = OS.GetMenuItemCount (hMenu);
+ if ((style & SWT.CLOSE) == 0 || newCount != oldCount) {
+ OS.DeleteMenu (hMenu, OS.SC_TASKLIST, OS.MF_BYCOMMAND);
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID;
+ int index = 0;
+ while (index < newCount) {
+ if (OS.GetMenuItemInfo (hMenu, index, true, info)) {
+ if (info.wID == OS.SC_CLOSE) break;
+ }
+ index++;
+ }
+ if (index != newCount) {
+ OS.DeleteMenu (hMenu, index - 1, OS.MF_BYPOSITION);
+ if ((style & SWT.CLOSE) == 0) {
+ OS.DeleteMenu (hMenu, OS.SC_CLOSE, OS.MF_BYCOMMAND);
+ }
+ }
+ }
+}
+
+/**
+ * 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 may not be null.
+ *
+ * @param text the new text
+ *
+ * @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>
+ */
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SetWindowText (handle, buffer);
+}
+
+public void setVisible (boolean visible) {
+ checkWidget ();
+ if (visible == OS.IsWindowVisible (handle)) 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.DrawMenuBar (handle);
+ OS.ShowWindow (handle, swFlags);
+ OS.UpdateWindow (handle);
+ } else {
+ if (OS.IsIconic (handle)) {
+ swFlags = OS.SW_SHOWMINNOACTIVE;
+ } else {
+ if (OS.IsZoomed (handle)) {
+ swFlags = OS.SW_SHOWMAXIMIZED;
+ } else {
+ if (handle == OS.GetActiveWindow ()) {
+ swFlags = OS.SW_RESTORE;
+ } else {
+ swFlags = OS.SW_SHOWNOACTIVATE;
+ }
+ }
+ }
+ OS.ShowWindow (handle, OS.SW_HIDE);
+ sendEvent (SWT.Hide);
+ }
+}
+
+boolean translateAccelerator (MSG msg) {
+ if (!isEnabled ()) return false;
+ if (hAccel == -1) createAcceleratorTable ();
+ if (hAccel == 0) return false;
+ return OS.TranslateAccelerator (handle, hAccel, msg) != 0;
+}
+
+boolean traverseItem (boolean next) {
+ return false;
+}
+
+int widgetExtStyle () {
+ int bits = 0;
+ if ((style & SWT.TOOL) != 0) bits |= OS.WS_EX_TOOLWINDOW;
+ if ((style & SWT.RESIZE) != 0) return bits;
+ if ((style & SWT.BORDER) != 0) bits |= OS.WS_EX_DLGMODALFRAME;
+ return bits;
+}
+
+int widgetStyle () {
+
+ /* Set WS_POPUP and clear WS_VISIBLE and WS_TABSTOP */
+ int bits = super.widgetStyle () | OS.WS_POPUP;
+ bits &= ~(OS.WS_VISIBLE | OS.WS_TABSTOP);
+
+ /* Set the title bits and no-trim bits */
+ bits &= ~OS.WS_BORDER;
+ if ((style & SWT.NO_TRIM) != 0) return bits;
+ if ((style & SWT.TITLE) != 0) bits |= OS.WS_CAPTION;
+
+ /* Set the min and max button bits */
+ if ((style & SWT.MIN) != 0) bits |= OS.WS_MINIMIZEBOX;
+ if ((style & SWT.MAX) != 0) bits |= OS.WS_MAXIMIZEBOX;
+
+ /*
+ * Bug in Windows. The WS_CAPTION style must be
+ * set when the window is resizable or it does not
+ * draw properly.
+ */
+ if ((style & SWT.RESIZE) != 0) {
+ bits |= OS.WS_CAPTION | OS.WS_THICKFRAME;
+ } else {
+ if ((style & SWT.BORDER) == 0) bits |= OS.WS_BORDER;
+ }
+
+ /*
+ * Feature in Windows. Both WS_SYSMENU and WS_CAPTION
+ * must be set in order to get a system menu.
+ */
+ if ((style & SWT.CLOSE) != 0) {
+ bits |= OS.WS_SYSMENU | OS.WS_CAPTION;
+ }
+
+ return bits;
+}
+
+LRESULT WM_ACTIVATE (int wParam, int lParam) {
+ LRESULT result = super.WM_ACTIVATE (wParam, lParam);
+ if (result != null) return result;
+ if ((wParam & 0xFFFF) == 0) {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the deactivate
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Deactivate);
+ if (isDisposed ()) return LRESULT.ZERO;
+ saveFocus ();
+ } else {
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the activate
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Activate);
+ if (isDisposed ()) return LRESULT.ZERO;
+ if (restoreFocus ()) return LRESULT.ZERO;
+ }
+ return result;
+}
+
+LRESULT WM_CLOSE (int wParam, int lParam) {
+ LRESULT result = super.WM_CLOSE (wParam, lParam);
+ if (result != null) return result;
+ Event event = new Event ();
+ sendEvent (SWT.Close, event);
+ // the widget could be disposed at this point
+ if (event.doit && !isDisposed ()) dispose ();
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
+ if (result != null) return result;
+ saveFocus ();
+ return result;
+}
+
+LRESULT WM_NCACTIVATE (int wParam, int lParam) {
+ LRESULT result = super.WM_NCACTIVATE (wParam, lParam);
+ if (result != null) return result;
+ if (wParam == 0) {
+ Display display = getDisplay ();
+ if (display.lockActiveWindow) return LRESULT.ZERO;
+ }
+ return result;
+}
+
+LRESULT WM_QUERYOPEN (int wParam, int lParam) {
+ LRESULT result = super.WM_QUERYOPEN (wParam, lParam);
+ if (result != null) return result;
+ sendEvent (SWT.Deiconify);
+ // widget could be disposed at this point
+ return result;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if (result != null) return result;
+ restoreFocus ();
+ return result;
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the resize
+ * event. If this happens, end the processing of the
+ * Windows message by returning the result of the
+ * WM_SIZE message.
+ */
+ if (isDisposed ()) return result;
+ if (wParam == OS.SIZE_MINIMIZED) {
+ sendEvent (SWT.Iconify);
+ // widget could be disposed at this point
+ }
+ return result;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
new file mode 100755
index 0000000000..421245adae
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/DirectoryDialog.java
@@ -0,0 +1,233 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class allow the user to navigate
+ * the file system and select a directory.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+
+public class DirectoryDialog extends Dialog {
+ String message = "", filterPath = "";
+ String directoryPath;
+
+/**
+ * Constructs a new instance of this class given only its
+ * parent.
+ * <p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the dialog on the currently active
+ * display if there is one. If there is no current display, the
+ * dialog 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_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.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
+ * for all SWT dialog classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </p>
+ * Note: Currently, null can be passed in for the parent.
+ * This has the effect of creating the dialog on the currently active
+ * display if there is one. If there is no current display, the
+ * dialog 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_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, style);
+}
+
+int BrowseCallbackProc (int hwnd, int uMsg, int lParam, int lpData) {
+ switch (uMsg) {
+ case OS.BFFM_INITIALIZED:
+ if (filterPath != null && filterPath.length () != 0) {
+ byte [] buffer = Converter.wcsToMbcs (0, filterPath, true);
+ OS.SendMessage (hwnd, OS.BFFM_SETSELECTION, 1, buffer);
+ }
+ if (title != null && title.length () != 0) {
+ byte [] buffer = Converter.wcsToMbcs (0, title, true);
+ OS.SetWindowText (hwnd, buffer);
+ }
+ break;
+ case OS.BFFM_VALIDATEFAILED:
+ byte [] buffer1 = new byte [256];
+ OS.MoveMemory (buffer1, lParam, 256);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ int length = 0;
+ while (length < buffer2.length && buffer2 [length] != 0) length++;
+ directoryPath = new String (buffer2, 0, length);
+ break;
+ }
+ return 0;
+}
+
+/**
+ * Returns the path which the receiver will use to filter
+ * the directories it shows.
+ *
+ * @return the filter path
+ */
+public String getFilterPath () {
+ return filterPath;
+}
+
+/**
+ * Returns the receiver's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the receiver while it is open.
+ *
+ * @return the message
+ */
+public String getMessage () {
+ return message;
+}
+
+/**
+ * Makes the receiver visible and brings it to the front
+ * of the display.
+ *
+ * @return a string describing the absolute path of the selected directory
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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 open () {
+
+ /* Initialize OLE */
+ OS.OleInitialize (0);
+
+ int hHeap = OS.GetProcessHeap ();
+
+ /* Get the owner HWND for the dialog */
+ int hwndOwner = 0;
+ if (parent != null) hwndOwner = parent.handle;
+
+ /* Copy the message to OS memory */
+ int lpszTitle = 0;
+ if (message != null && message.length () != 0) {
+ byte [] buffer = Converter.wcsToMbcs (0, message, true);
+ lpszTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory (lpszTitle, buffer, buffer.length);
+ }
+
+ /* Create the BrowseCallbackProc */
+ Callback callback = new Callback (this, "BrowseCallbackProc", 4);
+ int address = callback.getAddress ();
+
+ /* Open the dialog */
+ directoryPath = null;
+ BROWSEINFO lpbi = new BROWSEINFO ();
+ lpbi.hwndOwner = hwndOwner;
+ lpbi.lpszTitle = lpszTitle;
+ lpbi.ulFlags = OS.BIF_RETURNONLYFSDIRS | OS.BIF_EDITBOX | OS.BIF_VALIDATE;
+ lpbi.lpfn = address;
+ int lpItemIdList = OS.SHBrowseForFolder (lpbi);
+ if (lpItemIdList != 0) {
+ byte [] buffer = new byte [256];
+ if (OS.SHGetPathFromIDList (lpItemIdList, buffer)) {
+ char [] path = Converter.mbcsToWcs (0, buffer);
+ int length = 0;
+ while ((length < path.length) && (path [length] != 0)) length++;
+ directoryPath = new String (path, 0, length);
+ }
+ }
+
+ /* Free the BrowseCallbackProc */
+ callback.dispose ();
+
+ /* Free the OS memory */
+ if (lpszTitle != 0) OS.HeapFree (hHeap, 0, lpszTitle);
+
+ /* Free the pointer to the ITEMIDLIST */
+ int [] ppMalloc = new int [1];
+ if (OS.SHGetMalloc (ppMalloc) == OS.S_OK) {
+ /* void Free (struct IMalloc *this, void *pv); */
+ OS.VtblCall (5, ppMalloc [0], lpItemIdList);
+ }
+
+ /* Uninitialize OLE */
+ OS.OleUninitialize ();
+
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when a dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
+
+ /* Return the directory path */
+ return directoryPath;
+}
+
+/**
+ * Sets the path which the receiver will use to filter
+ * the directories it shows to the argument, which may be
+ * null.
+ *
+ * @param string the filter path
+ */
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+/**
+ * Sets the receiver's message, which is a description of
+ * the purpose for which it was opened. This message will be
+ * visible on the receiver while it is open.
+ *
+ * @param string the message
+ */
+public void setMessage (String string) {
+ message = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
new file mode 100755
index 0000000000..75801d2226
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java
@@ -0,0 +1,1502 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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><p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ *
+ * @see #syncExec
+ * @see #asyncExec
+ * @see #wake
+ * @see #readAndDispatch
+ * @see #sleep
+ * @see #dispose
+ */
+
+public class Display extends Device {
+
+ /**
+ * the handle to the OS message queue
+ * (Warning: This field is platform dependent)
+ */
+ public MSG msg = new MSG ();
+
+ /* Windows, Events and Callback */
+ byte [] windowClass;
+ Callback windowCallback;
+ int windowProc, threadId, processId;
+ Event [] eventQueue;
+ static int windowClassCount = 0;
+ static final String WindowName = "SWT_Window";
+
+ /* Sync/Async Widget Communication */
+ Synchronizer synchronizer = new Synchronizer (this);
+ Thread thread = Thread.currentThread ();
+
+ /* Display Shutdown */
+ Runnable [] disposeList;
+
+ /* Timers */
+ int [] timerIds;
+ Runnable [] timerList;
+
+ /* Keyboard and Mouse State */
+ boolean lastVirtual;
+ boolean lockActiveWindow;
+ int lastKey, lastAscii, lastMouse;
+ byte [] keyboard = new byte [256];
+ boolean accelKeyHit, mnemonicKeyHit;
+
+ /* Key Mappings */
+ static final int [] [] KeyTable = {
+
+ /* Keyboard and Mouse Masks */
+ {OS.VK_MENU, SWT.ALT},
+ {OS.VK_SHIFT, SWT.SHIFT},
+ {OS.VK_CONTROL, SWT.CONTROL},
+
+ /* NOT CURRENTLY USED */
+// {OS.VK_LBUTTON, SWT.BUTTON1},
+// {OS.VK_MBUTTON, SWT.BUTTON3},
+// {OS.VK_RBUTTON, SWT.BUTTON2},
+
+ /* Non-Numeric Keypad Constants */
+ {OS.VK_UP, SWT.ARROW_UP},
+ {OS.VK_DOWN, SWT.ARROW_DOWN},
+ {OS.VK_LEFT, SWT.ARROW_LEFT},
+ {OS.VK_RIGHT, SWT.ARROW_RIGHT},
+ {OS.VK_PRIOR, SWT.PAGE_UP},
+ {OS.VK_NEXT, SWT.PAGE_DOWN},
+ {OS.VK_HOME, SWT.HOME},
+ {OS.VK_END, SWT.END},
+ {OS.VK_INSERT, SWT.INSERT},
+
+ /* NOT CURRENTLY USED */
+// {OS.VK_DELETE, SWT.DELETE},
+
+ /* Functions Keys */
+ {OS.VK_F1, SWT.F1},
+ {OS.VK_F2, SWT.F2},
+ {OS.VK_F3, SWT.F3},
+ {OS.VK_F4, SWT.F4},
+ {OS.VK_F5, SWT.F5},
+ {OS.VK_F6, SWT.F6},
+ {OS.VK_F7, SWT.F7},
+ {OS.VK_F8, SWT.F8},
+ {OS.VK_F9, SWT.F9},
+ {OS.VK_F10, SWT.F10},
+ {OS.VK_F11, SWT.F11},
+ {OS.VK_F12, SWT.F12},
+
+ /* Numeric Keypad Constants */
+ /* NOT CURRENTLY USED */
+// {OS.VK_ADD, SWT.KP_PLUS},
+// {OS.VK_SUBTRACT, SWT.KP_MINUS},
+// {OS.VK_MULTIPLY, SWT.KP_TIMES},
+// {OS.VK_DIVIDE, SWT.KP_DIVIDE},
+// {OS.VK_DECIMAL, SWT.KP_PERIOD},
+// {OS.VK_RETURN, SWT.KP_ENTER},
+// {OS.VK_NUMPAD0, SWT.KP_0},
+// {OS.VK_NUMPAD1, SWT.KP_1},
+// {OS.VK_NUMPAD2, SWT.KP_2},
+// {OS.VK_NUMPAD3, SWT.KP_3},
+// {OS.VK_NUMPAD4, SWT.KP_4},
+// {OS.VK_NUMPAD5, SWT.KP_5},
+// {OS.VK_NUMPAD6, SWT.KP_6},
+// {OS.VK_NUMPAD7, SWT.KP_7},
+// {OS.VK_NUMPAD8, SWT.KP_8},
+// {OS.VK_NUMPAD9, SWT.KP_9},
+
+ };
+
+ /* Multiple Displays */
+ static Display Default;
+ static Display [] Displays = new Display [4];
+
+ /* Modality */
+ Shell [] ModalWidgets;
+ static boolean TrimEnabled = false;
+
+ /* Package Name */
+ static final String PACKAGE_NAME;
+ static {
+ String name = Display.class.getName ();
+ int index = name.lastIndexOf ('.');
+ PACKAGE_NAME = name.substring (0, index + 1);
+ }
+
+ /* Display Data */
+ Object data;
+ String [] keys;
+ Object [] values;
+
+/**
+ * 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 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 #getCurrent
+ * @see #getDefault
+ * @see Widget#checkSubclass
+ * @see Shell
+ */
+public Display () {
+ this (null);
+}
+
+public Display (DeviceData data) {
+ super (data);
+}
+
+int asciiKey (int key) {
+
+ /* Get the current keyboard. */
+ for (int i=0; i<keyboard.length; i++) keyboard [i] = 0;
+ if (!OS.GetKeyboardState (keyboard)) return 0;
+
+ /* Translate the key to ASCII using the current keyboard. */
+ short [] result = new short [1];
+ if (OS.ToAscii (key, key, keyboard, result, 0) == 1) return result [0];
+ 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 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
+ */
+public void asyncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.asyncExec (runnable);
+}
+
+/**
+ * Causes the system hardware to emit a short sound
+ * (if it supports this capability).
+ */
+public void beep () {
+ checkDevice ();
+ OS.MessageBeep (OS.MB_OK);
+}
+
+/**
+ * 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);
+}
+
+protected void checkDevice () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+}
+
+synchronized void checkDisplay () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] != null && Displays [i].thread == thread) {
+ error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ }
+ }
+}
+
+void clearModal (Shell shell) {
+ if (ModalWidgets == null) return;
+ int index = 0, length = ModalWidgets.length;
+ while (index < length) {
+ if (ModalWidgets [index] == shell) break;
+ if (ModalWidgets [index] == null) return;
+ index++;
+ }
+ if (index == length) return;
+ System.arraycopy (ModalWidgets, index + 1, ModalWidgets, index, --length - index);
+ ModalWidgets [length] = null;
+ if (index == 0 && ModalWidgets [0] == null) ModalWidgets = null;
+ if (!TrimEnabled) return;
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) shells [i].updateModal ();
+}
+
+int controlKey (int key) {
+ int upper = OS.CharUpper ((short) key);
+ if (64 <= upper && upper <= 95) return upper & 0xBF;
+ return key;
+}
+
+/**
+ * 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 ();
+ createDisplay (data);
+ register ();
+ if (Default == null) Default = this;
+}
+
+void createDisplay (DeviceData data) {
+}
+
+synchronized void deregister () {
+ for (int i=0; i<Displays.length; i++) {
+ if (this == 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 #dispose
+ * @see #release
+ */
+protected void destroy () {
+ if (this == Default) Default = null;
+ deregister ();
+ destroyDisplay ();
+}
+
+void destroyDisplay () {
+}
+
+/**
+ * Causes the <code>run()</code> method of the runnable to
+ * be invoked by the user-interface thread just before the
+ * receiver is disposed.
+ *
+ * @param runnable code to run at dispose time.
+ */
+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);
+}
+
+boolean filterMessage (MSG msg) {
+ int message = msg.message;
+ if (message == OS.WM_TIMER && msg.hwnd == 0) {
+ if (timerList == null || timerIds == null) return false;
+ for (int i=0; i<timerIds.length; i++) {
+ if (timerIds [i] == msg.wParam) {
+ OS.KillTimer (0, timerIds [i]);
+ timerIds [i] = 0;
+ Runnable runnable = timerList [i];
+ timerList [i] = null;
+ if (runnable != null) runnable.run ();
+ }
+ }
+ return false;
+ }
+ if (OS.WM_KEYFIRST <= message && message <= OS.WM_KEYLAST) {
+ if (translateAccelerator (msg)) return true;
+ if (translateMnemonic (msg)) return true;
+ if (translateTraversal (msg)) return true;
+ }
+ return false;
+}
+
+/**
+ * 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.
+ *
+ * @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>
+ * </ul>
+ */
+public Widget findWidget (int handle) {
+ checkDevice ();
+ return WidgetTable.get (handle);
+}
+
+Control findControl(int handle) {
+ if (handle == 0) return null;
+ /*
+ * This code is intentionally commented. It is possible
+ * find the SWT control that is associated with a handle
+ * that belongs to another process when the handle was
+ * created by an in-proc OLE client. In this case, the
+ * handle comes from another process, but it is a child
+ * of an SWT control. For now, it is necessary to look
+ * at handles that do not belong to the SWT process.
+ */
+// int [] hwndProcessId = new int [1];
+// OS.GetWindowThreadProcessId (handle, hwndProcessId);
+// if (hwndProcessId [0] != processId) return null;
+ do {
+ Control control = WidgetTable.get (handle);
+ if (control != null && control.handle == handle) {
+ return control;
+ }
+ } while ((handle = OS.GetParent (handle)) != 0);
+ return null;
+}
+
+
+/**
+ * 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.
+ *
+ * @param thread the user-interface thread
+ * @return the display for the given thread
+ */
+public static synchronized Display findDisplay (Thread thread) {
+ for (int i=0; i<Displays.length; i++) {
+ Display display = Displays [i];
+ if (display != null && display.thread == thread) {
+ return display;
+ }
+ }
+ return null;
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public Shell getActiveShell () {
+ checkDevice ();
+ Control control = findControl (OS.GetActiveWindow ());
+ if (control instanceof Shell) return (Shell) control;
+ return null;
+}
+
+/**
+ * Returns a rectangle describing the receiver's size and location.
+ *
+ * @return the bounding rectangle
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public Rectangle getBounds () {
+ checkDevice ();
+ int width = OS.GetSystemMetrics (OS.SM_CXSCREEN);
+ int height = OS.GetSystemMetrics (OS.SM_CYSCREEN);
+ return new Rectangle (0, 0, width, 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 synchronized Display getCurrent () {
+ return findDisplay (Thread.currentThread ());
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public Control getCursorControl () {
+ checkDevice ();
+ POINT pt = new POINT ();
+ OS.GetCursorPos (pt);
+ return findControl (OS.WindowFromPoint (pt));
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public Point getCursorLocation () {
+ checkDevice ();
+ POINT pt = new POINT ();
+ OS.GetCursorPos (pt);
+ return new Point (pt.x, pt.y);
+}
+
+/**
+ * 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 synchronized Display getDefault () {
+ 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_NAME);
+}
+
+/**
+ * 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 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>
+ * </ul>
+ *
+ * @see #setData
+ * @see #disposeExec
+ */
+public Object getData (String key) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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 provide a
+ * <code>disposeExec()</code> handler which does so.
+ * </p>
+ *
+ * @return the display specific data
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #setData
+ * @see #disposeExec
+ */
+public Object getData () {
+ checkDevice ();
+ return data;
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public int getDoubleClickTime () {
+ checkDevice ();
+ return OS.GetDoubleClickTime ();
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public Control getFocusControl () {
+ checkDevice ();
+ return findControl (OS.GetFocus ());
+}
+
+/**
+ * Returns the maximum allowed depth of icons on this display.
+ * 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>
+ * </ul>
+ */
+public int getIconDepth () {
+ checkDevice ();
+ int [] phkResult = new int [1];
+ byte [] buffer1 = Converter.wcsToMbcs (0, "Control Panel\\Desktop\\WindowMetrics", true);
+ int result = OS.RegOpenKeyEx (OS.HKEY_CURRENT_USER, buffer1, 0, OS.KEY_READ, phkResult);
+ if (result != 0) return 4;
+ int depth = 4;
+ int [] lpcbData = {128};
+ byte [] lpData = new byte [lpcbData [0]];
+ byte [] buffer2 = Converter.wcsToMbcs (0, "Shell Icon BPP", true);
+ result = OS.RegQueryValueEx (phkResult [0], buffer2, 0, null, lpData, lpcbData);
+ if (result == 0) {
+ char [] buffer3 = Converter.mbcsToWcs (0, lpData);
+ int length = 0;
+ while (length < buffer3.length && buffer3 [length] != 0) length++;
+ try {
+ depth = Integer.parseInt (new String (buffer3, 0, length));
+ } catch (NumberFormatException e) {};
+ }
+ OS.RegCloseKey (phkResult [0]);
+ return depth;
+}
+
+Shell getModalShell () {
+ if (ModalWidgets == null) return null;
+ int index = ModalWidgets.length;
+ while (--index >= 0) {
+ Shell shell = ModalWidgets [index];
+ if (shell != null) return shell;
+ }
+ return null;
+}
+
+/**
+ * Returns an 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>
+ * </ul>
+ */
+public Shell [] getShells () {
+ checkDevice ();
+ /*
+ * NOTE: Need to check that the shells that belong
+ * to another display have not been disposed by the
+ * other display's thread as the shells list is being
+ * processed.
+ */
+ int count = 0;
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ count++;
+ }
+ }
+ if (count == shells.length) return shells;
+ int index = 0;
+ Shell [] result = new Shell [count];
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ result [index++] = shell;
+ }
+ }
+ return result;
+}
+
+/**
+ * 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
+ */
+public Thread getSyncThread () {
+ 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>
+ * </ul>
+ *
+ * @see SWT
+ */
+public Color getSystemColor (int id) {
+ checkDevice ();
+ int pixel = 0x02000000;
+ switch (id) {
+ case SWT.COLOR_WIDGET_DARK_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DDKSHADOW); break;
+ case SWT.COLOR_WIDGET_NORMAL_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DSHADOW); break;
+ case SWT.COLOR_WIDGET_LIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DLIGHT); break;
+ case SWT.COLOR_WIDGET_HIGHLIGHT_SHADOW: pixel = OS.GetSysColor (OS.COLOR_3DHIGHLIGHT); break;
+ case SWT.COLOR_WIDGET_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_3DFACE); break;
+ case SWT.COLOR_WIDGET_BORDER: pixel = OS.GetSysColor (OS.COLOR_WINDOWFRAME); break;
+ case SWT.COLOR_WIDGET_FOREGROUND:
+ case SWT.COLOR_LIST_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_WINDOWTEXT); break;
+ case SWT.COLOR_LIST_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_WINDOW); break;
+ case SWT.COLOR_LIST_SELECTION: pixel = OS.GetSysColor (OS.COLOR_HIGHLIGHT); break;
+ case SWT.COLOR_LIST_SELECTION_TEXT: pixel = OS.GetSysColor (OS.COLOR_HIGHLIGHTTEXT);break;
+ case SWT.COLOR_INFO_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_INFOTEXT); break;
+ case SWT.COLOR_INFO_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_INFOBK); break;
+ case SWT.COLOR_TITLE_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_CAPTIONTEXT); break;
+ case SWT.COLOR_TITLE_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_ACTIVECAPTION); break;
+ case SWT.COLOR_TITLE_BACKGROUND_GRADIENT: pixel = OS.GetSysColor (OS.COLOR_GRADIENTACTIVECAPTION); break;
+ case SWT.COLOR_TITLE_INACTIVE_FOREGROUND: pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTIONTEXT); break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND: pixel = OS.GetSysColor (OS.COLOR_INACTIVECAPTION); break;
+ case SWT.COLOR_TITLE_INACTIVE_BACKGROUND_GRADIENT: pixel = OS.GetSysColor (OS.COLOR_GRADIENTINACTIVECAPTION); break;
+ default:
+ return super.getSystemColor (id);
+ }
+ return Color.win32_new (this, pixel);
+}
+
+/**
+ * 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>
+ * </ul>
+ */
+public Font getSystemFont () {
+ checkDevice ();
+ int hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (hFont == 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ return Font.win32_new (this, hFont);
+}
+
+/**
+ * Returns the user-interface thread for the receiver.
+ *
+ * @return the receiver's user-interface thread
+ */
+public Thread getThread () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ return thread;
+}
+
+/**
+ * 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
+ *
+ * @private
+ */
+public int internal_new_GC (GCData data) {
+ int hDC = OS.GetDC (0);
+ if (hDC == 0) SWT.error (SWT.ERROR_NO_HANDLES);
+ if (data != null) {
+ data.device = this;
+ int hFont = OS.GetStockObject (OS.DEFAULT_GUI_FONT);
+ if (hFont == 0) hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ data.hFont = hFont;
+ }
+ return hDC;
+}
+
+/**
+ * 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 ();
+
+ /* Create the callbacks */
+ windowCallback = new Callback (this, "windowProc", 4);
+ windowProc = windowCallback.getAddress ();
+ if (windowProc == 0) error (SWT.ERROR_NO_MORE_CALLBACKS);
+
+ /* Remember the current procsss and thread */
+ threadId = OS.GetCurrentThreadId ();
+ processId = OS.GetCurrentProcessId ();
+
+ /* Register the SWT window class */
+ int hHeap = OS.GetProcessHeap ();
+ int hInstance = OS.GetModuleHandle (null);
+ windowClass = Converter.wcsToMbcs (0, WindowName + windowClassCount++ + "\0");
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ if (OS.GetClassInfoEx (hInstance, windowClass, lpWndClass)) {
+ OS.UnregisterClass (windowClass, hInstance);
+ }
+ lpWndClass.hInstance = hInstance;
+ lpWndClass.lpfnWndProc = windowProc;
+ lpWndClass.style = OS.CS_BYTEALIGNWINDOW | OS.CS_DBLCLKS;
+ lpWndClass.hCursor = OS.LoadCursor (0, OS.IDC_ARROW);
+ lpWndClass.lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, windowClass.length);
+ OS.MoveMemory (lpWndClass.lpszClassName, windowClass, windowClass.length);
+ OS.RegisterClassEx (lpWndClass);
+ OS.HeapFree (hHeap, 0, lpWndClass.lpszClassName);
+}
+
+/**
+ * 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 handle the platform specific GC handle
+ * @param data the platform specific GC data
+ *
+ * @private
+ */
+public void internal_dispose_GC (int hDC, GCData data) {
+ OS.ReleaseDC (0, hDC);
+}
+
+boolean isValidThread () {
+ return thread == Thread.currentThread ();
+}
+
+boolean isVirtualKey (int key) {
+ return (key == OS.VK_TAB) || (key == OS.VK_MENU) ||
+ (key == OS.VK_RETURN) || (key == OS.VK_BACK) ||
+ (key == OS.VK_SPACE) || (key == OS.VK_ESCAPE) ||
+ (key == OS.VK_SHIFT) || (key == OS.VK_CONTROL);
+}
+
+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;
+}
+
+/**
+ * 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>
+ * </ul>
+ *
+ * @see #sleep
+ * @see #wake
+ */
+public boolean readAndDispatch () {
+ checkDevice ();
+ if (OS.PeekMessage (msg, 0, 0, 0, OS.PM_REMOVE)) {
+ if (filterMessage (msg)) return false;
+ OS.TranslateMessage (msg);
+ OS.DispatchMessage (msg);
+ runDeferredEvents ();
+ return true;
+ }
+ return runAsyncMessages ();
+}
+
+synchronized void register () {
+ for (int i=0; i<Displays.length; i++) {
+ if (Displays [i] == null) {
+ Displays [i] = this;
+ return;
+ }
+ }
+ Display [] newDisplays = new Display [Displays.length + 4];
+ System.arraycopy (Displays, 0, newDisplays, 0, Displays.length);
+ newDisplays [Displays.length] = this;
+ 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 #dispose
+ * @see #destroy
+ */
+protected void release () {
+ super.release ();
+
+ /* Release shells */
+ Shell [] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ if (this == shell.getDisplay ()) shell.dispose ();
+ }
+ }
+ while (readAndDispatch ()) {};
+
+ /* Run dispose list */
+ if (disposeList != null) {
+ for (int i=0; i<disposeList.length; i++) {
+ if (disposeList [i] != null) disposeList [i].run ();
+ }
+ }
+ disposeList = null;
+
+ /* Release synchronizer */
+ synchronizer.releaseSynchronizer ();
+ synchronizer = null;
+
+ releaseDisplay ();
+}
+
+void releaseDisplay () {
+
+ /* Unregister the SWT Window class */
+ int hHeap = OS.GetProcessHeap ();
+ int hInstance = OS.GetModuleHandle (null);
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, windowClass, lpWndClass);
+ int ptr = lpWndClass.lpszClassName;
+ OS.UnregisterClass (windowClass, hInstance);
+ OS.HeapFree (hHeap, 0, ptr);
+
+ /* Release callbacks */
+ windowClass = null;
+ windowCallback.dispose ();
+ windowCallback = null;
+
+ /* Release references */
+ thread = null;
+ msg = null;
+ keyboard = null;
+ ModalWidgets = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
+boolean runAsyncMessages () {
+ return synchronizer.runAsyncMessages ();
+}
+
+boolean runDeferredEvents () {
+ /*
+ * Run deferred events. This code is always
+ * called in the Display's thread so it must
+ * be re-enterant 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.notifyListeners (event.type, 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;
+}
+
+/**
+ * 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>
+ * </ul>
+ *
+ * @see #setData
+ * @see #disposeExec
+ */
+public void setData (String key, Object value) {
+ checkDevice ();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* 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 - when called from the wrong thread</li>
+ * </ul>
+ *
+ * @see #getData
+ * @see #disposeExec
+ */
+public void setData (Object data) {
+ checkDevice ();
+ this.data = data;
+}
+
+/**
+ * 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.
+ *
+ * @param name the new app name
+ */
+public static void setAppName (String name) {
+ /* Do nothing */
+}
+
+void setModal (Shell shell) {
+ if (ModalWidgets == null) ModalWidgets = new Shell [4];
+ int index = 0, length = ModalWidgets.length;
+ while (index < length) {
+ if (ModalWidgets [index] == shell) return;
+ if (ModalWidgets [index] == null) break;
+ index++;
+ }
+ if (index == length) {
+ Shell [] newModalWidgets = new Shell [length + 4];
+ System.arraycopy (ModalWidgets, 0, newModalWidgets, 0, length);
+ ModalWidgets = newModalWidgets;
+ }
+ ModalWidgets [index] = shell;
+ if (!TrimEnabled) return;
+ 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>
+ * </ul>
+ */
+public void setSynchronizer (Synchronizer synchronizer) {
+ checkDevice ();
+ if (synchronizer == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (this.synchronizer != null) {
+ this.synchronizer.runAsyncMessages();
+ }
+ this.synchronizer = synchronizer;
+}
+
+int shiftedKey (int key) {
+
+ /* Clear the virtual keyboard and press the shift key. */
+ for (int i=0; i<keyboard.length; i++) keyboard [i] = 0;
+ keyboard [OS.VK_SHIFT] |= 0x80;
+
+ /* Translate aKey to ASCII using the virtual keyboard. */
+ short [] result = new short [1];
+ if (OS.ToAscii (key, key, keyboard, result, 0) == 1) return result [0];
+ return 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>
+ * </ul>
+ *
+ * @see #wake
+ */
+public boolean sleep () {
+ checkDevice ();
+ return OS.WaitMessage ();
+}
+
+/**
+ * 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.
+ *
+ * @see #asyncExec
+ */
+public void syncExec (Runnable runnable) {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ synchronizer.syncExec (runnable);
+}
+
+/**
+ * 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.
+ *
+ * @param milliseconds the delay before running the runnable
+ * @param runnable code to run on the user-interface thread
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @see #asyncExec
+ */
+public void timerExec (int milliseconds, Runnable runnable) {
+ checkDevice ();
+ if (timerList == null) {
+ timerList = new Runnable [4];
+ timerIds = new int [4];
+ }
+ int 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.SetTimer (0, 0, milliseconds, 0);
+ if (timerID != 0) {
+ timerList [index] = runnable;
+ timerIds [index] = timerID;
+ }
+}
+
+boolean translateAccelerator (MSG msg) {
+ Control control = findControl (msg.hwnd);
+ if (control == null) return false;
+ accelKeyHit = true;
+ boolean result = control.translateAccelerator (msg);
+ accelKeyHit = false;
+ return result;
+}
+
+static int translateKey (int key) {
+ for (int i=0; i<KeyTable.length; i++) {
+ if (KeyTable [i] [0] == key) return KeyTable [i] [1];
+ }
+ return 0;
+}
+
+boolean translateMnemonic (MSG msg) {
+ switch (msg.message) {
+ case OS.WM_CHAR:
+ case OS.WM_SYSCHAR:
+ Control control = findControl (msg.hwnd);
+ if (control == null) return false;
+ return control.translateMnemonic (msg);
+ }
+ return false;
+}
+
+boolean translateTraversal (MSG msg) {
+ if (msg.message == OS.WM_KEYDOWN) {
+ switch (msg.wParam) {
+ case OS.VK_RETURN:
+ case OS.VK_ESCAPE:
+ case OS.VK_TAB:
+ case OS.VK_UP:
+ case OS.VK_DOWN:
+ case OS.VK_LEFT:
+ case OS.VK_RIGHT:
+ Control control = findControl (msg.hwnd);
+ if (control == null) return false;
+ return control.translateTraversal (msg);
+ }
+ }
+ return false;
+}
+
+static int untranslateKey (int key) {
+ for (int i=0; i<KeyTable.length; i++) {
+ if (KeyTable [i] [1] == key) return KeyTable [i] [0];
+ }
+ return 0;
+}
+
+public void update() {
+ checkDevice ();
+ Shell[] shells = WidgetTable.shells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed () && this == shell.getDisplay ()) {
+ shell.update ();
+ }
+ }
+}
+
+/**
+ * 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.
+ *
+ * @see #sleep
+ */
+public void wake () {
+ if (isDisposed ()) error (SWT.ERROR_DEVICE_DISPOSED);
+ OS.PostThreadMessage (threadId, OS.WM_NULL, 0, 0);
+}
+
+int windowProc (int hwnd, int msg, int wParam, int lParam) {
+ Control control = WidgetTable.get (hwnd);
+ if (control != null) return control.windowProc (msg, wParam, lParam);
+ return OS.DefWindowProc (hwnd, msg, wParam, lParam);
+}
+
+static String withCrLf (String string) {
+
+ /* If the string is empty, return the string. */
+ int length = string.length ();
+ if (length == 0) return string;
+
+ /*
+ * Check for an LF or CR/LF and assume the rest of
+ * the string is formated that way. This will not
+ * work if the string contains mixed delimiters.
+ */
+ int i = string.indexOf ('\n', 0);
+ if (i == -1) return string;
+ if (i > 0 && string.charAt (i - 1) == '\r') {
+ return string;
+ }
+
+ /*
+ * The string is formatted with LF. Compute the
+ * number of lines and the size of the buffer
+ * needed to hold the result
+ */
+ i++;
+ int count = 1;
+ while (i < length) {
+ if ((i = string.indexOf ('\n', i)) == -1) break;
+ count++; i++;
+ }
+ count += length;
+
+ /* Create a new string with the CR/LF line terminator. */
+ i = 0;
+ StringBuffer result = new StringBuffer (count);
+ while (i < length) {
+ int j = string.indexOf ('\n', i);
+ if (j == -1) j = length;
+ result.append (string.substring (i, j));
+ if ((i = j) < length) {
+ result.append ("\r\n");
+ i++;
+ }
+ }
+ return result.toString ();
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
new file mode 100755
index 0000000000..01529ac9a9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FileDialog.java
@@ -0,0 +1,252 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * 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>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class FileDialog extends Dialog {
+ String [] filterNames = new String [0];
+ String [] filterExtensions = new String [0];
+ String [] fileNames = new String [0];
+ String filterPath = "", fileName = "";
+ String fullPath = "";
+ static final String FILTER = "*.*";
+ static int BUFFER_SIZE = 1024 * 10;
+
+public FileDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public FileDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public String getFileName () {
+ return fileName;
+}
+
+public String [] getFileNames () {
+ return fileNames;
+}
+
+public String [] getFilterNames () {
+ return filterNames;
+}
+
+public String [] getFilterExtensions () {
+ return filterExtensions;
+}
+
+public String getFilterPath () {
+ return filterPath;
+}
+
+public String open () {
+ int hHeap = OS.GetProcessHeap ();
+
+ /* Get the owner HWND for the dialog */
+ int hwndOwner = 0;
+ if (parent != null) hwndOwner = parent.handle;
+
+ /* Convert the title and copy it into lpstrTitle */
+ if (title == null) title = "";
+ byte [] buffer3 = Converter.wcsToMbcs (0, title, true);
+ int lpstrTitle = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer3.length);
+ OS.MoveMemory (lpstrTitle, buffer3, buffer3.length);
+
+ /* Compute filters and copy into lpstrFilter */
+ String strFilter = "";
+ if (filterNames == null) filterNames = new String [0];
+ if (filterExtensions == null) filterExtensions = new String [0];
+ for (int i=0; i<filterExtensions.length; i++) {
+ String filterName = filterExtensions [i];
+ if (i < filterNames.length) filterName = filterNames [i];
+ strFilter = strFilter + filterName + '\0' + filterExtensions [i] + '\0';
+ }
+ if (filterExtensions.length == 0) {
+ strFilter = strFilter + FILTER + '\0' + FILTER + '\0';
+ }
+ byte [] buffer4 = Converter.wcsToMbcs (0, strFilter, true);
+ int lpstrFilter = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer4.length);
+ OS.MoveMemory (lpstrFilter, buffer4, buffer4.length);
+
+ /* Convert the fileName and filterName to C strings */
+ if (fileName == null) fileName = "";
+ byte [] name = Converter.wcsToMbcs (0, fileName, false);
+ if (filterPath == null) filterPath = "";
+ byte [] path = Converter.wcsToMbcs (0, filterPath, false);
+
+ /*
+ * Bug/Feature in Windows. Verify that the file name is valid.
+ * If an invalid file name is passed to the standard dialog, it
+ * does not open and returns an error code. The fix is to avoid
+ * this behavior by verifying the file name before opening the
+ * dialog. If the file name is not valid, use an empty string.
+ */
+ byte [] buffer2 = new byte [name.length + 1];
+ System.arraycopy (name, 0, buffer2, 0, name.length);
+ if (OS.GetFileTitle (buffer2, null, (short) 0) < 0) {
+ name = new byte [0];
+ }
+
+ /*
+ * Copy the name into lpstrFile and ensure that the
+ * last byte is NULL and the buffer does not overrun.
+ * Note that the longest that a single path name can
+ * be on Windows is 256.
+ */
+ int bufferSize = 256;
+ if ((style & SWT.MULTI) != 0) bufferSize = Math.max (256, BUFFER_SIZE);
+ int lpstrFile = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, bufferSize);
+ OS.MoveMemory (lpstrFile, name, Math.min (name.length, bufferSize - 1));
+
+ /*
+ * Copy the path into lpstrInitialDir and ensure that
+ * the last byte is NULL and the buffer does not overrun.
+ */
+ int lpstrInitialDir = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, bufferSize);
+ OS.MoveMemory (lpstrInitialDir, path, Math.min (path.length, bufferSize - 1));
+
+ /* Create the file dialog struct */
+ OPENFILENAME struct = new OPENFILENAME ();
+ struct.lStructSize = OPENFILENAME.sizeof;
+ struct.Flags = OS.OFN_HIDEREADONLY | OS.OFN_NOCHANGEDIR;
+ if ((style & SWT.MULTI) != 0) {
+ struct.Flags |= OS.OFN_ALLOWMULTISELECT | OS.OFN_EXPLORER;
+ }
+ struct.hwndOwner = hwndOwner;
+ struct.lpstrTitle = lpstrTitle;
+ struct.lpstrFile = lpstrFile;
+ struct.nMaxFile = bufferSize;
+ struct.lpstrInitialDir = lpstrInitialDir;
+ struct.lpstrFilter = lpstrFilter;
+ struct.nFilterIndex = 0;
+
+ /*
+ * Feature in Windows. The focus window is not saved and
+ * and restored automatically by the call to GetOpenFileName ().
+ * The fix is to save and restore the focus window.
+ */
+ int hwndFocus = OS.GetFocus ();
+
+ /*
+ * Bug/Feature in Windows. When Windows opens the standard
+ * file dialog, it changes the cursor to the hourglass and
+ * does not put it back. The fix is to save the current
+ * cursor and restore it when the dialog closes.
+ */
+ int hCursor = OS.GetCursor ();
+
+ /*
+ * Open the dialog. If the open fails due to an invalid
+ * file name, use an empty file name and open it again.
+ */
+ boolean save = (style & SWT.SAVE) != 0;
+ boolean success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
+ if (OS.CommDlgExtendedError () == OS.FNERR_INVALIDFILENAME) {
+ OS.MoveMemory (lpstrFile, new byte [1], 1);
+ success = (save) ? OS.GetSaveFileName (struct) : OS.GetOpenFileName (struct);
+ }
+
+ /* Set the new path, file name and filter */
+ fullPath = null;
+ if (success) {
+ int count = 0;
+ fileNames = new String [1];
+ byte [] buffer = new byte [struct.nMaxFile];
+ OS.MoveMemory (buffer, lpstrFile, buffer.length);
+ byte [] prefix = new byte [struct.nFileOffset - 1];
+ System.arraycopy (buffer, 0, prefix, 0, prefix.length);
+ filterPath = new String (Converter.mbcsToWcs (0, prefix));
+ int start = struct.nFileOffset;
+ do {
+ int end = start;
+ while (end < buffer.length && buffer [end] != 0) end++;
+ byte [] buffer1 = new byte [end - start];
+ System.arraycopy (buffer, start, buffer1, 0, buffer1.length);
+ start = end;
+ String string = new String (Converter.mbcsToWcs (0, buffer1));
+ if (count == fileNames.length) {
+ String [] newFileNames = new String [fileNames.length + 4];
+ System.arraycopy (fileNames, 0, newFileNames, 0, fileNames.length);
+ fileNames = newFileNames;
+ }
+ fileNames [count++] = string;
+ if ((style & SWT.MULTI) == 0) break;
+ start++;
+ } while (start < buffer.length && buffer [start] != 0);
+ if (fileNames.length > 0) fileName = fileNames [0];
+ String separator = "";
+ int length = filterPath.length ();
+ if (length > 0 && filterPath.charAt (length - 1) != '\\') {
+ separator = "\\";
+ }
+ fullPath = filterPath + separator + fileName;
+ if (count < fileNames.length) {
+ String [] newFileNames = new String [count];
+ System.arraycopy (fileNames, 0, newFileNames, 0, count);
+ fileNames = newFileNames;
+ }
+ }
+
+ /* Free the memory that was allocated. */
+ OS.HeapFree (hHeap, 0, lpstrFile);
+ OS.HeapFree (hHeap, 0, lpstrFilter);
+ OS.HeapFree (hHeap, 0, lpstrInitialDir);
+ OS.HeapFree (hHeap, 0, lpstrTitle);
+
+ /* Restore the old cursor */
+ OS.SetCursor (hCursor);
+
+ /* Restore the old focus */
+ OS.SetFocus (hwndFocus);
+
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when a dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
+
+ /* Answer the full path or null */
+ return fullPath;
+}
+
+public void setFileName (String string) {
+ fileName = string;
+}
+
+public void setFilterExtensions (String [] extensions) {
+ filterExtensions = extensions;
+}
+
+public void setFilterNames (String [] names) {
+ filterNames = names;
+}
+
+public void setFilterPath (String string) {
+ filterPath = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
new file mode 100755
index 0000000000..ca4cdf5719
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/FontDialog.java
@@ -0,0 +1,110 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class allow the user to select a font
+ * from all available fonts in the system.
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class FontDialog extends Dialog {
+ FontData fontData;
+
+public FontDialog (Shell parent) {
+ this (parent, SWT.PRIMARY_MODAL);
+}
+
+public FontDialog (Shell parent, int style) {
+ super (parent, style);
+}
+
+public FontData getFontData() {
+ return fontData;
+}
+
+public FontData open () {
+
+ /* Get the owner HWND for the dialog */
+ int hwndOwner = 0;
+ if (parent != null) hwndOwner = parent.handle;
+
+ /* Open the dialog */
+ int hHeap = OS.GetProcessHeap ();
+ CHOOSEFONT lpcf = new CHOOSEFONT ();
+ lpcf.lStructSize = CHOOSEFONT.sizeof;
+ lpcf.hwndOwner = hwndOwner;
+ lpcf.Flags = OS.CF_SCREENFONTS | OS.CF_EFFECTS;
+ int lpLogFont = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, LOGFONT.sizeof);
+ if (fontData != null && fontData.data != null) {
+ lpcf.Flags |= OS.CF_INITTOLOGFONTSTRUCT;
+ OS.MoveMemory (lpLogFont, fontData.data, LOGFONT.sizeof);
+ }
+ lpcf.lpLogFont = lpLogFont;
+ fontData = null;
+ if (OS.ChooseFont (lpcf)) {
+ LOGFONT logFont = new LOGFONT ();
+ OS.MoveMemory (logFont, lpLogFont, LOGFONT.sizeof);
+
+ /*
+ * This will not work on multiple screens or
+ * for printing. Should use DC for the proper device.
+ */
+ int hDC = OS.GetDC(0);
+ int logPixelsY = OS.GetDeviceCaps(hDC, OS.LOGPIXELSY);
+ int pixels = 0;
+ if (logFont.lfHeight > 0) {
+ /*
+ * Feature in Windows. If the lfHeight of the LOGFONT structure
+ * is positive, the lfHeight measures the height of the entire
+ * cell, including internal leading, in logical units. Since the
+ * height of a font in points does not include the internal leading,
+ * we must subtract the internal leading, which requires a TEXTMETRIC,
+ * which in turn requires font creation.
+ */
+ int hFont = OS.CreateFontIndirect(logFont);
+ int oldFont = OS.SelectObject(hDC, hFont);
+ TEXTMETRIC lptm = new TEXTMETRIC();
+ OS.GetTextMetrics(hDC, lptm);
+ OS.SelectObject(hDC, oldFont);
+ OS.DeleteObject(hFont);
+ pixels = logFont.lfHeight - lptm.tmInternalLeading;
+ } else {
+ pixels = -logFont.lfHeight;
+ }
+ OS.ReleaseDC(0, hDC);
+
+ /* Avoid using Math.round() */
+ int points = (int)((pixels * 72.0f / logPixelsY) + 0.5f);
+ fontData = FontData.win32_new (logFont, points);
+ }
+
+ /* Free the OS memory */
+ if (lpLogFont != 0) OS.HeapFree (hHeap, 0, lpLogFont);
+
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when a dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
+
+ return fontData;
+}
+
+public void setFontData (FontData fontData) {
+ this.fontData = fontData;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
new file mode 100755
index 0000000000..2d3dc893cf
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java
@@ -0,0 +1,283 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class provide by 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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Group extends Composite {
+ static final int GroupProc;
+ static final byte [] GroupClass = Converter.wcsToMbcs (0, "BUTTON\0", false);
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, GroupClass, lpWndClass);
+ GroupProc = lpWndClass.lpfnWndProc;
+ }
+
+public Group (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (GroupProc, handle, msg, wParam, lParam);
+}
+
+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 ();
+ int width = 0, height = 0;
+ RECT rect = new RECT ();
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ int length = OS.GetWindowTextLength (handle);
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, length + 1);
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE;
+ OS.DrawText (hDC, buffer1, length, rect, flags);
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ width = size.x; height = size.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;
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = Math.max (trim.width, rect.right - rect.left + 6);
+ height = trim.height;
+ return new Point (width, height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget ();
+ Rectangle trim = super.computeTrim (x, y, width, height);
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ int inset = 3;
+ trim.x -= inset; trim.y -= tm.tmHeight;
+ trim.width += (inset * 2); trim.height += tm.tmHeight + inset;
+ return trim;
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+}
+
+public Rectangle getClientArea () {
+ checkWidget ();
+ if (parent.hdwp != 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ int count = parent.getChildrenCount ();
+ parent.hdwp = OS.BeginDeferWindowPos (count);
+ }
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ int inset = 3, x = inset, y = tm.tmHeight;
+ return new Rectangle (x, y, rect.right - (inset * 2), rect.bottom - y - inset);
+}
+
+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 ();
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, buffer1.length);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+}
+
+boolean mnemonicHit () {
+ return setFocus ();
+}
+
+boolean mnemonicMatch (char key) {
+ char mnemonic = findMnemonic (getText ());
+ if (mnemonic == '\0') return false;
+ return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
+}
+
+/**
+ * Sets the receiver's text, which is the string that will
+ * be display as the receiver's <em>title</em>, to the argument,
+ * which may not be null.
+ *
+ * @param text the new text
+ *
+ * @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>
+ */
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SetWindowText (handle, buffer);
+}
+
+int widgetStyle () {
+ /*
+ * Bug in Windows. When GetDCEx () is called with DCX_INTERSECTUPDATE,
+ * the HDC that is returned does not include the current update region.
+ * This was confirmed under DEBUG Windows when GetDCEx () complained about
+ * invalid flags. Therefore, it is not easily possible to get an HDC from
+ * outside of WM_PAINT that includes the current damage and clips children.
+ * Because the receiver has children and draws a frame and label, it is
+ * necessary that the receiver always draw clipped, in the current damaged
+ * area. The fix is to force the receiver to be fully clipped by including
+ * WS_CLIPCHILDREN and WS_CLIPSIBLINGS in the default style bits.
+ */
+ return super.widgetStyle () | OS.BS_GROUPBOX | OS.WS_CLIPCHILDREN | OS.WS_CLIPSIBLINGS;
+}
+
+byte [] windowClass () {
+ return GroupClass;
+}
+
+int windowProc () {
+ return GroupProc;
+}
+
+LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the user clicks on the group
+ * box label, the group box takes focus. This is unwanted.
+ * The fix is to avoid calling the group box window proc.
+ */
+ /*
+ * Bug in Windows. For some reason, if we allow the group
+ * box to take focus, it will draw on top of pull down combo
+ * box children. The fix is to avoid calling the window proc
+ * to disallow the receiver from getting focus.
+ */
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 1, OS.WM_LBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the user clicks on the group
+ * box label, the group box takes focus. This is unwanted.
+ * The fix is to avoid calling the group box window proc.
+ */
+ /*
+ * Bug in Windows. For some reason, if we allow the group
+ * box to take focus, it will draw on top of pull down combo
+ * box children. The fix is to avoid calling the window proc
+ * to disallow the receiver from getting focus.
+ */
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ if (hooks (SWT.DragDetect)) {
+ POINT pt = new POINT ();
+ pt.x = (short) (lParam & 0xFFFF);
+ pt.y = (short) (lParam >> 16);
+ if (OS.DragDetect (handle, pt)) {
+ sendEvent (SWT.DragDetect);
+ // widget could be disposed at this point
+ }
+ }
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_NCHITTEST (int wParam, int lParam) {
+ LRESULT result = super.WM_NCHITTEST (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. The window proc for the group box
+ * returns HTTRANSPARTENT indicating that mouse messages
+ * should not be delivered to the receiver and any children.
+ * Normally, group boxes in Windows do not have children and
+ * this is the correct behavior for this case. Because we
+ * allow children, answer HTCLIENT to allow mouse messages
+ * to be delivered to the children.
+ */
+ return new LRESULT (OS.HTCLIENT);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java
new file mode 100755
index 0000000000..8dce0641b9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ImageList.java
@@ -0,0 +1,262 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+class ImageList {
+ int handle, background;
+ Image [] images;
+ static final int CREATE_FLAGS;
+ static {
+ int flags = OS.ILC_MASK;
+ int hDC = OS.GetDC (0);
+ int bits = OS.GetDeviceCaps (hDC, OS.BITSPIXEL);
+ int planes = OS.GetDeviceCaps (hDC, OS.PLANES);
+ OS.ReleaseDC (0, hDC);
+ int depth = bits * planes;
+ switch (depth) {
+ case 4:
+ flags |= OS.ILC_COLOR4;
+ break;
+ case 8:
+ flags |= OS.ILC_COLOR8;
+ break;
+ case 16:
+ flags |= OS.ILC_COLOR16;
+ break;
+ case 24:
+ flags |= OS.ILC_COLOR24;
+ break;
+ case 32:
+ flags |= OS.ILC_COLOR32;
+ break;
+ default:
+ flags |= OS.ILC_COLOR;
+ }
+ CREATE_FLAGS = flags;
+ }
+
+public ImageList () {
+ handle = OS.ImageList_Create (32, 32, CREATE_FLAGS, 16, 16);
+ images = new Image [4];
+ background = 0x00FFFFFF;
+}
+
+public int add (Image image) {
+ int count = OS.ImageList_GetImageCount (handle);
+ int index = 0;
+ while (index < count) {
+ if (images [index] != null) {
+ if (images [index].isDisposed ()) images [index] = null;
+ }
+ if (images [index] == null) break;
+ index++;
+ }
+ int hImage = image.handle;
+ int [] cx = new int [1], cy = new int [1];
+ OS.ImageList_GetIconSize (handle, cx, cy);
+ switch (image.type) {
+ case SWT.BITMAP: {
+ if (count == 0) {
+ BITMAP bm = new BITMAP ();
+ OS.GetObject (hImage, BITMAP.sizeof, bm);
+ cx [0] = bm.bmWidth; cy [0] = bm.bmHeight;
+ OS.ImageList_SetIconSize (handle, cx [0], cy [0]);
+ }
+ int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
+ if (index == count) {
+ OS.ImageList_AddMasked (handle, hBitmap, background);
+ } else {
+ int hMask = createMask (hBitmap, cx [0], cy [0]);
+ OS.ImageList_Replace (handle, index, hBitmap, hMask);
+ OS.DeleteObject (hMask);
+ }
+ OS.DeleteObject (hBitmap);
+ break;
+ }
+ case SWT.ICON: {
+ if (count == 0) {
+ BITMAP bm = new BITMAP ();
+ ICONINFO info = new ICONINFO ();
+ OS.GetIconInfo (hImage, info);
+ int hBitmap = info.hbmColor;
+ if (hBitmap == 0) hBitmap = info.hbmMask;
+ OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+ if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
+ if (info.hbmColor != 0) OS.DeleteObject (info.hbmColor);
+ if (info.hbmMask != 0) OS.DeleteObject (info.hbmMask);
+ cx [0] = bm.bmWidth; cy [0] = bm.bmHeight;
+ OS.ImageList_SetIconSize (handle, cx [0], cy [0]);
+ }
+ int hIcon = copyIcon (hImage, cx [0], cy [0]);
+ OS.ImageList_ReplaceIcon (handle, index == count ? -1 : index, hIcon);
+ OS.DestroyIcon (hIcon);
+ break;
+ }
+ }
+ if (index == images.length) {
+ Image [] newImages = new Image [images.length + 4];
+ System.arraycopy (images, 0, newImages, 0, images.length);
+ images = newImages;
+ }
+ images [index] = image;
+ return index;
+}
+
+int copyBitmap (int hImage, int width, int height) {
+ BITMAP bm = new BITMAP ();
+ OS.GetObject (hImage, BITMAP.sizeof, bm);
+ int hDC = OS.GetDC (0);
+ int hdc1 = OS.CreateCompatibleDC (hDC);
+ OS.SelectObject (hdc1, hImage);
+ int hdc2 = OS.CreateCompatibleDC (hDC);
+ int hBitmap = OS.CreateCompatibleBitmap (hDC, width, height);
+ OS.SelectObject (hdc2, hBitmap);
+ OS.SetStretchBltMode(hdc2, OS.COLORONCOLOR);
+ OS.StretchBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, bm.bmWidth, bm.bmHeight, OS.SRCCOPY);
+ OS.DeleteDC (hdc1);
+ OS.DeleteDC (hdc2);
+ OS.ReleaseDC (0, hDC);
+ return hBitmap;
+}
+
+int copyIcon (int hImage, int width, int height) {
+ int hIcon = OS.CopyImage (hImage, OS.IMAGE_ICON, width, height, OS.LR_DEFAULTCOLOR);
+ return hIcon;
+}
+
+int createMask (int hBitmap, int width, int height) {
+ int hDC = OS.GetDC (0);
+ int hdc1 = OS.CreateCompatibleDC (hDC);
+ OS.SelectObject (hdc1, hBitmap);
+ int hdc2 = OS.CreateCompatibleDC (hDC);
+ int hMask = OS.CreateBitmap (width, height, 1, 1, null);
+ OS.SelectObject (hdc2, hMask);
+ OS.SetBkColor (hdc1, background);
+ OS.BitBlt (hdc2, 0, 0, width, height, hdc1, 0, 0, OS.SRCCOPY);
+ OS.ReleaseDC (0, hDC);
+ OS.DeleteDC (hdc1);
+ OS.DeleteDC (hdc2);
+ return hMask;
+}
+
+public void dispose () {
+ if (handle != 0) OS.ImageList_Destroy (handle);
+ handle = 0;
+ images = null;
+}
+
+public Image get (int index) {
+ return images [index];
+}
+
+public int getBackground () {
+ return background;
+}
+
+public int getHandle () {
+ return handle;
+}
+
+public int indexOf (Image image) {
+ int count = OS.ImageList_GetImageCount (handle);
+ for (int i=0; i<count; i++) {
+ if (images [i] != null) {
+ if (images [i].isDisposed ()) images [i] = null;
+ if (images [i] != null && images [i].equals (image)) return i;
+ }
+ }
+ return -1;
+}
+
+public void put (int index, Image image) {
+ int count = OS.ImageList_GetImageCount (handle);
+ if (!(0 <= index && index < count)) return;
+ if (image != null) {
+ int [] cx = new int [1], cy = new int [1];
+ OS.ImageList_GetIconSize (handle, cx, cy);
+ int hImage = image.handle;
+ switch (image.type) {
+ case SWT.BITMAP:
+ int hBitmap = copyBitmap (hImage, cx [0], cy [0]);
+ int hMask = createMask (hBitmap, cx [0], cy [0]);
+ OS.ImageList_Replace (handle, index, hBitmap, hMask);
+ OS.DeleteObject (hBitmap);
+ OS.DeleteObject (hMask);
+ break;
+ case SWT.ICON:
+ int hIcon = copyIcon (hImage, cx [0], cy [0]);
+ OS.ImageList_ReplaceIcon (handle, index, hIcon);
+ OS.DestroyIcon (hIcon);
+ break;
+ }
+ }
+ images [index] = image;
+}
+
+public void remove (int index) {
+ int count = OS.ImageList_GetImageCount (handle);
+ if (!(0 <= index && index < count)) return;
+ OS.ImageList_Remove (handle, index);
+ System.arraycopy (images, index + 1, images, index, --count - index);
+ images [index] = null;
+}
+
+public void setBackground (int color) {
+ if (background == color) return;
+ background = color;
+ /*
+ * This code is intentionally commented. When the background
+ * color of the control changes, it is necessary to recompute
+ * the masks for all bitmaps in the image list. This can look
+ * really bad when the application program assumes the original
+ * color of the control and makes bitmaps accordingly. Typically
+ * this happens when the colors are change using the control panel.
+ * Therefore, this code remains commented even though it is correct.
+ */
+// int length = OS.ImageList_GetImageCount (handle);
+// if (length == 0) return;
+// int [] cx = new int [1], cy = new int [1];
+// OS.ImageList_GetIconSize (handle, cx, cy);
+// int width = cx [0], height = cy [0];
+// OS.ImageList_Destroy (handle);
+// handle = OS.ImageList_Create (width, height, CREATE_FLAGS, length, 16);
+// for (int i=0; i<length; i++) {
+// Image image = images [i];
+// if (image == null || image.isDisposed ()) {
+// images [i] = null;
+// int hBitmap = OS.CreateBitmap (width, height, 1, 1, null);
+// OS.ImageList_AddMasked (handle, hBitmap, background);
+// OS.DeleteObject (hBitmap);
+// } else {
+// int hImage = image.handle;
+// switch (image.type) {
+// case SWT.BITMAP:
+// int hBitmap = copyBitmap (hImage, width, height);
+// OS.ImageList_AddMasked (handle, hBitmap, background);
+// OS.DeleteObject (hBitmap);
+// break;
+// case SWT.ICON:
+// int hIcon = copyIcon (hImage, width, height);
+// OS.ImageList_ReplaceIcon (handle, -1, hIcon);
+// OS.DestroyIcon (hIcon);
+// break;
+// default:
+// SWT.error (SWT.ERROR_NOT_IMPLEMENTED);
+// break;
+// }
+// }
+// }
+}
+
+public int size () {
+ return OS.ImageList_GetImageCount (handle);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
new file mode 100755
index 0000000000..646486fbdd
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java
@@ -0,0 +1,510 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a non-selectable
+ * user interface object displays a string or image.
+ * When the SEPARATOR is specified, displays a single
+ * vertical or horizontal line.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SEPARATOR, HORIZONTAL, SHADOW_IN, SHADOW_OUT, VERTICAL</dd>
+ * <dd>CENTER, LEFT, RIGHT, WRAP</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>
+ */
+
+public class Label extends Control {
+ Image image;
+ int font;
+ static final int LabelProc;
+ static final byte [] LabelClass = Converter.wcsToMbcs (0, "STATIC\0");
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, LabelClass, lpWndClass);
+ LabelProc = lpWndClass.lpfnWndProc;
+ }
+
+public Label (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (LabelProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ if ((style & SWT.SEPARATOR) != 0) return style;
+ return checkBits (style, SWT.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = 0, height = 0;
+ int border = getBorderWidth ();
+ if ((style & SWT.SEPARATOR) != 0) {
+ int lineWidth = OS.GetSystemMetrics (OS.SM_CXBORDER);
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width = DEFAULT_WIDTH; height = lineWidth * 2;
+ } else {
+ width = lineWidth * 2; height = DEFAULT_HEIGHT;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ width += border * 2; height += border * 2;
+ return new Point (width, height);
+ }
+ /*
+ * NOTE: SS_BITMAP and SS_ICON are not single bit
+ * masks so it is necessary to test for all of the
+ * bits in these masks.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ boolean isBitmap = (bits & OS.SS_BITMAP) == OS.SS_BITMAP;
+ boolean isIcon = (bits & OS.SS_ICON) == OS.SS_ICON;
+ if (isBitmap || isIcon) {
+ if (image != null) {
+ BITMAP bm = new BITMAP ();
+ int hImage = image.handle;
+ switch (image.type) {
+ case SWT.BITMAP:
+ OS.GetObject (hImage, BITMAP.sizeof, bm);
+ width = bm.bmWidth; height = bm.bmHeight;
+ break;
+ case SWT.ICON: {
+ ICONINFO info = new ICONINFO ();
+ OS.GetIconInfo (hImage, info);
+ int hBitmap = info.hbmColor;
+ if (hBitmap == 0) hBitmap = info.hbmMask;
+ OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+ if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
+ if (info.hbmColor != 0) OS.DeleteObject (info.hbmColor);
+ if (info.hbmMask != 0) OS.DeleteObject (info.hbmMask);
+ width = bm.bmWidth; height = bm.bmHeight;
+ break;
+ }
+ }
+ }
+ } else {
+ int hDC = OS.GetDC (handle);
+ int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ int oldFont = OS.SelectObject (hDC, newFont);
+ RECT rect = new RECT ();
+ int flags = OS.DT_CALCRECT;
+ if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
+ flags |= OS.DT_WORDBREAK;
+ rect.right = wHint;
+ }
+ int length = OS.GetWindowTextLength (handle);
+ byte [] buffer = new byte [length + 1];
+ OS.GetWindowText (handle, buffer, length + 1);
+ OS.DrawText (hDC, buffer, length, rect, flags);
+ width = rect.right - rect.left;
+ height = rect.bottom - rect.top;
+ if (height == 0) {
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ height = tm.tmHeight;
+ }
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ }
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ width += border * 2; height += border * 2;
+ return new Point (width, height);
+}
+
+/**
+ * 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;
+}
+
+/**
+ * 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 "";
+ int length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, buffer1.length);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+}
+
+/*
+* Not currently used.
+*/
+boolean getWrap () {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & (OS.SS_RIGHT | OS.SS_CENTER)) != 0) return true;
+ if ((bits & OS.SS_LEFTNOWORDWRAP) != 0) return false;
+ return true;
+}
+
+boolean mnemonicHit () {
+ 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 true;
+ }
+ control = control.parent;
+ }
+ return false;
+}
+
+boolean mnemonicMatch (char key) {
+ char mnemonic = findMnemonic (getText ());
+ if (mnemonic == '\0') return false;
+ return Character.toUpperCase (key) == Character.toUpperCase (mnemonic);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ image = null;
+}
+
+/**
+ * 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);
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ /*
+ * Feature in Windows. The windows label does not align
+ * the bitmap or icon. Any attempt to set alignment bits
+ * such as SS_CENTER cause the label to display text. The
+ * fix is to disallow alignment.
+ *
+ * NOTE: SS_BITMAP and SS_ICON are not single bit
+ * masks so it is necessary to test for all of the
+ * bits in these masks.
+ */
+ if ((bits & OS.SS_BITMAP) == OS.SS_BITMAP) return;
+ if ((bits & OS.SS_ICON) == OS.SS_ICON) return;
+ bits &= ~(OS.SS_LEFTNOWORDWRAP | OS.SS_CENTER | OS.SS_RIGHT);
+ if ((style & SWT.LEFT) != 0 && (style & SWT.WRAP) == 0) {
+ bits |= OS.SS_LEFTNOWORDWRAP;
+ }
+ if ((style & SWT.CENTER) != 0) bits |= OS.SS_CENTER;
+ if ((style & SWT.RIGHT) != 0) bits |= OS.SS_RIGHT;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ OS.InvalidateRect (handle, null, true);
+}
+
+public boolean setFocus () {
+ return false;
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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;
+ int hImage = 0, imageBits = 0, fImageType = 0;
+ if (image != null) {
+ hImage = image.handle;
+ switch (image.type) {
+ case SWT.BITMAP:
+ imageBits = OS.SS_BITMAP;
+ fImageType = OS.IMAGE_BITMAP;
+ break;
+ case SWT.ICON:
+ imageBits = OS.SS_ICON;
+ fImageType = OS.IMAGE_ICON;
+ break;
+ default:
+ return;
+ }
+ }
+ this.image = image;
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int newBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int oldBits = newBits;
+ newBits &= ~(OS.SS_BITMAP | OS.SS_ICON);
+ newBits |= imageBits | OS.SS_REALSIZEIMAGE | OS.SS_CENTERIMAGE;
+ if (newBits != oldBits) {
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ }
+ OS.SendMessage (handle, OS.STM_SETIMAGE, fImageType, hImage);
+ /*
+ * Feature in Windows. When STM_SETIMAGE is used to set the
+ * image for a static control, Windows either streches the image
+ * to fit the control or shrinks the control to fit the image.
+ * While not stricly wrong, neither of these is desirable.
+ * The fix is to stop Windows from stretching the image by
+ * using SS_REALSIZEIMAGE and SS_CENTERIMAGE, allow Windows
+ * to shrink the control, and then restore the control to the
+ * original size.
+ */
+ int flags = OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE | OS.SWP_NOMOVE;
+ OS.SetWindowPos (handle, 0, 0, 0, rect.right - rect.left, rect.bottom - rect.top, flags);
+ OS.InvalidateRect (handle, null, true);
+}
+
+/**
+ * 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);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ int newBits = OS.GetWindowLong (handle, OS.GWL_STYLE), oldBits = newBits;
+ newBits &= ~(OS.SS_BITMAP | OS.SS_ICON | OS.SS_REALSIZEIMAGE | OS.SS_CENTERIMAGE);
+ if ((style & SWT.LEFT) != 0 && (style & SWT.WRAP) == 0) newBits |= OS.SS_LEFTNOWORDWRAP;
+ if ((style & SWT.CENTER) != 0) newBits |= OS.SS_CENTER;
+ if ((style & SWT.RIGHT) != 0) newBits |= OS.SS_RIGHT;
+ if (newBits != oldBits) {
+ /*
+ * Bug in Windows. When the style of a label is SS_BITMAP
+ * or SS_ICON, the label does not remember the font that is
+ * set in WM_SETFONT. The fix is to remember the font and
+ * return the font in WM_GETFONT and to reset the font when
+ * the style is changed from SS_BITMAP or SS_ICON to a style
+ * that displays text.
+ */
+ int hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ if (hFont != 0) OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
+ }
+ string = Display.withCrLf (string);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SetWindowText (handle, buffer);
+}
+
+/*
+* Not currently used.
+*/
+void setWrap (boolean wrap) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & (OS.SS_RIGHT | OS.SS_CENTER)) != 0) return;
+ bits &= ~OS.SS_LEFTNOWORDWRAP;
+ if (!wrap) bits |= OS.SS_LEFTNOWORDWRAP;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ OS.InvalidateRect (handle, null, true);
+}
+
+int widgetExtStyle () {
+ if ((style & SWT.BORDER) != 0) return OS.WS_EX_STATICEDGE;
+ return super.widgetExtStyle ();
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.SS_NOTIFY;
+ if ((style & SWT.SEPARATOR) != 0) return bits | OS.SS_OWNERDRAW;
+ if ((style & SWT.CENTER) != 0) return bits | OS.SS_CENTER;
+ if ((style & SWT.RIGHT) != 0) return bits | OS.SS_RIGHT;
+ if ((style & SWT.WRAP) != 0) return bits | OS.SS_LEFT;
+ return bits | OS.SS_LEFTNOWORDWRAP;
+}
+
+byte [] windowClass () {
+ return LabelClass;
+}
+
+int windowProc () {
+ return LabelProc;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.SEPARATOR) == 0) {
+ /*
+ * Bug in Windows. When a label has the SS_BITMAP
+ * or SS_ICON style, the label does not draw the
+ * background. The fix is to draw the background
+ * when the label is showing a bitmap or icon.
+ *
+ * NOTE: SS_BITMAP and SS_ICON are not single bit
+ * masks so it is necessary to test for all of the
+ * bits in these masks.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.SS_BITMAP) != OS.SS_BITMAP &&
+ (bits & OS.SS_ICON) != OS.SS_ICON) return result;
+ }
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ int pixel = getBackgroundPixel ();
+ int hBrush = findBrush (pixel);
+ OS.FillRect (wParam, rect, hBrush);
+ return LRESULT.ONE;
+}
+
+LRESULT WM_GETFONT (int wParam, int lParam) {
+ LRESULT result = super.WM_GETFONT (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Bug in Windows. When the style of a label is SS_BITMAP
+ * or SS_ICON, the label does not remember the font that is
+ * set in WM_SETFONT. The fix is to remember the font and
+ * return the font in WM_GETFONT.
+ */
+ if (font == 0) font = defaultFont ();
+ return new LRESULT (font);
+}
+
+LRESULT WM_SETFONT (int wParam, int lParam) {
+ /*
+ * Bug in Windows. When the style of a label is SS_BITMAP
+ * or SS_ICON, the label does not remember the font that is
+ * set in WM_SETFONT. The fix is to remember the font and
+ * return the font in WM_GETFONT.
+ */
+ return super.WM_SETFONT (font = wParam, lParam);
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the resize
+ * event. If this happens, end the processing of the
+ * Windows message by returning the result of the
+ * WM_SIZE message.
+ */
+ if (isDisposed ()) return result;
+
+ /*
+ * Bug in Windows. For some reason, a label with
+ * style SS_LEFT, SS_CENTER or SS_RIGHT does not
+ * redraw the text in the new position when resized.
+ * Note that SS_LEFTNOWORDWRAP does no have the problem.
+ * The fix is to force the redraw.
+ */
+ if ((style & SWT.SEPARATOR) == 0) {
+ if ((style & (SWT.WRAP | SWT.CENTER | SWT.RIGHT)) != 0) {
+ OS.InvalidateRect (handle, null, true);
+ }
+ }
+ return result;
+}
+
+LRESULT wmDrawChild (int wParam, int lParam) {
+ if ((style & SWT.SHADOW_NONE) != 0) return null;
+ DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+ RECT rect = new RECT ();
+ int lineWidth = OS.GetSystemMetrics (OS.SM_CXBORDER);
+ int flags = OS.EDGE_ETCHED;
+ if ((style & SWT.SHADOW_IN) != 0) flags = OS.EDGE_SUNKEN;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ int bottom = struct.top + Math.max (lineWidth * 2, (struct.bottom - struct.top) / 2);
+ OS.SetRect (rect, struct.left, struct.top, struct.right, bottom);
+ OS.DrawEdge (struct.hDC, rect, flags, OS.BF_BOTTOM);
+ return null;
+ }
+ int right = struct.left + Math.max (lineWidth * 2, (struct.right - struct.left) / 2);
+ OS.SetRect (rect, struct.left, struct.top, right, struct.bottom);
+ OS.DrawEdge (struct.hDC, rect, flags, OS.BF_RIGHT);
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
new file mode 100755
index 0000000000..be29a769b4
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/List.java
@@ -0,0 +1,1427 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+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 displays a list of strings and issues notificiation
+ * when a string 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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class List extends Scrollable {
+ static final int ListProc;
+ static final byte [] ListClass = Converter.wcsToMbcs (0, "LISTBOX\0", false);
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ListClass, lpWndClass);
+ ListProc = lpWndClass.lpfnWndProc;
+ }
+/**
+* Creates a new instance of the widget.
+*/
+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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String,int)
+ */
+public void add (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, buffer);
+ if (result == OS.LB_ERR) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);
+}
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ *
+ * @see #add(String)
+ */
+public void add (String string, int index) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (index == -1) error (SWT.ERROR_INVALID_RANGE);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int result = OS.SendMessage (handle, OS.LB_INSERTSTRING, index, buffer);
+ if (result == OS.LB_ERRSPACE) error (SWT.ERROR_ITEM_NOT_ADDED);
+ if (result == OS.LB_ERR) {
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (0 <= index && index <= count) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ } else {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, true);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ListProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+/**
+* Computes the preferred size.
+*/
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int itemHeight = OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ int width = 0, height = count * itemHeight;
+ if ((style & SWT.H_SCROLL) != 0) {
+ width = OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
+ } else {
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ RECT rect = new RECT ();
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ byte [] buffer = new byte [64 + 1];
+ for (int i=0; i<count; i++) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
+ if (length != OS.LB_ERR) {
+ if (length + 1 > buffer.length) buffer = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
+ if (result != OS.LB_ERR) {
+ OS.DrawText (hDC, buffer, length, rect, flags);
+ width = Math.max (width, rect.right - rect.left);
+ }
+ }
+ }
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ }
+ 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 + 3;
+ height += border * 2;
+ if ((style & SWT.V_SCROLL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ }
+ return new Point (width, height);
+}
+
+ScrollBar createScrollBar (int type) {
+ return new ScrollBar (this, type);
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_WINDOW);
+}
+
+/**
+ * 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 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>
+ */
+public void deselect (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (indices.length == 0) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ if (oldIndex == OS.LB_ERR) return;
+ for (int i=0; i<indices.length; i++) {
+ if (oldIndex == indices [i]) {
+ OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
+ return;
+ }
+ }
+ return;
+ }
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (index != -1) {
+ OS.SendMessage (handle, OS.LB_SETSEL, 0, index);
+ }
+ }
+}
+
+/**
+ * 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 == -1) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ if (oldIndex == OS.LB_ERR) return;
+ if (oldIndex == index) OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
+ return;
+ }
+ OS.SendMessage (handle, OS.LB_SETSEL, 0, index);
+}
+
+/**
+ * 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 > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ if (oldIndex == OS.LB_ERR) return;
+ if (start <= oldIndex && oldIndex <= end) {
+ OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
+ }
+ return;
+ }
+ /*
+ * Ensure that at least one item is contained in
+ * the range from start to end. Note that when
+ * start = end, LB_SELITEMRANGEEX deselects the
+ * item.
+ */
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (start < 0 && end < 0) return;
+ if (start >= count && end >= count) return;
+ start = Math.min (count - 1, Math.max (0, start));
+ end = Math.min (count - 1, Math.max (0, end));
+ OS.SendMessage (handle, OS.LB_SELITEMRANGEEX, end, start);
+}
+
+/**
+ * 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 ();
+ if ((style & SWT.SINGLE) != 0) {
+ OS.SendMessage (handle, OS.LB_SETCURSEL, -1, 0);
+ return;
+ }
+ OS.SendMessage (handle, OS.LB_SETSEL, 0, -1);
+}
+
+/**
+ * Returns the zero-relative index of the item which is currently
+ * has the focus in the receiver, or -1 if no item is 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 ();
+ return OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public String getItem (int index) {
+ checkWidget ();
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ if (length != OS.LB_ERR) {
+ byte [] buffer1 = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer1);
+ if (result != OS.LB_ERR) {
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+ }
+ }
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (0 <= index && index < count) {
+ error (SWT.ERROR_CANNOT_GET_ITEM);
+ } else {
+ 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 ();
+ int result = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_COUNT);
+ return result;
+}
+
+/**
+ * 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 result = OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_ITEM_HEIGHT);
+ return result;
+}
+
+/**
+ * Returns an 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 effect 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_ITEM - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public String [] getItems () {
+ checkWidget ();
+ int count = getItemCount ();
+ String [] result = new String [count];
+ for (int i=0; i<count; i++) result [i] = getItem (i);
+ return result;
+}
+
+/**
+ * Returns an array of <code>String</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 effect 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 ();
+ if ((style & SWT.SINGLE) != 0) {
+ int result = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ if (result == OS.LB_ERR) return 0;
+ return 1;
+ }
+ int result = OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
+ if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_COUNT);
+ return result;
+}
+
+/**
+ * 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 ((style & SWT.SINGLE) != 0) {
+ return OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ }
+ int count = OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
+ if (count == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_SELECTION);
+ if (count == 0) return -1;
+ int index = OS.SendMessage (handle, OS.LB_GETCARETINDEX, 0, 0);
+ int result = OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
+ if (result == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_SELECTION);
+ if (result != 0) return index;
+ int [] buffer = new int [1];
+ result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, buffer);
+ if (result != 1) error (SWT.ERROR_CANNOT_GET_SELECTION);
+ return buffer [0];
+}
+
+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver. 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 effect 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 ();
+ if ((style & SWT.SINGLE) != 0) {
+ int result = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ if (result == OS.LB_ERR) return new int [0];
+ return new int [] {result};
+ }
+ int length = OS.SendMessage (handle, OS.LB_GETSELCOUNT, 0, 0);
+ if (length == OS.LB_ERR) error (SWT.ERROR_CANNOT_GET_SELECTION);
+ int [] indices = new int [length];
+ int result = OS.SendMessage (handle, OS.LB_GETSELITEMS, length, indices);
+ if (result != length) error (SWT.ERROR_CANNOT_GET_SELECTION);
+ return indices;
+}
+
+/**
+ * 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 ();
+ return OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+}
+
+/**
+* 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 SWTError <ul>
+* <li>ERROR_THREAD_INVALID_ACCESS when called from the wrong thread</li>
+* <li>ERROR_WIDGET_DISPOSED when the widget has been disposed</li>
+* <li>ERROR_NULL_ARGUMENT when string is null</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
+ * @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);
+
+ /*
+ * Bug in Windows. For some reason, LB_FINDSTRINGEXACT
+ * will not find empty strings even though it is legal
+ * to insert an empty string into a list. The fix is
+ * to search the list, an item at a time.
+ */
+ if (string.length () == 0) {
+ int count = getItemCount ();
+ for (int i=start; i<count; i++) {
+ if (string.equals (getItem (i))) return i;
+ }
+ return -1;
+ }
+
+ /* Use LB_FINDSTRINGEXACT to search for the item */
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (!((0 <= start) && (start < count))) return -1;
+ int index = start - 1, last;
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ do {
+ index = OS.SendMessage (handle, OS.LB_FINDSTRINGEXACT, last = index, buffer);
+ if ((index == OS.LB_ERR) || (index <= last)) return -1;
+ } while (!string.equals (getItem (index)));
+ return index;
+}
+
+/**
+ * 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 visibility 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 result = OS.SendMessage (handle, OS.LB_GETSEL, index, 0);
+ return (result != 0) && (result != OS.LB_ERR);
+}
+
+/**
+ * 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>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] newIndices = new int [indices.length];
+ System.arraycopy (indices, 0, newIndices, 0, indices.length);
+ sort (newIndices);
+ int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ RECT rect = null;
+ int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0;
+ if ((style & SWT.H_SCROLL) != 0) {
+ rect = new RECT ();
+ hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ }
+ byte [] buffer = null;
+ int i = 0, count = 0, last = -1;
+ while (i < newIndices.length) {
+ int index = newIndices [i];
+ if (index != last || i == 0) {
+ if ((style & SWT.H_SCROLL) != 0) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ if (length == OS.LB_ERR) break;
+ buffer = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
+ if (result == OS.LB_ERR) break;
+ }
+ int result = OS.SendMessage (handle, OS.LB_DELETESTRING, index, 0);
+ if (result == OS.LB_ERR) break;
+ if ((style & SWT.H_SCROLL) != 0) {
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ OS.DrawText (hDC, buffer, -1, rect, flags);
+ newWidth = Math.max (newWidth, rect.right - rect.left);
+ }
+ if (index < topIndex) count++;
+ last = index;
+ }
+ i++;
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ setScrollWidth (newWidth, false);
+ }
+ if (count > 0) {
+ topIndex -= count;
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex, 0);
+ }
+ if (i < newIndices.length) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int index) {
+ checkWidget ();
+ byte [] buffer = null;
+ if ((style & SWT.H_SCROLL) != 0) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, index, 0);
+ if (length == OS.LB_ERR) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ buffer = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, index, buffer);
+ if (result == OS.LB_ERR) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int result = OS.SendMessage (handle, OS.LB_DELETESTRING, index, 0);
+ if (result == OS.LB_ERR) {
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (0 <= index && index < count) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth (buffer, false);
+ if (index < topIndex) {
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex - 1, 0);
+ }
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+ checkWidget ();
+ if (start > end) return;
+ int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ RECT rect = null;
+ int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0;
+ if ((style & SWT.H_SCROLL) != 0) {
+ rect = new RECT ();
+ hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ }
+ int index = start;
+ byte [] buffer = null;
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ while (index <= end) {
+ if ((style & SWT.H_SCROLL) != 0) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, start, 0);
+ if (length == OS.LB_ERR) break;
+ buffer = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, start, buffer);
+ if (result == OS.LB_ERR) break;
+ }
+ int result = OS.SendMessage (handle, OS.LB_DELETESTRING, start, 0);
+ if (result == OS.LB_ERR) break;
+ if ((style & SWT.H_SCROLL) != 0) {
+ OS.DrawText (hDC, buffer, -1, rect, flags);
+ newWidth = Math.max (newWidth, rect.right - rect.left);
+ }
+ index++;
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ setScrollWidth (newWidth, false);
+ }
+ if (end < topIndex) {
+ topIndex -= end - start + 1;
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex, 0);
+ }
+ if (index <= end) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (String string) {
+ checkWidget ();
+ int index = indexOf (string, 0);
+ if (index == -1) error (SWT.ERROR_INVALID_ARGUMENT);
+ remove (index);
+}
+
+/**
+ * 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 ();
+ OS.SendMessage (handle, OS.LB_RESETCONTENT, 0, 0);
+ if ((style & SWT.H_SCROLL) != 0) {
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, 0, 0);
+ }
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @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 items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver
+ * is not selected, it is selected. If the item at the index
+ * was selected, it remains selected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @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>
+ */
+public void select (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SINGLE) != 0) {
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (0 <= index && index < count) {
+ select (index);
+ return;
+ }
+ }
+ return;
+ }
+ for (int i=0; i<indices.length; i++) {
+ int index = indices [i];
+ if (index != -1) {
+ OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
+ }
+ }
+}
+
+/**
+ * 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) return;
+ int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ RECT itemRect = new RECT (), selectedRect = null;
+ OS.SendMessage (handle, OS.LB_GETITEMRECT, index, itemRect);
+ boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
+ if (redraw) {
+ OS.UpdateWindow (handle);
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ if ((style & SWT.SINGLE) != 0) {
+ int oldIndex = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ if (oldIndex != -1) {
+ selectedRect = new RECT ();
+ OS.SendMessage (handle, OS.LB_GETITEMRECT, oldIndex, selectedRect);
+ }
+ OS.SendMessage (handle, OS.LB_SETCURSEL, index, 0);
+ } else {
+ OS.SendMessage (handle, OS.LB_SETSEL, 1, index);
+ }
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, topIndex, 0);
+ if (redraw) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.ValidateRect (handle, null);
+ OS.InvalidateRect (handle, itemRect, true);
+ if (selectedRect != null) {
+ OS.InvalidateRect (handle, selectedRect, true);
+ }
+ }
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the index was already selected, it remains
+ * selected. The range of the indices is inclusive. Indices that are
+ * out of range 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>
+ */
+public void select (int start, int end) {
+ checkWidget ();
+ if (start > end) return;
+ if ((style & SWT.SINGLE) != 0) {
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int index = Math.min (count - 1, end);
+ if (index >= start) select (index);
+ return;
+ }
+ /*
+ * Ensure that at least one item is contained in
+ * the range from start to end. Note that when
+ * start = end, LB_SELITEMRANGEEX deselects the
+ * item.
+ */
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (start < 0 && end < 0) return;
+ if (start >= count && end >= count) return;
+ start = Math.min (count - 1, Math.max (0, start));
+ end = Math.min (count - 1, Math.max (0, end));
+ if (start == end) {
+ select (start);
+ return;
+ }
+ OS.SendMessage (handle, OS.LB_SELITEMRANGEEX, start, end);
+}
+
+/**
+ * Selects all 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 void selectAll () {
+ checkWidget ();
+ if ((style & SWT.SINGLE) != 0) return;
+ OS.SendMessage (handle, OS.LB_SETSEL, 1, -1);
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ /*
+ * Bug in Windows. If the receiver is scrolled horizontally
+ * and is resized, the list does not redraw properly. The fix
+ * is to redraw the receiver.
+ */
+ if ((parent.hdwp != 0) || ((flags & OS.SWP_NOSIZE) != 0)) {
+ super.setBounds (x, y, width, height, flags);
+ return;
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ super.setBounds (x, y, width, height, flags);
+ if (((rect.right - rect.left) == width) || ((rect.bottom - rect.top) == height)) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS;
+ if (!OS.GetScrollInfo (handle, OS.SB_HORZ, info)) return;
+ if (info.nPos != 0) OS.InvalidateRect (handle, null, true);
+}
+
+void setFocusIndex (int index) {
+ OS.SendMessage (handle, OS.LB_SETCARETINDEX, index, 0);
+}
+
+public void setFont (Font font) {
+ checkWidget ();
+ super.setFont (font);
+ if ((style & SWT.H_SCROLL) != 0) setScrollWidth ();
+}
+
+/**
+ * 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>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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_ITEM_NOT_REMOVED - if the remove operation fails because of an operating system failure</li>
+ * <li>ERROR_ITEM_NOT_ADDED - if the add operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void setItem (int index, String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int topIndex = getTopIndex ();
+ boolean isSelected = isSelected (index);
+ remove (index);
+ add (string, index);
+ if (isSelected) select (index);
+ setTopIndex (topIndex);
+}
+
+/**
+ * Sets the receiver's items to be the given array of items.
+ *
+ * @param items the array 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_ADDED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */public void setItems (String [] items) {
+ checkWidget ();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, ListProc);
+ boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
+ if (redraw) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ RECT rect = null;
+ boolean failed = false;
+ int hDC = 0, oldFont = 0, newFont = 0, newWidth = 0;
+ if ((style & SWT.H_SCROLL) != 0) {
+ rect = new RECT ();
+ hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, 0, 0);
+ }
+ int length = items.length, guess = 32;
+ OS.SendMessage (handle, OS.LB_RESETCONTENT, 0, 0);
+ OS.SendMessage (handle, OS.LB_INITSTORAGE, length, length * guess);
+ int index = 0;
+ char [] unicode = new char [guess];
+ byte [] mbcs = new byte [unicode.length * 2];
+ while (index < length) {
+ String string = items [index];
+ if (string == null) break;
+ int nUnicode = string.length ();
+ if (nUnicode >= unicode.length) {
+ unicode = new char [nUnicode + 1];
+ mbcs = new byte [unicode.length * 2];
+ }
+ string.getChars (0, nUnicode, unicode, 0);
+ unicode [nUnicode] = 0;
+ int nMbcs = nUnicode, i = 0;
+ while (i <= nUnicode) {
+ if (unicode [i] > 0x7F) break;
+ mbcs [i] = (byte) unicode [i];
+ i++;
+ }
+ if (i < nUnicode) {
+ nMbcs = OS.WideCharToMultiByte (OS.CP_ACP, 0, unicode, nUnicode, mbcs, nUnicode * 2, null, null);
+ }
+ int result = OS.SendMessage (handle, OS.LB_ADDSTRING, 0, mbcs);
+ if (result == OS.LB_ERR || result == OS.LB_ERRSPACE) break;
+ if ((style & SWT.H_SCROLL) != 0) {
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ OS.DrawText (hDC, mbcs, nMbcs - 1, rect, flags);
+ newWidth = Math.max (newWidth, rect.right - rect.left);
+ }
+ index++;
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + 3, 0);
+ }
+ if (redraw) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ /*
+ * This code is intentionally commented. The window proc
+ * for the list box implements WM_SETREDRAW to invalidate
+ * and erase the widget. This is undocumented behavior.
+ * The commented code below shows what is actually happening
+ * and reminds us that we are relying on this undocumented
+ * behavior.
+ */
+// int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE;
+// OS.RedrawWindow (handle, null, 0, flags);
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ if (index < items.length) error (SWT.ERROR_ITEM_NOT_ADDED);
+}
+
+void setScrollWidth () {
+ int newWidth = 0;
+ RECT rect = new RECT ();
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ for (int i=0; i<count; i++) {
+ int length = OS.SendMessage (handle, OS.LB_GETTEXTLEN, i, 0);
+ if (length != OS.LB_ERR) {
+ byte [] buffer = new byte [length + 1];
+ int result = OS.SendMessage (handle, OS.LB_GETTEXT, i, buffer);
+ if (result != OS.LB_ERR) {
+ OS.DrawText (hDC, buffer, -1, rect, flags);
+ newWidth = Math.max (newWidth, rect.right - rect.left);
+ }
+ }
+ }
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + 3, 0);
+}
+
+void setScrollWidth (byte [] buffer, boolean grow) {
+ RECT rect = new RECT ();
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ OS.DrawText (hDC, buffer, -1, rect, flags);
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ setScrollWidth (rect.right - rect.left, grow);
+}
+
+void setScrollWidth (int newWidth, boolean grow) {
+ int width = OS.SendMessage (handle, OS.LB_GETHORIZONTALEXTENT, 0, 0);
+ if (grow) {
+ if (newWidth <= width) return;
+ OS.SendMessage (handle, OS.LB_SETHORIZONTALEXTENT, newWidth + 3, 0);
+ } else {
+ if (newWidth < width) return;
+ setScrollWidth ();
+ }
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selected of first cleared, then the new items are selected.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @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 List#deselectAll()
+ * @see List#select(int[])
+ */
+public void setSelection(int [] indices) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (indices);
+}
+
+/**
+ * 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 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 List#deselectAll()
+ * @see List#select(int)
+ */
+public void setSelection (String [] items) {
+ checkWidget ();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ for (int i=items.length-1; i>=0; --i) {
+ int index = 0;
+ String string = items [i];
+ if (string != null) {
+ while ((index = indexOf (string, index)) != -1) {
+ select (index);
+ if ((style & SWT.SINGLE) != 0 && isSelected (index)) return;
+ index++;
+ }
+ }
+ }
+ if ((style & SWT.SINGLE) != 0) deselectAll ();
+}
+
+/**
+ * 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 selected 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>
+ * @see List#deselectAll()
+ * @see List#select(int)
+ */
+public void setSelection (int index) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (index);
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selected if first cleared, then the new items are selected.
+ *
+ * @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) {
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ select (start, end);
+}
+
+/**
+ * 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 ();
+ int result = OS.SendMessage (handle, OS.LB_SETTOPINDEX, index, 0);
+ if (result == OS.LB_ERR) {
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ index = Math.min (count - 1, Math.max (0, index));
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, index, 0);
+ }
+}
+
+/**
+ * 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 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>
+ */
+public void showSelection () {
+ checkWidget ();
+ int index;
+ if ((style & SWT.SINGLE) != 0) {
+ index = OS.SendMessage (handle, OS.LB_GETCURSEL, 0, 0);
+ } else {
+ int [] indices = new int [1];
+ int result = OS.SendMessage (handle, OS.LB_GETSELITEMS, 1, indices);
+ index = indices [0];
+ if (result != 1) index = -1;
+ }
+ if (index == -1) return;
+ int count = OS.SendMessage (handle, OS.LB_GETCOUNT, 0, 0);
+ if (count == 0) return;
+ int height = OS.SendMessage (handle, OS.LB_GETITEMHEIGHT, 0, 0);
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ int topIndex = OS.SendMessage (handle, OS.LB_GETTOPINDEX, 0, 0);
+ int visibleCount = Math.max (rect.bottom / height, 1);
+ int bottomIndex = Math.min (topIndex + visibleCount + 1, count - 1);
+ if ((topIndex <= index) && (index <= bottomIndex)) return;
+ int newTop = Math.min (Math.max (index - (visibleCount / 2), 0), count - 1);
+ OS.SendMessage (handle, OS.LB_SETTOPINDEX, newTop, 0);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP | OS.LBS_NOTIFY | OS.LBS_NOINTEGRALHEIGHT;
+ if ((style & SWT.SINGLE) != 0) return bits;
+ if ((style & SWT.MULTI) != 0) {
+ if ((style & SWT.SIMPLE) != 0) return bits | OS.LBS_MULTIPLESEL;
+ return bits | OS.LBS_EXTENDEDSEL;
+ }
+ return bits;
+}
+
+byte [] windowClass () {
+ return ListClass;
+}
+
+int windowProc () {
+ return ListProc;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ int code = wParam >> 16;
+ switch (code) {
+ case OS.LBN_SELCHANGE:
+ postEvent (SWT.Selection);
+ break;
+ case OS.LBN_DBLCLK:
+ postEvent (SWT.DefaultSelection);
+ break;
+ }
+ return super.wmCommandChild (wParam, lParam);
+}
+
+LRESULT wmScroll (int msg, int wParam, int lParam) {
+ int code = callWindowProc (msg, wParam, lParam);
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
new file mode 100755
index 0000000000..0bc33f0134
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Menu.java
@@ -0,0 +1,716 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class are user interface objects that contain
+ * menu items.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>BAR, DROP_DOWN, POP_UP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Help, Hide, Show </dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Menu extends Widget {
+ public int handle;
+ int x, y;
+ boolean hasLocation;
+ MenuItem cascade;
+ Decorations parent;
+
+public Menu (Control parent) {
+ this (checkNull (parent).getShell (), SWT.POP_UP);
+}
+
+public Menu (Decorations parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget ();
+}
+
+public Menu (Menu parentMenu) {
+ this (checkNull (parentMenu).parent, SWT.DROP_DOWN);
+}
+
+public Menu (MenuItem parentItem) {
+ this (checkNull (parentItem).parent);
+}
+
+/**
+ * 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 help events are generated for the control, 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);
+}
+
+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 createHandle () {
+ if ((style & SWT.BAR) != 0) {
+ handle = OS.CreateMenu ();
+ } else {
+ handle = OS.CreatePopupMenu ();
+ }
+ if (handle == 0) error (SWT.ERROR_NO_HANDLES);
+}
+
+void createItem (MenuItem item, int index) {
+ int count = OS.GetMenuItemCount (handle);
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ parent.add (item);
+ /*
+ * Bug in Windows. For some reason, when InsertMenuItem ()
+ * is used to insert an item without text, it is not possible
+ * to use SetMenuItemInfo () to set the text at a later time.
+ * The fix is to insert the item with an empty string.
+ */
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 1);
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID | OS.MIIM_TYPE;
+ info.wID = item.id;
+ info.fType = item.widgetStyle ();
+ info.dwTypeData = pszText;
+ boolean success = OS.InsertMenuItem (handle, index, true, info);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ if (!success) {
+ parent.remove (item);
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+ redraw ();
+}
+
+void createWidget () {
+ createHandle ();
+ parent.add (this);
+}
+
+/*
+* Currently not used.
+*/
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_MENU);
+}
+
+/*
+* Currently not used.
+*/
+int defaultForeground () {
+ return OS.GetSysColor (OS.COLOR_MENUTEXT);
+}
+
+void destroyAcceleratorTable () {
+ parent.destroyAcceleratorTable ();
+}
+
+void destroyItem (MenuItem item) {
+ if (!OS.RemoveMenu (handle, item.id, OS.MF_BYCOMMAND)) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ redraw ();
+}
+
+void destroyWidget () {
+ int hMenu = handle;
+ releaseHandle ();
+ if (hMenu != 0) {
+ OS.DestroyMenu (hMenu);
+ }
+}
+
+/**
+ * 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 ();
+ int id = OS.GetMenuDefaultItem (handle, OS.MF_BYCOMMAND, OS.GMDI_USEDISABLED);
+ if (id == -1) return null;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID;
+ if (OS.GetMenuItemInfo (handle, id, false, info)) {
+ return parent.findMenuItem (info.wID);
+ }
+ return null;
+}
+
+public Display getDisplay () {
+ Decorations parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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>
+ */
+public boolean getEnabled () {
+ checkWidget ();
+ return (state & DISABLED) == 0;
+}
+
+/**
+ * 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 ();
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID;
+ if (!OS.GetMenuItemInfo (handle, index, true, info)) {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ return parent.findMenuItem (info.wID);
+}
+
+/**
+ * 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.GetMenuItemCount (handle);
+}
+
+/**
+ * Returns an 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 effect 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 count = OS.GetMenuItemCount (handle);
+ MenuItem [] items = new MenuItem [count];
+ if (items.length == 0) return items;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID;
+ for (int i=0; i<count; i++) {
+ if (OS.GetMenuItemInfo (handle, i, true, info)) {
+ items [i] = parent.findMenuItem (info.wID);
+ }
+ }
+ 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 cascade.parent;
+ return null;
+}
+
+/**
+ * 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 ();
+ return true;
+}
+
+/**
+ * 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 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 (MenuItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = OS.GetMenuItemCount (handle);
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID;
+ for (int i=0; i<count; i++) {
+ if (OS.GetMenuItemInfo (handle, i, true, info)) {
+ if (info.wID == item.id) return i;
+ }
+ }
+ return -1;
+}
+
+/**
+ * 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>
+ */
+public boolean isEnabled () {
+ checkWidget ();
+ Menu parentMenu = getParentMenu ();
+ if (parentMenu == null) return getEnabled ();
+ return getEnabled () && parentMenu.isEnabled ();
+}
+
+boolean isValidWidget () {
+ return handle != 0;
+}
+
+/**
+ * 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 isVisible () {
+ checkWidget ();
+ return getVisible ();
+}
+
+void redraw () {
+ if ((style & SWT.BAR) != 0) {
+ OS.DrawMenuBar (parent.handle);
+ return;
+ }
+ if ((WIN32_MAJOR << 16 | WIN32_MINOR) < (4 << 16 | 10)) {
+ return;
+ }
+ boolean hasCheck = false, hasImage = false;
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (item.getImage () != null) {
+ if ((hasImage = true) && hasCheck) break;
+ }
+ if ((item.getStyle () & (SWT.CHECK | SWT.RADIO)) != 0) {
+ if ((hasCheck = true) && hasImage) break;
+ }
+ }
+ MENUINFO lpcmi = new MENUINFO ();
+ lpcmi.cbSize = MENUINFO.sizeof;
+ lpcmi.fMask = OS.MIM_STYLE;
+ OS.GetMenuInfo (handle, lpcmi);
+ if (hasImage && !hasCheck) {
+ lpcmi.dwStyle |= OS.MNS_CHECKORBMP;
+ } else {
+ lpcmi.dwStyle &= ~OS.MNS_CHECKORBMP;
+ }
+ OS.SetMenuInfo (handle, lpcmi);
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (cascade != null) cascade.setMenu (null);
+ if ((style & SWT.BAR) != 0 && this == parent.menuBar) {
+ parent.setMenuBar (null);
+ }
+}
+
+void releaseHandle () {
+ handle = 0;
+}
+
+void releaseWidget () {
+ MenuItem [] items = getItems ();
+ for (int i=0; i<items.length; i++) {
+ MenuItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ super.releaseWidget ();
+ if (parent != null) parent.remove (this);
+ parent = null;
+ cascade = null;
+}
+
+/**
+ * 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 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 menu events are generated for the control.
+ *
+ * @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 #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);
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 ();
+ int command = -1;
+ if (item != null) command = item.id;
+ OS.SetMenuDefaultItem (handle, command, OS.MF_BYCOMMAND);
+ redraw ();
+}
+
+/**
+ * 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 ();
+ state &= ~DISABLED;
+ if (!enabled) state |= DISABLED;
+}
+
+/**
+ * Sets the receiver's location to the point specified by
+ * the arguments which are relative to the display.
+ * <p>
+ * Note: 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;
+ hasLocation = true;
+}
+
+/**
+ * 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;
+ int hwndParent = parent.handle;
+ if (!visible) {
+ OS.SendMessage (hwndParent, OS.WM_CANCELMODE, 0, 0);
+ return;
+ }
+ int flags = OS.TPM_LEFTBUTTON | OS.TPM_RIGHTBUTTON | OS.TPM_LEFTALIGN;
+ int nX = x, nY = y;
+ if (!hasLocation) {
+ int pos = OS.GetMessagePos ();
+ nX = (short) (pos & 0xFFFF);
+ nY = (short) (pos >> 16);
+ }
+ /*
+ * Feature in Windows. It is legal use TrackPopupMenu ()
+ * to display an empty menu as long menu items are added
+ * inside of WM_INITPOPUPMENU. If no items are added, then
+ * TrackPopupMenu () fails and does not send an indication
+ * that the menu has been closed. This is not strictly a
+ * bug but leads to unwanted behavior when application code
+ * assumes that every WM_INITPOPUPMENU will eventually result
+ * in a WM_MENUSELECT, wParam=0xFFFF0000, lParam=0 to indicate
+ * that the menu has been closed. The fix is to detect the
+ * case when TrackPopupMenu fails and the number of items in
+ * the menu is zero and issue a fake WM_MENUSELECT.
+ */
+ boolean success = OS.TrackPopupMenu (handle, flags, nX, nY, 0, hwndParent, null);
+ if (!success && OS.GetMenuItemCount (handle) == 0) {
+ OS.SendMessage (hwndParent, OS.WM_MENUSELECT, 0xFFFF0000, 0);
+ }
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
new file mode 100755
index 0000000000..f45f932480
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java
@@ -0,0 +1,657 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+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 notificiation 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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class MenuItem extends Item {
+ Menu parent, menu;
+ int id, accelerator;
+
+public MenuItem (Menu parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+public MenuItem (Menu parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+/**
+ * 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 control is selected, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+static int checkStyle (int style) {
+ return checkBits (style, SWT.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.CASCADE, 0);
+}
+
+void fillAccel (ACCEL accel) {
+ accel.fVirt = 0;
+ accel.cmd = accel.key = 0;
+ if (accelerator == 0) return;
+ int key = accelerator & ~(SWT.ALT | SWT.CTRL | SWT.SHIFT);
+ int newKey = Display.untranslateKey (key);
+ if (newKey != 0) {
+ key = newKey;
+ } else {
+ if (key == 0x7F) {
+ key = OS.VK_DELETE;
+ } else {
+ char ch = wcsToMbcs ((char) key);
+ key = OS.CharUpper ((short) ch);
+ }
+ }
+ accel.key = (short) key;
+ accel.cmd = (short) id;
+ accel.fVirt = (byte) OS.FVIRTKEY;
+ if ((accelerator & SWT.ALT) != 0) accel.fVirt |= OS.FALT;
+ if ((accelerator & SWT.CTRL) != 0) accel.fVirt |= OS.FCONTROL;
+ if ((accelerator & SWT.SHIFT) != 0) accel.fVirt |= OS.FSHIFT;
+}
+
+/**
+ * Return 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>.
+ *
+ * @return the accelerator
+ *
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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;
+}
+
+public Display getDisplay () {
+ Menu parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+ * 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>
+ */
+public boolean getEnabled () {
+ checkWidget ();
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_STATE;
+ boolean success = OS.GetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_GET_ENABLED);
+ return (info.fState & (OS.MFS_DISABLED | OS.MFS_GRAYED)) == 0;
+}
+/**
+ * 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;
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_STATE;
+ boolean success = OS.GetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_GET_SELECTION);
+ return (info.fState & OS.MFS_CHECKED) !=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>
+ */
+public boolean isEnabled () {
+ return getEnabled () && parent.isEnabled ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ if (menu != null) menu.dispose ();
+ menu = null;
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ if (menu != null) {
+ menu.releaseWidget ();
+ menu.releaseHandle ();
+ }
+ menu = null;
+ super.releaseWidget ();
+ if (accelerator != 0) {
+ parent.destroyAcceleratorTable ();
+ }
+ accelerator = 0;
+ Decorations shell = parent.parent;
+ shell.remove (this);
+ parent = null;
+}
+
+/**
+ * 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 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 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.
+ *
+ * @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 #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 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>.
+ *
+ * @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 ();
+ this.accelerator = accelerator;
+ parent.destroyAcceleratorTable ();
+}
+
+/**
+ * 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 ();
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_STATE;
+ boolean success = OS.GetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_SET_ENABLED);
+ info.fState &= ~(OS.MFS_DISABLED | OS.MFS_GRAYED);
+ if (!enabled) info.fState |= (OS.MFS_DISABLED | OS.MFS_GRAYED);
+ success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_SET_ENABLED);
+ parent.redraw ();
+}
+
+public void setImage (Image image) {
+ checkWidget ();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+ if ((WIN32_MAJOR << 16 | WIN32_MINOR) < (4 << 16 | 10)) {
+ return;
+ }
+ int hMenu = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_BITMAP;
+ if (image != null) info.hbmpItem = OS.HBMMENU_CALLBACK;
+ boolean success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ /*
+ * This code is intentionally commented.
+ */
+// if (!success) error (SWT.ERROR_CANNOT_SET_TEXT);
+ parent.redraw ();
+}
+
+/**
+ * Sets the receiver's cascade 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.
+ *
+ * @param menu the new pop up menu
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_MENU_NOT_DROP_DOWN - the menu is not a drop down menu</li>
+ * <li>ERROR_MENUITEM_NOT_CASCADE - the menu item is not a <code>CASCADE</code></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;
+ if (oldMenu != null) oldMenu.cascade = null;
+ this.menu = menu;
+
+ /* Assign the new menu in the OS */
+
+ /*
+ * Feature in Windows. When SetMenuItemInfo () is used to
+ * set a submenu and the menu item already has a submenu,
+ * Windows destroys the previous menu. This is undocumented
+ * and unexpected but not necessarily wrong. The fix is to
+ * remove the item with RemoveMenu () which does not destroy
+ * the submenu and then insert the item with InsertMenuItem ().
+ */
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_ID;
+ int index = 0, count = OS.GetMenuItemCount (hMenu);
+ while (index < count) {
+ if (OS.GetMenuItemInfo (hMenu, index, true, info) && (info.wID == id)) {
+ break;
+ }
+ index++;
+ }
+ if (index == count) return;
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 128);
+ info.fMask = OS.MIIM_STATE | OS.MIIM_ID | OS.MIIM_TYPE;
+ info.dwTypeData = pszText;
+ info.cch = 128;
+ boolean success = OS.GetMenuItemInfo (hMenu, index, true, info);
+ if (menu != null) {
+ menu.cascade = this;
+ info.fMask |= OS.MIIM_SUBMENU;
+ info.hSubMenu = menu.handle;
+ }
+ OS.RemoveMenu (hMenu, index, OS.MF_BYPOSITION);
+ success = OS.InsertMenuItem (hMenu, index, true, info);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ if (!success) error (SWT.ERROR_CANNOT_SET_MENU);
+ parent.destroyAcceleratorTable ();
+}
+
+/**
+ * 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;
+ int hMenu = parent.handle;
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_STATE;
+ boolean success = OS.GetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_SET_SELECTION);
+ info.fState &= ~OS.MFS_CHECKED;
+ if (selected) info.fState |= OS.MFS_CHECKED;
+ success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ if (!success) error (SWT.ERROR_CANNOT_SET_SELECTION);
+ parent.redraw ();
+}
+
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ int hMenu = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ MENUITEMINFO info = new MENUITEMINFO ();
+ info.cbSize = MENUITEMINFO.sizeof;
+ info.fMask = OS.MIIM_TYPE;
+ info.fType = widgetStyle ();
+ info.dwTypeData = pszText;
+ boolean success = OS.SetMenuItemInfo (hMenu, id, false, info);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ if (!success) error (SWT.ERROR_CANNOT_SET_TEXT);
+ parent.redraw ();
+}
+
+int widgetStyle () {
+ if ((style & SWT.SEPARATOR) != 0) return OS.MFT_SEPARATOR;
+ if ((style & SWT.RADIO) != 0) return OS.MFT_RADIOCHECK;
+ return OS.MFT_STRING;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ if ((style & (SWT.CHECK | SWT.RADIO)) != 0) {
+ setSelection (!getSelection ());
+ }
+ postEvent (SWT.Selection);
+ return null;
+}
+
+/*
+* Not currently used.
+*/
+LRESULT wmDrawChild (int wParam, int lParam) {
+ DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof);
+ if (image != null) {
+ /*
+ * This code intentionally commented.
+ */
+// GC gc = GC.win32_new (struct.hDC, null);
+// gc.drawImage (image, struct.left, struct.top);
+ int hImage = image.handle;
+ switch (image.type) {
+ case SWT.BITMAP:
+ BITMAP bm = new BITMAP ();
+ OS.GetObject (hImage, BITMAP.sizeof, bm);
+ int hDC = OS.CreateCompatibleDC (struct.hDC);
+ int oldBitmap = OS.SelectObject (hDC, hImage);
+ OS.BitBlt (struct.hDC, struct.left, struct.top + 2, bm.bmWidth, bm.bmHeight, hDC, 0, 0, OS.SRCCOPY);
+ OS.SelectObject (hDC, oldBitmap);
+ OS.DeleteDC (hDC);
+ break;
+ case SWT.ICON:
+ OS.DrawIconEx (struct.hDC, struct.left, struct.top + 2, hImage, 0, 0, 0, 0, OS.DI_NORMAL);
+ break;
+ }
+ }
+ return null;
+}
+
+/*
+* Not currently used.
+*/
+LRESULT wmMeasureChild (int wParam, int lParam) {
+ MEASUREITEMSTRUCT struct = new MEASUREITEMSTRUCT ();
+ OS.MoveMemory (struct, lParam, MEASUREITEMSTRUCT.sizeof);
+ if (image != null) {
+ /*
+ * This code intentionally commented.
+ */
+// Rectangle rect = image.getBounds ();
+// struct.itemWidth = rect.width;
+// struct.itemHeight = rect.height;
+ int hImage = image.handle;
+ BITMAP bm = new BITMAP ();
+ switch (image.type) {
+ case SWT.BITMAP:
+ OS.GetObject (hImage, BITMAP.sizeof, bm);
+ break;
+ case SWT.ICON:
+ ICONINFO info = new ICONINFO ();
+ OS.GetIconInfo (hImage, info);
+ int hBitmap = info.hbmColor;
+ if (hBitmap == 0) hBitmap = info.hbmMask;
+ OS.GetObject (hBitmap, BITMAP.sizeof, bm);
+ if (hBitmap == info.hbmMask) bm.bmHeight /= 2;
+ if (info.hbmColor != 0) OS.DeleteObject (info.hbmColor);
+ if (info.hbmMask != 0) OS.DeleteObject (info.hbmMask);
+ break;
+ }
+ struct.itemWidth = bm.bmWidth + 4;
+ struct.itemHeight = bm.bmHeight + 4;
+ }
+ OS.MoveMemory (lParam, struct, MEASUREITEMSTRUCT.sizeof);
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
new file mode 100755
index 0000000000..33e6b28bdc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MessageBox.java
@@ -0,0 +1,158 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+/* Imports */
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.widgets.*;
+
+/**
+ * Instances of this class are used 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>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class MessageBox extends Dialog {
+ String message = "";
+
+public MessageBox (Shell parent) {
+ this (parent, SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL);
+}
+
+public MessageBox (Shell parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+static int checkStyle (int style) {
+ if ((style & (SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL)) == 0) style |= SWT.APPLICATION_MODAL;
+ 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;
+}
+
+public String getMessage () {
+ return message;
+}
+
+public int open () {
+
+ /* Compute the MessageBox style */
+ int buttonBits = 0;
+ if ((style & SWT.OK) == SWT.OK) buttonBits = OS.MB_OK;
+ if ((style & (SWT.OK | SWT.CANCEL)) == (SWT.OK | SWT.CANCEL)) buttonBits = OS.MB_OKCANCEL;
+ if ((style & (SWT.YES | SWT.NO)) == (SWT.YES | SWT.NO)) buttonBits = OS.MB_YESNO;
+ if ((style & (SWT.YES | SWT.NO | SWT.CANCEL)) == (SWT.YES | SWT.NO | SWT.CANCEL)) buttonBits = OS.MB_YESNOCANCEL;
+ if ((style & (SWT.RETRY | SWT.CANCEL)) == (SWT.RETRY | SWT.CANCEL)) buttonBits = OS.MB_RETRYCANCEL;
+ if ((style & (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) == (SWT.ABORT | SWT.RETRY | SWT.IGNORE)) buttonBits = OS.MB_ABORTRETRYIGNORE;
+ if (buttonBits == 0) buttonBits = OS.MB_OK;
+
+ int iconBits = 0;
+ if ((style & SWT.ICON_ERROR) != 0) iconBits = OS.MB_ICONERROR;
+ if ((style & SWT.ICON_INFORMATION) != 0) iconBits = OS.MB_ICONINFORMATION;
+ if ((style & SWT.ICON_QUESTION) != 0) iconBits = OS.MB_ICONQUESTION;
+ if ((style & SWT.ICON_WARNING) != 0) iconBits = OS.MB_ICONWARNING;
+ if ((style & SWT.ICON_WORKING) != 0) iconBits = OS.MB_ICONINFORMATION;
+
+ int modalBits = 0;
+ if ((style & SWT.PRIMARY_MODAL) != 0) modalBits = OS.MB_APPLMODAL;
+ if ((style & SWT.APPLICATION_MODAL) != 0) modalBits = OS.MB_TASKMODAL;
+ if ((style & SWT.SYSTEM_MODAL) != 0) modalBits = OS.MB_SYSTEMMODAL;
+
+ int bits = buttonBits | iconBits | modalBits;
+
+ /*
+ * Feature in Windows. System modal is not supported
+ * on Windows 95 and NT. The fix is to convert system
+ * modal to task modal.
+ */
+ if ((bits & OS.MB_SYSTEMMODAL) != 0) {
+ bits |= OS.MB_TASKMODAL;
+ bits &= ~OS.MB_SYSTEMMODAL;
+ }
+
+ /*
+ * Bug in Windows. In order for MB_TASKMODAL to work,
+ * the parent HWND of the MessageBox () call must be NULL.
+ * The fix is to force the parent to be NULL when this
+ * style is set.
+ */
+ int hwndOwner = 0;
+ if (parent != null && (bits & OS.MB_TASKMODAL) == 0) {
+ hwndOwner = parent.handle;
+ }
+
+ /*
+ * Feature in Windows. The focus window is not saved and
+ * and restored automatically by the call to MessageBox().
+ * The fix is to save and restore the focus window.
+ */
+ int hwndFocus = OS.GetFocus ();
+
+ /* Open the message box */
+ byte [] buffer1 = Converter.wcsToMbcs (0, message, true);
+ byte [] buffer2 = Converter.wcsToMbcs (0, title, true);
+ int code = OS.MessageBox (hwndOwner, buffer1, buffer2, bits);
+
+ /* Restore focus */
+ OS.SetFocus (hwndFocus);
+
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when a dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// if (hwndOwner != 0) OS.UpdateWindow (hwndOwner);
+
+ /* Compute and return the result */
+ if (code != 0) {
+ int type = bits & 0x0F;
+ if (type == OS.MB_OK) return SWT.OK;
+ if (type == OS.MB_OKCANCEL) {
+ return (code == OS.IDOK) ? SWT.OK : SWT.CANCEL;
+ }
+ if (type == OS.MB_YESNO) {
+ return (code == OS.IDYES) ? SWT.YES : SWT.NO;
+ }
+ if (type == OS.MB_YESNOCANCEL) {
+ if (code == OS.IDYES) return SWT.YES;
+ if (code == OS.IDNO) return SWT.NO;
+ return SWT.CANCEL;
+ }
+ if (type == OS.MB_RETRYCANCEL) {
+ return (code == OS.IDRETRY) ? SWT.RETRY : SWT.CANCEL;
+ }
+ if (type == OS.MB_ABORTRETRYIGNORE) {
+ if (code == OS.IDRETRY) return SWT.RETRY;
+ if (code == OS.IDABORT) return SWT.ABORT;
+ return SWT.IGNORE;
+ }
+ }
+ return SWT.CANCEL;
+}
+
+public void setMessage (String string) {
+ message = string;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
new file mode 100755
index 0000000000..0855b56930
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java
@@ -0,0 +1,223 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of the receiver represent is an unselectable
+ * user interface object that is used to display progress,
+ * typlically in the form of a bar.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SMOOTH, HORIZONTAL, VERTICAL</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>
+ */
+public class ProgressBar extends Control {
+ static final int ProgressBarProc;
+ static final byte [] ProgressBarClass = OS.PROGRESS_CLASS;
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ProgressBarClass, lpWndClass);
+ ProgressBarProc = lpWndClass.lpfnWndProc;
+ }
+
+public ProgressBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ProgressBarProc, handle, msg, wParam, lParam);
+}
+
+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 ();
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ } else {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ height += OS.GetSystemMetrics (OS.SM_CYVSCROLL) * 10;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+void createHandle () {
+ super.createHandle ();
+ OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 0, 100);
+ OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, 10);
+ OS.SendMessage (handle, OS.TBM_SETTICFREQ, 10, 0);
+}
+
+int defaultForeground () {
+ return OS.GetSysColor (OS.COLOR_HIGHLIGHT);
+}
+
+/**
+ * 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 OS.SendMessage (handle, OS.PBM_GETRANGE, 0, 0);
+}
+
+/**
+ * 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 OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
+}
+
+/**
+ * Returns the single <em>selection</em> 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 OS.SendMessage (handle, OS.PBM_GETPOS, 0, 0);
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ background = pixel;
+ /*
+ * Feature in Windows. Setting the color to be
+ * the current default is not correct because the
+ * widget will not change colors when the colors
+ * are changed from the control panel. There is
+ * no fix at this time.
+ */
+ if (pixel == -1) pixel = defaultBackground ();
+ OS.SendMessage (handle, OS.PBM_SETBKCOLOR, 0, pixel);
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+ /*
+ * Feature in Windows. Setting the color to be
+ * the current default is not correct because the
+ * widget will not change colors when the colors
+ * are changed from the control panel. There is
+ * no fix at this time.
+ */
+ if (pixel == -1) pixel = defaultForeground ();
+ OS.SendMessage (handle, OS.PBM_SETBARCOLOR, 0, pixel);
+}
+
+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (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 setMaximum (int value) {
+ checkWidget ();
+ int minimum = OS.SendMessage (handle, OS.PBM_GETRANGE, 1, 0);
+ if (0 <= minimum && minimum < value) {
+ OS.SendMessage (handle, OS.PBM_SETRANGE32, minimum, value);
+ }
+}
+
+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (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 setMinimum (int value) {
+ checkWidget ();
+ int maximum = OS.SendMessage (handle, OS.PBM_GETRANGE, 0, 0);
+ if (0 <= value && value < maximum) {
+ OS.SendMessage (handle, OS.PBM_SETRANGE32, value, maximum);
+ }
+}
+
+/**
+ * Sets the single <em>selection</em> 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 ();
+ if (value < 0) return;
+ OS.SendMessage (handle, OS.PBM_SETPOS, value, 0);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle ();
+ if ((style & SWT.SMOOTH) != 0) bits |= OS.PBS_SMOOTH;
+ if ((style & SWT.VERTICAL) != 0) bits |= OS.PBS_VERTICAL;
+ return bits;
+}
+
+byte [] windowClass () {
+ return ProgressBarClass;
+}
+
+int windowProc () {
+ return ProgressBarProc;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
new file mode 100755
index 0000000000..753163958e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -0,0 +1,284 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+public class Sash extends Control {
+ boolean dragging;
+ int startX, startY, lastX, lastY;
+
+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 sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.DefWindowProc (handle, msg, wParam, lParam);
+}
+
+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 ();
+ 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 drawBand (int x, int y, int width, int height) {
+ int hwndTrack = parent.handle;
+ byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
+ int stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);
+ int stippleBrush = OS.CreatePatternBrush (stippleBitmap);
+ int hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);
+ int oldBrush = OS.SelectObject (hDC, stippleBrush);
+ OS.PatBlt (hDC, x, y, width, height, OS.PATINVERT);
+ OS.SelectObject (hDC, oldBrush);
+ OS.ReleaseDC (hwndTrack, hDC);
+ OS.DeleteObject (stippleBrush);
+ OS.DeleteObject (stippleBitmap);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 #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);
+}
+
+byte [] windowClass () {
+ return getDisplay ().windowClass;
+}
+
+int windowProc () {
+ return getDisplay ().windowProc;
+}
+
+LRESULT WM_ERASEBKGND (int wParam, int lParam) {
+ LRESULT result = super.WM_ERASEBKGND (wParam, lParam);
+ if (result != null) return result;
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ int pixel = getBackgroundPixel ();
+ int hBrush = findBrush (pixel);
+ OS.FillRect (wParam, rect, hBrush);
+ return LRESULT.ONE;
+}
+
+LRESULT WM_GETDLGCODE (int wParam, int lParam) {
+ return new LRESULT (OS.DLGC_STATIC);
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
+
+ /* Compute the banding rectangle */
+ int hwndTrack = parent.handle;
+ POINT pt = new POINT ();
+ pt.x = (short) (lParam & 0xFFFF);
+ pt.y = (short) (lParam >> 16);
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ OS.MapWindowPoints (handle, 0, pt, 1);
+ startX = pt.x - rect.left;
+ startY = pt.y - rect.top;
+ OS.MapWindowPoints (0, hwndTrack, rect, 2);
+ lastX = rect.left; lastY = rect.top;
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+
+ /* The event must be sent because doit flag is used */
+ Event event = new Event ();
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ event.detail = SWT.DRAG;
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the selection
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return LRESULT.ZERO;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ dragging = true;
+ menuShell ().bringToTop ();
+ int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (hwndTrack, null, 0, flags);
+ drawBand (lastX = event.x, lastY = event.y, width, height);
+ }
+ return result;
+}
+
+LRESULT WM_LBUTTONUP (int wParam, int lParam) {
+ LRESULT result = super.WM_LBUTTONUP (wParam, lParam);
+
+ /* Compute the banding rectangle */
+ if (!dragging) return result;
+ dragging = false;
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+
+ /* The event must be sent because doit flag is used */
+ Event event = new Event ();
+ event.x = lastX; event.y = lastY;
+ event.width = width; event.height = height;
+ drawBand (lastX, lastY, width, height);
+ sendEvent (SWT.Selection, event);
+ // widget could be disposed at this point
+ return result;
+}
+
+LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
+ LRESULT result = super.WM_MOUSEMOVE (wParam, lParam);
+ if (result != null) return result;
+ if (!dragging || ((wParam & OS.MK_LBUTTON) == 0)) return result;
+
+ /* Compute the banding rectangle */
+ POINT pt = new POINT ();
+ pt.x = (short) (lParam & 0xFFFF);
+ pt.y = (short) (lParam >> 16);
+ int hwndTrack = parent.handle;
+ OS.MapWindowPoints (handle, hwndTrack, pt, 1);
+ RECT rect = new RECT (), clientRect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ OS.GetClientRect (hwndTrack, clientRect);
+ int clientWidth = clientRect.right - clientRect.left;
+ int clientHeight = clientRect.bottom - clientRect.top;
+ int newX = lastX, newY = lastY;
+ if ((style & SWT.VERTICAL) != 0) {
+ newX = Math.min (Math.max (0, pt.x - startX), clientWidth - width);
+ } else {
+ newY = Math.min (Math.max (0, pt.y - startY), clientHeight - height);
+ }
+ if ((newX == lastX) && (newY == lastY)) return result;
+ drawBand (lastX, lastY, width, height);
+
+ /* The event must be sent because doit flag is used */
+ Event event = new Event ();
+ event.x = newX; event.y = newY;
+ event.width = width; event.height = height;
+ event.detail = SWT.DRAG;
+
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the selection
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Selection, event);
+ if (isDisposed ()) return LRESULT.ZERO;
+
+ /* Draw the banding rectangle */
+ if (event.doit) {
+ lastX = event.x; lastY = event.y;
+ int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (hwndTrack, null, 0, flags);
+ drawBand (lastX, lastY, width, height);
+ }
+ return result;
+}
+
+LRESULT WM_SETCURSOR (int wParam, int lParam) {
+ LRESULT result = super.WM_SETCURSOR (wParam, lParam);
+ if (result != null) return result;
+ int hitTest = lParam & 0xFFFF;
+ if (hitTest == OS.HTCLIENT) {
+ int hCursor;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ hCursor = OS.LoadCursor (0, OS.IDC_SIZENS);
+ } else {
+ hCursor = OS.LoadCursor (0, OS.IDC_SIZEWE);
+ }
+ OS.SetCursor (hCursor);
+ return LRESULT.ONE;
+ }
+ return result;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
new file mode 100755
index 0000000000..3c45f6d06f
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java
@@ -0,0 +1,369 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ * IMPORTANT: This class is intended to be subclassed <em>only</em>
+ * within the SWT implementation.
+ * </p>
+ */
+
+public class Scale extends Control {
+ static final int TrackBarProc;
+ static final byte [] TrackBarClass = OS.TRACKBAR_CLASS;
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, TrackBarClass, lpWndClass);
+ TrackBarProc = lpWndClass.lpfnWndProc;
+ }
+
+public Scale (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's value changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (TrackBarProc, handle, msg, wParam, lParam);
+}
+
+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 ();
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ RECT rect = new RECT ();
+ OS.SendMessage (handle, OS.TBM_GETTHUMBRECT, 0, rect);
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
+ int scrollY = OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ height += (rect.top * 2) + scrollY + (scrollY / 3);
+ } else {
+ int scrollX = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ width += (rect.left * 2) + scrollX + (scrollX / 3);
+ height += OS.GetSystemMetrics (OS.SM_CYVSCROLL) * 10;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+void createHandle () {
+ super.createHandle ();
+ OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 0, 100);
+ OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, 10);
+ OS.SendMessage (handle, OS.TBM_SETTICFREQ, 10, 0);
+}
+
+int defaultForeground () {
+ return OS.GetSysColor (OS.COLOR_BTNFACE);
+}
+
+/**
+ * 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 ();
+ return OS.SendMessage (handle, OS.TBM_GETLINESIZE, 0, 0);
+}
+
+/**
+ * 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 OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+}
+
+/**
+ * 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 OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+}
+
+/**
+ * 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 ();
+ return OS.SendMessage (handle, OS.TBM_GETPAGESIZE, 0, 0);
+}
+
+/**
+ * Returns the single <em>selection</em> 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 OS.SendMessage (handle, OS.TBM_GETPOS, 0, 0);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's value changes.
+ *
+ * @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 increment) {
+ checkWidget ();
+ if (increment < 1) return;
+ int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+ int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ if (increment > maximum - minimum) return;
+ OS.SendMessage (handle, OS.TBM_SETLINESIZE, 0, increment);
+}
+
+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (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 setMaximum (int value) {
+ checkWidget ();
+ int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+ if (0 <= minimum && minimum < value) {
+ OS.SendMessage (handle, OS.TBM_SETRANGEMAX, 1, value);
+ }
+}
+
+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (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 setMinimum (int value) {
+ checkWidget ();
+ int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ if (0 <= value && value < maximum) {
+ OS.SendMessage (handle, OS.TBM_SETRANGEMIN, 1, value);
+ }
+}
+
+/**
+ * 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.
+ *
+ * @return 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 pageIncrement) {
+ checkWidget ();
+ if (pageIncrement < 1) return;
+ int minimum = OS.SendMessage (handle, OS.TBM_GETRANGEMIN, 0, 0);
+ int maximum = OS.SendMessage (handle, OS.TBM_GETRANGEMAX, 0, 0);
+ if (pageIncrement > maximum - minimum) return;
+ OS.SendMessage (handle, OS.TBM_SETPAGESIZE, 0, pageIncrement);
+ OS.SendMessage (handle, OS.TBM_SETTICFREQ, pageIncrement, 0);
+}
+
+/**
+ * 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 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 ();
+ if (value < 0) return;
+ OS.SendMessage (handle, OS.TBM_SETPOS, 1, value);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP | OS.TBS_BOTH | OS.TBS_AUTOTICKS;
+ if ((style & SWT.HORIZONTAL) != 0) return bits | OS.TBS_HORZ;
+ return bits | OS.TBS_VERT;
+}
+
+byte [] windowClass () {
+ return TrackBarClass;
+}
+
+int windowProc () {
+ return TrackBarProc;
+}
+
+LRESULT wmScrollChild (int wParam, int lParam) {
+
+ /* Do nothing when scrolling is ending */
+ int code = wParam & 0xFFFF;
+ if (code == OS.TB_ENDTRACK) return null;
+
+ /*
+ * This code is intentionally commented. The event
+ * detail field is not currently supported on all
+ * platforms.
+ */
+ Event event = new Event ();
+// switch (code) {
+// /*
+// * This line is intentionally commented. Do not set the detail
+// * field to DRAG to indicate that the dragging has ended when the
+// * scroll bar is finally positioned in TB_THUMBPOSITION.
+// */
+//// case OS.TB_THUMBPOSITION: break;
+// case OS.TB_THUMBTRACK: event.detail = SWT.DRAG; break;
+// case OS.TB_TOP: event.detail = SWT.HOME; break;
+// case OS.TB_BOTTOM: event.detail = SWT.END; break;
+// case OS.TB_LINEDOWN: event.detail = SWT.ARROW_DOWN; break;
+// case OS.TB_LINEUP: event.detail = SWT.ARROW_UP; break;
+// case OS.TB_PAGEDOWN: event.detail = SWT.PAGE_DOWN; break;
+// case OS.TB_PAGEUP: event.detail = SWT.PAGE_UP; break;
+// }
+
+ /*
+ * Send the event because WM_HSCROLL and WM_VSCROLL
+ * are sent from a modal message loop in windows that
+ * is active when the user is scrolling.
+ */
+ sendEvent (SWT.Selection, event);
+ // widget could be disposed at this point
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
new file mode 100755
index 0000000000..a4259bc2c6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -0,0 +1,884 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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 <em>selection</em> 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 left and right facing buttons for incrementing and
+ * decrementing the value) or <code>VERTICAL</code> (which have
+ * up and down facing buttons for incrementing and decrementing
+ * the value).
+ * </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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * @see Slider
+ * @see Scrollable
+ * @see Scrollable#getHorizontalBar
+ * @see Scrollable#getVerticalBar
+ */
+
+public class ScrollBar extends Widget {
+
+ Scrollable parent;
+ int increment, pageIncrement;
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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
+ */
+ScrollBar (Scrollable parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ createWidget ();
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's value changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 SelectionListener
+ * @see #removeSelectionListener
+ */
+public void addSelectionListener (SelectionListener listener) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ 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 createWidget () {
+ increment = 1;
+ pageIncrement = 10;
+}
+
+void destroyWidget () {
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ if (OS.ShowScrollBar (hwnd, type, false));
+}
+
+/*
+* Not currently used.
+*/
+Rectangle getBounds () {
+ RECT rect = new RECT ();
+ OS.GetClientRect (parent.handle, rect);
+ int x = 0, y = 0, width, height;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ y = rect.bottom - rect.top;
+ width = rect.right - rect.left;
+ height = OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ } else {
+ x = rect.right - rect.left;
+ width = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ height = rect.bottom - rect.top;
+ }
+ return new Rectangle (x, y, width, height);
+}
+
+public Display getDisplay () {
+ Scrollable parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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 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 boolean getEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return (state & DISABLED) == 0;
+}
+
+/**
+ * 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE;
+ int hwnd = hwndScrollBar ();
+ int type = scrollBarType ();
+ OS.GetScrollInfo (hwnd, type, info);
+ return info.nMax;
+}
+
+/**
+ * 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE;
+ int hwnd = hwndScrollBar ();
+ int type = scrollBarType ();
+ OS.GetScrollInfo (hwnd, type, info);
+ return info.nMin;
+}
+
+/**
+ * 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return pageIncrement;
+}
+
+/**
+ * Returns the receiver's parent, which must be 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent;
+}
+
+/**
+ * Returns the single <em>selection</em> 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS;
+ int hwnd = hwndScrollBar ();
+ int type = scrollBarType ();
+ OS.GetScrollInfo (hwnd, type, info);
+ return info.nPos;
+}
+
+/**
+ * For horizontal scroll bars, returns the height of the
+ * instance, and for vertical scroll bars, returns the width
+ * of the instance.
+ *
+ * @return the scroll bar 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ RECT rect = new RECT ();
+ OS.GetClientRect (parent.handle, rect);
+ int width, height;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width = rect.right - rect.left;
+ height = OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ } else {
+ width = OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ height = rect.bottom - rect.top;
+ }
+ return new Point (width, height);
+}
+
+/**
+ * Answers 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_PAGE;
+ int hwnd = hwndScrollBar ();
+ int type = scrollBarType ();
+ OS.GetScrollInfo (hwnd, type, info);
+ if (info.nPage != 0) --info.nPage;
+ return info.nPage;
+}
+
+/**
+ * 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return (state & HIDDEN) == 0;
+}
+
+int hwndScrollBar () {
+ return parent.handle;
+}
+
+/**
+ * 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.
+ * <p>
+ * Note: Because of the strong connection between a scroll bar
+ * and the widget which contains it (its parent), a scroll bar
+ * will not indicate that it is enabled if its parent is not.
+ * </p>
+ *
+ * @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>
+ */
+public boolean isEnabled () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getEnabled () && parent.isEnabled ();
+}
+
+/**
+ * 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 isVisible () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ return getVisible () && parent.isVisible ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ 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 receiver's value changes.
+ *
+ * @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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Selection, listener);
+ eventTable.unhook (SWT.DefaultSelection,listener);
+}
+
+int scrollBarType () {
+ if ((style & SWT.VERTICAL) != 0) return OS.SB_VERT;
+ /*
+ * This line is intentionally commented. There should
+ * only ever be HORIZONTAL and VERTICAL scroll bars.
+ * The commented code reminds us that this is the case
+ * and that the default style is HORIZONTAL.
+ */
+// if ((style & SWT.HORIZONTAL) != 0) return OS.SB_HORZ;
+ return OS.SB_HORZ;
+}
+
+/**
+ * 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ int flags = OS.ESB_DISABLE_BOTH;
+ if (enabled) flags = OS.ESB_ENABLE_BOTH;
+ OS.EnableScrollBar (hwnd, type, flags);
+ state &= ~DISABLED;
+ if (!enabled) state |= DISABLED;
+}
+
+/**
+ * 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ increment = value;
+}
+
+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (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 setMaximum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (hwnd, type, info);
+ if (value - info.nMin - info.nPage < 1) return;
+ info.nMax = value;
+ OS.SetScrollInfo (hwnd, type, info, (state & DISABLED) == 0);
+
+ /*
+ * Bug in Windows. For some reason, when the widget
+ * is a standard scroll bar, and SetScrollInfo () is
+ * called with SIF_RANGE or SIF_PAGE, the widget is
+ * incorrectly made visible so that the next time the
+ * widget is resized (or another scroll bar operation
+ * is performed), the scroll bar draws. The fix is
+ * to hide the scroll bar (again) when already hidden.
+ */
+ if ((state & HIDDEN) != 0) {
+ OS.ShowScrollBar (hwnd, type, false);
+ }
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH);
+ }
+}
+
+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (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 setMinimum (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 0) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (hwnd, type, info);
+ if (info.nMax - value - info.nPage < 1) return;
+ info.nMin = value;
+ OS.SetScrollInfo (hwnd, type, info, true);
+
+ /*
+ * Bug in Windows. For some reason, when the widget
+ * is a standard scroll bar, and SetScrollInfo () is
+ * called with SIF_RANGE or SIF_PAGE, the widget is
+ * incorrectly made visible so that the next time the
+ * widget is resized (or another scroll bar operation
+ * is performed), the scroll bar draws. The fix is
+ * to hide the scroll bar (again) when already hidden.
+ */
+ if ((state & HIDDEN) != 0) {
+ OS.ShowScrollBar (hwnd, type, false);
+ }
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH);
+ }
+}
+
+/**
+ * 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.
+ *
+ * @return 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (value < 1) return;
+ pageIncrement = value;
+}
+
+/**
+ * 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 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 selection) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ info.fMask = OS.SIF_POS;
+ info.nPos = selection;
+ OS.SetScrollInfo (hwnd, type, info, true);
+}
+
+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values to the
+ * argument which must be at least one.
+ *
+ * @param value the new thumb value (must be at least 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 ScrollBar
+ */
+public void setThumb (int value) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+
+ /* Position the thumb */
+ if (value < 1) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ info.fMask = OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (hwnd, type, info);
+ if (info.nMax - info.nMin - value < 0) return;
+ info.nPage = value;
+ if (info.nPage != 0) info.nPage++;
+ OS.SetScrollInfo (hwnd, type, info, true);
+
+ /*
+ * Bug in Windows. For some reason, when the widget
+ * is a standard scroll bar, and SetScrollInfo () is
+ * called with SIF_RANGE or SIF_PAGE, the widget is
+ * incorrectly made visible so that the next time the
+ * widget is resized (or another scroll bar operation
+ * is performed), the scroll bar draws. The fix is
+ * to hide the scroll bar (again) when already hidden.
+ */
+ if ((state & HIDDEN) != 0) {
+ OS.ShowScrollBar (hwnd, type, false);
+ }
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH);
+ }
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is equivalent 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) {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ if (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ this.increment = increment;
+ this.pageIncrement = pageIncrement;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS | OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ info.nPos = selection;
+ info.nMin = minimum;
+ info.nMax = maximum;
+ info.nPage = thumb;
+ if (info.nPage != 0) info.nPage++;
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ OS.SetScrollInfo (hwnd, type, info, true);
+
+ /*
+ * Bug in Windows. For some reason, when the widget
+ * is a standard scroll bar, and SetScrollInfo () is
+ * called with SIF_RANGE or SIF_PAGE, the widget is
+ * incorrectly made visible so that the next time the
+ * widget is resized (or another scroll bar operation
+ * is performed), the scroll bar draws. The fix is
+ * to hide the scroll bar (again) when already hidden.
+ */
+ if ((state & HIDDEN) != 0) {
+ OS.ShowScrollBar (hwnd, type, false);
+ }
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (hwnd, type, OS.ESB_DISABLE_BOTH);
+ }
+}
+
+/**
+ * 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 (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+ int hwnd = hwndScrollBar (), type = scrollBarType ();
+ if (OS.ShowScrollBar (hwnd, type, visible)) {
+ /*
+ * Bug in Windows. For some reason, when the widget
+ * is a standard scroll bar, and SetScrollInfo () is
+ * called with SIF_RANGE or SIF_PAGE while the widget
+ * is not visible, the widget is incorrectly disabled
+ * even though the values for SIF_RANGE and SIF_PAGE,
+ * when set for a visible scroll bar would not disable
+ * the scroll bar. The fix is to enable the scroll bar
+ * when already enabled after showing the scroll bar.
+ */
+ if ((state & DISABLED) == 0) {
+ OS.EnableScrollBar (hwnd, type, OS.ESB_ENABLE_BOTH);
+ }
+ state &= ~HIDDEN;
+ if (!visible) state |= HIDDEN;
+ sendEvent (visible ? SWT.Show : SWT.Hide);
+ // widget could be disposed at this point
+ }
+}
+
+LRESULT wmScrollChild (int wParam, int lParam) {
+
+ /* Do nothing when scrolling is ending */
+ int code = wParam & 0xFFFF;
+ if (code == OS.SB_ENDSCROLL) return null;
+
+ /*
+ * Send the event because WM_HSCROLL and
+ * WM_VSCROLL are sent from a modal message
+ * loop in Windows that is active when the
+ * user is scrolling.
+ */
+ Event event = new Event ();
+ switch (code) {
+ /*
+ * This line is intentionally commented. Do not set the detail
+ * field to DRAG to indicate that the dragging has ended when the
+ * scroll bar is finally positioned in SB_THUMBPOSITION.
+ */
+// case OS.SB_THUMBPOSITION: break;
+ case OS.SB_THUMBTRACK: event.detail = SWT.DRAG; break;
+ case OS.SB_TOP: event.detail = SWT.HOME; break;
+ case OS.SB_BOTTOM: event.detail = SWT.END; break;
+ case OS.SB_LINEDOWN: event.detail = SWT.ARROW_DOWN; break;
+ case OS.SB_LINEUP: event.detail = SWT.ARROW_UP; break;
+ case OS.SB_PAGEDOWN: event.detail = SWT.PAGE_DOWN; break;
+ case OS.SB_PAGEUP: event.detail = SWT.PAGE_UP; break;
+ }
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
new file mode 100755
index 0000000000..0ce4f0ab8d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -0,0 +1,313 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ */
+
+public abstract class Scrollable extends Control {
+
+ 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 Scrollable (Composite parent, int style) {
+ super (parent, style);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.DefWindowProc (handle, msg, wParam, lParam);
+}
+
+/**
+ * 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>
+ *
+ * @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 ();
+
+ /* Get the size of the trimmings */
+ RECT rect = new RECT ();
+ OS.SetRect (rect, x, y, x + width, y + height);
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ boolean hasMenu = ((bits & OS.WS_CHILD) == 0) && (OS.GetMenu (handle) != 0);
+ OS.AdjustWindowRectEx (rect, bits, hasMenu, OS.GetWindowLong (handle, OS.GWL_EXSTYLE));
+
+ /* Get the size of the scroll bars */
+ if ((horizontalBar != null) && (horizontalBar.getVisible ())) {
+ rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ }
+ if ((verticalBar != null) && (verticalBar.getVisible ())) {
+ rect.right += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ }
+
+ /* Get the height of the menu bar */
+ if (hasMenu) {
+ RECT testRect = new RECT ();
+ OS.SetRect (testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
+ OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect);
+ while ((testRect.bottom - testRect.top) < height) {
+ rect.top -= OS.GetSystemMetrics (OS.SM_CYMENU) - OS.GetSystemMetrics (OS.SM_CYBORDER);
+ OS.SetRect(testRect, 0, 0, rect.right - rect.left, rect.bottom - rect.top);
+ OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, testRect);
+ }
+ }
+ return new Rectangle (rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
+}
+
+ScrollBar createScrollBar (int type) {
+ ScrollBar bar = new ScrollBar (this, type);
+ bar.setMaximum (100);
+ bar.setThumb (10);
+ return bar;
+}
+
+void createWidget () {
+ super.createWidget ();
+ if ((style & SWT.H_SCROLL) != 0) horizontalBar = createScrollBar (SWT.H_SCROLL);
+ if ((style & SWT.V_SCROLL) != 0) verticalBar = createScrollBar (SWT.V_SCROLL);
+}
+
+/**
+ * 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 ();
+ if (parent != null && parent.hdwp != 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ int count = parent.getChildrenCount ();
+ parent.hdwp = OS.BeginDeferWindowPos (count);
+ }
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ return new Rectangle (0, 0, rect.right, rect.bottom);
+}
+
+/**
+ * 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;
+}
+
+void releaseWidget () {
+ if (horizontalBar != null) horizontalBar.releaseWidget ();
+ if (verticalBar != null) verticalBar.releaseWidget ();
+ horizontalBar = verticalBar = null;
+ super.releaseWidget ();
+}
+
+int widgetExtStyle () {
+ return super.widgetExtStyle ();
+ /*
+ * This code is intentionally commented. In future,
+ * we may wish to support different standard Windows
+ * edge styles. The issue here is that not all of
+ * these styles are available on the other platforms
+ * this would need to be a hint.
+ */
+// if ((style & SWT.BORDER) != 0) return OS.WS_EX_CLIENTEDGE;
+// if ((style & SWT.SHADOW_IN) != 0) return OS.WS_EX_STATICEDGE;
+// return super.widgetExtStyle ();
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP;
+ if ((style & SWT.H_SCROLL) != 0) bits |= OS.WS_HSCROLL;
+ if ((style & SWT.V_SCROLL) != 0) bits |= OS.WS_VSCROLL;
+ return bits;
+}
+
+byte [] windowClass () {
+ return getDisplay ().windowClass;
+}
+
+int windowProc () {
+ return getDisplay ().windowProc;
+}
+
+LRESULT WM_HSCROLL (int wParam, int lParam) {
+ LRESULT result = super.WM_HSCROLL (wParam, lParam);
+ if (result != null) return result;
+ if ((lParam == 0) && (horizontalBar != null)) {
+ result = wmScroll (OS.WM_HSCROLL, wParam, lParam);
+ horizontalBar.wmScrollChild (wParam, lParam);
+ }
+ return result;
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ int code = callWindowProc (OS.WM_SIZE, wParam, lParam);
+ super.WM_SIZE (wParam, lParam);
+ // widget may be disposed at this point
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+LRESULT WM_VSCROLL (int wParam, int lParam) {
+ LRESULT result = super.WM_VSCROLL (wParam, lParam);
+ if (result != null) return result;
+ if ((lParam == 0) && (verticalBar != null)) {
+ result = wmScroll (OS.WM_VSCROLL, wParam, lParam);
+ verticalBar.wmScrollChild (wParam, lParam);
+ }
+ return result;
+}
+
+LRESULT wmScroll (int msg, int wParam, int lParam) {
+ int type = OS.SB_HORZ;
+ ScrollBar bar = horizontalBar;
+ if (msg == OS.WM_VSCROLL) {
+ type = OS.SB_VERT;
+ bar = verticalBar;
+ }
+ if (bar == null) return null;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_TRACKPOS | OS.SIF_POS | OS.SIF_RANGE;
+ OS.GetScrollInfo (handle, type, info);
+ info.fMask = OS.SIF_POS;
+ int code = wParam & 0xFFFF;
+ switch (code) {
+ case OS.SB_ENDSCROLL: return null;
+ case OS.SB_THUMBTRACK:
+ case OS.SB_THUMBPOSITION:
+ info.nPos = info.nTrackPos;
+ break;
+ case OS.SB_TOP:
+ info.nPos = info.nMin;
+ break;
+ case OS.SB_BOTTOM:
+ info.nPos = info.nMax;
+ break;
+ case OS.SB_LINEDOWN:
+ info.nPos += bar.getIncrement ();
+ break;
+ case OS.SB_LINEUP: {
+ int increment = bar.getIncrement ();
+ info.nPos = Math.max (info.nMin, info.nPos - increment);
+ break;
+ }
+ case OS.SB_PAGEDOWN:
+ info.nPos += bar.getPageIncrement ();
+ break;
+ case OS.SB_PAGEUP: {
+ int pageIncrement = bar.getPageIncrement ();
+ info.nPos = Math.max (info.nMin, info.nPos - pageIncrement);
+ break;
+ }
+ }
+ OS.SetScrollInfo (handle, type, info, true);
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
new file mode 100755
index 0000000000..ab6d498c41
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -0,0 +1,944 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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 which 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 which 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), it's 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</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>
+ * IMPORTANT: This class is not intended to be subclassed.
+ * </p>
+ *
+ * @see Decorations
+ * @see SWT
+ */
+
+public class Shell extends Decorations {
+ Display display;
+ Menu activeMenu;
+ int hIMC;
+ int [] brushes;
+ boolean showWithParent;
+ int toolTipHandle, lpstrTip;
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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>
+ */
+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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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>
+ */
+public Shell (Display display, int style) {
+ this (display, null, style, 0);
+}
+
+Shell (Display display, Shell parent, int style, int handle) {
+ super ();
+ 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.parent = parent;
+ this.display = display;
+ this.handle = handle;
+ createWidget ();
+}
+
+/**
+ * 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_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 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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 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, int style) {
+ this (parent != null ? parent.getDisplay () : null, parent, style, 0);
+}
+
+/**
+ * Invokes platform specific functionality to allocate a new shell.
+ * <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
+ *
+ * @private
+ */
+public static Shell win32_new (Display display, int handle) {
+ return new Shell (display, null, SWT.NO_TRIM, handle);
+}
+
+static int checkStyle (int style) {
+ style = Decorations.checkStyle (style);
+ 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);
+}
+
+/**
+ * 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>
+ */
+public void close () {
+ checkWidget ();
+ OS.PostMessage (handle, OS.WM_CLOSE, 0, 0);
+}
+
+void createHandle () {
+ boolean embedded = handle != 0;
+ super.createHandle ();
+ if (!embedded) {
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ bits &= ~OS.WS_OVERLAPPED;
+ bits |= OS.WS_POPUP;
+ if ((style & (SWT.TITLE | SWT.CLOSE)) == 0) bits &= ~OS.WS_CAPTION;
+ if ((style & SWT.NO_TRIM) == 0) {
+ if ((style & (SWT.BORDER | SWT.RESIZE)) == 0) bits |= OS.WS_BORDER;
+ }
+ OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+ }
+ if (IsDBLocale) {
+ hIMC = OS.ImmCreateContext ();
+ if (hIMC != 0) OS.ImmAssociateContext (handle, hIMC);
+ }
+}
+
+void createWidget () {
+ super.createWidget ();
+ if (!display.TrimEnabled) return;
+ if (!isActive ()) setItemEnabled (OS.SC_CLOSE, false);
+}
+
+public void dispose () {
+ /*
+ * This code is intentionally commented. On some
+ * platforms, the owner window is repainted right
+ * away when a dialog window exits. This behavior
+ * is currently unspecified.
+ */
+// /*
+// * Note: It is valid to attempt to dispose a widget
+// * more than once. If this happens, fail silently.
+// */
+// if (!isValidWidget ()) return;
+// if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+// Display oldDisplay = display;
+ super.dispose ();
+ // widget is disposed at this point
+// if (oldDisplay != null) oldDisplay.update ();
+}
+
+int findBrush (int pixel) {
+ if (pixel == OS.GetSysColor (OS.COLOR_BTNFACE)) {
+ return OS.GetSysColorBrush (OS.COLOR_BTNFACE);
+ }
+ if (pixel == OS.GetSysColor (OS.COLOR_WINDOW)) {
+ return OS.GetSysColorBrush (OS.COLOR_WINDOW);
+ }
+ if (brushes == null) brushes = new int [4];
+ LOGBRUSH logBrush = new LOGBRUSH ();
+ for (int i=0; i<brushes.length; i++) {
+ int hBrush = brushes [i];
+ if (hBrush == 0) break;
+ OS.GetObject (hBrush, LOGBRUSH.sizeof, logBrush);
+ if (logBrush.lbColor == pixel) return hBrush;
+ }
+ int length = brushes.length;
+ int hBrush = brushes [--length];
+ if (hBrush != 0) OS.DeleteObject (hBrush);
+ System.arraycopy (brushes, 0, brushes, 1, length);
+ brushes [0] = hBrush = OS.CreateSolidBrush (pixel);
+ return hBrush;
+}
+
+int findCursor () {
+ return hCursor;
+}
+
+public Rectangle getBounds () {
+ checkWidget ();
+ if (OS.IsIconic (handle)) return super.getBounds ();
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+}
+
+public Display getDisplay () {
+ if (display == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return display;
+}
+
+public boolean getEnabled () {
+ checkWidget ();
+ if (!display.TrimEnabled) return super.getEnabled ();
+ return (state & DISABLED) == 0;
+}
+
+/**
+ * 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 ();
+ if (!IsDBLocale) return 0;
+ int hIMC = OS.ImmGetContext (handle);
+ int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];
+ boolean open = OS.ImmGetOpenStatus (hIMC);
+ if (open) open = OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence);
+ OS.ImmReleaseContext (handle, hIMC);
+ if (!open) return SWT.NONE;
+ int result = 0;
+ if ((lpfdwConversion [0] & OS.IME_CMODE_ROMAN) != 0) result |= SWT.ROMAN;
+ if ((lpfdwConversion [0] & OS.IME_CMODE_FULLSHAPE) != 0) result |= SWT.DBCS;
+ if ((lpfdwConversion [0] & OS.IME_CMODE_KATAKANA) != 0) return result | SWT.PHONETIC;
+ if ((lpfdwConversion [0] & OS.IME_CMODE_NATIVE) != 0) return result | SWT.NATIVE;
+ return result | SWT.ALPHA;
+}
+
+public Point getLocation () {
+ checkWidget ();
+ if (OS.IsIconic (handle)) {
+ return super.getLocation ();
+ }
+ RECT rect = new RECT ();
+ OS.GetWindowRect (handle, rect);
+ return new Point (rect.left, rect.top);
+}
+
+public Shell getShell () {
+ checkWidget ();
+ return this;
+}
+
+/**
+ * Returns an array containing all shells which are
+ * descendents 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.parent;
+ } 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.parent;
+ } while (shell != null && shell != this);
+ if (shell == this) {
+ result [index++] = shells [i];
+ }
+ }
+ return result;
+}
+
+public boolean isEnabled () {
+ checkWidget ();
+ return getEnabled ();
+}
+
+/**
+ * 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,
+ * and sets focus to its default button (if it has 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 Control#setVisible
+ * @see Decorations#setDefaultButton
+*/
+public void open () {
+ checkWidget ();
+ bringToTop ();
+ setVisible (true);
+ if (savedFocus == null) {
+ setFocus ();
+ } else {
+ restoreFocus ();
+ }
+}
+
+void releaseShells () {
+ Shell [] shells = getShells ();
+ for (int i=0; i<shells.length; i++) {
+ Shell shell = shells [i];
+ if (!shell.isDisposed ()) {
+ shell.releaseWidget ();
+ shell.releaseHandle ();
+ }
+ }
+}
+
+void releaseWidget () {
+ releaseShells ();
+ super.releaseWidget ();
+ activeMenu = null;
+ display.clearModal (this);
+ display = null;
+ if (lpstrTip != 0) {
+ int hHeap = OS.GetProcessHeap ();
+ OS.HeapFree (hHeap, 0, lpstrTip);
+ }
+ lpstrTip = 0;
+ toolTipHandle = 0;
+ if (brushes != null) {
+ for (int i=0; i<brushes.length; i++) {
+ int hBrush = brushes [i];
+ if (hBrush != 0) OS.DeleteObject (hBrush);
+ }
+ }
+ brushes = null;
+ if (IsDBLocale) {
+ if (hIMC != 0) OS.ImmDestroyContext (hIMC);
+ }
+}
+
+void remove (Menu menu) {
+ super.remove (menu);
+ if (menu == activeMenu) activeMenu = null;
+}
+
+/**
+ * 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);
+}
+
+LRESULT selectPalette (int hPalette) {
+ int hDC = OS.GetDC (handle);
+ int hOld = OS.SelectPalette (hDC, hPalette, false);
+ int result = OS.RealizePalette (hDC);
+ if (result > 0) {
+ OS.InvalidateRect (handle, null, true);
+ } else {
+ OS.SelectPalette (hDC, hOld, true);
+ OS.RealizePalette (hDC);
+ }
+ OS.ReleaseDC (handle, hDC);
+ return (result > 0) ? LRESULT.ONE : LRESULT.ZERO;
+}
+
+void setBounds (int x, int y, int width, int height, int flags) {
+ if (OS.IsIconic (handle)) {
+ super.setBounds (x, y, width, height, flags);
+ return;
+ }
+ flags |= OS.SWP_NOZORDER | OS.SWP_DRAWFRAME | OS.SWP_NOACTIVATE;
+ OS.SetWindowPos (handle, 0, x, y, width, height, flags);
+}
+
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ if (!display.TrimEnabled) {
+ super.setEnabled (enabled);
+ } else {
+ state &= ~DISABLED;
+ if (!enabled) state |= DISABLED;
+ if (isActive ()) setItemEnabled (OS.SC_CLOSE, enabled);
+ }
+}
+
+/**
+ * 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 ();
+ if (!IsDBLocale) return;
+ boolean imeOn = mode != SWT.NONE && mode != SWT.ROMAN;
+ int hIMC = OS.ImmGetContext (handle);
+ OS.ImmSetOpenStatus (hIMC, imeOn);
+ if (imeOn) {
+ int [] lpfdwConversion = new int [1], lpfdwSentence = new int [1];
+ if (OS.ImmGetConversionStatus (hIMC, lpfdwConversion, lpfdwSentence)) {
+ int newBits = 0;
+ int oldBits = OS.IME_CMODE_NATIVE | OS.IME_CMODE_KATAKANA;
+ if ((mode & SWT.PHONETIC) != 0) {
+ newBits = OS.IME_CMODE_KATAKANA | OS.IME_CMODE_NATIVE;
+ oldBits = 0;
+ } else {
+ if ((mode & SWT.NATIVE) != 0) {
+ newBits = OS.IME_CMODE_NATIVE;
+ oldBits = OS.IME_CMODE_KATAKANA;
+ }
+ }
+ if ((mode & SWT.DBCS) != 0) {
+ newBits |= OS.IME_CMODE_FULLSHAPE;
+ } else {
+ oldBits |= OS.IME_CMODE_FULLSHAPE;
+ }
+ if ((mode & SWT.ROMAN) != 0) {
+ newBits |= OS.IME_CMODE_ROMAN;
+ } else {
+ oldBits |= OS.IME_CMODE_ROMAN;
+ }
+ lpfdwConversion [0] |= newBits; lpfdwConversion [0] &= ~oldBits;
+ OS.ImmSetConversionStatus (hIMC, lpfdwConversion [0], lpfdwSentence [0]);
+ }
+ }
+ OS.ImmReleaseContext (handle, hIMC);
+}
+
+void setItemEnabled (int cmd, boolean enabled) {
+ int hMenu = OS.GetSystemMenu (handle, false);
+ if (hMenu == 0) return;
+ int flags = OS.MF_ENABLED;
+ if (!enabled) flags = OS.MF_DISABLED | OS.MF_GRAYED;
+ OS.EnableMenuItem (hMenu, cmd, OS.MF_BYCOMMAND | flags);
+}
+
+void setParent () {
+ /* Do nothing. Not necessary for Shells */
+}
+
+void setToolTipText (int hwnd, String text) {
+ if (toolTipHandle == 0) {
+ toolTipHandle = OS.CreateWindowEx (
+ 0,
+ OS.TOOLTIPS_CLASS,
+ null,
+ OS.TTS_ALWAYSTIP,
+ OS.CW_USEDEFAULT, 0, OS.CW_USEDEFAULT, 0,
+ handle,
+ 0,
+ OS.GetModuleHandle (null),
+ null);
+ if (toolTipHandle == 0) error (SWT.ERROR_NO_HANDLES);
+ }
+ TOOLINFO lpti = new TOOLINFO ();
+ lpti.cbSize = TOOLINFO.sizeof;
+ lpti.uId = hwnd;
+ lpti.hwnd = handle;
+ if (text == null) {
+ OS.SendMessage (toolTipHandle, OS.TTM_DELTOOL, 0, lpti);
+ } else {
+ lpti.uFlags = OS.TTF_IDISHWND | OS.TTF_SUBCLASS;
+ lpti.lpszText = OS.LPSTR_TEXTCALLBACK;
+ OS.SendMessage (toolTipHandle, OS.TTM_ADDTOOL, 0, lpti);
+ }
+}
+
+void setToolTipText (NMTTDISPINFO lpnmtdi, byte [] buffer) {
+ /*
+ * Ensure that the current position of the mouse
+ * is inside the client area of the shell. This
+ * prevents tool tips from popping up over the
+ * shell trimmings.
+ */
+ if (!hasCursor ()) return;
+ int hHeap = OS.GetProcessHeap ();
+ if (lpstrTip != 0) OS.HeapFree (hHeap, 0, lpstrTip);
+ lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory (lpstrTip, buffer, buffer.length);
+ lpnmtdi.lpszText = lpstrTip;
+}
+
+void setToolTipText (NMTTDISPINFO lpnmtdi, char [] buffer) {
+ /*
+ * Ensure that the current position of the mouse
+ * is inside the client area of the shell. This
+ * prevents tool tips from popping up over the
+ * shell trimmings.
+ */
+ if (!hasCursor ()) return;
+ int hHeap = OS.GetProcessHeap ();
+ if (lpstrTip != 0) OS.HeapFree (hHeap, 0, lpstrTip);
+ lpstrTip = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length * 2);
+ OS.MoveMemory (lpstrTip, buffer, buffer.length * 2);
+ lpnmtdi.lpszText = lpstrTip;
+}
+
+public void setVisible (boolean visible) {
+ checkWidget ();
+ super.setVisible (visible);
+ if (showWithParent == visible) return;
+ OS.ShowOwnedPopups (handle, showWithParent = visible);
+ int mask = SWT.PRIMARY_MODAL | SWT.APPLICATION_MODAL | SWT.SYSTEM_MODAL;
+ if ((style & mask) != 0) {
+ if (visible) {
+ display.setModal (this);
+ Control control = display.getFocusControl ();
+ if (control != null && !control.isActive ()) bringToTop ();
+ } else {
+ display.clearModal (this);
+ }
+ }
+}
+
+void updateModal () {
+ if (!display.TrimEnabled) return;
+ setItemEnabled (OS.SC_CLOSE, isActive ());
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () & ~OS.WS_POPUP;
+ if (handle != 0) return bits | OS.WS_CHILD;
+ bits &= ~OS.WS_CHILD;
+ return bits | OS.WS_OVERLAPPED | OS.WS_CAPTION;
+}
+
+LRESULT WM_CLOSE (int wParam, int lParam) {
+ if ((display.TrimEnabled && !isEnabled ()) || !isActive ()) {
+ return LRESULT.ZERO;
+ }
+ return super.WM_CLOSE (wParam, lParam);
+}
+
+LRESULT WM_DESTROY (int wParam, int lParam) {
+ LRESULT result = super.WM_DESTROY (wParam, lParam);
+ /*
+ * When the shell is a WS_CHILD window of a non-SWT
+ * window, the destroy code does not get called because
+ * the non-SWT window does not call dispose (). Instead,
+ * the destroy code is called here in WM_DESTROY.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.WS_CHILD) != 0) {
+ releaseChild ();
+ releaseWidget ();
+ }
+ return result;
+}
+
+LRESULT WM_MOUSEACTIVATE (int wParam, int lParam) {
+ LRESULT result = super.WM_MOUSEACTIVATE (wParam, lParam);
+ if (result != null) return result;
+ int hittest = lParam & 0xFFFF;
+ if (hittest == OS.HTMENU) return null;
+ POINT pt = new POINT ();
+ int pos = OS.GetMessagePos ();
+ pt.x = (short) (pos & 0xFFFF);
+ pt.y = (short) (pos >> 16);
+ int hwnd = OS.WindowFromPoint (pt);
+ if (hwnd == 0) return null;
+ Control control = WidgetTable.get (hwnd);
+ if (control == null) return null;
+ Button button = null;
+ boolean setDefault = false;
+ if (OS.GetActiveWindow () == handle && this == control.getShell ()) {
+ if ((hittest != OS.HTHSCROLL) && (hittest != OS.HTVSCROLL)) {
+ int hwndChild = control.handle;
+ int code = OS.SendMessage (hwndChild, OS.WM_GETDLGCODE, 0, 0);
+ setDefault = (code & OS.DLGC_STATIC) == 0;
+ if (setDefault && control instanceof Button) {
+ if (((button = (Button) control).style & SWT.PUSH) == 0) {
+ button = null;
+ }
+ }
+ }
+ }
+ if (setDefault) setDefaultButton (button, false);
+ /*
+ * This code is intentionally commented. On some platforms,
+ * shells that are created with SWT.NO_TRIM won't take focus
+ * when the user clicks in the client area or on the border.
+ * This behavior is usedful when emulating tool tip shells
+ * Until this behavior is specified, this code will remain
+ * commented.
+ */
+// if ((style & SWT.NO_TRIM) != 0) {
+// if (hittest == OS.HTBORDER || hittest == OS.HTCLIENT) {
+// return new LRESULT (OS.MA_NOACTIVATE);
+// }
+// }
+ return result;
+}
+
+LRESULT WM_NCHITTEST (int wParam, int lParam) {
+ if (!isEnabled () || !isActive ()) {
+ if (!display.TrimEnabled) return new LRESULT(OS.HTNOWHERE);
+ int hittest = callWindowProc (OS.WM_NCHITTEST, wParam, lParam);
+ if (hittest == OS.HTCLIENT || hittest == OS.HTMENU) hittest = OS.HTBORDER;
+ return new LRESULT (hittest);
+ }
+ if (menuBar != null && !menuBar.getEnabled ()) {
+ int hittest = callWindowProc (OS.WM_NCHITTEST, wParam, lParam);
+ if (hittest == OS.HTMENU) hittest = OS.HTBORDER;
+ return new LRESULT (hittest);
+ }
+ return null;
+}
+
+LRESULT WM_PALETTECHANGED (int wParam, int lParam) {
+ if (wParam != handle) {
+ int hPalette = display.hPalette;
+ if (hPalette != 0) return selectPalette (hPalette);
+ }
+ return super.WM_PALETTECHANGED (wParam, lParam);
+}
+
+LRESULT WM_QUERYNEWPALETTE (int wParam, int lParam) {
+ int hPalette = display.hPalette;
+ if (hPalette != 0) return selectPalette (hPalette);
+ return super.WM_QUERYNEWPALETTE (wParam, lParam);
+}
+
+LRESULT WM_SETCURSOR (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the shell is disabled
+ * by a Windows standard dialog (like a MessageBox
+ * or FileDialog), clicking in the shell does not
+ * bring the shell or the dialog to the front. The
+ * fix is to detect this case and bring the shell
+ * forward.
+ */
+ int msg = lParam >> 16;
+ if (msg == OS.WM_LBUTTONDOWN) {
+ if (!display.TrimEnabled) {
+ Shell modalShell = display.getModalShell ();
+ if (modalShell != null && !isActive ()) {
+ OS.SetActiveWindow (modalShell.handle);
+ }
+ }
+ if (!OS.IsWindowEnabled (handle)) {
+ int hwndPopup = OS.GetLastActivePopup (handle);
+ if (hwndPopup != 0 && hwndPopup != handle) {
+ if (WidgetTable.get (hwndPopup) == null) {
+ OS.SetActiveWindow (hwndPopup);
+ }
+ }
+ }
+ }
+ return super.WM_SETCURSOR (wParam, lParam);
+}
+
+LRESULT WM_SHOWWINDOW (int wParam, int lParam) {
+ LRESULT result = super.WM_SHOWWINDOW (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Bug in Windows. If the shell is hidden while the parent
+ * is iconic, Windows shows the shell when the parent is
+ * deiconified. This does not happen if the shell is hidden
+ * while the parent is not an icon. The fix is to track
+ * visible state for the shell and refuse to show the shell
+ * when the parent is shown.
+ */
+ if (lParam == OS.SW_PARENTOPENING) {
+ Control control = this;
+ while (control != null) {
+ Shell shell = control.getShell ();
+ if (!shell.showWithParent) return LRESULT.ZERO;
+ control = control.parent;
+ }
+ }
+ return result;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
new file mode 100755
index 0000000000..f072cc0eeb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Slider.java
@@ -0,0 +1,734 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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 <em>selection</em> 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 left and right facing buttons for incrementing and
+ * decrementing the value) or <code>VERTICAL</code> (which have
+ * up and down facing buttons for incrementing and decrementing
+ * the value).
+ * </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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ *
+ * @see Scrollbar
+ */
+
+public class Slider extends Control {
+ int increment, pageIncrement;
+ static final int ScrollBarProc;
+ static final byte [] ScrollBarClass = Converter.wcsToMbcs (0, "SCROLLBAR\0", false);
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ScrollBarClass, lpWndClass);
+ ScrollBarProc = lpWndClass.lpfnWndProc;
+ }
+
+public Slider (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's value changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ScrollBarProc, handle, msg, wParam, lParam);
+}
+
+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 ();
+ int border = getBorderWidth ();
+ int width = border * 2, height = border * 2;
+ if ((style & SWT.HORIZONTAL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXHSCROLL) * 10;
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ } else {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ height += OS.GetSystemMetrics (OS.SM_CYVSCROLL) * 10;
+ }
+ if (wHint != SWT.DEFAULT) width = wHint + (border * 2);
+ if (hHint != SWT.DEFAULT) height = hHint + (border * 2);
+ return new Point (width, height);
+}
+
+void createWidget () {
+ super.createWidget ();
+ increment = 1;
+ pageIncrement = 10;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_ALL;
+ info.nMax = 100;
+ info.nPage = pageIncrement + 1;
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, true);
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_SCROLLBAR);
+}
+
+int defaultForeground () {
+ return OS.GetSysColor (OS.COLOR_BTNFACE);
+}
+
+public boolean getEnabled () {
+ checkWidget ();
+ return (state & DISABLED) == 0;
+}
+
+/**
+ * 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 ();
+ return 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 ();
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ return info.nMax;
+}
+
+/**
+ * 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 ();
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ return info.nMin;
+}
+
+/**
+ * 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 ();
+ return pageIncrement;
+}
+
+/**
+ * Returns the single <em>selection</em> 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 ();
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ return info.nPos;
+}
+
+/**
+ * Answers 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 Slider
+ */
+public int getThumb () {
+ checkWidget ();
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_PAGE;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ if (info.nPage != 0) --info.nPage;
+ return info.nPage;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's value changes.
+ *
+ * @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 setBounds (int x, int y, int width, int height, int flags) {
+ super.setBounds (x, y, width, height, flags);
+ /*
+ * Bug in Windows. If the scroll bar is resized when it has focus,
+ * the flashing cursor that is used to show that the scroll bar has
+ * focus is not moved. The fix is to post a fake WM_SETFOCUS to
+ * get the scroll bar to recompute the size of the flashing cursor.
+ */
+ if (OS.GetFocus () == handle) {
+ OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
+ }
+}
+
+public void setEnabled (boolean enabled) {
+ checkWidget ();
+ int flags = OS.ESB_DISABLE_BOTH;
+ if (enabled) flags = OS.ESB_ENABLE_BOTH;
+ OS.EnableScrollBar (handle, OS.SB_CTL, flags);
+ state &= ~DISABLED;
+ if (!enabled) state |= DISABLED;
+}
+
+/**
+ * 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;
+ increment = value;
+}
+
+/**
+ * Sets the maximum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new maximum (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 setMaximum (int value) {
+ checkWidget ();
+ if (value < 0) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ if (value - info.nMin - info.nPage < 1) return;
+ info.nMax = value;
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, (state & DISABLED) == 0);
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (handle, OS.SB_CTL, OS.ESB_DISABLE_BOTH);
+ }
+
+ /*
+ * Bug in Windows. If the thumb is resized when it has focus,
+ * the flashing cursor that is used to show that the scroll bar has
+ * focus is not moved. The fix is to post a fake WM_SETFOCUS to
+ * get the scroll bar to recompute the size of the flashing cursor.
+ */
+ if (OS.GetFocus () == handle) {
+ OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
+ }
+}
+
+/**
+ * Sets the minimum value which the receiver will allow
+ * to be the argument which must be greater than or
+ * equal to zero.
+ *
+ * @param value the new minimum (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 setMinimum (int value) {
+ checkWidget ();
+ if (value < 0) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ if (info.nMax - value - info.nPage < 1) return;
+ info.nMin = value;
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, true);
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (handle, OS.SB_CTL, OS.ESB_DISABLE_BOTH);
+ }
+
+ /*
+ * Bug in Windows. If the thumb is resized when it has focus,
+ * the flashing cursor that is used to show that the scroll bar has
+ * focus is not moved. The fix is to post a fake WM_SETFOCUS to
+ * get the scroll bar to recompute the size of the flashing cursor.
+ */
+ if (OS.GetFocus () == handle) {
+ OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
+ }
+}
+
+/**
+ * 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.
+ *
+ * @return 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;
+ pageIncrement = value;
+}
+
+/**
+ * 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 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 ();
+ if (value < 0) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS;
+ info.nPos = value;
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, true);
+}
+
+/**
+ * Sets the size of the receiver's thumb relative to the
+ * difference between its maximum and minimum values to the
+ * argument which must be at least one.
+ *
+ * @param value the new thumb value (must be at least 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 ScrollBar
+ */
+public void setThumb (int value) {
+ checkWidget ();
+
+ /* Position the thumb */
+ if (value < 1) return;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ if (info.nMax - info.nMin - value < 0) return;
+ info.nPage = value;
+ if (info.nPage != 0) info.nPage++;
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, true);
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (handle, OS.SB_CTL, OS.ESB_DISABLE_BOTH);
+ }
+
+ /*
+ * Bug in Windows. If the thumb is resized when it has focus,
+ * the flashing cursor that is used to show that the scroll bar has
+ * focus is not moved. The fix is to post a fake WM_SETFOCUS to
+ * get the scroll bar to recompute the size of the flashing cursor.
+ */
+ if (OS.GetFocus () == handle) {
+ OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
+ }
+}
+
+/**
+ * Sets the receiver's selection, minimum value, maximum
+ * value, thumb, increment and page increment all at once.
+ * <p>
+ * Note: This is equivalent 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 (selection < 0) return;
+ if (minimum < 0) return;
+ if (maximum < 0) return;
+ if (thumb < 1) return;
+ if (maximum - minimum - thumb < 0) return;
+ if (increment < 1) return;
+ if (pageIncrement < 1) return;
+ this.increment = increment;
+ this.pageIncrement = pageIncrement;
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_POS | OS.SIF_PAGE | OS.SIF_RANGE | OS.SIF_DISABLENOSCROLL;
+ info.nPos = selection;
+ info.nMin = minimum;
+ info.nMax = maximum;
+ info.nPage = thumb;
+ if (info.nPage != 0) info.nPage++;
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, true);
+
+ /*
+ * Feature in Windows. Using SIF_DISABLENOSCROLL,
+ * SetScrollInfo () can change enabled and disabled
+ * state of the scroll bar causing a scroll bar that
+ * was disabled by the application to become enabled.
+ * The fix is to disable the scroll bar (again) when
+ * the application has disabled the scroll bar.
+ */
+ if ((state & DISABLED) != 0) {
+ OS.EnableScrollBar (handle, OS.SB_CTL, OS.ESB_DISABLE_BOTH);
+ }
+
+ /*
+ * Bug in Windows. If the thumb is resized when it has focus,
+ * the flashing cursor that is used to show that the scroll bar has
+ * focus is not moved. The fix is to post a fake WM_SETFOCUS to
+ * get the scroll bar to recompute the size of the flashing cursor.
+ */
+ if (OS.GetFocus () == handle) {
+ OS.PostMessage (handle, OS.WM_SETFOCUS, 0, 0);
+ }
+}
+
+int widgetExtStyle () {
+ /*
+ * Bug in Windows. If a scroll bar control is given a border,
+ * dragging the scroll bar thumb eats away parts of the border
+ * while the thumb is dragged. The fix is to clear WS_BORDER
+ * for all scroll bars.
+ */
+ int bits = super.widgetExtStyle ();
+ if ((style & SWT.BORDER) != 0) bits &= ~OS.WS_EX_CLIENTEDGE;
+ return bits;
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP;
+ /*
+ * Bug in Windows. If a scroll bar control is given a border,
+ * dragging the scroll bar thumb eats away parts of the border
+ * while the thumb is dragged. The fix is to clear WS_BORDER.
+ */
+ if ((style & SWT.BORDER) != 0) bits &= ~OS.WS_BORDER;
+ if ((style & SWT.HORIZONTAL) != 0) return bits | OS.SBS_HORZ;
+ return bits | OS.SBS_VERT;
+}
+
+byte [] windowClass () {
+ return ScrollBarClass;
+}
+
+int windowProc () {
+ return ScrollBarProc;
+}
+
+LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
+
+ /*
+ * Feature in Windows. For some reason, capturing
+ * the mouse after processing WM_LBUTTONDBLCLK for the
+ * widget interferes with the normal mouse processing
+ * for the widget. The fix is to avoid the automatic
+ * mouse capture.
+ */
+
+ /*
+ * Feature in Windows. Windows uses the WS_TABSTOP
+ * style for the scroll bar to decide that focus
+ * should be set during WM_LBUTTONDBLCLK. This is
+ * not the desired behavior. The fix is to clear
+ * and restore WS_TABSTOP so that Windows will not
+ * assign focus.
+ */
+
+ int hwndCapture = OS.GetCapture ();
+ int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int newBits = oldBits & ~OS.WS_TABSTOP;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ LRESULT result = super.WM_LBUTTONDBLCLK (wParam, lParam);
+ OS.SetWindowLong (handle, OS.GWL_STYLE, oldBits);
+ if (OS.GetCapture () != hwndCapture) OS.SetCapture (hwndCapture);
+ return result;
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+
+ /*
+ * Feature in Windows. For some reason, capturing
+ * the mouse after processing WM_LBUTTONDOWN for the
+ * widget interferes with the normal mouse processing
+ * for the widget. The fix is to avoid the automatic
+ * mouse capture.
+ */
+
+ /*
+ * Feature in Windows. Windows uses the WS_TABSTOP
+ * style for the scroll bar to decide that focus
+ * should be set during WM_LBUTTONDOWN. This is
+ * not the desired behavior. The fix is to clear
+ * and restore WS_TABSTOP so that Windows will not
+ * assign focus.
+ */
+
+ int hwndCapture = OS.GetCapture ();
+ int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int newBits = oldBits & ~OS.WS_TABSTOP;
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ LRESULT result = super.WM_LBUTTONDOWN (wParam, lParam);
+ OS.SetWindowLong (handle, OS.GWL_STYLE, oldBits);
+ if (OS.GetCapture () != hwndCapture) OS.SetCapture (hwndCapture);
+ return result;
+}
+
+LRESULT wmScrollChild (int wParam, int lParam) {
+
+ /* Do nothing when scrolling is ending */
+ int code = wParam & 0xFFFF;
+ if (code == OS.SB_ENDSCROLL) return null;
+
+ /* Move the thumb */
+ Event event = new Event ();
+ SCROLLINFO info = new SCROLLINFO ();
+ info.cbSize = SCROLLINFO.sizeof;
+ info.fMask = OS.SIF_TRACKPOS | OS.SIF_POS | OS.SIF_RANGE;
+ OS.GetScrollInfo (handle, OS.SB_CTL, info);
+ info.fMask = OS.SIF_POS;
+ switch (code) {
+ case OS.SB_THUMBPOSITION:
+ /*
+ * Do not set the detail field to DRAG to
+ * indicate that the dragging has ended.
+ */
+ info.nPos = info.nTrackPos;
+ break;
+ case OS.SB_THUMBTRACK:
+ event.detail = SWT.DRAG;
+ info.nPos = info.nTrackPos;
+ break;
+ case OS.SB_TOP:
+ event.detail = SWT.HOME;
+ info.nPos = info.nMin;
+ break;
+ case OS.SB_BOTTOM:
+ event.detail = SWT.END;
+ info.nPos = info.nMax;
+ break;
+ case OS.SB_LINEDOWN:
+ event.detail = SWT.ARROW_DOWN;
+ info.nPos += increment;
+ break;
+ case OS.SB_LINEUP:
+ event.detail = SWT.ARROW_UP;
+ info.nPos = Math.max (info.nMin, info.nPos - increment);
+ break;
+ case OS.SB_PAGEDOWN:
+ event.detail = SWT.PAGE_DOWN;
+ info.nPos += pageIncrement;
+ break;
+ case OS.SB_PAGEUP:
+ event.detail = SWT.PAGE_UP;
+ info.nPos = Math.max (info.nMin, info.nPos - pageIncrement);
+ break;
+ }
+ OS.SetScrollInfo (handle, OS.SB_CTL, info, true);
+
+ /*
+ * Send the event because WM_HSCROLL and
+ * WM_VSCROLL are sent from a modal message
+ * loop in Windows that is active when the
+ * user is scrolling.
+ */
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
new file mode 100755
index 0000000000..ad6c02dd2a
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java
@@ -0,0 +1,685 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement the notebook user interface
+ * metaphore. It allows the user to select a notebook page from
+ * set of pages.
+ * <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>
+ */
+
+public class TabFolder extends Composite {
+ TabItem [] items;
+ ImageList imageList;
+ static final int TabFolderProc;
+ static final byte [] TabFolderClass;
+ static {
+ byte [] prefix = Converter.wcsToMbcs (0, "SWT_");
+ TabFolderClass = new byte [prefix.length + OS.WC_TABCONTROL.length];
+ System.arraycopy (prefix, 0, TabFolderClass, 0, prefix.length);
+ System.arraycopy (OS.WC_TABCONTROL, 0, TabFolderClass, prefix.length, OS.WC_TABCONTROL.length);
+ /*
+ * Feature in Windows. The tab control window class
+ * uses the CS_HREDRAW and CS_VREDRAW style bits to
+ * force a full redraw of the control and all children
+ * when resized. This causes flashing. The fix is to
+ * register a new window class without these bits and
+ * implement special code that damages only the exposed
+ * area.
+ */
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, OS.WC_TABCONTROL, lpWndClass);
+ TabFolderProc = lpWndClass.lpfnWndProc;
+ int hInstance = OS.GetModuleHandle (null);
+ if (!OS.GetClassInfoEx (hInstance, TabFolderClass, lpWndClass)) {
+ int hHeap = OS.GetProcessHeap ();
+ lpWndClass.hInstance = hInstance;
+ lpWndClass.style &= ~(OS.CS_HREDRAW | OS.CS_VREDRAW);
+ lpWndClass.lpszClassName = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, TabFolderClass.length);
+ OS.MoveMemory (lpWndClass.lpszClassName, TabFolderClass, TabFolderClass.length);
+ OS.RegisterClassEx (lpWndClass);
+ }
+ }
+
+
+public TabFolder (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (TabFolderProc, handle, msg, wParam, lParam);
+}
+
+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 ();
+ RECT insetRect = new RECT (), itemRect = new RECT ();
+ OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, insetRect);
+ int width = insetRect.left - insetRect.right, height = 0;
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ if (count != 0) {
+ OS.SendMessage (handle, OS.TCM_GETITEMRECT, count - 1, itemRect);
+ width = Math.max (width, itemRect.right - insetRect.right);
+ }
+ Point size;
+ if (layout != null) {
+ size = layout.computeSize (this, wHint, hHint, changed);
+ } else {
+ size = minimumSize ();
+ }
+ 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;
+ width = Math.max (width, size.x);
+ height = Math.max (height, size.y);
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = trim.width; height = trim.height;
+ return new Point (width, height);
+}
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget ();
+ RECT rect = new RECT ();
+ OS.SetRect (rect, x, y, x + width, y + height);
+ OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 1, rect);
+ int border = getBorderWidth ();
+ rect.left -= border; rect.right += border;
+ rect.top -= border; rect.bottom += border;
+ int newWidth = rect.right - rect.left;
+ int newHeight = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, newWidth, newHeight);
+}
+
+void createItem (TabItem item, int index) {
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ if (count == items.length) {
+ TabItem [] newItems = new TabItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ TCITEM tcItem = new TCITEM ();
+ if (OS.SendMessage (handle, OS.TCM_INSERTITEM, index, tcItem) == -1) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+ System.arraycopy (items, index, items, index + 1, count - index);
+ items [index] = item;
+
+ /*
+ * Send a selection event when the item that is added becomes
+ * the new selection. This only happens when the first item
+ * is added.
+ */
+ if (count == 0) {
+ Event event = new Event ();
+ event.item = items [0];
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ }
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new TabItem [4];
+}
+
+void destroyItem (TabItem item) {
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
+ }
+ if (index == count) return;
+ int selectionIndex = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ if (OS.SendMessage (handle, OS.TCM_DELETEITEM, index, 0) == 0) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ items [count] = null;
+ if (count == 0) {
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+ items = new TabItem [4];
+ }
+ if (count > 0 && index == selectionIndex) {
+ setSelection (Math.max (0, selectionIndex - 1));
+ selectionIndex = getSelectionIndex ();
+ if (selectionIndex != -1) {
+ Event event = new Event ();
+ event.item = items [selectionIndex];
+ sendEvent (SWT.Selection, event);
+ // the widget could be destroyed at this point
+ }
+ }
+}
+
+public Rectangle getClientArea () {
+ checkWidget ();
+ if (parent.hdwp != 0) {
+ int oldHdwp = parent.hdwp;
+ parent.hdwp = 0;
+ OS.EndDeferWindowPos (oldHdwp);
+ int count = parent.getChildrenCount ();
+ parent.hdwp = OS.BeginDeferWindowPos (count);
+ }
+ RECT rect = new RECT ();
+ OS.GetClientRect (handle, rect);
+ OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+}
+
+/**
+ * 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 ();
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ if (!(0 <= index && index < count)) 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 OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+}
+
+/**
+ * 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 effect 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 = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ 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 effect 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.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ 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.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+}
+
+int imageIndex (Image image) {
+ if (image == null) return OS.I_IMAGENONE;
+ if (imageList == null) {
+ imageList = new ImageList ();
+ imageList.setBackground (getBackgroundPixel ());
+ imageList.add (image);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
+ return 0;
+ }
+ int index = imageList.indexOf (image);
+ if (index != -1) return index;
+ imageList.add (image);
+ return imageList.size () - 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 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 (TabItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) return i;
+ }
+ return -1;
+}
+
+void releaseWidget () {
+ int count = OS.SendMessage (handle, OS.TCM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<count; i++) {
+ TabItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ items = null;
+ super.releaseWidget ();
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @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 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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);
+ return;
+ }
+ for (int i=items.length-1; i>=0; --i) {
+ int index = indexOf (items [i]);
+ if (index != -1) setSelection (index);
+ }
+}
+
+/**
+ * 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 selected 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 ();
+ int oldIndex = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ if (oldIndex != -1) {
+ TabItem item = items [oldIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setVisible (false);
+ }
+ }
+ OS.SendMessage (handle, OS.TCM_SETCURSEL, index, 0);
+ int newIndex = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ if (newIndex != -1) {
+ TabItem item = items [newIndex];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ control.setVisible (true);
+ }
+ }
+}
+
+int toolTipHandle () {
+ return OS.SendMessage (handle, OS.TCM_GETTOOLTIPS, 0, 0);
+}
+
+String toolTipText (NMTTDISPINFO hdr) {
+ if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
+ return null;
+ }
+ int index = hdr.idFrom;
+ int hwndToolTip = toolTipHandle ();
+ if (hwndToolTip == hdr.hwndFrom) {
+ if ((0 <= index) && (index < items.length)) {
+ TabItem item = items [index];
+ if (item != null) return item.toolTipText;
+ }
+ }
+ return super.toolTipText (hdr);
+}
+
+int widgetStyle () {
+ /*
+ * Bug in Windows. Under certain circumstances,
+ * when TCM_SETITEM is used to change the text
+ * in a tab item, the tab folder draws on top
+ * of the client area. The fix is ensure that
+ * this cannot happen by setting WS_CLIPCHILDREN.
+ */
+ int bits = super.widgetStyle () | OS.WS_CLIPCHILDREN;
+ return bits | OS.TCS_TABS | OS.TCS_FOCUSNEVER | OS.TCS_TOOLTIPS;
+}
+
+byte [] windowClass () {
+ return TabFolderClass;
+}
+
+int windowProc () {
+ return TabFolderProc;
+}
+
+LRESULT WM_NCHITTEST (int wParam, int lParam) {
+ LRESULT result = super.WM_NCHITTEST (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. The tab control implements
+ * WM_NCHITTEST to return HTCLIENT when the cursor
+ * is inside the tab buttons. This causes mouse
+ * events like WM_MOUSEMOVE to be delivered to the
+ * parent. Also, tool tips for the tab control are
+ * never invoked because tool tips rely on mouse
+ * events to be delivered to the window that wants
+ * to display the tool tip. The fix is to call the
+ * default window proc that returns HTCLIENT when
+ * the mouse is in the client area.
+ */
+ int hittest = OS.DefWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam);
+ return new LRESULT (hittest);
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Bug in Windows NT. For some reason, Windows NT requests a
+ * UNICODE tool tip string instead of a DBCS string by sending
+ * TTN_GETDISPINFOW instead of TTN_GETDISPINFOA. This is not
+ * correct because the control is created as a DBCS control and
+ * expects to process TTN_GETDISPINFOA. TTN_GETDISPINFOA is
+ * never sent on NT. The fix is to handle TTN_GETDISPINFOW and
+ * give the control a UNICODE string.
+ */
+ if (IsWinNT) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ if (hdr.code == OS.TTN_GETDISPINFOW) {
+ NMTTDISPINFO lpnmtdi = new NMTTDISPINFO ();
+ OS.MoveMemory (lpnmtdi, lParam, NMTTDISPINFO.sizeof);
+ String string = null;
+ int index = hdr.idFrom;
+ if (0 <= index && index < items.length) {
+ TabItem item = items [index];
+ if (item != null) string = item.toolTipText;
+ }
+ if (string != null && string.length () != 0) {
+ int length = string.length ();
+ char [] buffer = new char [length + 1];
+ string.getChars (0, length, buffer, 0);
+ getShell ().setToolTipText (lpnmtdi, buffer);
+ OS.MoveMemory (lParam, lpnmtdi, NMTTDISPINFO.sizeof);
+ }
+ return LRESULT.ZERO;
+ }
+ }
+ return super.WM_NOTIFY (wParam, lParam);
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the resize
+ * event. If this happens, end the processing of the
+ * Windows message by returning the result of the
+ * WM_SIZE message.
+ */
+ if (isDisposed ()) return result;
+ int index = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ if (index != -1) {
+ TabItem item = items [index];
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getClientArea ());
+ }
+ }
+ return result;
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
+ if (result != null) return result;
+ if (imageList != null && background == -1) {
+ imageList.setBackground (defaultBackground ());
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TCM_SETIMAGELIST, 0, hImageList);
+ }
+ return result;
+}
+
+LRESULT WM_WINDOWPOSCHANGING (int wParam, int lParam) {
+ LRESULT result = super.WM_WINDOWPOSCHANGING (wParam, lParam);
+ if (result != null) return result;
+ if (!OS.IsWindowVisible (handle)) return result;
+ WINDOWPOS lpwp = new WINDOWPOS ();
+ OS.MoveMemory (lpwp, lParam, WINDOWPOS.sizeof);
+ if ((lpwp.flags & (OS.SWP_NOSIZE | OS.SWP_NOREDRAW)) != 0) {
+ return result;
+ }
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.TCS_MULTILINE) != 0) {
+ OS.InvalidateRect (handle, null, true);
+ return result;
+ }
+ RECT rect = new RECT ();
+ OS.SetRect (rect, 0, 0, lpwp.cx, lpwp.cy);
+ OS.SendMessage (handle, OS.WM_NCCALCSIZE, 0, rect);
+ int newWidth = rect.right - rect.left;
+ int newHeight = rect.bottom - rect.top;
+ OS.GetClientRect (handle, rect);
+ int oldWidth = rect.right - rect.left;
+ int oldHeight = rect.bottom - rect.top;
+ if ((newWidth == oldWidth) && (newHeight == oldHeight)) {
+ return result;
+ }
+ RECT inset = new RECT ();
+ OS.SendMessage (handle, OS.TCM_ADJUSTRECT, 0, inset);
+ int marginX = -inset.right, marginY = -inset.bottom;
+ if (newWidth != oldWidth) {
+ int left = oldWidth;
+ if (newWidth < oldWidth) left = newWidth;
+ OS.SetRect (rect, left - marginX, 0, newWidth, newHeight);
+ OS.InvalidateRect (handle, rect, true);
+ }
+ if (newHeight != oldHeight) {
+ int bottom = oldHeight;
+ if (newHeight < oldHeight) bottom = newHeight;
+ if (newWidth < oldWidth) oldWidth -= marginX;
+ OS.SetRect (rect, 0, bottom - marginY, oldWidth, newHeight);
+ OS.InvalidateRect (handle, rect, true);
+ }
+ return result;
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ int code = hdr.code;
+ switch (code) {
+ case OS.TCN_SELCHANGE:
+ case OS.TCN_SELCHANGING:
+ TabItem item = null;
+ int index = OS.SendMessage (handle, OS.TCM_GETCURSEL, 0, 0);
+ if (index != -1) item = items [index];
+ if (item != null) {
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ if (code == OS.TCN_SELCHANGE) {
+ control.setBounds (getClientArea ());
+ }
+ control.setVisible (code == OS.TCN_SELCHANGE);
+ }
+ }
+ if (code == OS.TCN_SELCHANGE) {
+ Event event = new Event ();
+ event.item = item;
+ postEvent (SWT.Selection, event);
+ }
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
new file mode 100755
index 0000000000..6271fa853e
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabItem.java
@@ -0,0 +1,193 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ */
+
+public class TabItem extends Item {
+ TabFolder parent;
+ Control control;
+ String toolTipText;
+
+public TabItem (TabFolder parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+
+public TabItem (TabFolder parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * 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;
+}
+
+public Display getDisplay () {
+ TabFolder parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+/**
+ * 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;
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ int index = parent.indexOf (this);
+ if (index == parent.getSelectionIndex ()) {
+ if (control != null) control.setVisible (false);
+ }
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ control = null;
+ parent = null;
+}
+
+/**
+ * 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 SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 && 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);
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setImage (image);
+ int hwnd = parent.handle;
+ TCITEM tcItem = new TCITEM ();
+ tcItem.mask = OS.TCIF_IMAGE;
+ tcItem.iImage = parent.imageIndex (image);
+ OS.SendMessage (hwnd, OS.TCM_SETITEM, index, tcItem);
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setText (string);
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ TCITEM tcItem = new TCITEM ();
+ tcItem.mask = OS.TCIF_TEXT;
+ tcItem.pszText = pszText;
+ int result = OS.SendMessage (hwnd, OS.TCM_SETITEM, index, tcItem);
+ OS.HeapFree (hHeap, 0, pszText);
+}
+
+/**
+ * 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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
new file mode 100755
index 0000000000..d70b459da5
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java
@@ -0,0 +1,2149 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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 issue
+ * notificiation when selected.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Table extends Composite {
+ TableItem [] items;
+ TableColumn [] columns;
+ ImageList imageList;
+ boolean ignoreSelect, dragStarted;
+ static final int TableProc;
+ static final byte [] TableClass = OS.WC_LISTVIEW;
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, TableClass, lpWndClass);
+ TableProc = lpWndClass.lpfnWndProc;
+ }
+
+public Table (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (TableProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ /*
+ * Feature in Windows. It is not possible to create
+ * a table that does not have scroll bars. Therefore,
+ * no matter what style bits are specified, set the
+ * H_SCROLL and V_SCROLL bits so that the SWT style
+ * will match the widget that Windows creates.
+ */
+ style |= SWT.H_SCROLL | SWT.V_SCROLL;
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int bits = 0;
+ if (wHint != SWT.DEFAULT) {
+ bits |= wHint & 0xFFFF;
+ } else {
+ int width = 0;
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<count; i++) {
+ width += OS.SendMessage (handle, OS.LVM_GETCOLUMNWIDTH, i, 0);
+ }
+ bits |= width & 0xFFFF;
+ }
+ if (hHint != SWT.DEFAULT) bits |= hHint << 16;
+ int result = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, -1, bits);
+ int width = result & 0xFFFF, height = result >> 16;
+ 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;
+ /*
+ * Feature in Windows. For some reason, LVM_APPROXIMATEVIEWRECT
+ * does not include the space for the vertical scroll bar but does
+ * take into account the horizontal scroll bar when calculating the
+ * space needed to show the items. The fix is to add in this space.
+ */
+ if ((style & SWT.V_SCROLL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ }
+ if (((style & SWT.H_SCROLL) != 0) && (hHint != SWT.DEFAULT)) {
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ }
+ return new Point (width, height);
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+
+ /*
+ * This code is intentionally commented. According to
+ * the documentation, setting the default item size is
+ * supposed to improve performance. By experimentation,
+ * this does not seem to have much of an effect.
+ */
+// OS.SendMessage (handle, OS.LVM_SETITEMCOUNT, 1024 * 2, 0);
+
+ /* Set the checkbox image list */
+ if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+
+ /*
+ * Feature in Windows. When the control is created,
+ * it does not use the default system font. A new HFONT
+ * is created and destroyed when the control is destroyed.
+ * This means that a program that queries the font from
+ * this control, uses the font in another control and then
+ * destroys this control will have the font unexpectedly
+ * destroyed in the other control. The fix is to assign
+ * the font ourselves each time the control is created.
+ * The control will not destroy a font that it did not
+ * create.
+ */
+ int hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
+
+ /*
+ * Bug in Windows. When the first column is inserted
+ * without setting the header text, Windows will never
+ * allow the header text for the first column to be set.
+ * The fix is to set the text to an empty string when
+ * the column is inserted.
+ */
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_TEXT;
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 1);
+ lvColumn.pszText = pszText;
+ OS.SendMessage (handle, OS.LVM_INSERTCOLUMN, 0, lvColumn);
+ OS.HeapFree (hHeap, 0, pszText);
+
+ /* Set the extended style bits */
+ int bits = OS.LVS_EX_SUBITEMIMAGES | OS.LVS_EX_LABELTIP;
+ if ((style & SWT.FULL_SELECTION) != 0) bits |= OS.LVS_EX_FULLROWSELECT;
+ OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, bits, bits);
+}
+
+void createItem (TableColumn column, int index) {
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (count == 1 && columns [0] == null) count = 0;
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ if (count == columns.length) {
+ TableColumn [] newColumns = new TableColumn [columns.length + 4];
+ System.arraycopy (columns, 0, newColumns, 0, columns.length);
+ columns = newColumns;
+ }
+ /*
+ * Insert the column into the columns array before inserting
+ * it into the widget so that the column will be present when
+ * any callbacks are issued as a result of LVM_INSERTCOLUMN
+ * or LVM_SETCOLUMN.
+ */
+ System.arraycopy (columns, index, columns, index + 1, count - index);
+ columns [index] = column;
+ if (index == 0) {
+ if (count > 0) {
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_WIDTH;
+ OS.SendMessage (handle, OS.LVM_INSERTCOLUMN, 1, lvColumn);
+ int cchTextMax = 1024;
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, cchTextMax);
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_TEXT | OS.LVIF_IMAGE | OS.LVIF_STATE;
+ int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<itemCount; i++) {
+ lvItem.iItem = i;
+ lvItem.iSubItem = 0;
+ lvItem.pszText = pszText;
+ lvItem.cchTextMax = cchTextMax;
+ OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ lvItem.iSubItem = 1;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ lvItem.iSubItem = 0;
+ lvItem.pszText = lvItem.cchTextMax = 0;
+ lvItem.iImage = OS.I_IMAGENONE;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ }
+ lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_WIDTH | OS.LVCF_FMT;
+ lvColumn.pszText = pszText;
+ lvColumn.cchTextMax = cchTextMax;
+ OS.SendMessage (handle, OS.LVM_GETCOLUMN, 0, lvColumn);
+ OS.SendMessage (handle, OS.LVM_SETCOLUMN, 1, lvColumn);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ }
+ } else {
+ int fmt = OS.LVCFMT_LEFT;
+ if ((column.style & SWT.CENTER) == SWT.CENTER) fmt = OS.LVCFMT_CENTER;
+ if ((column.style & SWT.RIGHT) == SWT.RIGHT) fmt = OS.LVCFMT_RIGHT;
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_WIDTH | OS.LVCF_FMT;
+ lvColumn.fmt = fmt;
+ OS.SendMessage (handle, OS.LVM_INSERTCOLUMN, index, lvColumn);
+ }
+}
+
+void createItem (TableItem item, int index) {
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ if (count == items.length) {
+ TableItem [] newItems = new TableItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ LVITEM lvItem = new LVITEM ();
+ lvItem.iItem = index;
+
+ /*
+ * Bug in Windows. Despite the fact that the image list
+ * index has never been set for the item, Windows always
+ * assumes that the image index for the item is valid.
+ * When an item is inserted, the image index is zero.
+ * Therefore, when the first image is inserted and is
+ * assigned image index zero, every item draws with this
+ * image. The fix is to set the image index to none when
+ * the image is created.
+ */
+ lvItem.iImage = OS.I_IMAGENONE;
+ lvItem.mask = OS.LVIF_IMAGE;
+
+ /* Set the initial unchecked state */
+ if ((style & SWT.CHECK) != 0) {
+ lvItem.mask = lvItem.mask | OS.TVIF_STATE;
+ lvItem.state = 1 << 12;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ }
+
+ /* Insert the item */
+ ignoreSelect = true;
+ int result = OS.SendMessage (handle, OS.LVM_INSERTITEM, 0, lvItem);
+ ignoreSelect = false;
+ if (result == -1) error (SWT.ERROR_ITEM_NOT_ADDED);
+ System.arraycopy (items, index, items, index + 1, count - index);
+ items [index] = item;
+}
+
+ScrollBar createScrollBar (int type) {
+ return new ScrollBar (this, type);
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new TableItem [4];
+ columns = new TableColumn [4];
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_WINDOW);
+}
+
+/**
+ * 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 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>
+ */
+public void deselect (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ for (int i=0; i<indices.length; i++) {
+ lvItem.iItem = indices [i];
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+ }
+}
+
+/**
+ * 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 ();
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ lvItem.iItem = index;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+}
+
+/**
+ * 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 ();
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ for (int i=start; i<=end; i++) {
+ lvItem.iItem = i;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+ }
+}
+
+/**
+ * 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 ();
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ OS.SendMessage (handle, OS.LVM_SETITEMSTATE, -1, lvItem);
+}
+
+void destroyItem (TableColumn column) {
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ int index = 0;
+ while (index < count) {
+ if (columns [index] == column) break;
+ index++;
+ }
+ if (index == count) return;
+ boolean first = false;
+ if (index == 0) {
+ first = true;
+ if (count > 1) {
+ index = 1;
+ int cchTextMax = 1024;
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, cchTextMax);
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_TEXT | OS.LVCF_WIDTH;
+ lvColumn.pszText = pszText;
+ lvColumn.cchTextMax = cchTextMax;
+ OS.SendMessage (handle, OS.LVM_GETCOLUMN, 1, lvColumn);
+ lvColumn.mask |= OS.LVCF_FMT;
+ lvColumn.fmt = OS.LVCFMT_LEFT;
+ OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, lvColumn);
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_TEXT | OS.LVIF_IMAGE | OS.LVIF_STATE;
+ lvItem.pszText = pszText;
+ lvItem.cchTextMax = cchTextMax;
+ int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<itemCount; i++) {
+ lvItem.iItem = i;
+ lvItem.iSubItem = 1;
+ OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ lvItem.iSubItem = 0;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ }
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ } else {
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, 1);
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_TEXT;
+ lvColumn.pszText = pszText;
+ OS.SendMessage (handle, OS.LVM_SETCOLUMN, 0, lvColumn);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, OS.LVSCW_AUTOSIZE);
+ }
+ }
+ if (count > 1) {
+ if (OS.SendMessage (handle, OS.LVM_DELETECOLUMN, index, 0) == 0) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ }
+ }
+ if (first) index = 0;
+ System.arraycopy (columns, index + 1, columns, index, --count - index);
+ columns [count] = null;
+}
+
+void destroyItem (TableItem item) {
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int index = 0;
+ while (index < count) {
+ if (items [index] == item) break;
+ index++;
+ }
+ if (index == count) return;
+ ignoreSelect = true;
+ int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ ignoreSelect = false;
+ if (code == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ items [count] = null;
+ if (count == 0) {
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+ items = new TableItem [4];
+ }
+}
+
+int getBackgroundPixel () {
+ return OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0);
+}
+
+/**
+ * Returns the column at the given, zero-relative index in the
+ * receiver. Throws an exception if the index is out of range.
+ * 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>
+ */
+public TableColumn getColumn (int index) {
+ checkWidget ();
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (count == 1 && columns [0] == null) count = 0;
+ if (!(0 <= index && index < count)) 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 is 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_CANNOT_GET_COUNT - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public int getColumnCount () {
+ checkWidget ();
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (count == 1 && columns [0] == null) count = 0;
+ return count;
+}
+
+/**
+ * Returns an array of <code>TableColumn</code>s which are the
+ * columns in the receiver. 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 effect 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 TableColumn [] getColumns () {
+ checkWidget ();
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (count == 1 && columns [0] == null) count = 0;
+ TableColumn [] result = new TableColumn [count];
+ System.arraycopy (columns, 0, result, 0, count);
+ return result;
+}
+
+int getFocusIndex () {
+ return OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+}
+
+int getForegroundPixel () {
+ return OS.SendMessage (handle, OS.LVM_GETTEXTCOLOR, 0, 0);
+}
+
+/**
+ * Returns the width in pixels of a grid 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 getGridLineWidth () {
+ checkWidget ();
+ return 1;
+}
+
+/**
+ * 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 ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.LVS_NOCOLUMNHEADER) == 0;
+}
+
+/**
+ * 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 ();
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ if (!(0 <= index && index < count)) 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 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>
+ */
+public TableItem getItem (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ LVHITTESTINFO pinfo = new LVHITTESTINFO ();
+ pinfo.x = point.x; pinfo.y = point.y;
+ OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ if (pinfo.iItem != -1) return items [pinfo.iItem];
+ 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 OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+}
+
+/**
+ * Returns the height of the area which would be used to
+ * display <em>one</em> of the items in the receiver's.
+ *
+ * @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 empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ return (oneItem >> 16) - (empty >> 16);
+}
+
+/**
+ * Returns an 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 effect 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 ();
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ TableItem [] result = new TableItem [count];
+ System.arraycopy (items, 0, result, 0, count);
+ 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 ();
+ int bits = OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ return (bits & OS.LVS_EX_GRIDLINES) != 0;
+}
+
+/**
+ * Returns an array of <code>TableItem</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 effect 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 i = -1, j = 0, count = OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ TableItem [] result = new TableItem [count];
+ while ((i = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
+ result [j++] = items [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 ();
+ return OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+}
+
+/**
+ * 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 ();
+ int focusIndex = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ int selectedIndex = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
+ if (focusIndex == selectedIndex) return selectedIndex;
+ int i = -1;
+ while ((i = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
+ if (i == focusIndex) return i;
+ }
+ return selectedIndex;
+}
+
+/**
+ * Returns the zero-relative indices of the items which are currently
+ * selected in the receiver. 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 effect 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 i = -1, j = 0, count = OS.SendMessage (handle, OS.LVM_GETSELECTEDCOUNT, 0, 0);
+ int [] result = new int [count];
+ while ((i = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, i, OS.LVNI_SELECTED)) != -1) {
+ result [j++] = i;
+ }
+ return result;
+}
+
+/**
+ * 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 ();
+ return OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
+}
+
+int imageIndex (Image image) {
+ if (image == null) return OS.I_IMAGENONE;
+ if (imageList == null) {
+ imageList = new ImageList ();
+ imageList.setBackground (getBackgroundPixel ());
+ imageList.add (image);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
+ return 0;
+ }
+ int index = imageList.indexOf (image);
+ if (index != -1) return index;
+ imageList.add (image);
+ return imageList.size () - 1;
+}
+
+/**
+ * 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 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 (TableColumn column) {
+ checkWidget ();
+ if (column == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<count; 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 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 (TableItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<count; i++) {
+ if (items [i] == item) 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 visibility 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 ();
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ lvItem.iItem = index;
+ int result = OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ return (result != 0) && ((lvItem.state & OS.LVIS_SELECTED) != 0);
+}
+
+void releaseWidget () {
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (columnCount == 1 && columns [0] == null) columnCount = 0;
+ for (int i=0; i<columnCount; i++) {
+ TableColumn column = columns [i];
+ if (!column.isDisposed ()) column.releaseWidget ();
+ }
+ columns = null;
+ int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<itemCount; i++) {
+ TableItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ items = null;
+ super.releaseWidget ();
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+ int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, 0);
+ if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+}
+
+/**
+ * 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>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - 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_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int [] newIndices = new int [indices.length];
+ System.arraycopy (indices, 0, newIndices, 0, indices.length);
+ sort (newIndices);
+ int last = -1;
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ for (int i=0; i<newIndices.length; i++) {
+ int index = newIndices [i];
+ if (index != last || i == 0) {
+ ignoreSelect = true;
+ int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ ignoreSelect = false;
+ if (code == 0) {
+ if (0 <= index && index < count) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ } else {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+
+ // BUG - disposed callback could remove an item
+ items [index].releaseWidget ();
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ items [count] = null;
+ last = index;
+ }
+ }
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int index) {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ ignoreSelect = true;
+ int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ ignoreSelect = false;
+ if (code == 0) {
+ if (0 <= index && index < count) {
+ error (SWT.ERROR_ITEM_NOT_REMOVED);
+ } else {
+ error (SWT.ERROR_INVALID_RANGE);
+ }
+ }
+ TableItem item = items [index];
+ System.arraycopy (items, index + 1, items, index, --count - index);
+ items [count] = null;
+ item.releaseWidget ();
+}
+
+/**
+ * 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>
+ * @exception SWTError <ul>
+ * <li>ERROR_ITEM_NOT_REMOVED - if the operation fails because of an operating system failure</li>
+ * </ul>
+ */
+public void remove (int start, int end) {
+ checkWidget ();
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ int index = end;
+ while (index >= start) {
+ ignoreSelect = true;
+ int code = OS.SendMessage (handle, OS.LVM_DELETEITEM, index, 0);
+ ignoreSelect = false;
+ if (code == 0) break;
+
+ // BUG - disposed callback could remove an item
+ items [index].releaseWidget ();
+ --index;
+ }
+ int first = index + 1, last = end + 1;
+ System.arraycopy (items, last, items, first, count - last);
+ for (int i=count-(last-first); i<count; i++) items [i] = null;
+ if (first > start) error (SWT.ERROR_ITEM_NOT_REMOVED);
+}
+
+/**
+ * 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 count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ ignoreSelect = true;
+ int code = OS.SendMessage (handle, OS.LVM_DELETEALLITEMS, 0, 0);
+ ignoreSelect = false;
+ if (code == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ for (int i=0; i<count; i++) {
+ TableItem item = items [i];
+ if (!item.isDisposed ()) item.releaseWidget ();
+ }
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+ items = new TableItem [4];
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @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 items at the given zero-relative indices in the receiver.
+ * If the item at the given zero-relative index in the receiver
+ * is not selected, it is selected. If the item at the index
+ * was selected, it remains selected. Indices that are out
+ * of range and duplicate indices are ignored.
+ *
+ * @param indices the array of indices for the items to select
+ *
+ * @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>
+ */
+public void select (int [] indices) {
+ checkWidget ();
+ if (indices == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int length = indices.length;
+ if (length == 0) return;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.state = OS.LVIS_SELECTED;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ for (int i=indices.length-1; i>=0; --i) {
+ lvItem.iItem = indices [i];
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = 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 ();
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.state = OS.LVIS_SELECTED;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ lvItem.iItem = index;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * If the item at the index was already selected, it remains
+ * selected. The range of the indices is inclusive. Indices that are
+ * out of range 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>
+ */
+public void select (int start, int end) {
+ checkWidget ();
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.state = OS.LVIS_SELECTED;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ for (int i=start; i<=end; i++) {
+ lvItem.iItem = i;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+ }
+}
+
+/**
+ * Selects all 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 void selectAll () {
+ checkWidget ();
+ if ((style & SWT.SINGLE) != 0) return;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.state = OS.LVIS_SELECTED;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEMSTATE, -1, lvItem);
+ ignoreSelect = false;
+}
+
+LRESULT sendMouseDownEvent (int type, int button, int msg, int wParam, int lParam) {
+ /*
+ * Feature in Windows. Inside WM_LBUTTONDOWN and WM_RBUTTONDOWN,
+ * the widget starts a modal loop to determine if the user wants
+ * to begin a drag/drop operation or marque select. Unfortunately,
+ * this modal loop eats the corresponding mouse up. The fix is to
+ * detect the cases when the modal loop has eaten the mouse up and
+ * issue a fake mouse up.
+ *
+ * By observation, when the mouse is clicked anywhere but the check
+ * box, the widget eats the mouse up. When the mouse is dragged,
+ * the widget does not eat the mouse up.
+ */
+ LVHITTESTINFO pinfo = new LVHITTESTINFO ();
+ pinfo.x = (short) (lParam & 0xFFFF);
+ pinfo.y = (short) (lParam >> 16);
+ OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ sendMouseEvent (type, button, msg, wParam, lParam);
+
+ /*
+ * Force the table to have focus so that when the user
+ * reselects the focus item, the LVIS_FOCUSED state bits
+ * for the item will be set. These bits are used when
+ * the table is multi-select to issue the selection
+ * event. If the user did not click on an item, then
+ * set focus to the table so that it will come to the
+ * front and take focus in the work around below.
+ */
+ OS.SetFocus (handle);
+
+ /*
+ * Feature in Windows. When the user selects outside of
+ * a table item, Windows deselects all the items, even
+ * when the table is multi-select. While not strictly
+ * wrong, this is unexpected. The fix is to detect the
+ * case and avoid calling the window proc.
+ */
+ if (pinfo.iItem == -1) {
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return LRESULT.ZERO;
+ }
+
+ /*
+ * Feature in Windows. In tables that have the style
+ * LVS_SINGLESEL, when a table item is reselected, the
+ * table does not issue a WM_NOTIFY because the item
+ * state has not changed. This is inconsistent with
+ * the list widget and other widgets in Windows. The
+ * fix is to detect the case when an item is reselected
+ * and issue the notification.
+ */
+ int oldState = 0;
+ if ((style & SWT.SINGLE) != 0 && pinfo.iItem != -1) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ lvItem.iItem = pinfo.iItem;
+ OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ oldState = lvItem.state;
+ }
+ dragStarted = false;
+ int code = callWindowProc (msg, wParam, lParam);
+ if ((style & SWT.SINGLE) != 0 && pinfo.iItem != -1) {
+ if ((oldState & OS.LVIS_SELECTED) != 0) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_SELECTED;
+ lvItem.iItem = pinfo.iItem;
+ OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ int newState = lvItem.state;
+ if ((newState & OS.LVIS_SELECTED) != 0) {
+ Event event = new Event ();
+ event.item = items [pinfo.iItem];
+ postEvent (SWT.Selection, event);
+ }
+ }
+ }
+ if (dragStarted) {
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ } else {
+ int flags = OS.LVHT_ONITEMLABEL | OS.LVHT_ONITEMICON;
+ boolean fakeMouseUp = (pinfo.flags & flags) != 0;
+ if (!fakeMouseUp && (style & SWT.MULTI) != 0) {
+ fakeMouseUp = (pinfo.flags & OS.LVHT_ONITEMSTATEICON) == 0;
+ }
+ if (fakeMouseUp) {
+ sendMouseEvent (SWT.MouseUp, button, msg, wParam, lParam);
+ }
+ }
+ dragStarted = false;
+ return new LRESULT (code);
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ background = pixel;
+
+ /*
+ * Feature in Windows. Setting the color to be
+ * the current default is not correct because the
+ * widget will not change colors when the colors
+ * are changed from the control panel. There is
+ * no fix at this time.
+ */
+ if (pixel == -1) pixel = defaultBackground ();
+ OS.SendMessage (handle, OS.LVM_SETBKCOLOR, 0, pixel);
+ OS.SendMessage (handle, OS.LVM_SETTEXTBKCOLOR, 0, pixel);
+ if (imageList != null) {
+ imageList.setBackground (pixel);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
+ }
+ if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+
+ /*
+ * Feature in Windows. When the background color is
+ * changed, the table does not redraw until the next
+ * WM_PAINT. The fix is to force a redraw.
+ */
+ OS.InvalidateRect (handle, null, true);
+}
+
+void setCheckboxImageList () {
+ if ((style & SWT.CHECK) == 0) return;
+ int count = 4;
+ int empty = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 0, 0);
+ int oneItem = OS.SendMessage (handle, OS.LVM_APPROXIMATEVIEWRECT, 1, 0);
+ int height = (oneItem >> 16) - (empty >> 16), width = height;
+ int hImageList = OS.ImageList_Create (width, height, OS.ILC_COLOR, count, count);
+ int hDC = OS.GetDC (handle);
+ int memDC = OS.CreateCompatibleDC (hDC);
+ int hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);
+ int hOldBitmap = OS.SelectObject (memDC, hBitmap);
+ RECT rect = new RECT ();
+ OS.SetRect (rect, 0, 0, width * count, height);
+ int hBrush = OS.CreateSolidBrush (getBackgroundPixel ());
+ OS.FillRect (memDC, rect, hBrush);
+ OS.DeleteObject (hBrush);
+ int oldFont = OS.SelectObject (hDC, defaultFont ());
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ OS.SelectObject (hDC, oldFont);
+ int itemWidth = Math.min (tm.tmHeight, width);
+ int itemHeight = Math.min (tm.tmHeight, height);
+ int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1;
+ OS.SetRect (rect, left, top, left + itemWidth, top + itemHeight);
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_FLAT);
+ rect.left += width; rect.right += width;
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_FLAT);
+ rect.left += width; rect.right += width;
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_INACTIVE | OS.DFCS_FLAT);
+ rect.left += width; rect.right += width;
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_INACTIVE | OS.DFCS_FLAT);
+ OS.SelectObject (memDC, hOldBitmap);
+ OS.DeleteDC (memDC);
+ OS.ReleaseDC (handle, hDC);
+ OS.ImageList_AddMasked (hImageList, hBitmap, 0);
+ OS.DeleteObject (hBitmap);
+ int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_STATE, 0);
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_STATE, hImageList);
+ if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+}
+
+public void setFont (Font font) {
+ checkWidget ();
+ super.setFont (font);
+ setScrollWidth ();
+ int bits = OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ if ((bits & OS.LVS_EX_GRIDLINES) == 0) return;
+ bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.LVS_NOCOLUMNHEADER) != 0) return;
+ setRowHeight ();
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+
+ /*
+ * Feature in Windows. Setting the color to be
+ * the current default is not correct because the
+ * table will not change colors when the colors
+ * are changed from the control panel. There is
+ * no fix at this time.
+ */
+ if (pixel == -1) pixel = defaultForeground ();
+ OS.SendMessage (handle, OS.LVM_SETTEXTCOLOR, 0, pixel);
+
+ /*
+ * Feature in Windows. When the foreground color is
+ * changed, the table does not redraw until the next
+ * WM_PAINT. The fix is to force a redraw.
+ */
+ OS.InvalidateRect (handle, null, true);
+}
+
+/**
+ * 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 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 setHeaderVisible (boolean show) {
+ checkWidget ();
+ int newBits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ newBits &= ~OS.LVS_NOCOLUMNHEADER;
+ if (!show) newBits |= OS.LVS_NOCOLUMNHEADER;
+ /*
+ * Feature in Windows. Setting or clearing LVS_NOCOLUMNHEADER
+ * causes the table to scroll to the beginning. The fix is to
+ * save and restore the top index.
+ */
+ int topIndex = getTopIndex ();
+ OS.SetWindowLong (handle, OS.GWL_STYLE, newBits);
+ if (topIndex != 0) setTopIndex (topIndex);
+ if (show) {
+ int bits = OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ if ((bits & OS.LVS_EX_GRIDLINES) != 0) setRowHeight ();
+ }
+}
+
+/**
+ * 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 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 setLinesVisible (boolean show) {
+ checkWidget ();
+ int newBits = 0;
+ if (show) {
+ newBits = OS.LVS_EX_GRIDLINES;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.LVS_NOCOLUMNHEADER) == 0) setRowHeight ();
+ }
+ OS.SendMessage (handle, OS.LVM_SETEXTENDEDLISTVIEWSTYLE, OS.LVS_EX_GRIDLINES, newBits);
+}
+
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+ if (redraw) {
+ if (--drawCount == 0) {
+ setScrollWidth ();
+ /*
+ * This code is intentionally commented. When many items
+ * are added to a table, it is slightly faster to temporarily
+ * unsubclass the window proc so that messages are dispatched
+ * directly to the table. This is optimization is dangerous
+ * because any operation can occur when redraw is turned off,
+ * even operations where the table must be subclassed in order
+ * to have the correct behavior or work around a Windows bug.
+ * For now, don't attempt it.
+ */
+// subclass ();
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ /*
+ * This code is intentionally commented. The window proc
+ * for the table implements WM_SETREDRAW to invalidate
+ * and erase the table and the header. This is undocumented
+ * behavior. The commented code below shows what is actually
+ * happening and reminds us that we are relying on this
+ * undocumented behavior.
+ */
+// int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+// if (hwndHeader != 0) OS.SendMessage (hwndHeader, OS.WM_SETREDRAW, 1, 0);
+// int flags = OS.RDW_ERASE | OS.RDW_FRAME | OS.RDW_INVALIDATE | OS.RDW_ALLCHILDREN;
+// OS.RedrawWindow (handle, null, 0, flags);
+// if (hwndHeader != 0) OS.RedrawWindow (hwndHeader, null, 0, flags);
+ }
+ } else {
+ if (drawCount++ == 0) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ if (hwndHeader != 0) OS.SendMessage (hwndHeader, OS.WM_SETREDRAW, 0, 0);
+ /*
+ * This code is intentionally commented. When many items
+ * are added to a table, it is slightly faster to temporarily
+ * unsubclass the window proc so that messages are dispatched
+ * directly to the table. This is optimization is dangerous
+ * because any operation can occur when redraw is turned off,
+ * even operations where the table must be subclassed in order
+ * to have the correct behavior or work around a Windows bug.
+ * For now, don't attempt it.
+ */
+// unsubclass ();
+ }
+ }
+}
+
+void setRowHeight () {
+ /*
+ * Bug in Windows. When both a header and grid lines are
+ * displayed, the grid lines do not take into account the
+ * height of the header and draw in the wrong place. The
+ * fix is to set the height of the table items to be the
+ * height of the header so that the lines draw in the right
+ * place. The height of a table item is the maximum of the
+ * height of the font or the height of image list.
+ *
+ * NOTE: In version 5.80 of COMCTL32.DLL, the bug is fixed.
+ */
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) return;
+ int hOldList = OS.SendMessage (handle, OS.LVM_GETIMAGELIST, OS.LVSIL_SMALL, 0);
+ if (hOldList != 0) return;
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ RECT rect = new RECT ();
+ OS.GetWindowRect (hwndHeader, rect);
+ int height = rect.bottom - rect.top - 1;
+ int hImageList = OS.ImageList_Create (1, height, 0, 0, 0);
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, 0);
+ OS.ImageList_Destroy (hImageList);
+}
+
+void setScrollWidth () {
+ if (drawCount != 0) return;
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (count == 1 && columns [0] == null) {
+ OS.SendMessage (handle, OS.LVM_SETCOLUMNWIDTH, 0, OS.LVSCW_AUTOSIZE);
+ }
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selected is first cleared, then the new items are selected.
+ *
+ * @param indices the indices of the items to select
+ *
+ * @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 Table#deselectAll()
+ * @see Table#select(int[])
+ */
+public void setSelection (int [] indices) {
+ deselectAll ();
+ select (indices);
+}
+
+/**
+ * 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 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 Table#deselectAll()
+ * @see Table#select(int)
+ */
+public void setSelection (TableItem [] items) {
+ checkWidget ();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+ deselectAll ();
+ int length = items.length;
+ if (length == 0) return;
+ if ((style & SWT.SINGLE) != 0) length = 1;
+ for (int i=length-1; i>=0; --i) {
+ int index = indexOf (items [i]);
+ if (index != -1) select (index);
+ }
+}
+
+/**
+ * Selects the item at the given zero-relative index in the receiver.
+ * The current selected 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) {
+ deselectAll ();
+ select (index);
+}
+
+/**
+ * Selects the items at the given zero-relative indices in the receiver.
+ * The current selected if first cleared, then the new items are selected.
+ *
+ * @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) {
+ deselectAll ();
+ select (start, end);
+}
+
+/**
+ * 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 ();
+ int topIndex = OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0);
+ if (index == topIndex) return;
+
+ /*
+ * Bug in Windows. For some reason, LVM_SCROLL refuses to
+ * scroll a table vertically when the width and height of
+ * the table is smaller than a certain size. The values
+ * that the author is seeing are width=68 and height=6
+ * but there is no guarantee that these values are absolute.
+ * They may depend on the font and any number of other
+ * factors. In fact, the author has observed that setting
+ * the font to anything but the default seems to sometimes
+ * fix the problem. The fix is to use LVM_GETCOUNTPERPAGE
+ * to detect the case when the number of visible items is
+ * zero and use LVM_ENSUREVISIBLE to scroll the table to
+ * make the index visible.
+ */
+
+ /*
+ * Bug in Windows. When the table header is visible and
+ * there is not enough space to show a single table item,
+ * LVM_GETCOUNTPERPAGE can return a negative number instead
+ * of zero. The fix is to test for negative or zero.
+ */
+ if (OS.SendMessage (handle, OS.LVM_GETCOUNTPERPAGE, 0, 0) <= 0) {
+
+ /*
+ * Bug in Windows. For some reason, LVM_ENSUREVISIBLE can
+ * scroll one item more or one item less when there is not
+ * enough space to show a single table item. The fix is
+ * to detect the case and call LVM_ENSUREVISIBLE again with
+ * the same arguments. It seems that once LVM_ENSUREVISIBLE
+ * has scrolled into the general area, it is able to scroll
+ * to the exact item.
+ */
+ OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 1);
+ if (index != OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0)) {
+ OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 1);
+ }
+ return;
+ }
+
+ /* Use LVM_SCROLL to scroll the table */
+ RECT rect = new RECT ();
+ rect.left = OS.LVIR_BOUNDS;
+ OS.SendMessage (handle, OS.LVM_GETITEMRECT, 0, rect);
+ int dy = (index - topIndex) * (rect.bottom - rect.top);
+ OS.SendMessage (handle, OS.LVM_SCROLL, 0, dy);
+}
+
+/**
+ * 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 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 Table#showSelection()
+ */
+public void showItem (TableItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int index = indexOf (item);
+ if (index != -1) {
+ OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
+ }
+}
+
+/**
+ * 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 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 Table#showItem(TableItem)
+ */
+public void showSelection () {
+ checkWidget ();
+ int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_SELECTED);
+ if (index != -1) OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP | OS.LVS_SHAREIMAGELISTS | OS.WS_CLIPCHILDREN;
+ if ((style & SWT.HIDE_SELECTION) == 0) bits |= OS.LVS_SHOWSELALWAYS;
+ if ((style & SWT.SINGLE) != 0) bits |= OS.LVS_SINGLESEL;
+ /*
+ * This code is intentionally commented. In the future,
+ * the FLAT bit may be used to make the header flat and
+ * unresponsive to mouse clicks.
+ */
+// if ((style & SWT.FLAT) != 0) bits |= OS.LVS_NOSORTHEADER;
+ bits |= OS.LVS_REPORT | OS.LVS_NOCOLUMNHEADER;
+ return bits;
+}
+
+byte [] windowClass () {
+ return TableClass;
+}
+
+int windowProc () {
+ return TableProc;
+}
+
+LRESULT WM_KEYDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.CHECK) != 0 && wParam == OS.VK_SPACE) {
+ int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ if (index != -1) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ lvItem.iItem = index;
+ OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ int state = lvItem.state >> 12;
+ if ((state & 0x1) != 0) {
+ state++;
+ } else {
+ --state;
+ }
+ lvItem.state = state << 12;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ }
+ }
+ return result;
+}
+
+LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the user selects outside of
+ * a table item, Windows deselects all the items, even
+ * when the table is multi-select. While not strictly
+ * wrong, this is unexpected. The fix is to detect the
+ * case and avoid calling the window proc.
+ */
+ LVHITTESTINFO pinfo = new LVHITTESTINFO ();
+ pinfo.x = (short) (lParam & 0xFFFF);
+ pinfo.y = (short) (lParam >> 16);
+ OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 1, OS.WM_LBUTTONDBLCLK, wParam, lParam);
+ if (pinfo.iItem != -1) callWindowProc (OS.WM_LBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+ /*
+ * Feature in Windows. For some reason, capturing
+ * the mouse after processing the mouse event for the
+ * widget interferes with the normal mouse processing
+ * for the widget. The fix is to avoid the automatic
+ * mouse capture.
+ */
+ LRESULT result = sendMouseDownEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+
+ /* Look for check/uncheck */
+ if ((style & SWT.CHECK) != 0) {
+ LVHITTESTINFO pinfo = new LVHITTESTINFO ();
+ pinfo.x = (short) (lParam & 0xFFFF);
+ pinfo.y = (short) (lParam >> 16);
+ /*
+ * Note that when the table has LVS_EX_FULLROWSELECT and the
+ * user clicks anywhere on a row except on the check box, all
+ * of the bits are set. The hit test flags are LVHT_ONITEM.
+ * This means that a bit test for LVHT_ONITEMSTATEICON is not
+ * the correct way to determine that the user has selected
+ * the check box.
+ */
+ int index = OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ if (index != -1 && pinfo.flags == OS.LVHT_ONITEMSTATEICON) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ lvItem.iItem = index;
+ OS.SendMessage (handle, OS.LVM_GETITEM, 0, lvItem);
+ int state = lvItem.state >> 12;
+ if ((state & 0x1) != 0) {
+ state++;
+ } else {
+ --state;
+ }
+ lvItem.state = state << 12;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ }
+ }
+
+ return result;
+}
+
+LRESULT WM_MOUSEHOVER (int wParam, int lParam) {
+ /*
+ * Feature in Windows. Despite the fact that hot
+ * tracking is not enabled, the hot tracking code
+ * in WM_MOUSEHOVER is executed causing the item
+ * under the cursor to be selected. The fix is to
+ * avoid calling the window proc.
+ */
+ LRESULT result = super.WM_MOUSEHOVER (wParam, lParam);
+ int bits = OS.SendMessage (handle, OS.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0);
+ int mask = OS.LVS_EX_ONECLICKACTIVATE | OS.LVS_EX_TRACKSELECT | OS.LVS_EX_TWOCLICKACTIVATE;
+ if ((bits & mask) != 0) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ int hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0);
+ if (hdr.hwndFrom == hwndHeader) {
+ /*
+ * Feature in Windows. On NT, the automatically created
+ * header control is created as a UNICODE window, not an
+ * ANSI window despite the fact that the parent is created
+ * as an ANSI window. This means that it sends UNICODE
+ * notification messages to the parent window on NT for
+ * no good reason. The data and size in the NMHEADER and
+ * HDITEM structs is identical between the platforms so no
+ * different message is actually necessary. Despite this,
+ * Windows sends different messages. The fix is to look
+ * for both messages, despite the platform. This works
+ * because only one will be sent on either platform, never
+ * both.
+ */
+ switch (hdr.code) {
+ case OS.HDN_BEGINTRACKW:
+ case OS.HDN_BEGINTRACK: {
+ NMHEADER phdn = new NMHEADER ();
+ OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);
+ HDITEM pitem = new HDITEM ();
+ OS.MoveMemory (pitem, phdn.pitem, HDITEM.sizeof);
+ TableColumn column = columns [phdn.iItem];
+ if (column != null && !column.getResizable ()) {
+ return LRESULT.ONE;
+ }
+ break;
+ }
+ case OS.HDN_ITEMCHANGEDW:
+ case OS.HDN_ITEMCHANGED: {
+ NMHEADER phdn = new NMHEADER ();
+ OS.MoveMemory (phdn, lParam, NMHEADER.sizeof);
+ Event event = new Event ();
+ if (phdn.pitem != 0) {
+ HDITEM pitem = new HDITEM ();
+ OS.MoveMemory (pitem, phdn.pitem, HDITEM.sizeof);
+ if ((pitem.mask & OS.HDI_WIDTH) != 0) {
+ TableColumn column = columns [phdn.iItem];
+ if (column != null) {
+ column.sendEvent (SWT.Resize, event);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the resize
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ if (isDisposed ()) return LRESULT.ZERO;
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (count == 1 && columns [0] == null) count = 0;
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the column in the move
+ * event. If this happens, process the move event
+ * for those columns that have not been destroyed.
+ */
+ TableColumn [] newColumns = new TableColumn [count];
+ System.arraycopy (columns, 0, newColumns, 0, count);
+ for (int i=phdn.iItem+1; i<count; i++) {
+ if (!newColumns [i].isDisposed ()) {
+ newColumns [i].sendEvent (SWT.Move, event);
+ }
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ return super.WM_NOTIFY (wParam, lParam);
+}
+
+LRESULT WM_RBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the user selects outside of
+ * a table item, Windows deselects all the items, even
+ * when the table is multi-select. While not strictly
+ * wrong, this is unexpected. The fix is to detect the
+ * case and avoid calling the window proc.
+ */
+ LVHITTESTINFO pinfo = new LVHITTESTINFO ();
+ pinfo.x = (short) (lParam & 0xFFFF);
+ pinfo.y = (short) (lParam >> 16);
+ OS.SendMessage (handle, OS.LVM_HITTEST, 0, pinfo);
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_RBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 1, OS.WM_RBUTTONDBLCLK, wParam, lParam);
+ if (pinfo.iItem != -1) callWindowProc (OS.WM_RBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_RBUTTONDOWN (int wParam, int lParam) {
+ /*
+ * Feature in Windows. For some reason, capturing
+ * the mouse after processing the mouse event for the
+ * widget interferes with the normal mouse processing
+ * for the widget. The fix is to avoid the automatic
+ * mouse capture.
+ */
+ return sendMouseDownEvent (SWT.MouseDown, 3, OS.WM_RBUTTONDOWN, wParam, lParam);
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Bug in Windows. For some reason, the table does
+ * not set the default focus rectangle to be the first
+ * item in the table when it gets focus and there is
+ * no selected item. The fix to make the first item
+ * be the focus item.
+ */
+ int count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0);
+ if (count == 0) return result;
+ int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ if (index == -1) {
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.state = OS.LVIS_FOCUSED;
+ lvItem.stateMask = OS.LVIS_FOCUSED;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.LVM_SETITEM, 0, lvItem);
+ ignoreSelect = false;
+ }
+ return result;
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
+ if (result != null) return result;
+ if (imageList != null && background == -1) {
+ imageList.setBackground (defaultBackground ());
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.LVM_SETIMAGELIST, OS.LVSIL_SMALL, hImageList);
+ }
+ if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+ return result;
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ case OS.LVN_MARQUEEBEGIN:
+ return LRESULT.ONE;
+ case OS.LVN_BEGINDRAG:
+ case OS.LVN_BEGINRDRAG:
+ dragStarted = true;
+ if (hdr.code == OS.LVN_BEGINDRAG) {
+ sendEvent (SWT.DragDetect);
+ // widget could be disposed at this point
+ }
+ break;
+ case OS.LVN_COLUMNCLICK: {
+ NMLISTVIEW pnmlv = new NMLISTVIEW ();
+ OS.MoveMemory(pnmlv, lParam, NMLISTVIEW.sizeof);
+ TableColumn column = columns [pnmlv.iSubItem];
+ if (column != null) {
+ column.postEvent (SWT.Selection);
+ }
+ break;
+ }
+ case OS.LVN_ITEMACTIVATE: {
+ NMLISTVIEW pnmlv = new NMLISTVIEW ();
+ OS.MoveMemory(pnmlv, lParam, NMLISTVIEW.sizeof);
+ if (pnmlv.iItem != -1) {
+ Event event = new Event ();
+ event.item = items [pnmlv.iItem];
+ postEvent (SWT.DefaultSelection, event);
+ }
+ break;
+ }
+ case OS.LVN_ITEMCHANGED: {
+ if (!ignoreSelect) {
+ NMLISTVIEW pnmlv = new NMLISTVIEW ();
+ OS.MoveMemory (pnmlv, lParam, NMLISTVIEW.sizeof);
+ if (pnmlv.iItem != -1 && (pnmlv.uChanged & OS.LVIF_STATE) != 0) {
+ int oldBits = pnmlv.uOldState & OS.LVIS_STATEIMAGEMASK;
+ int newBits = pnmlv.uNewState & OS.LVIS_STATEIMAGEMASK;
+ if (oldBits != newBits) {
+ Event event = new Event();
+ event.item = items [pnmlv.iItem];
+ event.detail = SWT.CHECK;
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, pnmlv.iItem, 0);
+ postEvent (SWT.Selection, event);
+ } else {
+ boolean isFocus = (pnmlv.uNewState & OS.LVIS_FOCUSED) != 0;
+ int index = OS.SendMessage (handle, OS.LVM_GETNEXTITEM, -1, OS.LVNI_FOCUSED);
+ if ((style & SWT.MULTI) != 0) {
+ if (!isFocus && index == pnmlv.iItem) {
+ if (OS.GetKeyState (OS.VK_CONTROL) < 0) {
+ boolean isSelected = (pnmlv.uNewState & OS.LVIS_SELECTED) != 0;
+ boolean wasSelected = (pnmlv.uOldState & OS.LVIS_SELECTED) != 0;
+ isFocus = isSelected != wasSelected;
+ }
+ }
+ }
+ if (OS.GetKeyState (OS.VK_SPACE) < 0) isFocus = true;
+ if (isFocus) {
+ Event event = new Event();
+ if (index != -1) {
+ int itemState = OS.SendMessage (handle, OS.LVM_GETITEMSTATE, index, OS.LVIS_SELECTED);
+ if ((itemState & OS.LVIS_SELECTED) != 0) event.item = items [index];
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.LVM_ENSUREVISIBLE, index, 0);
+ }
+ postEvent (SWT.Selection, event);
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+
+LRESULT wmScroll (int msg, int wParam, int lParam) {
+ int code = callWindowProc (msg, wParam, lParam);
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
new file mode 100755
index 0000000000..52bc9a523d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java
@@ -0,0 +1,369 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class represent a column in a table widget.
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>LEFT, RIGHT, CENTER</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd> Move, Resize, Selection</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class TableColumn extends Item {
+ Table parent;
+ boolean resizable;
+
+
+public TableColumn (Table parent, int style) {
+ super (parent, checkStyle (style));
+ resizable = true;
+ this.parent = parent;
+ parent.createItem (this, parent.getColumnCount ());
+}
+
+public TableColumn (Table parent, int style, int index) {
+ super (parent, checkStyle (style));
+ resizable = true;
+ this.parent = parent;
+ parent.createItem (this, 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 sending
+ * it one of the messages defined in the <code>SelectionListener</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 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.LEFT, SWT.CENTER, SWT.RIGHT, 0, 0, 0);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * 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;
+}
+
+public Display getDisplay () {
+ Table parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+String getNameText () {
+ return getText ();
+}
+
+/**
+ * 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.
+ * <p>
+ * @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 resizable;
+}
+
+/**
+ * Gets the width of the receiver.
+ * <p>
+ * @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 ();
+ int index = parent.indexOf (this);
+ if (index == -1) return 0;
+ int hwnd = parent.handle;
+ return OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+}
+
+/**
+ * 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 index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ byte [] buffer = Converter.wcsToMbcs (0, text, true);
+ int headerWidth = OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer);
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE);
+ int columnWidth = OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0);
+ if (headerWidth > columnWidth) {
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, OS.LVSCW_AUTOSIZE_USEHEADER);
+ }
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = 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 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.
+ *
+ * @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 #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>.
+ *
+ * @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);
+ int fmt = 0;
+ if ((style & SWT.LEFT) == SWT.LEFT) fmt = OS.LVCFMT_LEFT;
+ if ((style & SWT.CENTER) == SWT.CENTER) fmt = OS.LVCFMT_CENTER;
+ if ((style & SWT.RIGHT) == SWT.RIGHT) fmt = OS.LVCFMT_RIGHT;
+ int hwnd = parent.handle;
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_FMT;
+ lvColumn.fmt = fmt;
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
+}
+
+/**
+ * Sets the resizable attribute. A column that is
+ * not resizable cannot be dragged by the user but
+ * may be resized by the programmer.
+ * <p>
+ * @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 ();
+ this.resizable = resizable;
+}
+
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setText (string);
+
+ /*
+ * Bug in Windows. For some reason, when the title
+ * of a column is changed after the column has been
+ * created, the alignment must also be reset or the
+ * text does not draw. The fix is to query and then
+ * set the alignment.
+ */
+ int hwnd = parent.handle;
+ LVCOLUMN lvColumn = new LVCOLUMN ();
+ lvColumn.mask = OS.LVCF_FMT;
+ OS.SendMessage (hwnd, OS.LVM_GETCOLUMN, index, lvColumn);
+
+ /* Set the column title */
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ lvColumn.mask |= OS.LVCF_TEXT;
+ lvColumn.pszText = pszText;
+ int result = OS.SendMessage (hwnd, OS.LVM_SETCOLUMN, index, lvColumn);
+ if (pszText != 0) OS.HeapFree (hHeap, 0, pszText);
+ if (result == 0) error (SWT.ERROR_CANNOT_SET_TEXT);
+}
+
+/**
+ * Sets the width of the receiver.
+ * <p>
+ * @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 ();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ OS.SendMessage (hwnd, OS.LVM_SETCOLUMNWIDTH, index, width);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
new file mode 100755
index 0000000000..40f40908a6
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableItem.java
@@ -0,0 +1,527 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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>
+ */
+
+public class TableItem extends Item {
+ Table parent;
+
+public TableItem (Table parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+public TableItem (Table parent, int style, int index) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+/**
+ * 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();
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
+ int hwnd = parent.handle;
+ int hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (!(0 <= index && index < count)) return new Rectangle (0, 0, 0, 0);
+ int gridWidth = 0;
+ if (parent.getLinesVisible ()) gridWidth = parent.getGridLineWidth ();
+ RECT rect = new RECT ();
+ rect.top = index;
+ rect.left = OS.LVIR_LABEL;
+ OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, itemIndex, rect);
+ if (index == 0) {
+ RECT iconRect = new RECT ();
+ iconRect.left = OS.LVIR_ICON;
+ OS.SendMessage (hwnd, OS.LVM_GETSUBITEMRECT, itemIndex, iconRect);
+ rect.left = iconRect.left - gridWidth;
+ }
+ int width = rect.right - rect.left - gridWidth;
+ int height = rect.bottom - rect.top - gridWidth;
+ /*
+ * Bug in Windows. In version 5.80 of COMCTL32.DLL, the top
+ * of the rectangle returned by LVM_GETSUBITEMRECT is off by
+ * one pixel. The fix is to move the top of the rectangle up
+ * by one pixel.
+ */
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
+ --rect.top;
+ }
+ return new Rectangle (rect.left + gridWidth, rect.top + gridWidth, width, height);
+}
+
+/**
+ * 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.style & SWT.CHECK) == 0) return false;
+ int index = parent.indexOf (this);
+ if (index == -1) return false;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ lvItem.iItem = index;
+ int result = OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem);
+ return (result != 0) && (((lvItem.state >> 12) & 1) == 0);
+}
+
+public Display getDisplay () {
+ Table parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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.style & SWT.CHECK) == 0) return false;
+ int index = parent.indexOf (this);
+ if (index == -1) return false;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ lvItem.iItem = index;
+ int result = OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem);
+ return (result != 0) && ((lvItem.state >> 12) > 2);
+}
+
+public Image getImage (int index) {
+ checkWidget();
+ if (index == 0) return super.getImage ();
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return null;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_IMAGE;
+ lvItem.iItem = itemIndex;
+ lvItem.iSubItem = index;
+ if (OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem) == 0) return null;
+ if (lvItem.iImage >= 0) return parent.imageList.get (lvItem.iImage);
+ return null;
+}
+
+/**
+ * Returns a rectangle describing the size and location
+ * relative to its parent of an image at a column in the
+ * table.
+ *
+ * @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();
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return new Rectangle (0, 0, 0, 0);
+ int hwnd = parent.handle;
+ int hwndHeader = OS.SendMessage (hwnd, OS.LVM_GETHEADER, 0, 0);
+ int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
+ if (!(0 <= index && index < count)) return new Rectangle (0, 0, 0, 0);
+ int gridWidth = 0;
+ if (parent.getLinesVisible ()) gridWidth = parent.getGridLineWidth ();
+ RECT rect = new RECT ();
+ rect.top = index;
+ rect.left = OS.LVIR_ICON;
+ OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, itemIndex, rect);
+ if (index == 0) {
+ RECT iconRect = new RECT ();
+ iconRect.left = OS.LVIR_ICON;
+ OS.SendMessage (hwnd, OS.LVM_GETSUBITEMRECT, itemIndex, iconRect);
+ rect.left = iconRect.left - gridWidth;
+ }
+ int width = rect.right - rect.left - gridWidth;
+ int height = rect.bottom - rect.top - gridWidth;
+ if (gridWidth == 0) --height;
+ /*
+ * Bug in Windows. In version 5.80 of COMCTL32.DLL, the top
+ * of the rectangle returned by LVM_GETSUBITEMRECT is off by
+ * one pixel. The fix is to move the top of the rectangle up
+ * by one pixel.
+ */
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) >= (5 << 16 | 80)) {
+ --rect.top;
+ }
+ return new Rectangle (rect.left + gridWidth, rect.top + gridWidth, width, height);
+}
+
+/**
+ * Gets the image indent.
+ * <p>
+ * @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();
+ int index = parent.indexOf (this);
+ if (index == -1) return 0;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_INDENT;
+ lvItem.iItem = index;
+ OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem);
+ return lvItem.iIndent;
+}
+
+/**
+ * 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 (int index) {
+ checkWidget();
+ if (index == 0) return super.getText ();
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) error (SWT.ERROR_CANNOT_GET_TEXT);
+ int cchTextMax = 1024;
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, cchTextMax);
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_TEXT;
+ lvItem.iItem = itemIndex;
+ lvItem.iSubItem = index;
+ lvItem.pszText = pszText;
+ lvItem.cchTextMax = cchTextMax;
+ int result = OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem);
+ byte [] buffer1 = new byte [cchTextMax];
+ OS.MoveMemory (buffer1, pszText, cchTextMax);
+ OS.HeapFree (hHeap, 0, pszText);
+ if (result == 0) error (SWT.ERROR_CANNOT_GET_TEXT);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ int length = 0;
+ while (length < buffer2.length && buffer2 [length] != 0) length++;
+ return new String (buffer2, 0, length);
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+
+/**
+ * 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;
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ lvItem.iItem = index;
+ OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem);
+ int state = lvItem.state >> 12;
+ if (checked) {
+ if ((state & 0x1) != 0) state++;
+ } else {
+ if ((state & 0x1) == 0) --state;
+ }
+ lvItem.state = state << 12;
+ parent.ignoreSelect = true;
+ OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
+ parent.ignoreSelect = false;
+}
+
+/**
+ * Sets the grayed state of the receiver.
+ * <p>
+ *
+ * @param checked 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>
+ */
+public void setGrayed (boolean grayed) {
+ checkWidget();
+ if ((parent.style & SWT.CHECK) == 0) return;
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_STATE;
+ lvItem.stateMask = OS.LVIS_STATEIMAGEMASK;
+ lvItem.iItem = index;
+ OS.SendMessage (hwnd, OS.LVM_GETITEM, 0, lvItem);
+ int state = lvItem.state >> 12;
+ if (grayed) {
+ if (state <= 2) state +=2;
+ } else {
+ if (state > 2) state -=2;
+ }
+ lvItem.state = state << 12;
+ parent.ignoreSelect = true;
+ OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
+ parent.ignoreSelect = false;
+}
+
+/**
+ * Sets the image for multiple columns in the Table.
+ *
+ * @param strings the array of new images
+ *
+ * @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 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 receiver's image at a column.
+ *
+ * @param index the column index
+ * @param string the new image
+ *
+ * @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 setImage (int index, Image image) {
+ checkWidget();
+ if (index == 0) {
+ setImage (image);
+ return;
+ }
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_IMAGE;
+ lvItem.iItem = itemIndex;
+ lvItem.iSubItem = index;
+ lvItem.iImage = parent.imageIndex (image);
+ OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setImage (image);
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_IMAGE;
+ lvItem.iItem = index;
+ lvItem.iImage = parent.imageIndex (image);
+ if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
+ parent.setScrollWidth ();
+ }
+}
+
+/**
+ * Sets the image indent.
+ * <p>
+ * @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>
+ */
+public void setImageIndent (int indent) {
+ checkWidget();
+ if (indent < 0) return;
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_INDENT;
+ lvItem.iItem = index;
+ lvItem.iIndent = indent;
+ OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
+}
+
+/**
+ * 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);
+ }
+}
+
+/**
+ * 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 (index == 0) {
+ setText (string);
+ return;
+ }
+ int itemIndex = parent.indexOf (this);
+ if (itemIndex == -1) return;
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length);
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_TEXT;
+ lvItem.iItem = itemIndex;
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ lvItem.pszText = pszText;
+ lvItem.iSubItem = index;
+ OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem);
+ OS.HeapFree (hHeap, 0, pszText);
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ int index = parent.indexOf (this);
+ if (index == -1) return;
+ super.setText (string);
+ int hwnd = parent.handle;
+ LVITEM lvItem = new LVITEM ();
+ lvItem.mask = OS.LVIF_TEXT;
+ lvItem.iItem = index;
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ lvItem.pszText = pszText;
+ if (OS.SendMessage (hwnd, OS.LVM_SETITEM, 0, lvItem) != 0) {
+ parent.setScrollWidth ();
+ }
+ OS.HeapFree (hHeap, 0, pszText);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
new file mode 100755
index 0000000000..e84bc03bf9
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java
@@ -0,0 +1,1652 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>MULTI, SINGLE, READ_ONLY, WRAP</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>DefaultSelection, Modify, Verify</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ */
+
+public class Text extends Scrollable {
+ int tabs, oldStart, oldEnd;
+ boolean doubleClick, ignoreVerify, ignoreCharacter;
+
+ public static final int LIMIT;
+ public static final 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 = IsWinNT ? 0x7FFFFFFF : 0x7FFF;
+ DELIMITER = "\r\n";
+ }
+
+ static final int EditProc;
+ static final byte [] EditClass = Converter.wcsToMbcs (0, "EDIT\0", false);
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, EditClass, lpWndClass);
+ EditProc = lpWndClass.lpfnWndProc;
+ }
+
+public Text (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (EditProc, handle, msg, wParam, lParam);
+}
+
+void createHandle () {
+ super.createHandle ();
+ OS.SendMessage (handle, OS.EM_LIMITTEXT, 0, 0);
+}
+
+/**
+ * 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 sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+/**
+ * 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.
+ *
+ * @param string the string to be appended
+ *
+ * @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>
+ */
+public void append (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ string = Display.withCrLf (string);
+ int length = OS.GetWindowTextLength (handle);
+ if (hooks (SWT.Verify)) {
+ string = verifyText (string, length, length);
+ if (string == null) return;
+ }
+ OS.SendMessage (handle, OS.EM_SETSEL, length, length);
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
+}
+
+static int checkStyle (int style) {
+ if ((style & SWT.SINGLE) != 0) style &= ~(SWT.H_SCROLL | SWT.V_SCROLL);
+ 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;
+}
+
+/**
+ * Clears the selection.
+ * <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 clearSelection () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.EM_SETSEL, -1, 0);
+}
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ int count = OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ int height = count * tm.tmHeight, width = 0;
+ RECT rect = new RECT ();
+ int flags = OS.DT_CALCRECT | OS.DT_EDITCONTROL | OS.DT_NOPREFIX;
+ if ((style & SWT.WRAP) != 0 && wHint != SWT.DEFAULT) {
+ flags |= OS.DT_WORDBREAK;
+ rect.right = wHint;
+ }
+ String text = getText ();
+ byte [] buffer = Converter.wcsToMbcs (0, text, false);
+ OS.DrawText (hDC, buffer, buffer.length, rect, flags);
+ width = rect.right - rect.left;
+ if ((style & SWT.WRAP) != 0 && hHint == SWT.DEFAULT) {
+ int newHeight = rect.bottom - rect.top;
+ if (newHeight != 0) height = newHeight;
+ }
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ if (width == 0) width = DEFAULT_WIDTH;
+ if (height == 0) height = DEFAULT_HEIGHT;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+
+ /*
+ * Bug in Windows. For some reason, despite the fact
+ * that there is a 1-pixel margin height on a simple
+ * text widget with a border, EM_GETRECT returns 0.
+ * The fix is to detect this case and make the margin
+ * height 1.
+ */
+ RECT editRect = new RECT ();
+ OS.SendMessage (handle, OS.EM_GETRECT, 0, rect);
+ if ((style & SWT.BORDER) != 0 && editRect.top == 0) {
+ editRect.top = 1;
+ }
+
+ /*
+ * The preferred size of a single-line text widget
+ * has been hand-crafted to be the same height as
+ * the single-line text widget in an editable combo
+ * box.
+ */
+ width += editRect.left * 2;
+ height += editRect.top * 2;
+ if ((style & SWT.V_SCROLL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ if ((style & SWT.BORDER) == 0) width++;
+ }
+ if ((style & SWT.BORDER) != 0) {
+ int border = getBorderWidth ();
+ width += (border * 2) + 3;
+ height += (border * 2) + 1;
+ }
+ return new Point (width, height);
+}
+
+/**
+ * Copies the selected text.
+ * <p>
+ * The current selection is copied to 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>
+ */
+public void copy () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_COPY, 0, 0);
+}
+
+ScrollBar createScrollBar (int type) {
+ return new ScrollBar (this, type);
+}
+
+void createWidget () {
+ super.createWidget ();
+ doubleClick = true;
+ setTabStops (tabs = 8);
+}
+
+/**
+ * Cuts the selected text.
+ * <p>
+ * The current selection is first copied to the
+ * clipboard and then deleted from the widget.
+ *
+ * @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>
+ */
+public void cut () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_CUT, 0, 0);
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_WINDOW);
+}
+
+/**
+ * Gets the line number of the caret.
+ * <p>
+ * The line number of the caret is returned.
+ *
+ * @return the line number
+ *
+ * @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>
+ */
+public int getCaretLineNumber () {
+ checkWidget ();
+ return OS.SendMessage (handle, OS.EM_LINEFROMCHAR, -1, 0);
+}
+
+/**
+ * Gets the location the caret.
+ * <p>
+ * The location of the caret is returned.
+ *
+ * @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 ();
+
+ /*
+ * Bug in Windows. For some reason, Windows is unable
+ * to return the pixel coordinates of the last character
+ * in the widget. The fix is to temporarily insert a
+ * space, query the coordinates and delete the space.
+ * The selection is always an i-beam in this case because
+ * this is the only time the start of the selection can
+ * be equal to the last character position in the widget.
+ * If EM_POSFROMCHAR fails for any other reason, return
+ * pixel coordinates (0,0).
+ */
+ int [] start = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, (int []) null);
+ int pos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, start [0], 0);
+ if (pos == -1) {
+ pos = 0;
+ if (start [0] >= OS.GetWindowTextLength (handle)) {
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new byte [] {(byte)' ', 0});
+ pos = OS.SendMessage (handle, OS.EM_POSFROMCHAR, start [0], 0);
+ OS.SendMessage (handle, OS.EM_SETSEL, start [0], start [0] + 1);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, new byte [] {0});
+ }
+ }
+ return new Point ((short) (pos & 0xFFFF), (short) (pos >> 16));
+}
+
+/**
+ * Gets the position of the caret.
+ * <p>
+ * The character position of the caret is returned.
+ *
+ * @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 ();
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ int startLine = OS.SendMessage (handle, OS.EM_LINEFROMCHAR, start [0], 0);
+ int caretPos = OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
+ int caretLine = OS.SendMessage (handle, OS.EM_LINEFROMCHAR, caretPos, 0);
+ int caret = end [0];
+ if (caretLine == startLine) caret = start [0];
+ if (IsDBLocale) caret = mbcsToWcsPos (caret);
+ return caret;
+}
+
+/**
+ * Gets the number of characters.
+ * <p>
+ * @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 ();
+ int length = OS.GetWindowTextLength (handle);
+ if (IsDBLocale) length = mbcsToWcsPos (length);
+ return length;
+}
+
+char [] getClipboardData () {
+ char [] lpWideCharStr = null;
+ if (OS.OpenClipboard (0)) {
+ int hMem = OS.GetClipboardData (OS.CF_TEXT);
+ if (hMem != 0) {
+ int ptr = OS.GlobalLock (hMem);
+ if (ptr != 0) {
+ int cchWideChar = OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, ptr, -1, null, 0);
+ lpWideCharStr = new char [--cchWideChar];
+ OS.MultiByteToWideChar (OS.CP_ACP, OS.MB_PRECOMPOSED, ptr, -1, lpWideCharStr, cchWideChar);
+ }
+ }
+ OS.CloseClipboard ();
+ }
+ return lpWideCharStr;
+}
+
+String getClipboardText () {
+ char [] data = getClipboardData ();
+ if (data == null) return null;
+ return new String (data);
+}
+
+/**
+ * Gets 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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;
+}
+
+/**
+ * Gets 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.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ */
+public char getEchoChar () {
+ checkWidget ();
+ char echo = (char) OS.SendMessage (handle, OS.EM_GETPASSWORDCHAR, 0, 0);
+ if (echo != 0 && (echo = mbcsToWcs (echo)) == 0) echo = '*';
+ return echo;
+}
+
+/**
+ * Gets the editable state.
+ * <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 boolean getEditable () {
+ checkWidget ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ return (bits & OS.ES_READONLY) == 0;
+}
+
+/**
+ * Gets the number of lines.
+ * <p>
+ * @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 OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+}
+
+/**
+ * Gets the line delimiter.
+ * <p>
+ * @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>
+ */
+public String getLineDelimiter () {
+ checkWidget ();
+ return DELIMITER;
+}
+
+/**
+ * Gets the height of a line.
+ * <p>
+ * @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 ();
+ int newFont, oldFont = 0;
+ int hDC = OS.GetDC (handle);
+ newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ return tm.tmHeight;
+}
+
+/**
+ * Gets the position of the selected text.
+ * <p>
+ * Indexing is zero based. The range of
+ * a selection is from 0..N where N is
+ * the number of characters in the widget.
+ *
+ * @return the start and end of 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 Point getSelection () {
+ checkWidget ();
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ if (IsDBLocale) {
+ start [0] = mbcsToWcsPos (start [0]);
+ end [0] = mbcsToWcsPos (end [0]);
+ }
+ return new Point (start [0], end [0]);
+}
+
+/**
+ * Gets the number of selected characters.
+ * <p>
+ * @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 selection.y - selection.x;
+}
+
+/**
+ * Gets the selected text.
+ * <p>
+ *
+ * @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 ();
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ Point selection = getSelection ();
+ return getText ().substring (selection.x, selection.y);
+}
+
+/**
+ * Gets 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.
+ *
+ * @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) {
+ int oldFont = 0;
+ RECT rect = new RECT ();
+ int hDC = OS.GetDC (handle);
+ int newFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0);
+ if (newFont != 0) oldFont = OS.SelectObject (hDC, newFont);
+ int flags = OS.DT_CALCRECT | OS.DT_SINGLELINE | OS.DT_NOPREFIX;
+ OS.DrawText (hDC, new byte [] {(byte) ' '}, 1, rect, flags);
+ if (newFont != 0) OS.SelectObject (hDC, oldFont);
+ OS.ReleaseDC (handle, hDC);
+ return (rect.right - rect.left) * tabs;
+}
+
+/**
+ * Gets the widget text.
+ * <p>
+ * The text for a text widget is the characters in the widget.
+ *
+ * @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 length = OS.GetWindowTextLength (handle);
+ if (length == 0) return "";
+ byte [] buffer1 = new byte [length + 1];
+ OS.GetWindowText (handle, buffer1, buffer1.length);
+ char [] buffer2 = Converter.mbcsToWcs (0, buffer1);
+ return new String (buffer2, 0, buffer2.length - 1);
+}
+
+/**
+ * Gets a range of text.
+ * <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.
+ *
+ * @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 ();
+
+ /*
+ * NOTE: The current implementation uses substring ()
+ * which can reference a potentially large character
+ * array.
+ */
+ return getText ().substring (start, end + 1);
+}
+
+/**
+ * Returns the maximum number of characters that the receiver
+ * is capable of holding. If this has not been changed
+ * by <code>setTextLimit()</code>, it will be the constant
+ * <code>Text.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 OS.SendMessage (handle, OS.EM_GETLIMITTEXT, 0, 0);
+}
+
+/**
+ * Returns 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 or removed.
+ *
+ * @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 ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_MULTILINE) == 0) return 0;
+ return OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
+}
+
+/**
+ * Gets 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>
+ * The top pixel changes when the widget is scrolled.
+ * The top pixel does not include the widget trimming.
+ *
+ * @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 ();
+
+ /*
+ * Note, EM_GETSCROLLPOS is implemented in Rich Edit 3.0
+ * and greater. The plain text widget and previous versions
+ * of Rich Edit return zero.
+ */
+ int [] buffer = new int [2];
+ int code = OS.SendMessage (handle, OS.EM_GETSCROLLPOS, 0, buffer);
+ if (code == 1) return buffer [1];
+ return getTopIndex () * getLineHeight ();
+}
+
+/*
+* Currently not used.
+*/
+boolean getWrap () {
+ checkWidget ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_MULTILINE) == 0) return false;
+ return (bits & (OS.WS_HSCROLL | OS.ES_AUTOHSCROLL)) == 0;
+}
+
+/**
+ * Inserts a string.
+ * <p>
+ * The old selection is replaced with the new text.
+ *
+ * @param string the 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>
+ */
+public void insert (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ string = Display.withCrLf (string);
+ if (hooks (SWT.Verify)) {
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ string = verifyText (string, start [0], end [0]);
+ if (string == null) return;
+ }
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+}
+
+int mbcsToWcsPos (int mbcsPos) {
+ if (mbcsPos == 0) return 0;
+ int cp = OS.GetACP ();
+ int wcsTotal = 0, mbcsTotal = 0;
+ byte [] buffer = new byte [128];
+ String delimiter = getLineDelimiter();
+ int delimiterSize = delimiter.length ();
+ int count = OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ for (int line=0; line<count; line++) {
+ int wcsSize = 0;
+ int linePos = OS.SendMessage (handle, OS.EM_LINEINDEX, line, 0);
+ int mbcsSize = OS.SendMessage (handle, OS.EM_LINELENGTH, linePos, 0);
+ if (mbcsSize != 0) {
+ if (mbcsSize > buffer.length) buffer = new byte [mbcsSize + delimiterSize];
+ buffer [0] = (byte) (mbcsSize & 0xFF);
+ buffer [1] = (byte) (mbcsSize >> 8);
+ mbcsSize = OS.SendMessage (handle, OS.EM_GETLINE, line, buffer);
+ wcsSize = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, mbcsSize, null, 0);
+ }
+ if (line - 1 != count) {
+ for (int i=0; i<delimiterSize; i++) {
+ buffer [mbcsSize++] = (byte) delimiter.charAt (i);
+ }
+ wcsSize += delimiterSize;
+ }
+ if ((mbcsTotal + mbcsSize) >= mbcsPos) {
+ int bufferSize = mbcsPos - mbcsTotal;
+ wcsSize = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, bufferSize, null, 0);
+ return wcsTotal + wcsSize;
+ }
+ wcsTotal += wcsSize;
+ mbcsTotal += mbcsSize;
+ }
+ return wcsTotal;
+}
+
+/**
+ * Pastes text from clipboard.
+ * <p>
+ * The selected text is deleted from the widget
+ * and new text inserted from 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>
+ */
+public void paste () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.WM_PASTE, 0, 0);
+}
+
+/**
+ * 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.
+ *
+ * @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 #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
+ */
+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 ();
+ OS.SendMessage (handle, OS.EM_SETSEL, 0, -1);
+}
+
+boolean sendKeyEvent (int type, int msg, int wParam, int lParam, Event event) {
+ if (!super.sendKeyEvent (type, msg, wParam, lParam, event)) {
+ return false;
+ }
+ if (ignoreVerify) return true;
+ if (type != SWT.KeyDown) return true;
+ if (msg != OS.WM_CHAR && msg != OS.WM_KEYDOWN && msg != OS.WM_IME_CHAR) {
+ return true;
+ }
+ if (event.character == 0) return true;
+ if (!hooks (SWT.Verify)) return true;
+ char key = event.character;
+ int stateMask = event.stateMask;
+
+ /* Disable all magic keys that could modify the text */
+ switch (msg) {
+ case OS.WM_CHAR:
+ if (key != 0x08 && key != 0x7F && key != '\r' && key != '\t' && key != '\n') break;
+ // FALL THROUGH
+ case OS.WM_KEYDOWN:
+ if ((stateMask & (SWT.CTRL | SWT.SHIFT | SWT.ALT)) != 0) return false;
+ break;
+ }
+
+ /*
+ * If the left button is down, the text widget
+ * refuses the character.
+ */
+ if (OS.GetKeyState (OS.VK_LBUTTON) < 0) {
+ return true;
+ }
+
+ /* Verify the character */
+ String oldText = "";
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ switch (key) {
+ case 0x08: /* Bs */
+ if (start [0] == end [0]) {
+ if (start [0] == 0) return true;
+ int lineStart = OS.SendMessage (handle, OS.EM_LINEINDEX, -1, 0);
+ if (start [0] == lineStart) {
+ start [0] = start [0] - DELIMITER.length ();
+ } else {
+ start [0] = start [0] - 1;
+ if (IsDBLocale) {
+ int [] newStart = new int [1], newEnd = new int [1];
+ OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
+ OS.SendMessage (handle, OS.EM_GETSEL, newStart, newEnd);
+ if (start [0] != newStart [0]) start [0] = start [0] - 1;
+ }
+ }
+ start [0] = Math.max (start [0], 0);
+ }
+ break;
+ case 0x7F: /* Del */
+ if (start [0] == end [0]) {
+ int length = OS.GetWindowTextLength (handle);
+ if (start [0] == length) return true;
+ int line = OS.SendMessage (handle, OS.EM_LINEFROMCHAR, end [0], 0);
+ int lineStart = OS.SendMessage (handle, OS.EM_LINEINDEX, line + 1, 0);
+ if (end [0] == lineStart - DELIMITER.length ()) {
+ end [0] = end [0] + DELIMITER.length ();
+ } else {
+ end [0] = end [0] + 1;
+ if (IsDBLocale) {
+ int [] newStart = new int [1], newEnd = new int [1];
+ OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
+ OS.SendMessage (handle, OS.EM_GETSEL, newStart, newEnd);
+ if (end [0] != newEnd [0]) end [0] = end [0] + 1;
+ }
+ }
+ end [0] = Math.min (end [0], length);
+ }
+ break;
+ case '\r': /* Return */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_MULTILINE) == 0) return true;
+ oldText = DELIMITER;
+ break;
+ default: /* Tab and other characters */
+ if (key != '\t' && key < 0x20) return true;
+ oldText = new String (new char [] {key});
+ break;
+ }
+ String newText = verifyText (oldText, start [0], end [0], event);
+ if (newText == null) return false;
+ if (newText == oldText) return true;
+ newText = Display.withCrLf (newText);
+ byte [] buffer = Converter.wcsToMbcs (0, newText, true);
+ OS.SendMessage (handle, OS.EM_SETSEL, start [0], end [0]);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ return false;
+}
+
+/**
+ * Sets the double click enabled flag.
+ * <p>
+ * @param doubleClick the new double click flag
+ *
+ * The double click flag enables or disables the
+ * default action of the text widget when the user
+ * double 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 doubleClick) {
+ checkWidget ();
+ this.doubleClick = doubleClick;
+}
+
+/**
+ * Sets the echo character.
+ * <p>
+ * @param echo the new echo character
+ *
+ * The echo character is the character that is
+ * displayed when the user enters text or the
+ * text is changed by the programmer.
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the 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 (echo != 0 && (echo = wcsToMbcs (echo)) == 0) echo = '*';
+ OS.SendMessage (handle, OS.EM_SETPASSWORDCHAR, echo, 0);
+ /*
+ * Bug in Windows. When the password character is changed,
+ * Windows does not redraw to show the new password character.
+ * The fix is to force a redraw when the character is set.
+ */
+ OS.InvalidateRect (handle, null, true);
+}
+
+/**
+ * Sets the editable state.
+ * <p>
+ * @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;
+ OS.SendMessage (handle, OS.EM_SETREADONLY, editable ? 0 : 1, 0);
+}
+
+public void setFont (Font font) {
+ checkWidget ();
+ super.setFont (font);
+ setTabStops (tabs);
+}
+
+/**
+ * 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.
+ *
+ * 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.
+ *
+ * @param start new caret position
+ *
+ * @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 setSelection (int start) {
+ checkWidget ();
+ if (IsDBLocale) start = wcsToMbcsPos (start);
+ OS.SendMessage (handle, OS.EM_SETSEL, start, start);
+}
+
+/**
+ * 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.
+ *
+ * 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.
+ *
+ * @param start the start of the range
+ * @param end the end of the range
+ *
+ * @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 setSelection (int start, int end) {
+ checkWidget ();
+ if (IsDBLocale) {
+ start = wcsToMbcsPos (start);
+ end = wcsToMbcsPos (end);
+ }
+ OS.SendMessage (handle, OS.EM_SETSEL, start, end);
+}
+
+public void setRedraw (boolean redraw) {
+ checkWidget ();
+ super.setRedraw (redraw);
+ /*
+ * Feature in Windows. When WM_SETREDRAW is used to turn
+ * redraw off, the text control is not scrolled to show the
+ * i-beam. The fix is to detect that the i-beam has moved
+ * while redraw is turned off and force it to be visible
+ * when redraw is restored.
+ */
+ if (drawCount != 0) return;
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ if (!redraw) {
+ oldStart = start [0]; oldEnd = end [0];
+ return;
+ }
+ if (oldStart == start [0] && oldEnd == end [0]) return;
+ OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
+}
+
+/**
+ * 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.
+ *
+ * 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.
+ *
+ * @param selection the point
+ *
+ * @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 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.
+ *
+ * @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) {
+ /*
+ * Feature in Windows. Windows expects the tab spacing in
+ * dialog units so we must convert from space widths. Due
+ * to round off error, the tab spacing may not be the exact
+ * number of space widths, depending on the font.
+ */
+ int width = (getTabWidth (tabs) * 4) / (OS.GetDialogBaseUnits () & 0xFFFF);
+ OS.SendMessage (handle, OS.EM_SETTABSTOPS, 1, new short [] {(short) width});
+}
+
+/**
+ * Sets the contents of the receiver to the given string.
+ *
+ * @param text 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);
+ string = Display.withCrLf (string);
+ if (hooks (SWT.Verify)) {
+ int length = OS.GetWindowTextLength (handle);
+ string = verifyText (string, 0, length);
+ if (string == null) return;
+ }
+ byte [] buffer = Converter.wcsToMbcs (0, string, true);
+ OS.SetWindowText (handle, buffer);
+ /*
+ * Bug in Windows. When the widget is multi line
+ * text widget, it does not send a WM_COMMAND with
+ * control code EN_CHANGE from SetWindowText () to
+ * notify the application that the text has changed.
+ * The fix is to send the event.
+ */
+ if ((style & SWT.MULTI) != 0) {
+ sendEvent (SWT.Modify);
+ // widget could be disposed at this point
+ }
+}
+
+/**
+ * Sets the maximum number of characters that the receiver
+ * 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 ();
+ if (limit == 0) error (SWT.ERROR_CANNOT_BE_ZERO);
+ OS.SendMessage (handle, OS.EM_SETLIMITTEXT, limit, 0);
+}
+
+/**
+ * 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 ();
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_MULTILINE) == 0) return;
+ int count = OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ index = Math.min (Math.max (index, 0), count - 1);
+ int topIndex = OS.SendMessage (handle, OS.EM_GETFIRSTVISIBLELINE, 0, 0);
+ OS.SendMessage (handle, OS.EM_LINESCROLL, 0, index - topIndex);
+}
+
+/*
+* Not currently used.
+*/
+void setWrap (boolean wrap) {
+ if (wrap == getWrap ()) return;
+ style &= ~SWT.WRAP;
+ if (wrap) style |= SWT.WRAP;
+}
+
+/**
+ * Shows the selection. If the selection is already showing
+ * in the receiver, this method simply returns. Otherwise,
+ * lines are scrolled until the selection is visible.
+ *
+ * @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>
+ */
+public void showSelection () {
+ checkWidget ();
+ OS.SendMessage (handle, OS.EM_SCROLLCARET, 0, 0);
+}
+
+String verifyText (String string, int start, int end) {
+ return verifyText (string, start, end, null);
+}
+
+String verifyText (String string, int start, int end, Event keyEvent) {
+ if (ignoreVerify) return string;
+ Event event = new Event ();
+ event.text = string;
+ event.start = start;
+ event.end = end;
+ if (keyEvent != null) {
+ event.character = keyEvent.character;
+ event.keyCode = keyEvent.keyCode;
+ event.stateMask = keyEvent.stateMask;
+ }
+ if (IsDBLocale) {
+ event.start = mbcsToWcsPos (start);
+ event.end = mbcsToWcsPos (end);
+ }
+ /*
+ * 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;
+}
+
+int wcsToMbcsPos (int wcsPos) {
+ if (wcsPos == 0) return 0;
+ int cp = OS.GetACP ();
+ int wcsTotal = 0, mbcsTotal = 0;
+ byte [] buffer = new byte [128];
+ String delimiter = getLineDelimiter ();
+ int delimiterSize = delimiter.length ();
+ int count = OS.SendMessage (handle, OS.EM_GETLINECOUNT, 0, 0);
+ for (int line=0; line<count; line++) {
+ int wcsSize = 0;
+ int linePos = OS.SendMessage (handle, OS.EM_LINEINDEX, line, 0);
+ int mbcsSize = OS.SendMessage (handle, OS.EM_LINELENGTH, linePos, 0);
+ if (mbcsSize != 0) {
+ if (mbcsSize > buffer.length) buffer = new byte [mbcsSize + delimiterSize];
+ buffer [0] = (byte) (mbcsSize & 0xFF);
+ buffer [1] = (byte) (mbcsSize >> 8);
+ mbcsSize = OS.SendMessage (handle, OS.EM_GETLINE, line, buffer);
+ wcsSize = OS.MultiByteToWideChar (cp, OS.MB_PRECOMPOSED, buffer, mbcsSize, null, 0);
+ }
+ if (line - 1 != count) {
+ for (int i=0; i<delimiterSize; i++) {
+ buffer [mbcsSize++] = (byte) delimiter.charAt (i);
+ }
+ wcsSize += delimiterSize;
+ }
+ if ((wcsTotal + wcsSize) >= wcsPos) {
+ wcsSize = 0;
+ int index = 0;
+ while (index < mbcsSize) {
+ if ((wcsTotal + wcsSize) == wcsPos) {
+ return mbcsTotal + index;
+ }
+ if (OS.IsDBCSLeadByte (buffer [index++])) index++;
+ wcsSize++;
+ }
+ return mbcsTotal + mbcsSize;
+ }
+ wcsTotal += wcsSize;
+ mbcsTotal += mbcsSize;
+ }
+ return mbcsTotal;
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP;
+ if ((style & SWT.READ_ONLY) != 0) bits |= OS.ES_READONLY;
+ if ((style & SWT.SINGLE) != 0) return bits | OS.ES_AUTOHSCROLL;
+ bits |= OS.ES_MULTILINE | OS.ES_AUTOHSCROLL | OS.ES_NOHIDESEL;
+ if ((style & SWT.WRAP) != 0) bits &= ~(OS.WS_HSCROLL | OS.ES_AUTOHSCROLL);
+ return bits;
+}
+
+byte [] windowClass () {
+ return EditClass;
+}
+
+int windowProc () {
+ return EditProc;
+}
+
+LRESULT WM_CHAR (int wParam, int lParam) {
+ if (ignoreCharacter) return null;
+ LRESULT result = super.WM_CHAR (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. For some reason, when the
+ * widget is a single line text widget, when the
+ * user presses tab, return or escape, Windows beeps.
+ * The fix is to look for these keys and not call
+ * the window proc.
+ */
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_MULTILINE) == 0) {
+ switch (wParam) {
+ case OS.VK_RETURN:
+ postEvent (SWT.DefaultSelection);
+ // FALL THROUGH
+ case OS.VK_TAB:
+ case OS.VK_ESCAPE: return LRESULT.ZERO;
+ }
+ }
+ return result;
+}
+
+LRESULT WM_CLEAR (int wParam, int lParam) {
+ LRESULT result = super.WM_CLEAR (wParam, lParam);
+ if (result != null) return result;
+ if (!hooks (SWT.Verify)) return result;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_READONLY) != 0) return result;
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ if (start [0] == end [0]) return result;
+ String newText = verifyText ("", start [0], end [0]);
+ if (newText == null) return LRESULT.ZERO;
+ if (newText.length () != 0) {
+ result = new LRESULT (callWindowProc (OS.WM_CLEAR, 0, 0));
+ newText = Display.withCrLf (newText);
+ byte [] buffer = Converter.wcsToMbcs (0, newText, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ }
+ return result;
+}
+
+LRESULT WM_CUT (int wParam, int lParam) {
+ LRESULT result = super.WM_CUT (wParam, lParam);
+ if (result != null) return result;
+ if (!hooks (SWT.Verify)) return result;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_READONLY) != 0) return result;
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ if (start [0] == end [0]) return result;
+ String newText = verifyText ("", start [0], end [0]);
+ if (newText == null) return LRESULT.ZERO;
+ if (newText.length () != 0) {
+ result = new LRESULT (callWindowProc (OS.WM_CUT, 0, 0));
+ newText = Display.withCrLf (newText);
+ byte [] buffer = Converter.wcsToMbcs (0, newText, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ }
+ return result;
+}
+
+LRESULT WM_IME_CHAR (int wParam, int lParam) {
+
+ /* Process a DBCS character */
+ Display display = getDisplay ();
+ display.lastKey = 0;
+ display.lastAscii = wParam;
+ display.lastVirtual = false;
+ if (!sendKeyEvent (SWT.KeyDown, OS.WM_IME_CHAR, wParam, lParam)) {
+ return LRESULT.ZERO;
+ }
+ sendKeyEvent (SWT.KeyUp, OS.WM_IME_CHAR, wParam, lParam);
+ display.lastKey = display.lastAscii = 0;
+
+ /*
+ * Feature in Windows. The Windows text widget uses
+ * two 2 WM_CHAR's to process a DBCS key instead of
+ * using WM_IME_CHAR. The fix is to allow the text
+ * widget to get the WM_CHAR's but ignore sending
+ * them to the application.
+ */
+ ignoreCharacter = true;
+ int result = callWindowProc (OS.WM_IME_CHAR, wParam, lParam);
+ MSG msg = new MSG ();
+ while (OS.PeekMessage (msg, handle, OS.WM_CHAR, OS.WM_CHAR, OS.PM_REMOVE)) {
+ OS.TranslateMessage (msg);
+ OS.DispatchMessage (msg);
+ }
+ ignoreCharacter = false;
+ return new LRESULT (result);
+}
+
+LRESULT WM_LBUTTONDBLCLK (int wParam, int lParam) {
+ /*
+ * Prevent Windows from processing WM_LBUTTONDBLCLK
+ * when double clicking behavior is disabled by not
+ * calling the window proc.
+ */
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ sendMouseEvent (SWT.MouseDoubleClick, 1, OS.WM_LBUTTONDBLCLK, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ if (!doubleClick) return LRESULT.ZERO;
+
+ /*
+ * Bug in Windows. When the last line of text in the
+ * widget is double clicked and the line is empty, Windows
+ * hides the i-beam then moves it to the first line in
+ * the widget but does not scroll to show the user.
+ * If the user types without clicking the mouse, invalid
+ * characters are displayed at the end of each line of
+ * text in the widget. The fix is to detect this case
+ * and avoid calling the window proc.
+ */
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ if (start [0] == end [0]) {
+ int length = OS.GetWindowTextLength (handle);
+ if (length == start [0]) {
+ int result = OS.SendMessage (handle, OS.EM_LINELENGTH, length, 0);
+ if (result == 0) return LRESULT.ZERO;
+ }
+ }
+ return null;
+}
+
+LRESULT WM_PASTE (int wParam, int lParam) {
+ LRESULT result = super.WM_PASTE (wParam, lParam);
+ if (result != null) return result;
+ if (!hooks (SWT.Verify)) return result;
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.ES_READONLY) != 0) return result;
+ String oldText = getClipboardText ();
+ if (oldText == null) return result;
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ String newText = verifyText (oldText, start [0], end [0]);
+ if (newText == null) return LRESULT.ZERO;
+ if (newText != oldText) {
+ newText = Display.withCrLf (newText);
+ byte [] buffer = Converter.wcsToMbcs (0, newText, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ return LRESULT.ZERO;
+ }
+ return result;
+}
+
+LRESULT WM_UNDO (int wParam, int lParam) {
+ LRESULT result = super.WM_UNDO (wParam, lParam);
+ if (result != null) return result;
+ if (!hooks (SWT.Verify)) return result;
+
+ /* Undo and then Redo to get the Undo text */
+ if (OS.SendMessage (handle, OS.EM_CANUNDO, 0, 0) == 0) {
+ return result;
+ }
+ ignoreVerify = true;
+ callWindowProc (OS.WM_UNDO, wParam, lParam);
+ String oldText = getSelectionText ();
+ callWindowProc (OS.WM_UNDO, wParam, lParam);
+ ignoreVerify = false;
+
+ /* Verify the Undo operation */
+ int [] start = new int [1], end = new int [1];
+ OS.SendMessage (handle, OS.EM_GETSEL, start, end);
+ String newText = verifyText (oldText, start [0], end [0]);
+ if (newText == null) return LRESULT.ZERO;
+ if (newText != oldText) {
+ newText = Display.withCrLf (newText);
+ byte [] buffer = Converter.wcsToMbcs (0, newText, true);
+ OS.SendMessage (handle, OS.EM_REPLACESEL, 0, buffer);
+ return LRESULT.ZERO;
+ }
+
+ /* Do the original Undo */
+ ignoreVerify = true;
+ callWindowProc (OS.WM_UNDO, wParam, lParam);
+ ignoreVerify = false;
+ return LRESULT.ONE;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ int code = wParam >> 16;
+ switch (code) {
+ case OS.EN_CHANGE:
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the modify
+ * event. If this happens, end the processing of the
+ * Windows message by returning zero as the result of
+ * the window proc.
+ */
+ sendEvent (SWT.Modify);
+ if (isDisposed ()) return LRESULT.ZERO;
+ break;
+ }
+ return super.wmCommandChild (wParam, lParam);
+}
+
+LRESULT wmScroll (int msg, int wParam, int lParam) {
+ int code = callWindowProc (msg, wParam, lParam);
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
new file mode 100755
index 0000000000..07fed35b68
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java
@@ -0,0 +1,612 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class support the layout of selectable
+ * tool bar items.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>FLAT, WRAP, RIGHT</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>(none)</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class ToolBar extends Composite {
+ ToolItem [] items;
+ ImageList imageList, disabledImageList, hotImageList;
+ static final int ToolBarProc;
+ static final byte [] ToolBarClass = OS.TOOLBARCLASSNAME;
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, ToolBarClass, lpWndClass);
+ ToolBarProc = lpWndClass.lpfnWndProc;
+ }
+
+public ToolBar (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+int callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (ToolBarProc, handle, msg, wParam, lParam);
+}
+
+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 (layout != null) return super.computeSize (wHint, hHint, changed);
+ int width = 0, height = 0;
+ RECT oldRect = new RECT ();
+ OS.GetWindowRect (handle, oldRect);
+ int oldWidth = oldRect.right - oldRect.left;
+ int oldHeight = oldRect.bottom - oldRect.top;
+ int newWidth = wHint, newHeight = hHint;
+ if (newWidth == SWT.DEFAULT) newWidth = 0x3FFF;
+ if (newHeight == SWT.DEFAULT) newHeight = 0x3FFF;
+ boolean redraw = drawCount == 0 && OS.IsWindowVisible (handle);
+ if (redraw) {
+ OS.UpdateWindow (handle);
+ /*
+ * This line is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ int flags = OS.SWP_NOACTIVATE | OS.SWP_NOMOVE | OS.SWP_NOREDRAW | OS.SWP_NOZORDER;
+ OS.SetWindowPos (handle, 0, 0, 0, newWidth, newHeight, flags);
+ int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (count != 0) {
+ RECT rect = new RECT ();
+ OS.SendMessage (handle, OS.TB_GETITEMRECT, count - 1, rect);
+ width = Math.max (width, rect.right);
+ height = Math.max (height, rect.bottom);
+ }
+ OS.SetWindowPos (handle, 0, 0, 0, oldWidth, oldHeight, flags);
+ if (redraw) {
+ /*
+ * This line is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.RedrawWindow (handle, null, 0, OS.RDW_INVALIDATE | OS.RDW_UPDATENOW);
+ }
+
+ /*
+ * From the Windows SDK for TB_SETBUTTONSIZE:
+ *
+ * "If an application does not explicitly
+ * set the button size, the size defaults
+ * to 24 by 22 pixels".
+ */
+ if (width == 0) width = 24;
+ if (height == 0) height = 22;
+ if (wHint != SWT.DEFAULT) width = wHint;
+ if (hHint != SWT.DEFAULT) height = hHint;
+ Rectangle trim = computeTrim (0, 0, width, height);
+ width = trim.width; height = trim.height;
+ return new Point (width, height);
+}
+
+
+public Rectangle computeTrim (int x, int y, int width, int height) {
+ checkWidget ();
+ Rectangle trim = super. computeTrim (x, y, width, height);
+ int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ if ((bits & OS.CCS_NODIVIDER) == 0) trim.height += 2;
+ return trim;
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+
+ /*
+ * Feature in Windows. When the control is created,
+ * it does not use the default system font. A new HFONT
+ * is created and destroyed when the control is destroyed.
+ * This means that a program that queries the font from
+ * this control, uses the font in another control and then
+ * destroys this control will have the font unexpectedly
+ * destroyed in the other control. The fix is to assign
+ * the font ourselves each time the control is created.
+ * The control will not destroy a font that it did not
+ * create.
+ */
+ int hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
+
+ /* Set the button struct, bitmap and button sizes */
+ OS.SendMessage (handle, OS.TB_BUTTONSTRUCTSIZE, TBBUTTON.sizeof, 0);
+ OS.SendMessage (handle, OS.TB_SETBITMAPSIZE, 0, 0);
+ OS.SendMessage (handle, OS.TB_SETBUTTONSIZE, 0, 0);
+
+ /* Set the extended style bits */
+ int bits = OS.TBSTYLE_EX_DRAWDDARROWS;
+ OS.SendMessage (handle, OS.TB_SETEXTENDEDSTYLE, 0, bits);
+}
+
+void createItem (ToolItem item, int index) {
+ int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (!(0 <= index && index <= count)) error (SWT.ERROR_INVALID_RANGE);
+ int id = 0;
+ while (id < items.length && items [id] != null) id++;
+ if (id == items.length) {
+ ToolItem [] newItems = new ToolItem [items.length + 4];
+ System.arraycopy (items, 0, newItems, 0, items.length);
+ items = newItems;
+ }
+ int bits = item.widgetStyle ();
+ TBBUTTON lpButton = new TBBUTTON ();
+ lpButton.idCommand = id;
+ lpButton.fsStyle = (byte) bits;
+ lpButton.fsState = (byte) OS.TBSTATE_ENABLED;
+
+ /*
+ * Bug in Windows. Despite the fact that the image list
+ * index has never been set for the item, Windows always
+ * assumes that the image index for the item is valid.
+ * When an item is inserted, the image index is zero.
+ * Therefore, when the first image is inserted and is
+ * assigned image index zero, every item draws with this
+ * image. The fix is to set the image index to none
+ * when the item is created. This is not necessary in
+ * the case when the item has the BTNS_SEP style because
+ * separators cannot show images.
+ */
+ if ((bits & OS.BTNS_SEP) == 0) lpButton.iBitmap = OS.I_IMAGENONE;
+ if (OS.SendMessage (handle, OS.TB_INSERTBUTTON, index, lpButton) == 0) {
+ error (SWT.ERROR_ITEM_NOT_ADDED);
+ }
+ items [item.id = id] = item;
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new ToolItem [4];
+}
+
+void destroyItem (ToolItem item) {
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_IMAGE | OS.TBIF_STYLE;
+ int index = OS.SendMessage (handle, OS.TB_GETBUTTONINFO, item.id, info);
+ /*
+ * Feature in Windows. For some reason, a tool item that has
+ * the style BTNS_SEP does not return I_IMAGENONE when queried
+ * for an image index, despite the fact that no attempt has been
+ * made to assign an image to the item. As a result, operations
+ * on an image list that use the wrong index cause random results.
+ * The fix is to ensure that the tool item is not a separator
+ * before using the image index. Since separators cannot have
+ * an image and one is never assigned, this is not a problem.
+ */
+ if ((info.fsStyle & OS.BTNS_SEP) == 0 && info.iImage != OS.I_IMAGENONE) {
+ if (imageList != null) imageList.put (info.iImage, null);
+ if (hotImageList != null) hotImageList.put (info.iImage, null);
+ if (disabledImageList != null) disabledImageList.put (info.iImage, null);
+ }
+ int result = OS.SendMessage (handle, OS.TB_DELETEBUTTON, index, 0);
+ items [item.id] = null;
+ item.id = -1;
+ int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (count == 0) {
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
+ imageList.dispose ();
+ }
+ if (hotImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
+ hotImageList.dispose ();
+ }
+ if (disabledImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
+ disabledImageList.dispose ();
+ }
+ imageList = hotImageList = disabledImageList = null;
+ items = new ToolItem [4];
+ }
+}
+
+ImageList getDisabledImageList () {
+ return disabledImageList;
+}
+
+ImageList getHotImageList () {
+ return hotImageList;
+}
+
+ImageList getImageList () {
+ return imageList;
+}
+
+/**
+ * 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 ();
+ int count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ if (!(0 <= index && index < count)) error (SWT.ERROR_INVALID_RANGE);
+ TBBUTTON lpButton = new TBBUTTON ();
+ int result = OS.SendMessage (handle, OS.TB_GETBUTTON, index, lpButton);
+ if (result == 0) error (SWT.ERROR_CANNOT_GET_ITEM);
+ return items [lpButton.idCommand];
+}
+
+/**
+ * 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 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>
+ */
+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++) {
+ Rectangle rect = items [i].getBounds ();
+ if (rect.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 ();
+ return OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+}
+
+/**
+ * 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 effect 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 count = OS.SendMessage (handle, OS.TB_BUTTONCOUNT, 0, 0);
+ TBBUTTON lpButton = new TBBUTTON ();
+ ToolItem [] result = new ToolItem [count];
+ for (int i=0; i<count; i++) {
+ int code = OS.SendMessage (handle, OS.TB_GETBUTTON, i, lpButton);
+ result [i] = items [lpButton.idCommand];
+ }
+ 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 ();
+ return OS.SendMessage (handle, OS.TB_GETROWS, 0, 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 item 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 (ToolItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ return OS.SendMessage (handle, OS.TB_COMMANDTOINDEX, item.id, 0);
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseWidget ();
+ }
+ }
+ items = null;
+ super.releaseWidget ();
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, 0);
+ imageList.dispose ();
+ }
+ if (hotImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, 0);
+ hotImageList.dispose ();
+ }
+ if (disabledImageList != null) {
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, 0);
+ disabledImageList.dispose ();
+ }
+ imageList = hotImageList = disabledImageList = null;
+}
+
+void setDefaultFont () {
+ super.setDefaultFont ();
+ OS.SendMessage (handle, OS.TB_SETBITMAPSIZE, 0, 0);
+ OS.SendMessage (handle, OS.TB_SETBUTTONSIZE, 0, 0);
+}
+
+void setDisabledImageList (ImageList imageList) {
+ if (disabledImageList == imageList) return;
+ int hImageList = 0;
+ if ((disabledImageList = imageList) != null) {
+ hImageList = disabledImageList.getHandle ();
+ disabledImageList.setBackground (getBackgroundPixel ());
+ }
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);
+}
+
+
+public boolean setFocus () {
+ return false;
+}
+
+void setHotImageList (ImageList imageList) {
+ if (hotImageList == imageList) return;
+ int hImageList = 0;
+ if ((hotImageList = imageList) != null) {
+ hImageList = hotImageList.getHandle ();
+ hotImageList.setBackground (getBackgroundPixel ());
+ }
+ OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, hImageList);
+}
+
+void setImageList (ImageList imageList) {
+ if (this.imageList == imageList) return;
+ int hImageList = 0;
+ if ((this.imageList = imageList) != null) {
+ hImageList = imageList.getHandle ();
+ imageList.setBackground (getBackgroundPixel ());
+ }
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);
+}
+
+int toolTipHandle () {
+ return OS.SendMessage (handle, OS.TB_GETTOOLTIPS, 0, 0);
+}
+
+String toolTipText (NMTTDISPINFO hdr) {
+ if ((hdr.uFlags & OS.TTF_IDISHWND) != 0) {
+ return null;
+ }
+ int index = hdr.idFrom;
+ int hwndToolTip = toolTipHandle ();
+ if (hwndToolTip == hdr.hwndFrom) {
+ if ((0 <= index) && (index < items.length)) {
+ ToolItem item = items [index];
+ if (item != null) return item.toolTipText;
+ }
+ }
+ return super.toolTipText (hdr);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.CCS_NODIVIDER | OS.CCS_NORESIZE | OS.TBSTYLE_TOOLTIPS;
+ if ((style & SWT.WRAP) != 0) bits |= OS.TBSTYLE_WRAPABLE;
+ if ((style & SWT.FLAT) != 0) bits |= OS.TBSTYLE_FLAT;
+ if ((style & SWT.RIGHT) != 0) bits |= OS.TBSTYLE_LIST;
+ return bits;
+}
+
+byte [] windowClass () {
+ return ToolBarClass;
+}
+
+int windowProc () {
+ return ToolBarProc;
+}
+
+LRESULT WM_COMMAND (int wParam, int lParam) {
+ /*
+ * Feature in Windows. When the toolbar window
+ * proc processes WM_COMMAND, it forwards this
+ * message to the parent. This is done so that
+ * children of the toolbar that send WM_COMMAND
+ * messages to their parents will notify not only
+ * the toolbar but also the parent of the toolbar,
+ * which is typically the application window and
+ * the window that is looking for this message.
+ * If the toolbar did not do this, applications
+ * would have to subclass the toolbar window to
+ * see WM_COMMAND messages. Because the toolbar
+ * window is subclassed, the WM_COMMAND message
+ * is delivered twice. The fix is to avoid
+ * calling the toolbar window proc.
+ */
+ LRESULT result = super.WM_COMMAND (wParam, lParam);
+ if (result != null) return result;
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_NOTIFY (int wParam, int lParam) {
+ /*
+ * Bug in Windows NT. For some reason, Windows NT requests a
+ * UNICODE tool tip string instead of a DBCS string by sending
+ * TTN_GETDISPINFOW instead of TTN_GETDISPINFOA. This is not
+ * correct because the control is created as a DBCS control and
+ * expects to process TTN_GETDISPINFOA. TTN_GETDISPINFOA is
+ * never sent on NT. The fix is to handle TTN_GETDISPINFOW and
+ * give the control a UNICODE string.
+ */
+ if (IsWinNT) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ if (hdr.code == OS.TTN_GETDISPINFOW) {
+ NMTTDISPINFO lpnmtdi = new NMTTDISPINFO ();
+ OS.MoveMemory (lpnmtdi, lParam, NMTTDISPINFO.sizeof);
+ String string = null;
+ int index = hdr.idFrom;
+ if (0 <= index && index < items.length) {
+ ToolItem item = items [index];
+ if (item != null) string = item.toolTipText;
+ }
+ if (string != null && string.length () != 0) {
+ int length = string.length ();
+ char [] buffer = new char [length + 1];
+ string.getChars (0, length, buffer, 0);
+ getShell ().setToolTipText (lpnmtdi, buffer);
+ OS.MoveMemory (lParam, lpnmtdi, NMTTDISPINFO.sizeof);
+ }
+ return LRESULT.ZERO;
+ }
+ }
+ return super.WM_NOTIFY (wParam, lParam);
+}
+
+LRESULT WM_SIZE (int wParam, int lParam) {
+ LRESULT result = super.WM_SIZE (wParam, lParam);
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the resize
+ * event. If this happens, end the processing of the
+ * Windows message by returning the result of the
+ * WM_SIZE message.
+ */
+ if (isDisposed ()) return result;
+ for (int i=0; i<items.length; i++) {
+ ToolItem item = items [i];
+ if (item != null) {
+ Control control = item.control;
+ if (control != null && !control.isDisposed ()) {
+ Rectangle rect = item.getBounds ();
+ control.setLocation (rect.x, rect.y);
+ }
+ }
+ }
+ return result;
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
+ if (result != null) return result;
+ if (imageList != null && background == -1) {
+ imageList.setBackground (defaultBackground ());
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TB_SETIMAGELIST, 0, hImageList);
+ }
+ if (hotImageList != null && background == -1) {
+ hotImageList.setBackground (defaultBackground ());
+ int hImageList = hotImageList.getHandle ();
+ OS.SendMessage (handle, OS.TB_SETHOTIMAGELIST, 0, hImageList);
+ }
+ if (disabledImageList != null && background == -1) {
+ disabledImageList.setBackground (defaultBackground ());
+ int hImageList = disabledImageList.getHandle ();
+ OS.SendMessage (handle, OS.TB_SETDISABLEDIMAGELIST, 0, hImageList);
+ }
+ return result;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ ToolItem child = items [wParam & 0xFFFF];
+ if (child == null) return null;
+ return child.wmCommandChild (wParam, lParam);
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ switch (hdr.code) {
+ case OS.TBN_DROPDOWN:
+ NMTOOLBAR lpnmtb = new NMTOOLBAR ();
+ OS.MoveMemory (lpnmtb, lParam, NMTOOLBAR.sizeof);
+ ToolItem child = items [lpnmtb.iItem];
+ if (child != null) {
+ Event event = new Event ();
+ event.detail = SWT.ARROW;
+ child.postEvent (SWT.Selection, event);
+ return null;
+ }
+ break;
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
new file mode 100755
index 0000000000..6ce098603d
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolItem.java
@@ -0,0 +1,581 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+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 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>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ */
+
+public class ToolItem extends Item {
+ ToolBar parent;
+ Control control;
+ String toolTipText;
+ Image disabledImage, hotImage;
+ Image disabledImage2;
+ int id;
+
+public ToolItem (ToolBar parent, int style) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, parent.getItemCount ());
+}
+
+public ToolItem (ToolBar parent, int style, int index) {
+ super (parent, checkStyle (style));
+ this.parent = parent;
+ parent.createItem (this, index);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the control is selected, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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.PUSH, SWT.CHECK, SWT.RADIO, SWT.SEPARATOR, SWT.DROP_DOWN, 0);
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+Image createDisabledImage (Image image, Color color) {
+ Display display = getDisplay ();
+ Rectangle rect = image.getBounds ();
+ Image disabled = new Image (display, rect);
+ GC gc = new GC (disabled);
+ gc.setBackground (color);
+ gc.fillRectangle (rect);
+ int hDC = gc.handle;
+ int hImage = image.handle;
+ int fuFlags = OS.DSS_DISABLED;
+ switch (image.type) {
+ case SWT.BITMAP: fuFlags |= OS.DST_BITMAP; break;
+ case SWT.ICON: fuFlags |= OS.DST_ICON; break;
+ }
+ OS.DrawState (hDC, 0, 0, hImage, 0, 0, 0, rect.width, rect.height, fuFlags);
+ gc.dispose ();
+ return disabled;
+}
+
+/**
+ * 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();
+ int hwnd = parent.handle;
+ int index = OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+}
+
+/**
+ * Returns the control that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</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 disabled image if it has one, or null
+ * if it does not. The disabled image is displayed when the
+ * receiver is disabled.
+ *
+ * @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;
+}
+
+public Display getDisplay () {
+ ToolBar parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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>
+ */
+public boolean getEnabled () {
+ checkWidget();
+ int hwnd = parent.handle;
+ int fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ return (fsState & OS.TBSTATE_ENABLED) != 0;
+}
+
+/**
+ * Returns the receiver's hot image if it has one, or null
+ * if it does not. The hot image is displayed when the mouse
+ * enters the receiver.
+ *
+ * @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();
+ 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. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @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;
+ int hwnd = parent.handle;
+ int fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ return (fsState & OS.TBSTATE_CHECKED) != 0;
+}
+
+/**
+ * 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.
+ * <p>
+ * @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();
+ int hwnd = parent.handle;
+ int index = OS.SendMessage (hwnd, OS.TB_COMMANDTOINDEX, id, 0);
+ RECT rect = new RECT ();
+ OS.SendMessage (hwnd, OS.TB_GETITEMRECT, index, rect);
+ return rect.right - rect.left;
+}
+
+/**
+ * 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>
+ */
+public boolean isEnabled () {
+ checkWidget();
+ return getEnabled () && parent.isEnabled ();
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+ control = null;
+ toolTipText = null;
+ disabledImage = hotImage = null;
+ if (disabledImage2 != null) disabledImage2.dispose ();
+ disabledImage2 = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the control is selected.
+ *
+ * @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 #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 control that is used to fill the bounds of
+ * the item when the items is a <code>SEPARATOR</code>.
+ * <p>
+ * @param control the new 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 void setControl (Control control) {
+ checkWidget();
+ if (control != null && control.parent != parent) {
+ error (SWT.ERROR_INVALID_PARENT);
+ }
+ if ((style & SWT.SEPARATOR) == 0) return;
+ this.control = control;
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+
+/**
+ * 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();
+ int hwnd = parent.handle;
+ int fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ fsState &= ~OS.TBSTATE_ENABLED;
+ if (enabled) fsState |= OS.TBSTATE_ENABLED;
+ OS.SendMessage (hwnd, OS.TB_SETSTATE, id, fsState);
+}
+
+/**
+ * Sets the receiver's disabled image to the argument, which may be
+ * null indicating that no disabled image should be displayed. The
+ * disbled image is displayed when the receiver is disabled.
+ *
+ * @param image the hot image to display on 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 void setDisabledImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ disabledImage = image;
+ updateImages ();
+}
+
+/**
+ * Sets the receiver's hot image to the argument, which may be
+ * null indicating that no hot image should be displayed. The
+ * hot image is displayed when the mouse enters the receiver.
+ *
+ * @param image the hot image to display on 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 void setHotImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ hotImage = image;
+ updateImages ();
+}
+
+public void setImage (Image image) {
+ checkWidget();
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setImage (image);
+ updateImages ();
+}
+
+/**
+ * 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. When it is of type <code>TOGGLE</code>,
+ * it is selected when it is pushed.
+ *
+ * @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;
+ int hwnd = parent.handle;
+ int fsState = OS.SendMessage (hwnd, OS.TB_GETSTATE, id, 0);
+ fsState &= ~OS.TBSTATE_CHECKED;
+ if (selected) fsState |= OS.TBSTATE_CHECKED;
+ OS.SendMessage (hwnd, OS.TB_SETSTATE, id, fsState);
+}
+
+public void setText (String string) {
+ checkWidget();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if ((style & SWT.SEPARATOR) != 0) return;
+ super.setText (string);
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_TEXT | OS.TBIF_STYLE;
+ info.pszText = pszText;
+ info.fsStyle = (byte) (widgetStyle () | OS.BTNS_AUTOSIZE);
+ int result = OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
+ OS.HeapFree (hHeap, 0, pszText);
+
+ /*
+ * Bug in Windows. For some reason, when the font is set
+ * before any tool item has text, the tool items resize to
+ * a very small size. Also, a tool item will only show text
+ * when text has already been set on one item and then a new
+ * item is created. The fix is to use WM_SETFONT to force
+ * the tool bar to redraw and layout. [1G0G7TV, 1G0FUJ5]
+ */
+ int hFont = OS.SendMessage (hwnd, OS.WM_GETFONT, 0, 0);
+ OS.SendMessage (hwnd, OS.WM_SETFONT, hFont, 0);
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Sets the width of the receiver.
+ * <p>
+ * @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;
+ int hwnd = parent.handle;
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_SIZE;
+ info.cx = (short) width;
+ OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
+ if (control != null && !control.isDisposed ()) {
+ control.setBounds (getBounds ());
+ }
+}
+
+void updateImages () {
+ int hwnd = parent.handle;
+ TBBUTTONINFO info = new TBBUTTONINFO ();
+ info.cbSize = TBBUTTONINFO.sizeof;
+ info.dwMask = OS.TBIF_IMAGE;
+ OS.SendMessage (hwnd, OS.TB_GETBUTTONINFO, id, info);
+ if (info.iImage == OS.I_IMAGENONE && image == null) return;
+ ImageList imageList = parent.getImageList ();
+ ImageList hotImageList = parent.getHotImageList ();
+ ImageList disabledImageList = parent.getDisabledImageList();
+ if (info.iImage == OS.I_IMAGENONE) {
+ if (imageList == null) imageList = new ImageList ();
+ info.iImage = imageList.add (image);
+ parent.setImageList (imageList);
+ if (disabledImageList == null) disabledImageList = new ImageList ();
+ Image disabled = disabledImage;
+ if (disabledImage == null) {
+ Color color = parent.getBackground ();
+ disabled = disabledImage2 = createDisabledImage (image, color);
+ }
+ disabledImageList.add (disabled);
+ parent.setDisabledImageList (disabledImageList);
+ if ((parent.style & SWT.FLAT) != 0) {
+ if (hotImageList == null) hotImageList = new ImageList ();
+ hotImageList.add (hotImage != null ? hotImage : image);
+ parent.setHotImageList (hotImageList);
+ }
+ } else {
+ if (imageList != null) imageList.put (info.iImage, image);
+ if (disabledImageList != null) {
+ Image disabled = null;
+ if (image != null) {
+ if (disabledImage2 != null) disabledImage2.dispose ();
+ disabledImage2 = null;
+ disabled = disabledImage;
+ if (disabledImage == null) {
+ Color color = parent.getBackground ();
+ disabled = disabledImage2 = createDisabledImage (image, color);
+ }
+ }
+ disabledImageList.put (info.iImage, disabled);
+ }
+ if (hotImageList != null) {
+ Image hot = null;
+ if (image != null) hot = hotImage != null ? hotImage : image;
+ hotImageList.put (info.iImage, hot);
+ }
+ if (image == null) info.iImage = OS.I_IMAGENONE;
+ }
+ OS.SendMessage (hwnd, OS.TB_SETBUTTONINFO, id, info);
+}
+
+int widgetStyle () {
+ if ((style & SWT.DROP_DOWN) != 0) return OS.BTNS_DROPDOWN;
+ if ((style & SWT.PUSH) != 0) return OS.BTNS_BUTTON;
+ if ((style & SWT.CHECK) != 0) return OS.BTNS_CHECK;
+ if ((style & SWT.RADIO) != 0) return OS.BTNS_CHECKGROUP;
+ if ((style & SWT.SEPARATOR) != 0) return OS.BTNS_SEP;
+ return OS.BTNS_BUTTON;
+}
+
+LRESULT wmCommandChild (int wParam, int lParam) {
+ postEvent (SWT.Selection);
+ return null;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
new file mode 100755
index 0000000000..4ee8413cfb
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tracker.java
@@ -0,0 +1,272 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.events.*;
+
+/**
+ * Instances of this class implement rubber banding rectangles.
+ *
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>(none)</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Move</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Tracker extends Widget {
+ Control parent;
+ Display display;
+ boolean tracking, stippled;
+ Rectangle [] rectangles = new Rectangle [0];
+
+public Tracker (Composite parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ display = parent.getDisplay ();
+}
+
+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 = 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.Move,typedListener);
+}
+
+/**
+ * Stop displaying the tracker 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 void close () {
+ checkWidget ();
+ tracking = false;
+}
+
+/**
+ * Draw the rectangles displayed by the tracker.
+ */
+void drawRectangles () {
+ if (parent != null) {
+ if (parent.isDisposed ()) return;
+ parent.getShell ().update ();
+ } else {
+ display.update ();
+ }
+ int bandWidth = 1;
+ int hwndTrack = OS.GetDesktopWindow ();
+ if (parent != null) hwndTrack = parent.handle;
+ int hDC = OS.GetDCEx (hwndTrack, 0, OS.DCX_CACHE);
+ int hBitmap = 0, hBrush = 0, oldBrush = 0;
+ if (stippled) {
+ bandWidth = 3;
+ byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
+ hBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);
+ hBrush = OS.CreatePatternBrush (hBitmap);
+ oldBrush = OS.SelectObject (hDC, hBrush);
+ }
+ for (int i=0; i<rectangles.length; i++) {
+ Rectangle rect = rectangles [i];
+ OS.PatBlt (hDC, rect.x, rect.y, rect.width, bandWidth, OS.PATINVERT);
+ OS.PatBlt (hDC, rect.x, rect.y + bandWidth, bandWidth, rect.height - (bandWidth * 2), OS.PATINVERT);
+ OS.PatBlt (hDC, rect.x + rect.width - bandWidth, rect.y + bandWidth, bandWidth, rect.height - (bandWidth * 2), OS.PATINVERT);
+ OS.PatBlt (hDC, rect.x, rect.y + rect.height - bandWidth, rect.width, bandWidth, OS.PATINVERT);
+ }
+ if (stippled) {
+ OS.SelectObject (hDC, oldBrush);
+ OS.DeleteObject (hBrush);
+ OS.DeleteObject (hBitmap);
+ }
+ OS.ReleaseDC (hwndTrack, hDC);
+}
+
+public Display getDisplay () {
+ return display;
+}
+
+/**
+ * Returns the bounds of the Rectangles being drawn.
+ *
+ * @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 ();
+ return rectangles;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Start displaying the Tracker 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 open () {
+ checkWidget ();
+ boolean cancelled = false;
+ tracking = true;
+ Event event = new Event ();
+ POINT pt = new POINT ();
+ MSG msg = new MSG ();
+ drawRectangles ();
+ int oldPos = OS.GetMessagePos ();
+ while (tracking && !cancelled) {
+ if (parent != null && parent.isDisposed ()) break;
+ OS.GetMessage (msg, 0, 0, 0);
+ switch (msg.message) {
+ case OS.WM_LBUTTONUP:
+ case OS.WM_MOUSEMOVE:
+ int newPos = OS.GetMessagePos ();
+ if (newPos != oldPos) {
+ int oldX = (short) (oldPos & 0xFFFF);
+ int oldY = (short) (oldPos >> 16);
+ int newX = (short) (newPos & 0xFFFF);
+ int newY = (short) (newPos >> 16);
+ drawRectangles ();
+ for (int i=0; i<rectangles.length; i++) {
+ rectangles [i].x += newX - oldX;
+ rectangles [i].y += newY - oldY;
+ }
+ /*
+ * 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.
+ */
+ sendEvent (SWT.Move, event);
+ if (isDisposed ()) return false;
+ drawRectangles ();
+ oldPos = newPos;
+ }
+ tracking = msg.message != OS.WM_LBUTTONUP;
+ break;
+ case OS.WM_KEYDOWN:
+ cancelled = msg.wParam == OS.VK_ESCAPE;
+ break;
+ }
+ OS.DispatchMessage (msg);
+ }
+ drawRectangles ();
+ tracking = false;
+ return !cancelled;
+}
+
+/**
+ * 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 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);
+}
+
+/**
+ * Specify the rectangles that should be drawn.
+ *
+ * @param rectangles the bounds of the rectangles to be 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 void setRectangles (Rectangle [] rectangles) {
+ checkWidget ();
+ if (rectangles == null) error (SWT.ERROR_NULL_ARGUMENT);
+ this.rectangles = rectangles;
+}
+
+/**
+ * Change 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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
new file mode 100755
index 0000000000..b52dada557
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java
@@ -0,0 +1,1397 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+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 issue notificiation when an
+ * item in the hierarchy is selected.
+ * <p>
+ * <dl>
+ * <dt><b>Styles:</b></dt>
+ * <dd>SINGLE, MULTI, CHECK</dd>
+ * <dt><b>Events:</b></dt>
+ * <dd>Selection, DefaultSelection, Collapse, Expand</dd>
+ * </dl>
+ * <p>
+ * IMPORTANT: This class is <em>not</em> intended to be subclassed.
+ * </p>
+ */
+
+public class Tree extends Composite {
+ int hAnchor;
+ TreeItem [] items;
+ ImageList imageList;
+ boolean dragStarted;
+ boolean ignoreSelect, ignoreExpand, ignoreDeselect;
+ static final int TreeProc;
+ static final byte [] TreeClass = OS.WC_TREEVIEW;
+ static {
+ WNDCLASSEX lpWndClass = new WNDCLASSEX ();
+ lpWndClass.cbSize = WNDCLASSEX.sizeof;
+ OS.GetClassInfoEx (0, TreeClass, lpWndClass);
+ TreeProc = lpWndClass.lpfnWndProc;
+ }
+
+
+public Tree (Composite parent, int style) {
+ super (parent, checkStyle (style));
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notified when the receiver's selection changes, by sending
+ * it one of the messages defined in the <code>SelectionListener</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 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);
+}
+
+/**
+ * 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 callWindowProc (int msg, int wParam, int lParam) {
+ if (handle == 0) return 0;
+ return OS.CallWindowProc (TreeProc, handle, msg, wParam, lParam);
+}
+
+static int checkStyle (int style) {
+ /*
+ * Feature in Windows. It is not possible to create
+ * a tree that scrolls and does not have scroll bars.
+ * The TVS_NOSCROLL style will remove the scroll bars
+ * but the tree will never scroll. Therefore, no matter
+ * what style bits are specified, set the H_SCROLL and
+ * V_SCROLL bits so that the SWT style will match the
+ * widget that Windows creates.
+ */
+ style |= SWT.H_SCROLL | SWT.V_SCROLL;
+ return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
+}
+
+
+public Point computeSize (int wHint, int hHint, boolean changed) {
+ checkWidget ();
+ int width = 0, height = 0;
+ RECT rect = new RECT ();
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ while (hItem != 0) {
+ rect.left = hItem;
+ if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect) != 0) {
+ width = Math.max (width, rect.right - rect.left);
+ height += rect.bottom - rect.top;
+ }
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ }
+ width = width * 2;
+ 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;
+ if ((style & SWT.V_SCROLL) != 0) {
+ width += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
+ }
+ if ((style & SWT.H_SCROLL) != 0) {
+ height += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
+ }
+ return new Point (width, height);
+}
+
+void createHandle () {
+ super.createHandle ();
+ state &= ~CANVAS;
+
+ /* Set the checkbox image list */
+ if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+
+ /*
+ * Feature in Windows. When the control is created,
+ * it does not use the default system font. A new HFONT
+ * is created and destroyed when the control is destroyed.
+ * This means that a program that queries the font from
+ * this control, uses the font in another control and then
+ * destroys this control will have the font unexpectedly
+ * destroyed in the other control. The fix is to assign
+ * the font ourselves each time the control is created.
+ * The control will not destroy a font that it did not
+ * create.
+ */
+ int hFont = OS.GetStockObject (OS.SYSTEM_FONT);
+ OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0);
+}
+
+void createItem (TreeItem item, int hParent, int hInsertAfter) {
+ 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;
+ }
+ TVINSERTSTRUCT tvInsert = new TVINSERTSTRUCT ();
+ tvInsert.hParent = hParent;
+ tvInsert.hInsertAfter = hInsertAfter;
+ tvInsert.lParam = id;
+ tvInsert.iImage = OS.I_IMAGENONE;
+ tvInsert.iSelectedImage = tvInsert.iImage;
+ tvInsert.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM | OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE;
+
+ /* Set the initial unchecked state */
+ if ((style & SWT.CHECK) != 0) {
+ tvInsert.mask = tvInsert.mask | OS.TVIF_STATE;
+ tvInsert.state = 1 << 12;
+ tvInsert.stateMask = OS.TVIS_STATEIMAGEMASK;
+ }
+
+ /* Insert the item */
+ int hItem = OS.SendMessage (handle, OS.TVM_INSERTITEM, 0, tvInsert);
+ if (hItem == 0) error (SWT.ERROR_ITEM_NOT_ADDED);
+ item.handle = hItem;
+ items [id] = item;
+ /*
+ * This code is intentionally commented.
+ */
+// if (hParent != 0) {
+// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
+// bits |= OS.TVS_LINESATROOT;
+// OS.SetWindowLong (handle, OS.GWL_STYLE, bits);
+// }
+
+ /*
+ * Bug in Windows. When a child item ss added to a parent item
+ * that has no children outside of WM_NOTIFY with control code
+ * TVN_ITEMEXPANDED, the tree widget does not redraw the +/-
+ * indicator. The fix is to detect this case and force a redraw.
+ */
+ if (!OS.IsWindowVisible (handle) || drawCount > 0) return;
+ int hChild = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+ if (hChild == 0 || OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hChild) != 0) {
+ return;
+ }
+ RECT rect = new RECT ();
+ rect.left = hParent;
+ if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 0, rect) != 0) {
+ OS.InvalidateRect (handle, rect, false);
+ }
+}
+
+ScrollBar createScrollBar (int type) {
+ return new ScrollBar (this, type);
+}
+
+void createWidget () {
+ super.createWidget ();
+ items = new TreeItem [4];
+}
+
+int defaultBackground () {
+ return OS.GetSysColor (OS.COLOR_WINDOW);
+}
+
+/**
+ * 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 ();
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ if ((style & SWT.SINGLE) != 0) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) {
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ return;
+ }
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+}
+
+void destroyItem (TreeItem item) {
+ int hItem = item.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ releaseItems (new TreeItem [] {item}, tvItem);
+ boolean fixRedraw = false;
+ if (drawCount == 0 && OS.IsWindowVisible (handle)) {
+ RECT rect = new RECT ();
+ rect.left = hItem;
+ fixRedraw = OS.SendMessage (handle, OS.TVM_GETITEMRECT, 0, rect) == 0;
+ }
+ if (fixRedraw) {
+ OS.UpdateWindow (handle);
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ int result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, hItem);
+ if (fixRedraw) {
+ OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.ValidateRect (handle, null);
+ }
+ int count = OS.SendMessage (handle, OS.TVM_GETCOUNT, 0, 0);
+ if (count == 0) {
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+ items = new TreeItem [4];
+ }
+}
+
+int getBackgroundPixel () {
+ int pixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
+ if (pixel == -1) return OS.GetSysColor (OS.COLOR_WINDOW);
+ return pixel;
+}
+
+int getForegroundPixel () {
+ int pixel = OS.SendMessage (handle, OS.TVM_GETTEXTCOLOR, 0, 0);
+ if (pixel == -1) return OS.GetSysColor (OS.COLOR_WINDOWTEXT);
+ return pixel;
+}
+
+/**
+ * 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 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>
+ */
+public TreeItem getItem (Point point) {
+ checkWidget ();
+ if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
+ TVHITTESTINFO lpht = new TVHITTESTINFO ();
+ lpht.x = point.x; lpht.y = point.y;
+ OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
+ if (lpht.hItem != 0 && (lpht.flags & OS.TVHT_ONITEM) != 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ tvItem.hItem = lpht.hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ return items [tvItem.lParam];
+ }
+ return null;
+}
+
+/**
+ * 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 ();
+ int count = 0;
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ while (hItem != 0) {
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ count++;
+ }
+ return count;
+}
+
+/**
+ * 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 ();
+ return OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0);
+}
+
+/**
+ * Returns the number 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 effect the receiver.
+ * </p>
+ *
+ * @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 TreeItem [] getItems () {
+ checkWidget ();
+ int count = 0;
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ while (hItem != 0) {
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ count++;
+ }
+ int index = 0;
+ TreeItem [] result = new TreeItem [count];
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ tvItem.hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ while (tvItem.hItem != 0) {
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ result [index++] = items [tvItem.lParam];
+ tvItem.hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, tvItem.hItem);
+ }
+ return result;
+}
+
+/**
+ * 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;
+}
+
+/**
+ * Returns an array of <code>TreeItem</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 effect 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 ();
+ if ((style & SWT.SINGLE) != 0) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem == 0) return new TreeItem [0];
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE;
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) == 0) return new TreeItem [0];
+ return new TreeItem [] {items [tvItem.lParam]};
+ }
+ int count = 0;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE;
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) count++;
+ }
+ }
+ TreeItem [] result = new TreeItem [count];
+ if (count != 0) {
+ int index = 0;
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ result [index++] = item;
+ }
+ }
+ }
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ 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 ();
+ if ((style & SWT.SINGLE) != 0) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem == 0) return 0;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) == 0) return 0;
+ return 1;
+ }
+ int count = 0;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) count++;
+ }
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ return count;
+}
+
+int imageIndex (Image image) {
+ if (image == null) return OS.I_IMAGENONE;
+ if (imageList == null) {
+ int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+ imageList = new ImageList ();
+ imageList.setBackground (getBackgroundPixel ());
+ imageList.add (image);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
+ return 0;
+ }
+ int index = imageList.indexOf (image);
+ if (index != -1) return index;
+ imageList.add (image);
+ return imageList.size () - 1;
+}
+
+void releaseItems (TreeItem [] nodes, TVITEM tvItem) {
+ for (int i=0; i<nodes.length; i++) {
+ TreeItem item = nodes [i];
+ TreeItem [] sons = item.getItems ();
+ if (sons.length != 0) {
+ releaseItems (sons, tvItem);
+ }
+ int hItem = item.handle;
+ if (hItem == hAnchor) hAnchor = 0;
+ if (!item.isDisposed ()) {
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ items [tvItem.lParam] = null;
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+}
+
+void releaseWidget () {
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ items = null;
+ super.releaseWidget ();
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ imageList.dispose ();
+ } else {
+ int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, 0);
+ if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+ }
+ imageList = null;
+ int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, 0);
+ if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+}
+
+
+/**
+ * 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 ();
+ ignoreDeselect = ignoreSelect = true;
+ int result = OS.SendMessage (handle, OS.TVM_DELETEITEM, 0, OS.TVI_ROOT);
+ ignoreDeselect = ignoreSelect = false;
+ if (result == 0) error (SWT.ERROR_ITEM_NOT_REMOVED);
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null && !item.isDisposed ()) {
+ item.releaseWidget ();
+ item.releaseHandle ();
+ }
+ }
+ if (imageList != null) {
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, 0, 0);
+ imageList.dispose ();
+ }
+ imageList = null;
+ items = new TreeItem [4];
+ hAnchor = 0;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notified when the receiver's selection changes.
+ *
+ * @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);
+}
+
+/**
+ * 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 after true places the insert mark above 'item'. false places
+ * the insert mark below '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 (TreeItem item, boolean before) {
+ checkWidget ();
+ int hItem = 0;
+ if (item != null) hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_SETINSERTMARK, (before) ? 0 : 1, hItem);
+}
+
+/**
+ * Selects all 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 void selectAll () {
+ checkWidget ();
+ if ((style & SWT.SINGLE) != 0) return;
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem == 0) {
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ if (hItem != 0) {
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hItem);
+ ignoreSelect = false;
+ OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
+ }
+ }
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.state = OS.TVIS_SELECTED;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+}
+
+void setBackgroundPixel (int pixel) {
+ if (background == pixel) return;
+ background = pixel;
+ /*
+ * Bug in Windows. When TVM_GETBKCOLOR is used more
+ * than once to set the background color of a tree,
+ * the background color of the lines and the plus/minus
+ * does not change to the new color. The fix is to set
+ * the background color to the default before setting
+ * the new color.
+ */
+ int oldPixel = OS.SendMessage (handle, OS.TVM_GETBKCOLOR, 0, 0);
+ if (oldPixel != -1) OS.SendMessage (handle, OS.TVM_SETBKCOLOR, 0, -1);
+ OS.SendMessage (handle, OS.TVM_SETBKCOLOR, 0, pixel);
+ if (pixel == -1) pixel = getBackgroundPixel ();
+ if (imageList != null) {
+ imageList.setBackground (pixel);
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
+ }
+ if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+}
+
+void setCheckboxImageList () {
+ if ((style & SWT.CHECK) == 0) return;
+ int count = 5;
+ int height = OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0), width = height;
+ int hImageList = OS.ImageList_Create (width, height, OS.ILC_COLOR, count, count);
+ int hDC = OS.GetDC (handle);
+ int memDC = OS.CreateCompatibleDC (hDC);
+ int hBitmap = OS.CreateCompatibleBitmap (hDC, width * count, height);
+ int hOldBitmap = OS.SelectObject (memDC, hBitmap);
+ RECT rect = new RECT ();
+ OS.SetRect (rect, 0, 0, width * count, height);
+ int hBrush = OS.CreateSolidBrush (getBackgroundPixel ());
+ OS.FillRect (memDC, rect, hBrush);
+ OS.DeleteObject (hBrush);
+ int oldFont = OS.SelectObject (hDC, defaultFont ());
+ TEXTMETRIC tm = new TEXTMETRIC ();
+ OS.GetTextMetrics (hDC, tm);
+ OS.SelectObject (hDC, oldFont);
+ int itemWidth = Math.min (tm.tmHeight, width);
+ int itemHeight = Math.min (tm.tmHeight, height);
+ int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1;
+ OS.SetRect (rect, left + width, top, left + width + itemWidth, top + itemHeight);
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_FLAT);
+ rect.left += width; rect.right += width;
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_FLAT);
+ rect.left += width; rect.right += width;
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_INACTIVE | OS.DFCS_FLAT);
+ rect.left += width; rect.right += width;
+ OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_INACTIVE | OS.DFCS_FLAT);
+ OS.SelectObject (memDC, hOldBitmap);
+ OS.DeleteDC (memDC);
+ OS.ReleaseDC (handle, hDC);
+ OS.ImageList_AddMasked (hImageList, hBitmap, 0);
+ OS.DeleteObject (hBitmap);
+ int hOldList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0);
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, hImageList);
+ if (hOldList != 0) OS.ImageList_Destroy (hOldList);
+}
+
+void setForegroundPixel (int pixel) {
+ if (foreground == pixel) return;
+ foreground = pixel;
+ OS.SendMessage (handle, OS.TVM_SETTEXTCOLOR, 0, pixel);
+}
+
+/**
+ * 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 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 Tree#deselectAll()
+ */
+public void setSelection (TreeItem [] items) {
+ checkWidget ();
+ if (items == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* Select/deselect the first item */
+ if (items.length == 0) {
+ int hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hOldItem != 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ tvItem.hItem = hOldItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ } else {
+ int hNewItem = 0;
+ TreeItem item = items [0];
+ if (item != null) hNewItem = item.handle;
+ ignoreSelect = true;
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, hNewItem);
+ ignoreSelect = false;
+ }
+ if ((style & SWT.SINGLE) != 0) return;
+
+ /* Select/deselect the rest of the items */
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ for (int i=0; i<this.items.length; i++) {
+ TreeItem item = this.items [i];
+ if (item != null) {
+ int index = 0;
+ while (index < items.length) {
+ if (items [index] == item) break;
+ index++;
+ }
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ if (index == items.length) {
+ tvItem.state = 0;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ } else {
+ if (index != items.length) {
+ tvItem.state = OS.TVIS_SELECTED;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ }
+ }
+ }
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+}
+
+/**
+ * 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 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 Tree#showSelection()
+ */
+public void showItem (TreeItem item) {
+ checkWidget ();
+ if (item == null) error (SWT.ERROR_NULL_ARGUMENT);
+ OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, item.handle);
+}
+
+/**
+ * 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 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 Tree#showItem(TreeItem)
+ */
+public void showSelection () {
+ checkWidget ();
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem == 0) return;
+ OS.SendMessage (handle, OS.TVM_ENSUREVISIBLE, 0, hItem);
+}
+
+int widgetStyle () {
+ int bits = super.widgetStyle () | OS.WS_TABSTOP | OS.TVS_SHOWSELALWAYS;
+ bits |= OS.TVS_LINESATROOT | OS.TVS_HASLINES | OS.TVS_HASBUTTONS;
+ /*
+ * This code is intentionally commented. In future,
+ * FULL_SELECTION may be implemented for trees and
+ * automatic tool tips turned off.
+ */
+// if ((style & SWT.FULL_SELECTION) != 0) {
+// bits |= OS.TVS_FULLROWSELECT;
+// } else {
+// bits |= OS.TVS_HASLINES | OS.TVS_HASBUTTONS;
+// }
+// bits |= OS.TVS_NOTOOLTIPS;
+ return bits;
+}
+
+byte [] windowClass () {
+ return TreeClass;
+}
+
+int windowProc () {
+ return TreeProc;
+}
+
+LRESULT WM_CHAR (int wParam, int lParam) {
+ LRESULT result = super.WM_CHAR (wParam, lParam);
+ if (result != null) return result;
+ /*
+ * Feature in Windows. The tree control beeps
+ * in WM_CHAR when the search for the item that
+ * matches the key stroke fails. This is the
+ * standard tree behavior but is unexpected when
+ * the key that was typed was CR or SPACE. The
+ * fix is to avoid calling the tree window proc
+ * in these cases.
+ */
+ switch (wParam) {
+ case OS.VK_RETURN:
+ case OS.VK_SPACE: return LRESULT.ZERO;
+ }
+ return result;
+}
+
+LRESULT WM_KEYDOWN (int wParam, int lParam) {
+ LRESULT result = super.WM_KEYDOWN (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.CHECK) != 0 && wParam == OS.VK_SPACE) {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem != 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE | OS.TVIF_PARAM;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ int state = tvItem.state >> 12;
+ if ((state & 0x1) != 0) {
+ state++;
+ } else {
+ --state;
+ }
+ tvItem.state = state << 12;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ Event event = new Event ();
+ event.item = items [tvItem.lParam];
+ event.detail = SWT.CHECK;
+ postEvent (SWT.Selection, event);
+ }
+ }
+ return result;
+}
+
+LRESULT WM_KILLFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_KILLFOCUS (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.SINGLE) != 0) return result;
+ /*
+ * Feature in Windows. When multiple item have
+ * the TVIS_SELECTED state, Windows redraws only
+ * the focused item in the color used to show the
+ * selection when the tree loses or gains focus.
+ * The fix is to force Windows to redraw all the
+ * visible items when focus is gained or lost.
+ */
+ OS.InvalidateRect (handle, null, false);
+ return result;
+}
+
+LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
+
+ /*
+ * Feature in Windows. When a tree item is
+ * reselected, Windows does not issue a WM_NOTIFY.
+ * This is inconsistent with the list widget and
+ * other widgets in Windows. The fix is to detect
+ * the case when an item is reselected and issue
+ * the notification.
+ */
+ TVHITTESTINFO lpht = new TVHITTESTINFO ();
+ lpht.x = (short) (lParam & 0xFFFF);
+ lpht.y = (short) (lParam >> 16);
+ OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
+ if (lpht.hItem == 0 || (lpht.flags & OS.TVHT_ONITEM) == 0) {
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ int code = callWindowProc (OS.WM_LBUTTONDOWN, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return new LRESULT (code);
+ }
+
+ /* Look for check/uncheck */
+ if ((style & SWT.CHECK) != 0) {
+ if ((lpht.flags & OS.TVHT_ONITEMSTATEICON) != 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.hItem = lpht.hItem;
+ tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ int state = tvItem.state >> 12;
+ if ((state & 0x1) != 0) {
+ state++;
+ } else {
+ --state;
+ }
+ tvItem.state = state << 12;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ Event event = new Event ();
+ event.item = items [tvItem.lParam];
+ event.detail = SWT.CHECK;
+ postEvent (SWT.Selection, event);
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ return LRESULT.ZERO;
+ }
+ }
+
+ /* Get the selected state of the item under the mouse */
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_SELECTED;
+ boolean hittestSelected = false;
+ if ((style & SWT.MULTI) != 0) {
+ tvItem.hItem = lpht.hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ hittestSelected = (tvItem.state & OS.TVIS_SELECTED) != 0;
+ }
+
+ /* Get the selected state of the last selected item */
+ int hOldItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if ((style & SWT.MULTI) != 0) {
+ tvItem.hItem = hOldItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+
+ /* Check for CONTROL or drag selection */
+ if (hittestSelected || (wParam & OS.MK_CONTROL) != 0) {
+ if (drawCount == 0) {
+ OS.UpdateWindow (handle);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 0, 0);
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0);
+ }
+ } else {
+ deselectAll ();
+ }
+ }
+
+ /* Do the selection */
+ sendMouseEvent (SWT.MouseDown, 1, OS.WM_LBUTTONDOWN, wParam, lParam);
+ dragStarted = false;
+ ignoreDeselect = ignoreSelect = true;
+ int code = callWindowProc (OS.WM_LBUTTONDOWN, wParam, lParam);
+ ignoreDeselect = ignoreSelect = false;
+ if (dragStarted && OS.GetCapture () != handle) OS.SetCapture (handle);
+ int hNewItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+
+ /* Reselect the last item that was unselected */
+ if ((style & SWT.MULTI) != 0) {
+
+ /* Check for CONTROL and reselect the last item */
+ if (hittestSelected || (wParam & OS.MK_CONTROL) != 0) {
+ if (hOldItem == hNewItem && hOldItem == lpht.hItem) {
+ if ((wParam & OS.MK_CONTROL) != 0) {
+ tvItem.state ^= OS.TVIS_SELECTED;
+ if (dragStarted) tvItem.state = OS.TVIS_SELECTED;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ } else {
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ tvItem.state = OS.TVIS_SELECTED;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ if ((wParam & OS.MK_CONTROL) != 0 && !dragStarted) {
+ if (hittestSelected) {
+ tvItem.state = 0;
+ tvItem.hItem = lpht.hItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ }
+ }
+ if (drawCount == 0) {
+ RECT rect1 = new RECT (), rect2 = new RECT ();
+ rect1.left = hOldItem; rect2.left = hNewItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect1);
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect2);
+ /*
+ * This code is intentionally commented.
+ */
+// OS.SendMessage (handle, OS.WM_SETREDRAW, 1, 0);
+ OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
+ int flags = OS.RDW_UPDATENOW | OS.RDW_INVALIDATE;
+ OS.RedrawWindow (handle, rect1, 0, flags);
+ OS.RedrawWindow (handle, rect2, 0, flags);
+ }
+ }
+
+ /* Check for SHIFT or normal select and delect/reselect items */
+ if ((wParam & OS.MK_CONTROL) == 0) {
+ if (!hittestSelected || !dragStarted) {
+ tvItem.state = 0;
+ int oldProc = OS.GetWindowLong (handle, OS.GWL_WNDPROC);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, TreeProc);
+ for (int i=0; i<items.length; i++) {
+ TreeItem item = items [i];
+ if (item != null && item.handle != hNewItem) {
+ tvItem.hItem = item.handle;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ }
+ }
+ tvItem.hItem = hNewItem;
+ tvItem.state = OS.TVIS_SELECTED;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ OS.SetWindowLong (handle, OS.GWL_WNDPROC, oldProc);
+ if ((wParam & OS.MK_SHIFT) != 0) {
+ RECT rect1 = new RECT ();
+ if (hAnchor == 0) hAnchor = hNewItem;
+ rect1.left = hAnchor;
+ if (OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect1) != 0) {
+ RECT rect2 = rect2 = new RECT ();
+ rect2.left = hNewItem;
+ OS.SendMessage (handle, OS.TVM_GETITEMRECT, 1, rect2);
+ int flags = rect1.top < rect2.top ? OS.TVGN_NEXTVISIBLE : OS.TVGN_PREVIOUSVISIBLE;
+ tvItem.state = OS.TVIS_SELECTED;
+ int hItem = tvItem.hItem = hAnchor;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ while (hItem != hNewItem) {
+ tvItem.hItem = hItem;
+ OS.SendMessage (handle, OS.TVM_SETITEM, 0, tvItem);
+ hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, flags, hItem);
+ }
+ }
+ }
+ }
+ }
+ }
+ if ((wParam & OS.MK_SHIFT) == 0) hAnchor = hNewItem;
+
+ /* Issue notification */
+ tvItem.hItem = hNewItem;
+ tvItem.mask = OS.TVIF_STATE | OS.TVIF_PARAM;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ Event event = new Event ();
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ event.item = items [tvItem.lParam];
+ }
+ postEvent (SWT.Selection, event);
+
+ /*
+ * Feature in Windows. Inside WM_LBUTTONDOWN and WM_RBUTTONDOWN,
+ * the widget starts a modal loop to determine if the user wants
+ * to begin a drag/drop operation or marque select. Unfortunately,
+ * this modal loop eats the corresponding mouse up. The fix is to
+ * detect the cases when the modal loop has eaten the mouse up and
+ * issue a fake mouse up.
+ */
+ if (dragStarted) {
+ sendEvent (SWT.DragDetect);
+ // widget could be disposed at this point
+ } else {
+ sendMouseEvent (SWT.MouseUp, 1, OS.WM_LBUTTONUP, wParam, lParam);
+ }
+ dragStarted = false;
+ return new LRESULT (code);
+}
+
+LRESULT WM_RBUTTONDOWN (int wParam, int lParam) {
+ /*
+ * Feature in Windows. The receiver uses WM_RBUTTONDOWN
+ * to initiate a drag/drop operation depending on how the
+ * user moves the mouse. If the user clicks the right button,
+ * without moving the mouse, the tree consumes the corresponding
+ * WM_RBUTTONUP. The fix is to avoid calling the window proc for
+ * the tree.
+ */
+ sendMouseEvent (SWT.MouseDown, 3, OS.WM_RBUTTONDOWN, wParam, lParam);
+ /*
+ * This code is intentionally commented.
+ */
+// if (OS.GetCapture () != handle) OS.SetCapture (handle);
+ setFocus ();
+
+ /*
+ * Feature in Windows. When the user selects a tree item
+ * with the right mouse button, the item remains selected
+ * only as long as the user does not release or move the
+ * mouse. As soon as this happens, the selection snaps
+ * back to the previous selection. This behavior can be
+ * observed in the Explorer but is not instantly apparent
+ * because the Explorer explicity sets the selection when
+ * the user chooses a menu item. If the user cancels the
+ * menu, the selection snaps back. The fix is to avoid
+ * calling the window proc and do the selection ourselves.
+ * This behavior is consistent with the table.
+ */
+ TVHITTESTINFO lpht = new TVHITTESTINFO ();
+ lpht.x = (short) (lParam & 0xFFFF);
+ lpht.y = (short) (lParam >> 16);
+ OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
+ if (lpht.hItem != 0 && (lpht.flags & (OS.TVHT_ONITEMICON | OS.TVHT_ONITEMLABEL)) != 0) {
+ if ((wParam & (OS.MK_CONTROL | OS.MK_SHIFT)) == 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.hItem = lpht.hItem;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ if ((tvItem.state & OS.TVIS_SELECTED) == 0) {
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, lpht.hItem);
+ }
+ }
+ }
+ return LRESULT.ZERO;
+}
+
+LRESULT WM_SETFOCUS (int wParam, int lParam) {
+ LRESULT result = super.WM_SETFOCUS (wParam, lParam);
+ if (result != null) return result;
+ if ((style & SWT.SINGLE) != 0) return result;
+ /*
+ * Feature in Windows. When multiple item have
+ * the TVIS_SELECTED state, Windows redraws only
+ * the focused item in the color used to show the
+ * selection when the tree loses or gains focus.
+ * The fix is to force Windows to redraw all the
+ * visible items when focus is gained or lost.
+ */
+ OS.InvalidateRect (handle, null, false);
+ return result;
+}
+
+LRESULT WM_SYSCOLORCHANGE (int wParam, int lParam) {
+ LRESULT result = super.WM_SYSCOLORCHANGE (wParam, lParam);
+ if (result != null) return result;
+ if (imageList != null && background == -1) {
+ imageList.setBackground (defaultBackground ());
+ int hImageList = imageList.getHandle ();
+ OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_NORMAL, hImageList);
+ }
+ if ((style & SWT.CHECK) != 0) setCheckboxImageList ();
+ return result;
+}
+
+LRESULT wmNotifyChild (int wParam, int lParam) {
+ NMHDR hdr = new NMHDR ();
+ OS.MoveMemory (hdr, lParam, NMHDR.sizeof);
+ int code = hdr.code;
+ switch (code) {
+ case OS.NM_DBLCLK:
+ int pos = OS.GetMessagePos ();
+ TVHITTESTINFO lpht = new TVHITTESTINFO ();
+ POINT pt = new POINT ();
+ pt.x = (short) (pos & 0xFFFF);
+ pt.y = (short) (pos >> 16);
+ OS.ScreenToClient (handle, pt);
+ lpht.x = pt.x; lpht.y = pt.y;
+ OS.SendMessage (handle, OS.TVM_HITTEST, 0, lpht);
+ if ((lpht.flags & OS.TVHT_ONITEM) == 0) break;
+ // fall through
+ case OS.NM_RETURN:
+ case OS.TVN_SELCHANGED:
+ if (!ignoreSelect) {
+ TVITEM tvItem = null;
+ if (code == OS.TVN_SELCHANGED) {
+ tvItem = new TVITEM ();
+ int offset = NMHDR.sizeof + 4 + TVITEM.sizeof;
+ OS.MoveMemory (tvItem, lParam + offset, TVITEM.sizeof);
+ } else {
+ int hItem = OS.SendMessage (handle, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hItem == 0) {
+ tvItem = new TVITEM ();
+ tvItem.hItem = hItem;
+ tvItem.mask = OS.TVIF_PARAM | OS.TVIF_STATE;
+ OS.SendMessage (handle, OS.TVM_GETITEM, 0, tvItem);
+ }
+ }
+ TreeItem item = null;
+ if (tvItem != null) {
+ /*
+ * This code is intentionally commented.
+ */
+// hAnchor = tvItem.hItem;
+ if ((tvItem.state & OS.TVIS_SELECTED) != 0) {
+ item = items [tvItem.lParam];
+ }
+ }
+ Event event = new Event ();
+ event.item = item;
+ if (code == OS.TVN_SELCHANGED) {
+ postEvent (SWT.Selection, event);
+ } else {
+ postEvent (SWT.DefaultSelection, event);
+ }
+ }
+ if (code == OS.NM_DBLCLK && hooks (SWT.DefaultSelection)) {
+ return LRESULT.ONE;
+ }
+ break;
+ case OS.TVN_SELCHANGING:
+ if (!ignoreSelect && !ignoreDeselect) {
+ hAnchor = 0;
+ if ((style & SWT.MULTI) != 0) deselectAll ();
+ }
+ break;
+ case OS.TVN_ITEMEXPANDING:
+ if (!ignoreExpand) {
+ TVITEM tvItem = new TVITEM ();
+ int offset = NMHDR.sizeof + 4 + TVITEM.sizeof;
+ OS.MoveMemory (tvItem, lParam + offset, TVITEM.sizeof);
+ int [] action = new int [1];
+ OS.MoveMemory (action, lParam + NMHDR.sizeof, 4);
+ Event event = new Event ();
+ event.item = items [tvItem.lParam];
+ /*
+ * It is possible (but unlikely), that application
+ * code could have disposed the widget in the expand
+ * or collapse event. If this happens, end the
+ * processing of the Windows message by returning
+ * zero as the result of the window proc.
+ */
+ if (action [0] == OS.TVE_EXPAND) {
+ sendEvent (SWT.Expand, event);
+ if (isDisposed ()) return LRESULT.ZERO;
+ }
+ if (action [0] == OS.TVE_COLLAPSE) {
+ sendEvent (SWT.Collapse, event);
+ if (isDisposed ()) return LRESULT.ZERO;
+ }
+ }
+ break;
+ case OS.TVN_BEGINDRAG:
+ case OS.TVN_BEGINRDRAG:
+ TVITEM tvItem = new TVITEM ();
+ int offset = NMHDR.sizeof + 4 + TVITEM.sizeof;
+ OS.MoveMemory (tvItem, lParam + offset, TVITEM.sizeof);
+ if (tvItem.hItem != 0 && (tvItem.state & OS.TVIS_SELECTED) == 0) {
+ ignoreSelect = ignoreDeselect = true;
+ OS.SendMessage (handle, OS.TVM_SELECTITEM, OS.TVGN_CARET, tvItem.hItem);
+ ignoreSelect = ignoreDeselect = false;
+ }
+ dragStarted = true;
+ break;
+ }
+ return super.wmNotifyChild (wParam, lParam);
+}
+
+LRESULT wmScroll (int msg, int wParam, int lParam) {
+ int code = callWindowProc (msg, wParam, lParam);
+ if (code == 0) return LRESULT.ZERO;
+ return new LRESULT (code);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
new file mode 100755
index 0000000000..6049d1ae68
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeItem.java
@@ -0,0 +1,439 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+
+/**
+ * Instances of this class represent a selectable user interface object
+ * that represents a heirarchy 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>
+ */
+
+public class TreeItem extends Item {
+ public int handle;
+ Tree parent;
+
+public TreeItem (Tree parent, int style) {
+ super (parent, style);
+ this.parent = parent;
+ parent.createItem (this, 0, OS.TVI_LAST);
+}
+
+public TreeItem (Tree parent, int style, int position) {
+ super (parent, style);
+ if (position < 0) error (SWT.ERROR_INVALID_RANGE);
+ this.parent = parent;
+ int hItem = OS.TVI_FIRST;
+ if (position != 0) {
+ int count = 1, hwnd = parent.handle;
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_ROOT, 0);
+ while (hItem != 0 && count < position) {
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ count++;
+ }
+ if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
+ };
+ parent.createItem (this, 0, hItem);
+}
+
+public TreeItem (TreeItem parentItem, int style) {
+ super (checkNull (parentItem).parent, style);
+ parent = parentItem.parent;
+ int hItem = parentItem.handle;
+ parent.createItem (this, hItem, OS.TVI_LAST);
+}
+
+public TreeItem (TreeItem parentItem, int style, int position) {
+ super (checkNull (parentItem).parent, style);
+ if (position < 0) error (SWT.ERROR_INVALID_RANGE);
+ parent = parentItem.parent;
+ int hItem = OS.TVI_FIRST;
+ int hParent = parentItem.handle;
+ if (position != 0) {
+ int count = 1, hwnd = parent.handle;
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, hParent);
+ while (hItem != 0 && count < position) {
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ count++;
+ }
+ if (hItem == 0) error (SWT.ERROR_INVALID_RANGE);
+ }
+ parent.createItem (this, hParent, hItem);
+}
+
+static TreeItem checkNull (TreeItem item) {
+ if (item == null) SWT.error (SWT.ERROR_NULL_ARGUMENT);
+ return item;
+}
+
+protected void checkSubclass () {
+ if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
+}
+
+void destroyWidget () {
+ super.destroyWidget ();
+ 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>
+ */
+public Rectangle getBounds () {
+ checkWidget ();
+ int hwnd = parent.handle;
+ RECT rect = new RECT ();
+ rect.left = handle;
+ OS.SendMessage (hwnd, OS.TVM_GETITEMRECT, 1, rect);
+ int width = rect.right - rect.left;
+ int height = rect.bottom - rect.top;
+ return new Rectangle (rect.left, rect.top, width, height);
+}
+
+/**
+ * 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.style & SWT.CHECK) == 0) return false;
+ int hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ tvItem.hItem = handle;
+ int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ return (result != 0) && (((tvItem.state >> 12) & 1) == 0);
+}
+
+public Display getDisplay () {
+ Tree parent = this.parent;
+ if (parent == null) error (SWT.ERROR_WIDGET_DISPOSED);
+ return parent.getDisplay ();
+}
+
+/**
+ * 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 hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.hItem = handle;
+ tvItem.mask = OS.TVIF_STATE;
+ OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ return (tvItem.state & OS.TVIS_EXPANDED) != 0;
+}
+
+/**
+ * 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
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if 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.style & SWT.CHECK) == 0) return false;
+ int hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ tvItem.hItem = handle;
+ int result = OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ return (result != 0) && ((tvItem.state >> 12) > 2);
+}
+
+/**
+ * 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 ();
+ int count = 0;
+ int hwnd = parent.handle;
+ int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ while (hItem != 0) {
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ count++;
+ }
+ return count;
+}
+
+/**
+ * Returns an 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 effect 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 ();
+ int count = 0;
+ int hwnd = parent.handle;
+ int hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ while (hItem != 0) {
+ hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, hItem);
+ count++;
+ }
+ int index = 0;
+ TreeItem [] result = new TreeItem [count];
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CHILD, handle);
+ while (tvItem.hItem != 0) {
+ OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ result [index++] = parent.items [tvItem.lParam];
+ tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_NEXT, tvItem.hItem);
+ }
+ return result;
+}
+
+/**
+ * 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 hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ tvItem.hItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_PARENT, handle);
+ if (tvItem.hItem == 0) return null;
+ OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ return parent.items [tvItem.lParam];
+}
+
+void releaseChild () {
+ super.releaseChild ();
+ parent.destroyItem (this);
+}
+
+void releaseHandle () {
+ handle = 0;
+}
+
+void releaseWidget () {
+ super.releaseWidget ();
+ parent = null;
+}
+
+/**
+ * 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;
+ int hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ tvItem.hItem = handle;
+ OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ int state = tvItem.state >> 12;
+ if (checked) {
+ if ((state & 0x1) != 0) state++;
+ } else {
+ if ((state & 0x1) == 0) --state;
+ }
+ tvItem.state = state << 12;
+ OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+}
+
+/**
+ * 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 hwnd = parent.handle;
+ /*
+ * Feature in Windows. When the user collapses the root
+ * of a subtree that has the focus item, Windows moves
+ * the selection to the root of the subtree and issues
+ * a TVN_SELCHANGED to inform the programmer that the
+ * seletion has changed. When the programmer collapses
+ * the same subtree using TVM_EXPAND, Windows does not
+ * send the selection changed notification. This is not
+ * stricly wrong but is inconsistent. The fix is to notice
+ * that the selection has changed and issue the event.
+ */
+ int hOldItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ parent.ignoreExpand = true;
+ OS.SendMessage (hwnd, OS.TVM_EXPAND, expanded ? OS.TVE_EXPAND : OS.TVE_COLLAPSE, handle);
+ parent.ignoreExpand = false;
+ int hNewItem = OS.SendMessage (hwnd, OS.TVM_GETNEXTITEM, OS.TVGN_CARET, 0);
+ if (hNewItem != hOldItem) {
+ Event event = new Event ();
+ if (hNewItem != 0) {
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_PARAM;
+ tvItem.hItem = hNewItem;
+ if (OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem) != 0) {
+ event.item = parent.items [tvItem.lParam];
+ }
+ }
+ parent.sendEvent (SWT.Selection, event);
+ }
+}
+
+/**
+ * Sets the grayed state of the receiver.
+ * <p>
+ *
+ * @param checked 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>
+ */
+public void setGrayed (boolean grayed) {
+ checkWidget ();
+ if ((parent.style & SWT.CHECK) == 0) return;
+ int hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_STATE;
+ tvItem.stateMask = OS.TVIS_STATEIMAGEMASK;
+ tvItem.hItem = handle;
+ OS.SendMessage (hwnd, OS.TVM_GETITEM, 0, tvItem);
+ int state = tvItem.state >> 12;
+ if (grayed) {
+ if (state <= 2) state +=2;
+ } else {
+ if (state > 2) state -=2;
+ }
+ tvItem.state = state << 12;
+ OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+}
+
+public void setImage (Image image) {
+ checkWidget ();
+ super.setImage (image);
+ int hwnd = parent.handle;
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_IMAGE | OS.TVIF_SELECTEDIMAGE;
+ tvItem.iImage = parent.imageIndex (image);
+ tvItem.iSelectedImage = tvItem.iImage;
+ tvItem.hItem = handle;
+ int result = OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+}
+
+public void setText (String string) {
+ checkWidget ();
+ if (string == null) error (SWT.ERROR_NULL_ARGUMENT);
+ super.setText (string);
+ int hwnd = parent.handle;
+ int hHeap = OS.GetProcessHeap ();
+ byte [] buffer = Converter.wcsToMbcs (0, string, false);
+ int pszText = OS.HeapAlloc (hHeap, OS.HEAP_ZERO_MEMORY, buffer.length + 1);
+ OS.MoveMemory (pszText, buffer, buffer.length);
+ TVITEM tvItem = new TVITEM ();
+ tvItem.mask = OS.TVIF_HANDLE | OS.TVIF_TEXT;
+ tvItem.hItem = handle;
+ tvItem.pszText = pszText;
+ int result = OS.SendMessage (hwnd, OS.TVM_SETITEM, 0, tvItem);
+ OS.HeapFree (hHeap, 0, pszText);
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
new file mode 100755
index 0000000000..a8cd271360
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java
@@ -0,0 +1,971 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.*;
+import org.eclipse.swt.internal.win32.*;
+import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
+import org.eclipse.swt.events.*;
+import java.util.EventListener;
+
+/**
+ * This class is the abstract superclass of all user interface objects.
+ * Widgets are created, disposed and issue notification to listeners
+ * when events occur which effect 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
+ */
+
+public abstract class Widget {
+
+ int style, state;
+ EventTable eventTable;
+ Object data;
+ String [] keys;
+ Object [] values;
+
+ /* Global state flags */
+// static final int AUTOMATIC = 1<<0;
+// static final int ACTIVE = 1<<1;
+// static final int AUTOGRAB = 1<<2;
+// static final int MULTIEXPOSE = 1<<3;
+// static final int RESIZEREDRAW = 1<<4;
+// static final int WRAP = 1<<5;
+ static final int DISABLED = 1<<6;
+ static final int HIDDEN = 1<<7;
+// static final int FOREGROUND = 1<<8;
+// static final int BACKGROUND = 1<<9;
+ static final int DISPOSED = 1<<10;
+// static final int HANDLE = 1<<11;
+ static final int CANVAS = 1<<12;
+
+ /* Default widths for widgets */
+ static final int DEFAULT_WIDTH = 64;
+ static final int DEFAULT_HEIGHT = 64;
+ static final char Mnemonic = '&';
+
+ /* Windows, DBCS and COMCTL32.DLL flags */
+ static final boolean IsWinNT, IsDBLocale;
+ static final int WIN32_MAJOR, WIN32_MINOR;
+ static final int COMCTL32_MAJOR, COMCTL32_MINOR;
+ static {
+
+ /* Get the Windows version */
+ int version = OS.GetVersion ();
+ IsWinNT = (version & 0x80000000) == 0;
+ WIN32_MAJOR = version & 0x00FF;
+ WIN32_MINOR = (version & 0xFFFF) >> 8;
+
+ /* Get the DBCS flag */
+ boolean isDBLocale = false;
+ for (int i = 0; i <= 0xFF; i++) {
+ if (OS.IsDBCSLeadByte ((byte) i)) {
+ isDBLocale = true;
+ break;
+ }
+ }
+ IsDBLocale = isDBLocale;
+
+ /* Get the COMCTL32.DLL version */
+ DLLVERSIONINFO dvi = new DLLVERSIONINFO ();
+ dvi.cbSize = DLLVERSIONINFO.sizeof;
+ dvi.dwMajorVersion = 4;
+ dvi.dwMinorVersion = 0;
+ byte[] lpLibFileName = Converter.wcsToMbcs (0, "comctl32.dll\0");
+ int hModule = OS.LoadLibrary (lpLibFileName);
+ if (hModule != 0) {
+ byte [] lpProcName = Converter.wcsToMbcs (0, "DllGetVersion\0");
+ int DllGetVersion = OS.GetProcAddress (hModule, lpProcName);
+ if (DllGetVersion != 0) OS.Call (DllGetVersion, dvi);
+ OS.FreeLibrary (hModule);
+ }
+ COMCTL32_MAJOR = dvi.dwMajorVersion;
+ COMCTL32_MINOR = dvi.dwMinorVersion;
+ if ((COMCTL32_MAJOR << 16 | COMCTL32_MINOR) < (4 << 16 | 71)) {
+ System.out.println ("***WARNING: SWT requires comctl32.dll version 4.71 or greater");
+ }
+
+ /* Initialize the Common Controls DLL */
+ OS.InitCommonControls ();
+ }
+
+/**
+ * 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
+ * for all SWT widget classes should include a comment which
+ * describes the style constants which are applicable to the class.
+ * </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
+ * @see #checkSubclass
+ * @see #getStyle
+ */
+public Widget (Widget parent, int style) {
+ checkSubclass ();
+ checkParent (parent);
+ this.style = style;
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed 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.
+ *
+ * @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 #removeListener
+ */
+public void addListener (int eventType, Listener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) eventTable = new EventTable ();
+ eventTable.hook (eventType, listener);
+}
+
+/**
+ * Adds the listener to the collection of listeners who will
+ * be notifed 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);
+}
+
+/**
+ * Returns a style with exactly one style bit set out of
+ * the specified set of exclusive style bits. All other
+ * possible bits are cleared when the first matching bit
+ * is found. Bits that are not part of the possible set
+ * are untouched.
+ *
+ * @param style the original style bits
+ * @param int0 the 0th possible style bit
+ * @param int1 the 1st possible style bit
+ * @param int2 the 2nd possible style bit
+ * @param int3 the 3rd possible style bit
+ * @param int4 the 4th possible style bit
+ * @param int5 the 5th possible style bit
+ *
+ * @return the new style bits
+ */
+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;
+}
+
+/**
+ * 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>
+ * </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.isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+}
+
+/**
+ * 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 () {
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ if (!isValidWidget ()) error (SWT.ERROR_WIDGET_DISPOSED);
+}
+
+/**
+ * Destroys the widget in the operating system and releases
+ * the widget's handle. If the widget does not have a handle,
+ * this method may hide the widget, mark the widget as destroyed
+ * or do nothing, depending on the widget.
+ * <p>
+ * When a widget is destroyed in the operating system, its
+ * descendents are also destroyed by the operating system.
+ * This means that it is only necessary to call <code>destroyWidget</code>
+ * on the root of the widget tree.
+ * </p>
+ * This method is called after <code>releaseWidget</code>.
+ * </p>
+ * @see #dispose
+ * @see #releaseChild
+ * @see #releaseWidget
+ * @see #releaseHandle
+ */
+void destroyWidget () {
+}
+
+/**
+ * Disposes of the operating system resources associated with
+ * the receiver and all its descendents. After this method has
+ * been invoked, the receiver and all descendents 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 descendents
+ * 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 (!isValidWidget ()) return;
+ if (!isValidThread ()) error (SWT.ERROR_THREAD_INVALID_ACCESS);
+ releaseChild ();
+ releaseWidget ();
+ destroyWidget ();
+}
+
+/**
+ * Does whatever widget 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);
+}
+
+/**
+ * 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
+ */
+public Object getData () {
+ checkWidget();
+ return 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
+ */
+public Object getData (String key) {
+ checkWidget();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+ 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 <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.
+ *
+ * @return the receiver's 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 abstract Display getDisplay ();
+
+/**
+ * Returns the name of the widget. This is the name of
+ * the class without the package name.
+ *
+ * @return the name of the widget
+ */
+String getName () {
+ String string = getClass ().getName ();
+ int index = string.lastIndexOf ('.');
+ if (index == -1) return string;
+ return string.substring (index + 1, string.length ());
+}
+
+/*
+ * Returns a short printable representation for the contents
+ * of a widget. For example, a button may answer the label
+ * text. This is used by <code>toString</code> to provide a
+ * more meaningful description of the widget.
+ *
+ * @return the contents string for the widget
+ *
+ * @see toString
+ */
+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;
+}
+
+/*
+ * 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);
+}
+
+/**
+ * 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.
+ *
+ * @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.
+ *
+ * @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>
+ */
+protected boolean isListening (int eventType) {
+ checkWidget();
+ return hooks (eventType);
+}
+
+/*
+ * Returns <code>true</code> when subclassing is
+ * allowed and <code>false</code> otherwise
+ *
+ * @return <code>true</code> when subclassing is allowed and <code>false</code> otherwise
+ */
+boolean isValidSubclass () {
+ return Display.isValidClass (getClass ());
+}
+
+/*
+ * Returns <code>true</code> when the current thread is
+ * the thread that created the widget and <code>false</code>
+ * otherwise.
+ *
+ * @return <code>true</code> when the current thread is the thread that created the widget and <code>false</code> otherwise
+ */
+boolean isValidThread () {
+ return getDisplay ().isValidThread ();
+}
+
+/**
+ * Returns <code>true</code> if the widget is not disposed,
+ * and <code>false</code> otherwise.
+ * <p>
+ * Note: This method is no longer required and will be deprecated.
+ *
+ * @return <code>true</code> when the widget is not disposed and <code>false</code> otherwise
+ *
+ * @see #isDisposed
+ */
+boolean isValidWidget () {
+ return (state & DISPOSED) == 0;
+}
+
+/*
+ * Returns a single character, converted from the multi-byte
+ * character set (MBCS) used by the operating system widgets
+ * to a wide character set (WCS) used by Java.
+ *
+ * @param ch the MBCS character
+ * @return the WCS character
+ */
+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 (0, buffer);
+ if (result.length == 0) return 0;
+ return result [0];
+}
+
+/**
+ * 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.
+ *
+ * @param eventType the type of event which has occurred
+ * @param event the event data
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if 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>
+ */
+public void notifyListeners (int eventType, Event event) {
+ checkWidget();
+ if (event == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ eventTable.sendEvent (event);
+}
+
+void postEvent (int eventType) {
+ if (eventTable == null) return;
+ postEvent (eventType, new Event ());
+}
+
+void postEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.type = eventType;
+ event.widget = this;
+ if (event.time == 0) {
+ event.time = OS.GetMessageTime ();
+ }
+ getDisplay ().postEvent (event);
+}
+
+/*
+ * Releases the receiver, a child in a widget hierarchy,
+ * from its parent.
+ * <p>
+ * When a widget is destroyed, it may be necessary to remove
+ * it from an internal data structure of the parent. When
+ * a widget has no handle, it may also be necessary for the
+ * parent to hide the widget or otherwise indicate that the
+ * widget has been disposed. For example, disposing a menu
+ * bar requires that the menu bar first be released from the
+ * shell when the menu bar is active. This could not be done
+ * in <code>destroyWidget</code> for the menu bar because the
+ * parent shell as well as other fields have been null'd out
+ * already by <code>releaseWidget</code>.
+ * </p>
+ * This method is called first when a widget is disposed.
+ *
+ * @see #dispose
+ * @see #releaseChild
+ * @see #releaseWidget
+ * @see #releaseHandle
+ */
+void releaseChild () {
+}
+
+/*
+ * Releases the widget's handle by zero'ing it out.
+ * Does not destroy or release any operating system
+ * resources.
+ * <p>
+ * This method is called after <code>releaseWidget</code>
+ * or from <code>destroyWidget</code> when a widget is being
+ * destroyed to ensure that the widget is marked as destroyed
+ * in case the act of destroying the widget in the operating
+ * system causes application code to run in callback that
+ * could access the widget.
+ * </p>
+ *
+ * @see #dispose
+ * @see #releaseChild
+ * @see #releaseWidget
+ * @see #releaseHandle
+ */
+void releaseHandle () {
+}
+
+/*
+ * Releases any internal resources back to the operating
+ * system and clears all fields except the widget handle.
+ * <p>
+ * When a widget is destroyed, resources that were acquired
+ * on behalf of the programmer need to be returned to the
+ * operating system. For example, if the widget made a
+ * copy of an icon, supplied by the programmer, this copy
+ * would be freed in <code>releaseWidget</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 widget, all fields except the
+ * handle are zero'd. The handle is needed by <code>destroyWidget</code>.
+ * </p>
+ * <p>
+ * Typically, a widget with children will broadcast this
+ * message to all children so that they too can release their
+ * resources. The <code>releaseHandle</code> method is used
+ * as part of this broadcast to zero the handle fields of the
+ * children without calling <code>destroyWidget</code>. In
+ * this scenario, the children are actually destroyed later,
+ * when the operating system destroys the widget tree.
+ * </p>
+ * This method is called after <code>releaseChild</code>.
+ *
+ * @see #dispose
+ * @see #releaseChild
+ * @see #releaseWidget
+ * @see #releaseHandle
+ */
+void releaseWidget () {
+ sendEvent (SWT.Dispose);
+ state |= DISPOSED;
+ eventTable = null;
+ data = null;
+ keys = null;
+ values = null;
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when an event of the given type occurs.
+ *
+ * @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_WIDGET_DISPOSED - if 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
+ */
+public void removeListener (int eventType, Listener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed 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 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 #addListener
+ */
+protected void removeListener (int eventType, EventListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (eventType, listener);
+}
+
+/**
+ * Removes the listener from the collection of listeners who will
+ * be notifed when the widget is disposed.
+ *
+ * @param listener the listener which should no longer 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 removeDisposeListener (DisposeListener listener) {
+ checkWidget();
+ if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
+ if (eventTable == null) return;
+ eventTable.unhook (SWT.Dispose, listener);
+}
+
+void sendEvent (int eventType) {
+ if (eventTable == null) return;
+ sendEvent (eventType, new Event ());
+}
+
+void sendEvent (int eventType, Event event) {
+ if (eventTable == null) return;
+ event.widget = this;
+ event.type = eventType;
+ if (event.time == 0) {
+ event.time = OS.GetMessageTime ();
+ }
+ eventTable.sendEvent (event);
+}
+
+/**
+ * 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>
+ */
+public void setData (Object data) {
+ checkWidget();
+ 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
+ */
+public void setData (String key, Object value) {
+ checkWidget();
+ if (key == null) error (SWT.ERROR_NULL_ARGUMENT);
+
+ /* 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;
+}
+
+/**
+ * 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 + "}";
+}
+/*
+ * Returns a single character, converted from the wide
+ * character set (WCS) used by Java to the multi-byte
+ * character set used by the operating system widgets.
+ *
+ * @param ch the WCS character
+ * @return the MBCS character
+ */
+char wcsToMbcs (char ch) {
+ int key = ch & 0xFFFF;
+ if (key <= 0x7F) return ch;
+ byte [] buffer = Converter.wcsToMbcs (0, 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;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/WidgetTable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/WidgetTable.java
new file mode 100755
index 0000000000..4157cb2bdc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/WidgetTable.java
@@ -0,0 +1,113 @@
+package org.eclipse.swt.widgets;
+
+/*
+ * Licensed Materials - Property of IBM,
+ * (c) Copyright IBM Corp. 1998, 2001 All Rights Reserved
+ */
+
+import org.eclipse.swt.internal.win32.*;
+
+/**
+ * This class contains static methods which provide a map from the
+ * platform representation of a widget to the SWT control.
+ */
+
+class WidgetTable {
+ static int FreeSlot = 0;
+ static int GrowSize = 1024;
+ static int [] IndexTable = new int [GrowSize];
+ static Control [] ControlTable = new Control [GrowSize];
+ static {
+ for (int i=0; i<GrowSize-1; i++) IndexTable [i] = i + 1;
+ IndexTable [GrowSize - 1] = -1;
+ }
+
+public static synchronized Control get (int handle) {
+ if (handle == 0) return null;
+ int index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;
+ if (0 <= index && index < ControlTable.length) return ControlTable [index];
+ return null;
+}
+
+public synchronized static void put (int handle, Control control) {
+ if (handle == 0) return;
+ if (FreeSlot == -1) {
+ int length = (FreeSlot = IndexTable.length) + GrowSize;
+ int [] newIndexTable = new int [length];
+ Control [] newControlTable = new Control [length];
+ System.arraycopy (IndexTable, 0, newIndexTable, 0, FreeSlot);
+ System.arraycopy (ControlTable, 0, newControlTable, 0, FreeSlot);
+ for (int i=FreeSlot; i<length-1; i++) newIndexTable [i] = i + 1;
+ newIndexTable [length - 1] = -1;
+ IndexTable = newIndexTable;
+ ControlTable = newControlTable;
+ }
+ OS.SetWindowLong (handle, OS.GWL_USERDATA, FreeSlot + 1);
+ int oldSlot = FreeSlot;
+ FreeSlot = IndexTable [oldSlot];
+ IndexTable [oldSlot] = -2;
+ ControlTable [oldSlot] = control;
+}
+
+public static synchronized Control remove (int handle) {
+ if (handle == 0) return null;
+ Control control = null;
+ int index = OS.GetWindowLong (handle, OS.GWL_USERDATA) - 1;
+ if (0 <= index && index < ControlTable.length) {
+ control = ControlTable [index];
+ ControlTable [index] = null;
+ IndexTable [index] = FreeSlot;
+ FreeSlot = index;
+ OS.SetWindowLong (handle, OS.GWL_USERDATA, 0);
+ }
+ return control;
+}
+
+public static synchronized Shell [] shells () {
+ /*
+ * This code is intentionally commented.
+ * Bug in JVM 1.2. For some reason, when the following code
+ * is inlined in this method, the JVM issues this error error:
+ *
+ * A nonfatal internal JIT (3.00.072b(x)) error 'GetRegisterA' has occurred in :
+ * 'org/eclipse/swt/widgets/WidgetTable.shells ()[Lorg/eclipse/swt/widgets/Shell;': Interpreting method.
+ * Please report this error in detail to http://java.sun.com/cgi-bin/bugreport.cgi
+ *
+ * The fix is to move the code that would be inlined into another method.
+ */
+// int size = 0;
+// for (int i=0; i<WidgetTable.length; i++) {
+// Control control = WidgetTable [i];
+// if (control != null && control instanceof Shell) size++;
+// }
+
+ int size = shellSize ();
+ int index = 0;
+ Shell [] result = new Shell [size];
+ for (int i=0; i<ControlTable.length; i++) {
+ Control control = ControlTable [i];
+ if (control != null && control instanceof Shell) {
+ result [index++] = (Shell) control;
+ }
+ }
+ return result;
+}
+
+static int shellSize () {
+ int length = 0;
+ for (int i=0; i<ControlTable.length; i++) {
+ Control control = ControlTable [i];
+ if (control != null && control instanceof Shell) length++;
+ }
+ return length;
+}
+
+public static synchronized int size () {
+ int length = 0;
+ for (int i=0; i<ControlTable.length; i++) {
+ if (ControlTable [i] != null) length++;
+ }
+ return length;
+}
+
+}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/swt0105.dll b/bundles/org.eclipse.swt/Eclipse SWT/win32/swt0105.dll
new file mode 100755
index 0000000000..b70a7757dc
--- /dev/null
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/swt0105.dll
Binary files differ

Back to the top